akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        String  line= f.readLine();

        String[] theLine = line.split(" ");
        ArrayList<Integer> theInts = new ArrayList<>();

        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < Integer.parseInt(theLine[0]); i++)
        {

            theInts.add(Integer.parseInt(st.nextToken()));
        }
        Collections.sort(theInts);

        int sum = 0;
        for(int g = 0; g < Integer.parseInt(theLine[1]); g++)
        {
            sum+=theInts.get(g);
        }

        out.print(sum);


        out.close();
    }
}

Measured memory_bytes: 33360
#include <stdio.h>

int main () {
	int N, A, B;
	scanf ("%d %d %d", &N, &A, &B);
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int temp = i;
		int jumlah = 0;
		
		while (temp > 0) {
			jumlah += temp % 10;
			temp /= 10;
		}
		
		if (jumlah >= A && jumlah <= B) {
			ans += i;
		}
	}
	printf ("%d\n", ans);
	return 0;
}

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

int main() {
  // ここにプログラムを追記
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  if (A>=K){
    cout<<K<<endl;}
    else if (A<K&&K<=B){
      cout<< A<<endl;}
      else{
        ll D= K-A-B;
        
        cout<<A-D<<endl;}
    
    
}


Measured memory_bytes: 3636
import math
from decimal import Decimal


def task(a, b):
    b = b.replace('.', '')
    if b[0] == '0':
        b = b[1:]
    if b[0] == '0':
        b = b[1:]
    b = int(b)
    res = a * b

    if res < 100:
        print(0)
    else:
        print(str(res)[:-2])


a, b = input().split()
task(int(a), b)


Measured memory_bytes: 71104
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll a, b, c;
        cin >> a >> b >> c;
        if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
        else {
            cout << min({a * b, b * c, c * a}) << endl;
        }


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import numpy
import collections

rl = sys.stdin.readline

n = int(rl())
se = []
for _ in range(n):
    x, r = map(int, rl().split())
    start, end = x-r, x+r
    se.append([start, end])
se.sort(key=lambda x: x[1])

cur = se[0][0]
cnt = 0
for i in se:
    if cur <= i[0] <= i[1]:
        cur = i[1]
        cnt += 1
print(cnt)

Measured memory_bytes: 30340
/*input
5 4 4
1 2 2
2 3 2
3 4 3
4 5 2
20
2 1
3 1
4 1
5 1
1 2
3 2
4 2
5 2
1 3
2 3
4 3
5 3
1 4
2 4
3 4
5 4
1 5
2 5
3 5
4 5
*/

#pragma comment(linker, "stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include "bits/stdc++.h"
using namespace std;

struct tank_t{
	int refills;
	int rem;
	bool operator<(const tank_t &o) const{
		if(refills != o.refills)
			return refills < o.refills;
		return rem > o.rem;
	}
};
tank_t dis[305][305];
vector<pair<int,int>> v[305];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n, m, cap, q; cin >> n >> m >> cap;
	for(int i=0,x,y,z;i<m;++i){
		cin >> x >> y >> z;
		v[x].push_back({y,z});
		v[y].push_back({x,z});
	}
	for(int i=1;i<=n;++i) for(int j=1;j<=n;++j)
		dis[i][j] = {1<<30, 0};

	for(int s = 1; s <= n; ++s){
		queue<pair<tank_t,int>> pq;
		set<int> in_pq;
		pq.push({dis[s][s] = {0,cap}, s});
		in_pq.insert(s);
		while(!pq.empty()){
			auto u = pq.front().second; pq.pop();
			in_pq.erase(u);
			// cout << s << ' ' << u << ' ' << dis[s][u].refills << ' ' << dis[s][u].rem << endl;
			for(auto i:v[u]){
				tank_t now = dis[s][u];
				if(now.rem >= i.second)
					now.rem -= i.second;
				else if(cap >= i.second)
					now.refills++, now.rem = cap - i.second;
				else
					continue;
				if(now < dis[s][i.first]){
					dis[s][i.first] = now;
					if(!in_pq.count(i.first)){
						pq.push({now, i.first});
						in_pq.insert(i.first);
					}
				}
			}
		}
	}

	for(cin >> q; q--;){
		int s, t; cin >> s >> t;
		int ans = dis[s][t].refills;
		cout << (ans<1e8?ans:-1) << '\n';
	}
}

Measured memory_bytes: 2432
n = int(input())
a = list(map(int, input().split()))

dp = [[0] * (n+1) for _ in range(n+1)]

for i in range(n)[::-1]:
    for j in range(n + 1):
        if i >= j:
            continue
        dp[i][j] = max(a[j - 1] - dp[i][j - 1], a[i] - dp[i + 1][j])

print(dp[0][n])


Measured memory_bytes: 112220
#include <iostream>
#include <stdio.h>
#include <string.h>
#define min(a,b) {a > b ? b:a}
#define max(a,b) {a > b ? a:b}
using namespace std;

int  N = 1000000;
int segment[1000000 * 2];
int id[1000000 * 2];

void q99() {
	int n, q;
	cin >> n >> q;

	for (int i = 0; i < N; i++) {
		id[i + N] = i;
	}
	for (int i = 0; i < q; i++) {
		int a, v;
		cin >> a >> v;
		segment[N + a - 1] += v;
		for (int j = (N + a - 1) >> 1; j > 0; j = j >> 1) {
			if (segment[j * 2] == segment[j * 2 + 1]) {
				segment[j] = segment[j * 2];
				id[j] = min(id[j * 2], id[j * 2 + 1]);
			}
			else if (segment[j * 2] > segment[j * 2 + 1]) {
				segment[j] = segment[j * 2];
				id[j] = id[j * 2];
			}
			else {
				segment[j] = segment[j * 2 + 1];
				id[j] = id[j * 2 + 1];
			}
		}
		cout << id[1] + 1 << " " << segment[1] << endl;
	}

}

int main() {
	q99();
	return 0;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int gcd(int a , int b){
  if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
int inv(int a , int b){
  return binpow(a,b-2,b);
}
int32_t main() 
{ 
  fast;
  int n;
  cin >> n;
  cout << (((n+999)/1000)*1000) - n << "\n";
  return 0; 
}

Measured memory_bytes: 3584
S = input()

resString = ''

for i in range(1,len(S)):
    resString = S[:len(S)-1-i]
    if len(resString) % 2 == 0:
        border = int(len(resString)/2)
        if resString[:border] == resString[border:]:
            print(len(resString))
            exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
int main(int argc, char const *argv[]) {
  int a = read(), b = read();
  if (a <= 0 && b >= 0) {
    // - +
    puts("Zero");
  } else if (b < 0) {
    // - -
    puts(((b-a)&1) ? "Positive" : "Negative");
  } else {
    // + +
    puts("Positive");
  }
  return 0;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int a,b;
  cin>>a>>b;
  int cnt=1;
  int ans=0;
  while(cnt<b){
    cnt+=a-1;
    ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	
	sort(a.begin(), a.end());

	cout << a[n / 2] - a[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>
#include <cmath>
using namespace std;

int main(){
    int N;
    cin >> N;
    if(N >= 24){
        cout << 0 << endl;
        return 0;
    }
    vector<int> D(N);
    for(int i=0; i<N; i++)
        cin >> D[i];

    for(int i=0; i<N; i++)
        if(D[i] == 0){
            cout << 0 << endl;
            return 0;
        }

    int ans = 0;
    for(int i=0; i<(1<<N); i++){
        int vis[24];
        fill_n(vis, 24, 0);
        vis[0] = 1;
        for(int j=0; j<N; j++){
            if(i&(1<<j)) vis[D[j]]++;
            else vis[24-D[j]]++;
        }
        bool dup = false;
        for(int j=0; j<24; j++)
            if(vis[j] >= 2){
                dup = true;
                break;
            }
        if(dup) continue;

        int s = 24;
        int cnt = 24;
        for(int j=0; j<48; j++){
            cnt++;
            if(vis[j%24]){
                s = min(s, cnt);
                cnt = 0;
            }
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s = readln.chomp.to!(char[]);
  auto t = readln.chomp.to!(char[]);

  foreach (i; 0 .. s.length) {
    if (s == t) {
      writeln("Yes");
      return;
    }
    s = s[$ - 1] ~ s[0 .. ($ - 1)];
  }

  writeln("No");

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 372
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include<iostream>
using namespace std;
int main()
{
  string s;
  int c=0,k=0;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n;i++)
  {
    if(i%2==0)
    {
      if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
      {
        c++;
      }
    }
    else
    {
       if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')
      {
        k++;
      }
    }
  }
  if(k==0&&c==0)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}
      

Measured memory_bytes: 256
from math import floor

A, B, N = list(map(int, input().split()))
# print(A, B, N)

x = None
if N < B:
    x = N
else:
    x = B
    x = B - 1
    # max_diff = 0
    # for _x in range(B, N + 1):
    #     diff = (x / B) - floor(x / B)
    #     if max_diff <= diff:
    #         max_diff = diff
    #         x = _x

answer = floor(A * x / B) - A * floor(x / B)

print(answer)


Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int t = b - a;
		int i = 0;
		int h = 0;
		for(i = 1; i <= t; i++) {
			h = h + i; 
		}
		int snow = h - b;
		System.out.println(snow);
	}
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

void vprint(vector<ll> A){
    if(A.size()==0){
        p("");
    }else{
        cout << A[0];
        FOR(i, 1, A.size()){
            cout << " " << A[i];
        }
        cout << endl;
    }
}

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

    // input
    ll N, Q;
    cin >> N >> Q;

    priority_queue<ll> que[N];
    
    while(Q--){
        ll a;
        cin >> a;
        ll t, x;

        if(a==0){
            // insert
            cin >> t >> x;
            que[t].push(x);
        }
        else if(a==1){
            // get
            cin >> t;
            if(que[t].size()){
                p(que[t].top());
            }
        }
        else{
            // delete
            cin >> t;
            if(que[t].size()){
                que[t].pop();
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 5204
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef pair <ll, ll> pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int n ;

int main() {
	scanf("%d", &n) ;
	int k = 20 ;
	while (! (n & (1 << k))) k-- ;
	printf("%d %d\n", k + 1, 2 * k + __builtin_popcount(n) - 1) ;
	for (int i = 0; i < k; i++) {
		printf("%d %d %d\n", i + 1, i + 2, 0) ;
		printf("%d %d %d\n", i + 1, i + 2, 1 << i) ;
	}
	int a = 1 << k ;
	for (int i = k - 1; i >= 0; i--)
	if ((1 << i) & n) {
		printf("%d %d %d\n", i + 1, k + 1, a) ;
		a += 1 << i ;
	}
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


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

#define int long long



typedef long long ll;
typedef long double ld;

int mod = 1e9+7;






signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int k,a,b;
    cin>>k>>a>>b;
    for(;a <= b;a++){
    	if(a % k == 0) break;
	}
	if(a <= b) cout<<"OK";
	else cout<<"NG";
    return 0;
}


Measured memory_bytes: 3648
INF = 1145141919810364364334

n,m = map(int,input().split())
c = list(map(int,input().split()))
dp = [INF] * (n+1)
dp[0] = 0

for i in range(m):
    for j in range(n+1):
        if c[i] > j:
            continue
        else:
            dp[j] = min(dp[j] , dp[j-c[i]] + 1)
            
print(dp[n])


Measured memory_bytes: 7520
#include <iostream>
#include <vector>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

struct Network {
    vector<map<ll, ll>> adj;
    bool directed;

    explicit Network(bool directed) : directed(directed) {}

    void add_edge(ll from, ll to, ll weight){
        assert(from >= 0);
        assert(to >= 0);
        assert(weight >= 0);
        if(adj.size() < max(from, to) + 1){
            adj.resize(max(from, to) + 1);
        }
        adj.at(from)[to] = weight;

        if(!directed){
            adj.at(to)[from] = weight;
        }
    }

    ll get_weight(ll from, ll to) const {
        return adj.at(from).at(to);
    }

    void floyd_warhsall(vector<vector<ll>>& out){
        const ll n = adj.size();
        out.resize(adj.size(), vector<ll>(n, -1));
        for(ll i = 0; i < n; ++i){
            for(auto p : adj.at(i)){
                out.at(i).at(p.first) = p.second;
            }
            out.at(i).at(i) = 0;
        }

        for(ll k = 0; k < n; ++k){
            for(ll i = 0; i < n; ++i){
                if(out.at(i).at(k) == -1){
                    continue;
                }
                const ll dik = out.at(i).at(k);
                for(ll j = 0; j < n; ++j){
                    if(out.at(k).at(j) == -1){
                        continue;
                    }
                    const ll dkj = out.at(k).at(j);
                    const ll dij = out.at(i).at(j);

                    if(dij == -1 || dij > dik + dkj){
                        out.at(i).at(j) = dik + dkj;
                    }
                }
            }
        }
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    Network net(false);
    REP(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        net.add_edge(a, b, c);
    }

    vector<vector<ll>> dmat;
    net.floyd_warhsall(dmat);
    
    ll ans = 0;
    REP(i, n){
        for(auto it = net.adj.at(i).begin(); it != net.adj.at(i).end(); ++it){
            if(i >= it->first){ continue; }
            if(dmat.at(i).at(it->first) < it->second){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  double n,m;
  cin>>n>>m;
  vector<double>a(n);
  rep(i,n) cin>>a[i];
 double sum=0;
  rep(i,n) sum+=a[i];
   double count=0;
  rep(i,n){
    if(a[i]>=sum/4/m) count++;
  }
  string s="No";
 if(count>=m) s="Yes";
   cout<<s<<endl;
}


Measured memory_bytes: 256
valuenum = int(input())

Input = input()
print(Input)
values = [int(value) for value in Input.split()]

for i in range(1,valuenum):
  for j in range(0,i):
    if values[i] < values[j]:
      values.insert(j, values[i])
      values.pop(i + 1)
      break

  ans = map(lambda value:str(value), values)
  print(' '.join(ans).strip())


Measured memory_bytes: 5604
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"

using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1E9+7
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const string yes = "Yes", no = "No";
// vector<bad()ool> v(1E5, false);

int main()
{
    ll x,y,z,e;
    cin>>x>>y>>z;

    e = x/(y+z);
    ll ans = 0;
    ans+=e*y;


    ans+= min(x%(y+z), y);
    cout<<ans;




}

Measured memory_bytes: 256
integer a,b
character(50) S
read*,a,b
read*,S
if(S(b:b)=="A")S(b:b)="a"
if(S(b:b)=="B")S(b:b)="b"
if(S(b:b)=="C")S(b:b)="c"
print"(A)",trim(S)
end

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

const long double PI = acos(-1.0);

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ld a = 0, b =0, x =0;
    cin >> a >> b >> x;

    x /= a;

     cout << fixed << setprecision(10);

    if(x>(a*b)/2){
     cout <<  atan2(2*(a*b-x),a*a)* 180/PI;

    }
    else{
    cout << atan2(b*b,2*x)* 180/PI;
    }
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

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

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

    int ans = 100000;
    for(ll a = 1; a < n; a++){
        ll b = n - a;
        ll ta = a;
        int ad = 0, bd = 0;
        while(ta != 0){
            ad += ta % 10;
            ta /= 10;
        }
        while(b != 0){
            bd += b % 10;
            b /= 10;
        }
        ans = min(ans, ad + bd);
        // if(ans == 5) cout << a << endl;
    }

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

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1

    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    def Count(self, x):
        return -self.root[self.Find_Root(x)]


def is_bridge(n, ab, i):
    uni = UnionFind(n)
    for j, val in enumerate(ab):
        if i == j:
            continue
        else:
            uni.Unite(val[0]-1, val[1]-1)
    if uni.Count(0) == n:
        return False
    else:
        return True


n, m = map(int, input().split())
ab = []
for i in range(m):
    a, b = map(int, input().split())
    ab.append((a, b))

ret = 0

for i in range(m):
    if is_bridge(n, ab, i):
        ret += 1

print(ret)


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main() {
	int h,m,s,S;
	scanf("%d", &S);
	h = S / 3600;
	m = (S / 60) % 60;
	s = S % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 2724
//AtCoder Beginner Contest 134 - D
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 

 
int main(){
	int n;
	scanf("%d",&n);
	bool a[n+1];
	bool b[n+1];
	memset(b,0,sizeof(b));
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	bool ok=1;
	for (int i=n;i>=1;i--){
		if (a[i]){
			b[i]=1;
			for (int j=1;j*j<=i;j++){
				if(i%j==0){
					a[j]=!a[j];
					if (j!=(i/j)){		
						a[i/j]=!a[i/j];
					}
				}
			}		
		}
	}
	
	int cnt=0;
	vector<int> yes;
	for (int i=1;i<=n;i++){
		if (b[i]){
			cnt++;
			yes.push_back(i);
		}
	}
	printf("%d\n",cnt);
	for(int i=0;i<cnt;i++){
		printf("%d\n",yes[i]);
	}
	
} 

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

using namespace std;

int main() {
    string s;
    cin >> s;
    set<char> a1;
    set<char> a2;
    for (int i = 0; i < 4; ++i) {
        if (i == 0) {
            a1.insert(s[i]);
        } else {
            if (i == 3) {
                a2.insert(s[i]);
            } else {
                a1.insert(s[i]);
                a2.insert(s[i]);
            }
        }
    }
    if (a1.size() == 1 || a2.size() == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

struct LazySegmentTree {
private:
	int n;
	vector<LL> node, lazy;
public:
	LazySegmentTree(int sz) {
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1,INF<int>());
		lazy.resize(2 * n - 1, -1);
	}

	void eval(int k, int l, int r) {
		if (lazy[k] != -1) {
			node[k] = lazy[k];;
			if (k < n - 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
			}
			lazy[k] = -1;
		}
	}

	void add(int a, int b, LL x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, 2 * k + 1, l, (l + r) / 2);
			add(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min( node[2 * k + 1] , node[2 * k + 2]);
		}
	}

	LL getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return INF<int>();
		if (a <= l && r <= b) return node[k];
		LL vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
		LL vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl ,vr);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	LazySegmentTree seg(n);
	REP(i, q) {
		int k, s, t, x;
		cin >> k;
		if (k == 0) {
			cin >> s >> t >> x;
			seg.add(s, t + 1, x);
		}
		else {
			cin >> s;
			cout << seg.getmin(s, s + 1) << endl;
		}
	}
}


Measured memory_bytes: 7068
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  ll m = *max_element(A.begin(),A.end());
  ll sa = 1e9;
  ll m2;
  for(int i=0; i<N; i++){
    if(m == A[i]) continue;
    ll t;
    if(m/2 < A[i]){
      t = m-A[i];
    }else{
      t = A[i];
    }
    if(sa >= m/2-t){
      sa = m/2-t;
      m2 = A[i];
    }
  }
  cout << m << " " << m2 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define  inf 2e18
#define  bg begin()
#define  en end()
#define  ll long long int
#define  pb push_back
#define  mp make_pair
#define  mod 1000000007
#define  vi vector<int>
#define  eb emplace_back
#define  lb(v,a) lower_bound(v.begin(),v.end(),a)
#define  ub(v,a) upper_bound(v.begin(),v.end(),a)
#define  bs binary_search
#define  vll vector<long long int>
#define  vpll vector<pair<long long int,long long int> >
#define  vpii vector<pair<int,int> >
#define  mpii map<int ,int>
#define  mpll map<long long int,long long int >
#define  max3(a,b,c) max(a,max(b,c))
#define  min3(a,b,c) min(a,min(b,c))
#define  w(t) ll t; cin>>t; while(t--)
#define  forn(i,n) for(int i=0;i<n;i++)
#define  forn1(i,n) for(int i=1;i<=n;i++)
#define  forv(it,v) for(auto it=v.begin();it!=v.end();it++)
#define  mem(a,val) memset(a,val,sizeof(a))
#define  Sort(vec) sort(vec.begin(),vec.end())
#define  RSort(vec) sort(vec.rbegin(),vec.rend())
#define  vin(v,n) for(int i=0;i<n;i++){cin>>x; v.pb(x);}
#define  deb1(x) cerr<<#x<<": "<<x<<" "<<endl
#define  deb2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define  deb3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define  deb4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define  FIFO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define  PI 3.141592653589793238462643383279502884L
mpii mpx;
int main() {
    FIFO;
    ll t;
    cin >> t;
    ll a = t / 10;
    ll b = t % 10;
    if (b == 2 || b == 4 || b == 5 || b == 7 || b == 9)
        cout << "hon" << endl;
    else if (b == 0 || b == 1 || b == 6 || b == 8)
        cout << "pon" << endl;
    else if (b == 3)
        cout << "bon" << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=110000;
int N;
int c[MAXN];

bool check() {
	if (c[N-1]==N) return true;
	rep(i,1,N) if (c[i]==N) return i<=N/2;
	rep(i,2,N) if (c[i]+c[i-1]==N) return c[i-1]<i && i<=c[i-1]+c[i]/2;
	return false;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>N;
	rep(i,0,N) {
		int x;
		cin>>x;
		c[x]++;
	}
	
	cout<<(check()?"Yes":"No")<<"\n";
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x/gcd(x,y)*y;
}
int main(){
	int A,B;
	scan(A>>B);
	prin(lcm(A,B));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 10001
#define INF 2000000001
#define LGMAX 18
#define MOD 1000003
#define F first
#define S second
#define ll long long
#define pb push_back
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    cout << (n - k + 1);
}


Measured memory_bytes: 256
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int N; scanf("%d\n", &N);
    auto A = new ulong[N];
    foreach (i; 0 .. N) {
        scanf("%lld\n", &A[i]);
    }

    auto B = new ulong[5 * N + 3];
    B[0] = 0;
    foreach (i; 1 .. 5 * N + 3) {
        B[i] = B[i - 1] + A[(i - 1) % N];
    }

    bool C(ulong x) {
        int end(int begin) {
            int lb = begin, ub = begin + N;
            while (lb + 1 < ub) {
                int mid = (lb + ub) / 2;
                if (x <= B[mid] - B[begin]) {
                    ub = mid;
                } else {
                    lb = mid;
                }
            }
            return ub;
        }
        foreach (int i; 0 .. N) {
            int j = end(i);
            int k = end(j);
            if (end(k) - i <= N) return true;
        }
        return false;
    }


    ulong lb = 0, ub = B[N];
    while (lb + 1 < ub) {
        ulong mid = (lb + ub) / 2;
        if (C(mid)) {
            lb = mid;
        } else {
            ub = mid;
        }
    }

    writeln(lb);
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	
	cout << (min(a, b) + min(c, d)) << endl;
	
	return 0;
}


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

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second

const long long BIG = 1000000000000000000LL;

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

void solve();
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

const int borne = 1005;
int nbPoints;
pair<int, int> co[borne];
int rad[borne];
double mat[borne][borne];

double getDis(int a, int b)
{
	double dx = co[a].fi - co[b].fi;
	double dy = co[a].se - co[b].se;
	double td = sqrt(dx*dx + dy*dy);
	td = max((double)(0), td-rad[a]-rad[b]);
	return td;
}

void solve()
{
	form(i, 2) cin >> co[i].fi >> co[i].se;
	cin >> nbPoints;
	form(i, nbPoints) { cin >> co[i+2].fi >> co[i+2].se >> rad[i+2]; }
	nbPoints += 2;

	form(i, nbPoints) form(j, nbPoints) mat[i][j] = getDis(i, j);
	form(k, nbPoints) form(i, nbPoints) form(j, nbPoints) {
		chmin(mat[i][j], mat[i][k] + mat[k][j]);
	}

	cout << setprecision(12) << fixed << mat[0][1] << endl;
}


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

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

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

template <class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template <class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template <class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }
template <class T> inline T bigmod(T p, T e, T m) { T ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % m; p = (p * p) % m; } return (T)ret; }



void solve() {
	long long r, D, x;
	cin >> r >> D >> x;


	for (int i = 1; i <= 10; i++) {
		x = r*x - D;
		cout << x << endl;
	}
}

int main()
{

	ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); cout.tie(nullptr); cin.tie(nullptr);

	int t = 1;
	while (t--) {

		solve();
	}


	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int rbc = 0;
  ll ans = 0;
  for (int i = s.size()-2; i >= 0; --i) {
    if (s[i] == 'A' && (s[i+1] == 'A' || s[i+1] == 'B')) {
      ans += rbc;
      continue;
    }
    if (s[i] == 'B' && s[i+1] == 'C') {
      ++rbc;
      continue;
    }
    if (s[i] == 'C' && (s[i+1] == 'A' || s[i+1] == 'B')) continue;
    rbc = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
n, k = list(map(int, input().split()))
s = list(str(input()))

if s[k-1] == "A":
    s[k-1] = "a"
if s[k-1] == "B":
    s[k-1] = "b"
if s[k-1] == "C":
    s[k-1] = "c"
print("".join([str(i) for i in s]))

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

using namespace std;

void trace(vector<int> a, int n)
{
	for (int i = 0;i < n;i++)
	{
		if (i > 0)cout << " ";
		cout << a[i];
	}
	cout << endl;
}

int bubbleSort(vector<int> A,int N)
{
	int swapv = 0;
	bool f = true;
	for (int i = 0;f;i++)
	{
		f = false;
		for (int j = N - 1;j >= i + 1;j--)
		{
			if (A[j] < A[j - 1])
			{
				swap(A[j], A[j - 1]);
				swapv++;
				f = true;
			}
		}
	}
	trace(A, N);

	return swapv;
}

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

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

	int sw = bubbleSort(A, N);

	cout << sw << endl;

	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){

    long long int n;
    cin >> n;

    long long int min = 9223372036854775807;
    for (int i = 1; i <= sqrt(n); ++i)
    {
        if(n%i==0){
            if((n/i-1)+(i-1)<min){
                min = (n / i - 1) + (i - 1);
            }
        }
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint N,K;
    cin >> N >> K;
    lint R,S,P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    lint ans=0;
    lint dp[N][3]={};
    rep(i,N){
        if(T[i]=='r') ans+=P;
        else if(T[i]=='s') ans+=R;
        else ans+=S;
    }
    for(int i=K;i<N;i++){
        if(T[i]==T[i-K]){
            if(T[i]=='r') ans-=P,T[i]='0';
            else if(T[i]=='s') ans-=R,T[i]='0';
            else ans-=S,T[i]='0';
        }
    }
    cout << ans << endl;
}

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

    public static void main(String[] args) {
        Scanner stdIn =new Scanner(System.in);
        int a,b,c;
        a = stdIn.nextInt();
        b = stdIn.nextInt();
        c = stdIn.nextInt();
        if (a < b && b < c) {
            System.out.println("Yes");
        }
        if (a > b && b > c){
            System.out.println("No");
        }
        if (a < b && b > c){
            System.out.println("No");
        }
        if (a > b && b < c){
            System.out.println("No");
        }
        if (a == b && b < c){
            System.out.println("No");
        }
        if (a < b && b ==c){
            System.out.println("No");
        }
        if (a == b && b > c){
            System.out.println("No");
        }
        if (a > b && b ==c){
            System.out.println("No");
        }
        if (a == b && b == c){
            System.out.println("No");
        }

    }
}

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

int main(void) {
    long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    b -= a;

    bool f = false;
    for(int i=0; i<n; i++) {
        long r1 = -i*c + (n-1-i)*d;
        long r2 = (n-1-i)*c - i*d;

        if(r1 <= b && b <= r2) f = true;
        if(r2 <= b && b <= r1) f = true;
    }
    cout << (f ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int H, W;
  while (cin >> H >> W) {
    vector<string> a(H);
    for (int i = 0; i < H; i++) cin >> a[i];
    bool reacheable = true;
    int y = 0, x = 0;
    while (y != H - 1 || x != W - 1) {
      if (x + 1 < W && a[y][x + 1] == '#') {
        ++x;
      } else if (y + 1 < H && a[y + 1][x] == '#') {
        ++y;
      } else {
        reacheable = false;
        break;
      }
    }
    int cnt = 0;
    for (auto& line : a) cnt += count(line.begin(), line.end(), '#');
    bool res = reacheable && cnt == H + W - 1;
    cout << (res ? "Possible" : "Impossible") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.map!(to!size_t), n = rd[0], m = rd[1];
  auto aij = n.iota.map!(_ => readln.split.map!(to!int)).array;
  auto bi = m.iota.map!(_ => readln.chomp.to!int).array;

  auto ci = new int[](n);
  foreach (i; 0..n)
    ci[i] = iota(m).map!(j => aij[i][j] * bi[j]).sum;

  ci.each!(writeln);
}

Measured memory_bytes: 2640
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;
#define MAX 44

int F[MAX];

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



Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    FOR(i, A, min(A + K, B + 1)) {
        cout << i << endl;
    }
    FOR(i, max(B - K + 1, A + K), B + 1) {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;

using namespace std;

int main(){
  int N;
  cin >> N;
  string s;
  map<string, int> mp;
  for(int i = 0; i < N; i++){
  	cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for(auto& m : mp){
  	int a = m.second;
    ans += (ll)a*(a-1)/2;
  }
	cout << ans << endl;
}

Measured memory_bytes: 11136
N=int(input())
T,A= map(int,input().split())
H_list=list(map(int,input().split()))

A_dif=[]

for i in range(N):
    A_dif.append(abs((T - H_list[i]*0.006)-A))

minimum = min(A_dif)
palace=0

for j in range(N):
    if minimum == A_dif[j]:
        palace = j+1
        break

print(palace)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll table[100001][21];

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> v;
    ll l;  // max travel distance per day
    for(long long i=0;i<n;i++){
        long long k;
        cin>>k;
        v.pb(k);
    }
    v.pb(1e17);
    cin>>l;
    int k=20;
    ll pointer=0;
    for(ll i=0;i<n;i++){
        for(ll j=pointer;j<=n;j++){
            if(v[j]-v[i]>l){
                pointer=j;
                table[i][0]=j-1;
                break;
            }
        }
    }
    for(ll j = 1; j <= k; j++) {
        for(ll i = 0; i <= n ; i++)
            table[i][j] = table[table[i][j - 1]][j-1];
    }
    ll q;
    cin>>q;
    for(ll i=0;i<q;i++){
        ll a,b;
        cin>>a>>b;
        if(a>b)
            swap(a,b);
        a--;
        b--;
        long long answer = 0;
        while(a<b){
            for(ll j = k; j >= 0; j--) {
                if(table[a][j] < b || j==0) {
                    answer = answer +(1<<j);
                    a=table[a][j];
                    break;
                }
            }
        }
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 18164