akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    string S, ans;
    cin >> S;

    int N = S.length();
    vector<int> array(N);

    rep(i, N){
        int froma;
        froma = S[i] - 'a';
        array[i] = froma;
    }
    
    ans = "";
    for(int i = 0; i < 26; i++){
        if(find(array.begin(), array.end(), i) == array.end()){
            array.push_back(i);
            for(int n: array){
                ans += 'a' + n;
            }
            cout << ans << endl;
            return 0;
        }
    }
    
    for(int i = N - 2; i >= 0; i--){
        for(int j = array[i] + 1; j < 26; j++){

            bool inArray = false;
            rep(k, i){
                if(array[k] == j){
                    inArray = true;
                }
            }
            if(!inArray){
                rep(k, i){
                    ans += 'a' + array[k];
                }
                ans += 'a' + j;
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;

    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i,kai;

	while(scanf("%d",&i)!=EOF){
		i%=39;
		if(i==0)i=39;
		if(i>9)
			printf("3C%d\n",i);
		else
			printf("3C0%d\n",i);
	}
	return 0;
}

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

using namespace std;

int main()
{
	string N;
	char checkValue;
	getline(cin, N);
	checkValue = N[1];
	if((N[0] == checkValue && N[2] == checkValue) || (N[2] == checkValue && N[3] == checkValue))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//最大公約数
long long gcd(long long a, long long b) {
  if (a < b) std::swap(a, b);
  long long r = a % b;
  while (r) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

  ll ans = 0;
  for (ll i = k + 1; i <= n; i++) {
    ll a, b = i;
    ans += (b - k) * (n / b);
    if (n % b > 0 && n % b > k - 1) {
      ans += n % b - max(0ll, k - 1);
    }
  }
  cout << ans << endl;
}

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

int nf[8];

int f(int h[], int n)
{
  int order[8];
  for (int i = 0; i < n; ++i) order[i] = i;
  
  int o = 0;
  for (int i = 0; i < n; ++i)
  {
    o += order[h[i]-1] * nf[n-1-i];
    for (int j = h[i]; j < n; ++j) --order[j];
  }
  
  return ++o;
}

int main()
{
  int n;
  cin >> n;
  int p[8], q[8];
  for (int i = 0; i < n; ++i) cin >> p[i];
  for (int i = 0; i < n; ++i) cin >> q[i];
  
  nf[0] = 1;
  for (int i = 1; i < n; ++i) nf[i] = nf[i-1] * i;
  
  int a = f(p, n), b = f(q, n);
  cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    cout << "2018" << S.substr( 4, S.size() ) << endl; 
    return 0;
}

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

int main(){
	char c;
	int a[26]={0};
	char d[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	int b,i;
	while(scanf("%c",&c)!=EOF){
		if(c>='a'&&c<='z'){
		b=c-'a';
		a[b]++;
		}
		else if(c>='A'&&c<='Z'){
		b=c-'A';
		a[b]++;
		}
	}
	for(i=0;i<26;i++){
		cout << d[i] << " : " << a[i] <<endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64



int main(){
    int n,k;
    cin >> n >> k;
    int tmp,ans=0;
    vector<int> A;
    REP(i,n){
        cin >> tmp;
        A.push_back(tmp);
    }
    Sort(A);
    Reverse(A);
    for(auto itr=A.begin();itr!=A.begin() + k;itr++) ans += *itr;    
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
N,W = map(int,input().split())
dp = np.full(N*1000+1,W+1)
dp[0] = 0
for _ in range(N):
    w,v = map(int,input().split())
    np.minimum(dp[v:],dp[:-v]+w,out = dp[v:])
print(np.where(dp<=W)[0][-1])

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n-1; i++) {
        if(s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    for(int i = 0; i < n-2; i++) {
        if(s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
def Sugar_water():
    key_list = ["wA", "wB", "sC", "sD", "dE", "tF"]
    # val = "1 2 1 2 100 1000"
    val = "17 19 22 26 55 2802"
    # val = "1 2 1 2 1 101"
    if 'LOCAL_FLAG' in globals():
        val_list = list(map(int, val.split()))
    else:
        val_list = list(map(int, input().split()))

    var = dict(zip(key_list, val_list))
    limit = var.copy()

    m_density=0
    m_sugar=0
    m_water=0

    limit_density=var['dE']/(100+var['dE'])
    limit['wA'] = int(var['tF']/100/var['wA'])
    limit['wB'] = int(var['tF']/100/var['wB'])

    for A in range(0, limit['wA']+1):
        for B in range(0, limit['wB']+1):
            water = 100*var['wA']*A + 100*var['wB']*B
            if(water > var['tF']):
                break
            elif((var['tF']-water)*m_density > (var['tF']-water)):
                break
            limit['sC'] = int(water/100*var['dE']/var['sC'])
            limit['sD'] = int(water/100*var['dE']/var['sD'])

            for C in range(0, limit['sC']+1):
                for D in range(0, limit['sD']+1):
                    sugar = var['sC']*C + var['sD']*D

                    total = water + sugar
                    density = sugar / total if total > 0 else 0

                    if(total > var['tF']):
                        break
                    elif(density > limit_density):
                        break
                    elif(density > m_density):
                        # print("# ", total, " ", sugar, " ", density, "  -- ", A, B, C, D)
                        m_density=density
                        m_sugar=sugar
                        m_water=water


    if(m_water == 0):
        m_water = 100*var['wA']
    print(m_sugar + m_water, " ", m_sugar)

Sugar_water()

Measured memory_bytes: 3188
while input = gets
    input = input.chomp.split(" ")
    
    a = input[0].to_i
    op = input[1]
    b = input[2].to_i
    
    case op
    when "+"
        puts a + b
    when "-"
        puts a - b
    when "*"
        puts a * b
    when "/"
        puts a / b
    end
end


Measured memory_bytes: 6868
#include <iostream>

int main(){
    long long n, m;
    std::cin >> n >> m;

    if(2 * n < m){
        std::cout << n + (m - 2 * n) / 4 << std::endl;;
    }else{
        std::cout << m / 2 << std::endl;
    }

    std::cout << "" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#ABC045C
S=input()
def DP(x,i):
    ans=0
    if i==len(S):
        if '+' in x:
            return eval(x)
        else:
            return int(x)
    else:
        ans+=DP(x+S[i],i+1)
        if i>0:
            ans+=DP(x+'+'+S[i],i+1)
        return ans
print(DP('',0))


Measured memory_bytes: 3188
#include <map>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int n=0,N,i,j,k,c;
	scanf("%d",&N);
	vector<map<int,int> >dist(N);
	vector<bool>used(N);
	vector<int>cost(N);
	for(;n<N;n++){
		cost[n]=9999999;
		for(scanf("%d%d",&i,&k);k--;dist[i][j]=c)scanf("%d%d",&j,&c); //i->j cost c
	}
	for(cost[0]=0;;){ //dijkstra
		int m=9999999;
		for(i=0;i<N;i++)if(!used[i]&&m>cost[i])m=cost[i];
		if(m==9999999)break;
		for(j=0;j<N;j++)if(m==cost[j]){
			map<int,int>::iterator it=dist[j].begin();
			for(used[j]=1;it!=dist[j].end();it++)if(cost[it->first]>it->second+cost[j])cost[it->first]=it->second+cost[j];
		}
	}
	for(i=0;i<n;i++)printf("%d %d\n",i,cost[i]);
}

Measured memory_bytes: 1268
#include<stdio.h>
#include<math.h>
int check(int x){
    int i;
    if(x%2==0&&x!=2||x==1)return 0;
    else if(x%2==1)for(i=3; i<=sqrt(x); i+=2)if(x%i==0)return 0;
    return 1;
}
int main(){
    int i, n, a, count=0;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a);
        if(check(a))count++;
    }
    printf("%d\n", count);
    return 0;
}

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

bool prime(int X) {
  if (X <= 1) return false;
  for (int i = 2; i*i <= X; i++) {
    if (X % i == 0) return false;
  }
  return true;
}

int main(void) {
  int X;
  cin >> X;
  for (int i = 0; ; i++) {
    if (prime(X + i)) {
      cout << X + i << endl;
      return 0;
    }
  }
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	int ans = 1;
	int current = H[0];
	for (int i = 1; i < N; i++) {
		if (current <= H[i]) {
			ans++;
			current = H[i];
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  stack<int> S1;
  stack<pair <int, int> > S2;

  char ch;
  int sum = 0;
  for (int i=0; cin>>ch; i++){
    if (ch == '\\') S1.push(i);
    else if (ch == '/' && S1.size() > 0){
      int j = S1.top(); S1.pop();
      sum += i-j;
      int a = i-j;
// WAKARAN
      while (S2.size() > 0 && S2.top().first > j) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  int t = 0;
  while ( S2.size() > 0) {ans.push_back(S2.top().second); S2.pop(); }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i=0; i < ans.size(); i++){
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3160
#include <iostream>

using namespace std;

int main(){
  while(true){
    int n,a,b,c,x,y,r;
    cin >> n >> a >> b >> c >> x;
    if (n == 0)
	break;
    cin >> y;
    r = 0;
    while(r <= 10000){
      if (x == y){
	n--;
	if (n>0){
	  cin >> y;
	}
	else{
	  break;
	}
      }
      x = (a*x+b)%c;
      r++;
    }
    n--;
    while(n>0){
      cin >> y;
      n--;
    }
    if (r == 10001)
      r = -1;
    cout << r << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
9
0 0 0 0 0 0 0 0 0
)");
#define cin input
#endif

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

	vector<int> a(n);
	for (auto& i : a)
		cin >> i;

	ll r = 0;

	int c = 0;
	int i = 0, j = 0;
	while (i < n)
	{
		if (j == n || c & a[j])
		{
			r += j - i;
			c &= ~a[i++];
		}
		else
			c |= a[j++];
	}

	cout << r << endl;

	return 0;
}


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

int main()
{
  int n, m;

  while (scanf("%d%d", &n, &m), n || m){
    bool check[501][501] = {false};
    int a, b;
    for (int i = 0; i < m; i++){
      scanf("%d%d", &a, &b);
      check[a][b] = check[b][a] = true;
    }
    int cnt = 0;
    bool mem[501] = {false};
    for (int i = 2; i <= n; i++){
      if (check[1][i]){
        mem[i] = true;
        for (int j = 2; j <= n; j++){
          if (check[i][j]){
            mem[j] = true;
          }
        }
      }
    }
    for (int i = 2; i <= n; i++){
      if (mem[i]){
        cnt++;
      }
    }
    printf("%d\n", cnt);
  }

  return (0);
}

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

#define all(x) (x).begin(), (x).end()
#define X real()
#define Y imag()

typedef array<int, 3> tri;
typedef long long ll;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; cout << '\n'; return O;}


void _main() {
        int n, k; cin >> n >> k;
        vector<int> vec(n); cin >> vec;
        auto valid = [&](int w) {
                int cnt = 0;
                for (const auto it: vec) cnt += (it + w - 1) / w - 1;
                return cnt <= k;
        };


        int l = 1, r = *max_element(all(vec));
        int ans = r;
        while (l <= r) {
                int mid = (l + r) / 2;
                if (valid(mid)) ans = mid, r = mid - 1;
                else l = mid + 1;
        }

        cout << ans;
}

int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ
{
    class Program
    {
        static readonly int[] stops_ = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };
        static readonly int nInvalidStops_ = stops_.Length + 1;

        static int checkLoop(int stopNoGetOff, ref List<int> result, int iCurrent)
        {
            for (; ; )
            {
                var iNext = (iCurrent + 1) % stops_.Length;
                var next = stops_[iNext];
                result.Add(next);
                if (stopNoGetOff == next)
                {
                    return result.Count;
                }
                iCurrent = iNext;
            }
        }
        static int traverseInner(int stopNoGetOff, ref List<int> result, int iCurrent)
        {
            var iNext = (iCurrent + 1) % stops_.Length;
            var next = stops_[iNext];
            result.Add(next);
            if (stopNoGetOff == next)
            {
                return result.Count;
            }
            return traverseInner(stopNoGetOff, ref result, iNext);
        }
        static int traverse(int stopNoGetOn, int stopNoGetOff, ref List<int> result)
        {
            int count = nInvalidStops_;   // 最小の結果を返したい
            for (int i = 0; i < stops_.Length; ++i)
            {
                if (stops_[i] == stopNoGetOn)
                {
                    List<int> temp = new List<int>();
                    temp.Add(stopNoGetOn);
#if true
                    var tempCount = traverseInner(stopNoGetOff, ref temp, i);
#else
                    var tempCount = checkLoop(stopNoGetOff, ref temp, i);
#endif
                    if (tempCount < count)
                    {
                        result = temp;
                        count = temp.Count;
                    }
                }
            }
            return result.Count;
        }
        static void Main(string[] args)
        {
            var count = int.Parse(Console.In.ReadLine());
            for (int i = 0; i < count; ++i)
            {
                var inputs = Console.In.ReadLine().Split(' ');
                var istopGetOn = int.Parse(inputs[0]);
                var istopGetOff = int.Parse(inputs[1]);

                var resultLeft = new List<int>();
                var countLeft = traverse(istopGetOn, istopGetOff, ref resultLeft);

                var resultRight = new List<int>();
                var countRight = traverse(istopGetOn, istopGetOff, ref resultRight);

                List<int> result;
                if (countLeft == 0 && countRight == 0)
                {
                    throw new Exception("乗り降りできない");
                }

                if (countLeft < countRight)
                {
                    result = resultLeft;
                }
                else
                {
                    result = resultRight;
                }

                Console.Out.WriteLine(string.Join(" ", result.ToArray()));
            }
        }
    }
}



Measured memory_bytes: 13892
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N];

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for(int i = 1, x; i <= n; ++i) {
    scanf("%d", &x);
    a[x]++;
  }
  sort(a + 1, a + 1 + n);
  int ans = 0;
  for(int i = n - k; i >= 1; --i) {
    ans += a[i];
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1024
// AOJ 2197
#include<iostream>
#include<cmath>
using namespace std;

int solve(int N) {
  int answers = 0;
  for (int nums = 2 * sqrt(2 * N); nums > 1; nums--) {
    for (int a = 1; (a + a + nums - 1) * nums / 2 <= N; a++) {
      if ((a + a + nums - 1) * nums / 2 == N) {
        answers++;
      }
    }
  }
  return answers;
}

int main() {
  int n;
  while (cin >> n and n) {
    cout << solve(n) << endl;
  }
}

Measured memory_bytes: 1160
import java.io.*;
import java.math.BigInteger;
import java.util.*;

 
public class Main{
	/*
	 * use Integer for sorting
	 * avoid object comparison
	 * NEVER APPEND A STRING -> APPEND char by char
	 * Always use TreeSet instead of HashSet
	 * 
	 */
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e8;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static long[] fac;
    public static int N = 400000+200;
    public static int x = 0;
    public static boolean[] visited;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		int i=0,j=0,k=0;
		while(i < n || j < n) {
			if(k == 0) out.print(s[i++]);
			else out.print(t[j++]);
			k^=1;
		}
		
		
		
		out.close();
	}
}

Measured memory_bytes: 22484
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int n, i, j, k, a[303][303];
	bool us[303][303] = { false };
	ll ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++) for (j = 0; j < n; j++) {
		scanf("%d", &a[i][j]);
	}

	for (i = 0; i < n; i++) for (j = i + 1; j < n; j++) for (k = 0; k < n; k++) {
		if (i == k || j == k) continue;
		if (a[i][j] > a[i][k] + a[k][j]) {
			printf("-1\n");
			return 0;
		}
		if (a[i][j] == a[i][k] + a[k][j]) {
			us[i][j] = true;
		}
	}

	ans = 0;
	for (i = 0; i < n; i++) for (j = i + 1; j < n; j++) {
		if (!us[i][j]) {
			ans += a[i][j];
		}
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
 
using namespace std;
 
struct Node{
    Node(){
        left_child = right_child = parent = -1;
    };
    int left_child,right_child,parent;
};
 
void preORDER(Node order[],int id){
    printf(" %d",id);
    if(order[id].left_child != -1) preORDER(order,order[id].left_child );
    if(order[id].right_child != -1) preORDER(order,order[id].right_child );
}
 
void inORDER(Node order[],int id){
    if(order[id].left_child != -1) inORDER(order,order[id].left_child );
    printf(" %d",id);
    if(order[id].right_child != -1) inORDER(order,order[id].right_child );
}
 
void postORDER(Node order[],int id){
    if(order[id].left_child != -1) postORDER(order,order[id].left_child );
    if(order[id].right_child != -1) postORDER(order,order[id].right_child );
    printf(" %d",id);
}
 
int main(){
    int n,id,left,right,root_id;
    scanf("%d",&n);
    Node order[n];
    for(int i = 0; i < n; i++){
        scanf("%d %d %d",&id,&left,&right);
        if(left != -1){
            order[id].left_child = left;
            order[left].parent = id;
        }
        if(right != -1){
            order[id].right_child = right;
            order[right].parent = id;
        }
    }
 
    for(root_id = 0; root_id < n; root_id++){
        if(order[root_id].parent == -1) break;
    }
 
    printf("Preorder\n");
    preORDER(order,root_id);
    printf("\n");
 
    printf("Inorder\n");
    inORDER(order,root_id);
    printf("\n");
 
    printf("Postorder\n");
    postORDER(order,root_id);
    printf("\n");
}


Measured memory_bytes: 2716
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i = 0; i < N - 1; i++){
        int cnt = 0;
        vector<int> c1(26), c2(26);
        for(int j = 0; j < N; j++){
            if(j <= i){
                c1[S[j] - 'a']++;
            }
            else c2[S[j] - 'a']++;
        }
        for(int j = 0; j < 26; j++){
            if(c1[j] > 0 && c2[j] > 0) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll n, a, b;
    cin >> n >> a >> b;

    cout << n / (a + b) * a + min(a, n % (a + b)) << "\n";
    return 0;
}

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

int main() {
  int K,X;
  cin >> K >> X;
  int a;
  a= X-K+1;
  int b;
  b= X+K-1;
  for (int i=a; i<=b; i++){
  cout << i << " " ;
  }
  
}

Measured memory_bytes: 256
n,m = map(int,input().split())
li = list(map(int,input().split()))

if n >= m:
  print(0)
else:
  li = sorted(li)
  diff = [0]*(m-1)
  for i in range(m-1):
    diff[i] = li[i+1] - li[i]
  diff = sorted(diff)
  if n == 1:
    print(sum(diff))
  else:
    print(sum(diff[:-n+1]))

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

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n, c; cin >> n >> c;
    vector<vector<ll> > lis(n, vector<ll>(2, 0));
    REP(i, 0, n){
        cin >> lis[i][0] >> lis[i][1];
    }
    vector<vector<ll>> right(n+1, vector<ll>(2, 0)), left(n+1, vector<ll>(2, 0));
    REP(i, 0, n){
        right[i+1][1] = right[i][1] + lis[i][1];
        right[i+1][0] = lis[i][0];
    }
    REP(i, 0, n){
        ll a = right[i+1][1] - right[i+1][0];
        ll b = right[i][1] - right[i][0];
        if(b > a){
            right[i+1] = right[i];
        }
        //cout << right[i+1][0] << " " << right[i+1][1] << endl;
    }
    REP(i, 0, n){
        left[i+1][1] = left[i][1] + lis[n-i-1][1];
        left[i+1][0] = c - lis[n-i-1][0];
    }
    REP(i, 0, n){
        ll a = left[i+1][1] - left[i+1][0];
        ll b = left[i][1] - left[i][0];
        if(b > a){
            left[i+1] = left[i];
        }
        //cout << left[i+1][0] << " " << left[i+1][1] << endl;
    }
    ll ans = 0;
    REP(i, 0, n+1){
        ll a;
        if(left[n-i][1] - left[n-i][0] - right[i][0] > 0){
            a = (right[i][1] - right[i][0]) + (left[n-i][1] - left[n-i][0]) - right[i][0];
        }else{
            a = (right[i][1] - right[i][0]);
        }
        ans = max(ans, a);
    }
    REP(i, 0, n+1){
        ll a;
        if(right[n-i][1] - right[n-i][0] - left[i][0] > 0){
            a = (left[i][1] - left[i][0]) + (right[n-i][1] - right[n-i][0]) - left[i][0];
        }else{
            a = (left[i][1] - left[i][0]);
        }
        ans = max(ans, a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 19628
H, W = map(int,input().split())
MAP = []
INF = 10 ** 8
for _ in range(H):
    MAP.append(input())

dp = [[0 for i in range(W)] for i in range(H)]

for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            if MAP[i][j] == "#":
                dp[i][j] = 1
        elif i == 0:
            flag = 0
            if MAP[i][j] == "#" and MAP[i][j-1] == ".":
                flag = 1
            dp[i][j] = flag + dp[i][j-1]
        elif j == 0:
            flag = 0
            if MAP[i][j] == "#" and MAP[i-1][j] == ".":
                flag = 1
            dp[i][j] = flag + dp[i-1][j]
        else:
            flag1 = 0
            flag2 = 0
            if MAP[i][j] == "#" and MAP[i][j-1] == ".":
                flag1 = 1
            if MAP[i][j] == "#" and MAP[i-1][j] == ".":
                flag2 = 1
            dp[i][j] = min(dp[i][j-1]+flag1,dp[i-1][j]+flag2)
        

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

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define pb push_back
#define f first
#define s second
#define INF 1000000000000
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 1100, MAXK = 25;
const ll MOD = 1e9+7;

bool grid[MAXN][MAXN];
ll dp[MAXN][MAXN];

int main()
{
    FAST_IO;

    int h, w; cin >> h >> w;
    FOR(i, 1, h) FOR(j, 1, w) {
        char c; cin >> c;
        grid[i][j] = (c=='.');
    }

    dp[1][1] = 1;
    grid[1][1] = false;
    FOR(i, 1, h) FOR(j, 1, w) {
        if (!grid[i][j]) continue;
        dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
    }

    cout << dp[h][w] << endl;

    return 0;
}


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

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

    string op;
    cin >> op;

    int b;
    cin >> b;

    if (op == "+")
    {
       cout << (a+b) << endl;
    } else if (op=="-")
    {
        cout << (a-b) << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m;
  cin >> n >> m;
  for(ll i=0;i<(m+1)/2;i++) {
    cout << (m+1)/2-i << " " << (m+1)/2+1+i << endl;
  }
  for(ll i=0;i<m-(m+1)/2;i++) {
    cout << (m+1)/2+m-i << " " << (m+1)/2+m+2+i << endl;
  }
}

Measured memory_bytes: 3564
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<limits>
#include<stdio.h>
using namespace std;
typedef long long ll;

void solve() {
	string str;
	cin >> str;
	int ans = 0;
	
	int N = (int)(str.length());
	for (int i = 0;i < N;i += 2) {
		if (str[i]=='R' || str[i]=='U' || str[i]=='D')ans++;
	}
	
	for (int i = 1;i < N;i += 2) {
		if (str[i] == 'L' || str[i] == 'U' || str[i] == 'D')ans++;
	}
	
	if (ans == N) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	
}


int main() {
	solve();

}

Measured memory_bytes: 256
#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<int,int> 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;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder

vector<string> s(101);

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,l;
    cin >> n >> l;
    for(int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s.begin(),s.begin()+n);
    for(int i = 0; i < n; i++)
    {
        cout << s[i];
    }
    cout << endl;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;

    int a = 1, b = n;
    unordered_set<int> st;
    for (int i=0; i<m; i++) {
        while (st.count(b - a) || st.count(n + a - b) || b - a == n + a - b)
            b--;
        cout << a << " " << b << "\n";
        st.insert(b - a);
        st.insert(n + a - b);
        a++;
        b--;
    }

    return 0;
}


Measured memory_bytes: 10880
#include <iostream>
#include <fstream>
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <cstring>
#include <numeric>
#include <stack>
#include <iomanip>
#include <chrono>
using namespace std;

#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385

#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",mark)
#define sl(mark) scanf("%lld",&mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define setinf(mark) memset(mark,0x3f,sizeof(mark))

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

#define int ll

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

#ifndef KaalaNamak
#define endl '\n'
#define trace(...)
#define start_routine() 
#define end_routine()
#endif

signed main() {
    start_routine();
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout<<fixed<<setprecision(10);
    int t=1;
    // cin>>t;
    #ifdef KaalaNamak
        // t=4;
    #endif
    while(t--){
        int n;
        cin>>n;
        int a=2*mod,b=-1*a,c=2*mod,d=b;
        int x,y;
        for(int i=0;i<n;i++){
            cin>>x>>y;
            a=min(a,x+y);
            b=max(b,x+y);
            c=min(c,x-y);
            d=max(d,x-y);
        }
        cout<<max(b-a,d-c);

    }
    end_routine();

} 

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}



signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int k;
    cin>>k;
    int base=k/50;
    int numplus=k%50;
    cout<<50<<endl;
    REP(i,0,numplus){
        cout<<base+100-numplus<<" ";
    }
    REP(i,0,50-numplus){
        cout<<base+49-numplus<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=1e9;
const double eps=1e-9;
typedef long long ll;
inline ll read(){
	ll x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	ll a,b,c,d;
	ll i,j,k,m,n;
	a=read();b=read();c=read();d=read();
	n=read();
	c=min(min(min(c,b*2),a*2+b),a*4);
	if(c>d/2)
		if(n%2==0)
			printf("%lld\n",1ll*d*n/2ll);
		else printf("%lld\n",1ll*d*(n/2ll)+c);
	else printf("%lld\n",1ll*c*n);
	return 0;
}


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

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

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

int main()
{
  	int w, h, n;
  	cin>>w>>h>>n;
  	int xm = 0, xM = w, ym = 0, yM = h;
  	for(int i = 0; i < n; i++)
    {
    	int x, y, a;
      	cin>>x>>y>>a;
      	if(a == 1)
          	xm = max(xm, x);
      	else if(a == 2)
          	xM = min(xM, x);
      	else if(a == 3)
          	ym = max(ym, y);
      	else
          	yM = min(yM, y);
    }
  	if((xM > xm) && (yM > ym))
      	cout<<(xM-xm)*(yM-ym)<<"\n";
  	else
      	cout<<0<<"\n";
	return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> v(n,0);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        v[a-1]++;
        v[b-1]++;
    }
    rep(i,n) cout << v[i] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#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--)
#define sz(a) (int) a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
//-----
const int N = 2e5+7;
int dp[2007][4007];
int r[N],b[N],n;
const int MOD = 998244353;
int C[4007][4007];
int add(int a,int b) {
    a += b;
    if(a >= MOD) a -= MOD;
    return a;
}
int dfs(int dep,int hr,int hb,int rr,int rb) {
    if(dep == n) {
        return C[rr+rb][rr];
    }
    dep++;
    if(dp[dep][hr] != -1) return dp[dep][hr];
    rr += r[dep];
    rb += b[dep];

    int ret = 0;
    if(rr) ret = add(ret,dfs(dep,hr+1,hb,rr-1,rb));
    if(rb) ret = add(ret,dfs(dep,hr,hb+1,rr,rb-1));
    return dp[dep][hr] = ret;
}
char s[4007];
int main()
{
    scanf("%s",s+1);
    //scanf("%d",&n);
    n = strlen(s+1);
    memset(dp,-1,sizeof(dp));
    rep(i,0,2*n+3) {
        rep(j,0,i+1) {
            if(j == 0 || i == j) C[i][j] = 1;
            else C[i][j] = add(C[i-1][j],C[i-1][j-1]);
        }
    }
    rep(i,1,n+1) {
        char t = s[i];
        if(t == '0') r[i] = 2;
        else if(t == '1') r[i] = b[i] = 1;
        else b[i] = 2;
    }
    printf("%d\n",dfs(0,0,0,0,0));
    return 0;
}


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

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

int main( void )
{
	string w;
	cin >> w;

	bool flg[26] = {};
	for ( char& c : w ) {
		flg[c - 'a'] = !flg[c - 'a'];
	}

	rep( i, 26 ) {
		if ( flg[i] ) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.StringBuilder;

class Main {


    private static String toString(int[] numbers){
        StringBuilder ans = new StringBuilder().append(numbers[0]);
        for (int x = 1; x < numbers.length; x++)
            ans.append(" ").append(numbers[x]);
        return ans.toString();
    }

    public static void main(String[] args) {



        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] A = new int[n];

        for (int i = 0; i < n; i++)
            A[i] = sc.nextInt();


        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = n-1; j > i; j--) {
                if(A[j] < A[j-1]){
                    int temp = A[j-1];
                    A[j-1] = A[j];
                    A[j] = temp;
                    count++;
                }

            }
        }

        System.out.println(toString(A));
        System.out.println(count);
    }
}



Measured memory_bytes: 26332
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
int main(void)
{
    int N;

    cin >> N;

    cout << (N-2)*180 << endl;

    return 0;
}

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

int main() {
  ll a,b; cin >> a >> b;
  ll p = a+b;
  ll m = a-b;
  ll e = a*b;
  cout << max({p,m,e}) << endl;
  
  return 0;
}



Measured memory_bytes: 256
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    students = list(map(string_to_int, inputs[:N]))
    points = list(map(string_to_int, inputs[N:]))
    s_p = []

    for s in students:
        min_d = None
        min_p = None
        for i, p in enumerate(points):
            d = abs(s[0] - p[0]) + abs(s[1] - p[1])
            if min_d is None or min_d > d:
                min_d = d
                min_p = i
        s_p.append(min_p+1)
    return s_p


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(N+M))
    for r in ret:
        print(r)


Measured memory_bytes: 39664
n = int(raw_input())
a = map(int,raw_input().split(' '))

nswap = 0
for i in range(n):
    for j in reversed(range(i+1,n)):
        if a[j] < a[j-1]:
            a[j],a[j-1]=a[j-1],a[j]
            nswap+=1

print ' '.join([str(v) for v in a])
print nswap

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

int main()
{
    ll N, T;
    cin >> N >> T;
    vector<ll> t(N);
    rep(i, N) cin >> t.at(i);

    ll answer = T;
    for (int i = 1; i < N; i++)
    {
        if (t.at(i) - t.at(i - 1) <= T)
        {
            answer += t.at(i) - t.at(i - 1);
        }
        else
        {
            answer += T;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 1792
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
int main()
{
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

#define LL long long
const int N = 211;
const int mod = 998244353;
int n;
LL base[N];

struct ddd {
	int x, y;
}nd[N];

LL sq(LL x) { return x * x; }

bool check(LL x1, LL y1, LL x2, LL y2) {
	LL a = x1 * x2 + y1 * y2;
	LL b = (sq(x1) + sq(y1)) * (sq(x2) + sq(y2));
	return a > 0 && b == sq(a);
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &nd[i].x, &nd[i].y);
	}
	base[0] = 1;
	for (int i = 1; i <= 200; i++)base[i] = base[i - 1] * 2 % mod;
	LL ans = (base[n] - 1 - n + mod) % mod;
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			int tot = 0;
			for (int k = 1; k <= n; k++) {
				if (i == k || j == k)continue;
				if (check(nd[i].x - nd[k].x, nd[i].y - nd[k].y, nd[k].x - nd[j].x, nd[k].y - nd[j].y))tot++;
			}
			ans = (ans + mod - base[tot]) % mod;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      double p = 0;
      for (int k = 0; k < d; k++) {
        p += pow(x[i][k] - x[j][k], 2);
      }
      p = sqrt(p);
      if (p == floor(p)) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3736
N = input()
K = int(input())

# dp[i][j][smaller] := i 桁目まで追加して, 0の個数がj個の数字の個数
keta = len(N)

dp = [[[0] * 2 for _ in range(K+3)] for __ in range(keta + 1)]

dp[0][0][0] = 1

for i in range(keta):
    now_digit = int(N[i])
    for k in range(10):
        for j in range(K+1):
            if k == 0:
                if k < now_digit:
                    dp[i+1][j][1] += dp[i][j][1] + dp[i][j][0]
                elif k == now_digit:
                    dp[i+1][j][1] += dp[i][j][1]
                    dp[i+1][j][0] += dp[i][j][0]
                else:
                    dp[i+1][j][1] += dp[i][j][1]
            else:
                if k < now_digit:
                    dp[i+1][j+1][1] += dp[i][j][1] + dp[i][j][0]
                elif k == now_digit:
                    dp[i+1][j+1][1] += dp[i][j][1]
                    dp[i+1][j+1][0] += dp[i][j][0]
                else:
                    dp[i+1][j+1][1] += dp[i][j][1]
print(dp[-1][K][0] + dp[-1][K][1])

Measured memory_bytes: 3064