akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define OM ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define pi 3.14159265358979323846

typedef long long ll;

/*LETS BEGIN WITH THE NAME OF MAHADEV*/

int main(){
	OM;
	int t;
	cin >> t;
	cout << (t >= 30 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vvint ans(10,vint(10));
  erep(i,n){
    if(i % 10 != 0){
      int num = i;
      int down = num % 10;
      while(num >= 10){
        num /= 10;
      }
      int up = num;
      ans[up][down]++;
    }
  }
  int ANS = 0;
  rep1(i,10){
    rep1(j,10){
      //cout << ans[i][j] << ' ';
      ANS += ans[i][j]*ans[j][i];
    }
    //cout << endl;
  }
  cout << ANS << endl;
}

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

int main(){
	while(1){
		unsigned int a, b;
		cin >> a >> b;
		if(a == 0 && b == 0) break;
		if(a < b) swap(a, b);
		int ans = 0;
		while(b != 0){
			int temp = a;
			a = b;
			b = temp % b;
			ans++;
		}
		cout << a << ' ' << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
using namespace std;
int main(){
	long n,ans=0;
	string temp;
	char target[5]={'M','A','R','C','H'};
	long count[5]={0,0,0,0,0};

	cin >>n;
	for(int i=0;i<n;i++){
		cin >>temp;
		for(int j=0;j<5;j++){
			if(temp[0]==target[j])count[j]++;
		}
	}
	for(int i=0;i<3;i++){
		for(int j=i+1;j<4;j++){
			for(int k=j+1;k<5;k++){
				ans+=count[i]*count[j]*count[k];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  ll a[252521];;
  cin>>n;
  REP(i, n){
    cin>>a[i];
  }
  sort(a, a+n);
  int cur=2, idx=n-2;
  ll ans=a[n-1];
  while(cur<n){
    if(cur+1==n){
      ans+=a[idx];
      break;
    }
    ans+=a[idx]*2;
    --idx;
    cur+=2;
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 5144
import java.io.*;
import java.util.*;

public class Main {
	static int vertex;
	static int edge;
	static int start;
	static int[] cost;
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static Main obj = new Main();
	static ArrayList<Edge>[] graph;

	private class Edge implements Comparable<Edge> {
		int from;
		int to;
		int weight;

		public Edge(int a, int b, int c) {
			from = a;
			to = b;
			weight = c;
		}

		@Override
		public int compareTo(Edge other) {
			return weight - other.weight;
		}
	}

	public static void main(String[] args) throws IOException {
		input();
		compute(start);

	}

	public static void compute(int a) {
		if (vertex == 0 || edge == 0) {
			System.out.println(0);
			System.exit(0);
		}
		cost[a] = 0;
		ArrayList<Edge> temp = graph[a];
		for (Edge e : temp) {
			if (cost[e.to] > e.weight) {
				cost[e.to] = e.weight;
			}
		}
		boolean changed = true;
		int index = 1;
		while (changed) {
			if (index == vertex) {
				System.out.println("NEGATIVE CYCLE");
				System.exit(0);
			}
			changed = false;
			for (int i = 1; i <= vertex; i++) {
				for (Edge e : graph[i]) {
					if (cost[e.from] != Integer.MAX_VALUE && cost[e.to] > e.weight + cost[e.from]) {
						cost[e.to] = e.weight + cost[e.from];
						changed = true;
					}
				}
			}
			index++;
		}
		for (int i = 1; i < cost.length; i++) {
			if(cost[i]!= Integer.MAX_VALUE){
				System.out.println(cost[i]);
			}else{
				System.out.println("INF");
			}
		}
	}

	@SuppressWarnings("unchecked")
	public static void input() throws IOException {
		StringTokenizer st = new StringTokenizer(br.readLine());
		vertex = Integer.parseInt(st.nextToken());
		edge = Integer.parseInt(st.nextToken());
		start = Integer.parseInt(st.nextToken())+1;
		graph = new ArrayList[vertex + 1];
		cost = new int[vertex + 1];
		for (int i = 1; i <= vertex; i++) {
			graph[i] = new ArrayList<Edge>();
			cost[i] = Integer.MAX_VALUE;
		}
		for (int i = 0; i < edge; i++) {
			st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			graph[a+1].add(obj.new Edge(a+1, b+1, c));
		}

	}
}

Measured memory_bytes: 45952
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF (1e9)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define print(s) cout<<(s)<<endl
#define all(x) (x).begin(),(x).end()

int main() {
    int N;
    vector<int> l;
    cin >> N;
    rep(i, 0, N){
        int x;
        cin >> x;
        l.push_back(x);
    }
    int ans;
    rep(i, 0, N - 1){
        rep(j, i + 1, N){
            ans += l[i] * l[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=2000010, inf=1e9, mod=1e9+7;
int pos, pos2;
ll a, b, ans;

inline void read(ll &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-' && (f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;
}

int main()
{
	read(a); read(b); if(a==b) return puts("1"), 0;
	for(int i=60;~i;i--) 
	if(((a>>i)&1)!=((b>>i)&1)) {pos=i; break;}
	a&=(1ll<<(pos+1))-1; b&=(1ll<<(pos+1))-1; pos2=-1;
	for(int i=pos-1;~i;i--) if((b>>i)&1) {pos2=i; break;} pos2++;
	ans=(1ll<<pos)+(1ll<<pos2)-a;
	ans+=(1ll<<(pos+1))-((1ll<<pos)+a)-max(0ll, (1ll<<pos)+(1ll<<pos2)-(1ll<<pos)-a);
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
using namespace std;
#define MAX_A 17
#define MAX_B 17
#define MAX_N 40

int a, b, n, i, j, x, y, dp[MAX_A][MAX_B];
int sort(const void *a, const void *b){
  return *(int*)b - *(int*)a;
}

int main(){
  while(1){
    scanf("%d %d", &a, &b);
    if(a == 0 && b == 0) break;
    for(i = 0; i <= a; i++) dp[a][0] = 0;
    for(i = 0; i <= b; i++) dp[0][b] = 0;
    for(i = 1; i <= a; i++)
      for(j = 1; j <= b; j++)
	dp[i][j] = -1;
    dp[1][1] = 1;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
      scanf("%d %d", &x, &y);
      dp[x][y] = 0;
    }
    for(i = 1; i <= a; i++){
      for(j = 1; j <= b; j++){
	if(dp[i][j] != -1) continue;
	dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
      }
    }
    printf("%d\n", dp[a][b]);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  int n, k;
  cin >> n >> k;
  V h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(), h.end());
  int mi = 1e9;
  for (int i = 0; i <= n-k; i++) {
    mi = min(mi, h[i+k-1] - h[i]);
  }
  dump(mi);
  return 0;
}

Measured memory_bytes: 640
//temprates
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using ll = long long;
using namespace std;

#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define LFOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define FORR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LFORR(i,a,b) for(ll i = (int)(a); i >= (ll)(b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define LREP(i,n) LFOR(i,0,(ll)(n)-1)
#define REPR(i,n) FORR(i,(int)(n)-1,0)
#define LREPR(i,n) LFORR(i,(ll)(n)-1,0)

#define SIZ(v) int(v.size())
const int INF = 1e8;
const ll LINF = 1e15;
const int MOD = 1e9+7;

typedef vector<int> point;

ll dist(int d, point X, point Y){
  ll res=0;
  REP(i,d){
    res += (X[i]-Y[i])*(X[i]-Y[i]);
  }
  return res;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,d;
  vector<point> X;
  vector<int> annt;
  REP(i,150){
    annt.push_back(i*i);
  }

  int ans=0;

  cin >> n >> d;
  X.resize(n);
  REP(i,n){
    REP(j,d){
      int k; cin >> k;
      X[i].push_back(k);
    }
  }
  REP(i,n-1){
    FOR(j,i+1,n-1){
      if(binary_search(annt.begin(),annt.end(),
          dist(d,X[i],X[j]))) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 30;
const int MAXL = (1 << 21) + 40;
const int MOD = 1e9 + 7;
int dp[MAXN][MAXL], mask[MAXN], n;
int fazdp(int pos, int bmask){
	if(pos == n) return (__builtin_popcount(bmask) == n);
	if(dp[pos][bmask] != -1) return dp[pos][bmask];
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(!(bmask &  (1 << i)) && (mask[pos] & (1 << i))){
			ans  = (ans + fazdp(pos + 1, bmask | (1 << i))) % MOD;
		}

	}
	return dp[pos][bmask] = ans;

	


}



int main(){
	scanf("%d", &n);
	memset(dp, -1, sizeof(dp));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			int h;
			scanf("%d", &h);
			if(h){
				mask[i] |= (1 << j);
			}


		}


	}

	printf("%d\n", fazdp(0, 0));




}

Measured memory_bytes: 246016
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        s:Bytes,
    }
    if (s[0] == s[1] && s[2] == s[3])
        || (s[1] == s[2] && s[0] == s[3])
        || (s[0] == s[2] && s[1] == s[3])
    {
        if s[0] != s[1] || s[1] != s[2] || s[2] != s[3] {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final String s = scanner.next();
        final String t = scanner.next();

        final long answer = IntStream.range(0, s.length())
            .filter(i -> s.charAt(i) != t.charAt(i))
            .count();

        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

Measured memory_bytes: 38164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	ll a,b,c,sum=0;
	cin>>a>>b>>c;
	if(a+b>=c)
		cout<<c+b<<endl;
	else
		cout<<min(a+b,c)+1+b<<endl;
	return 0;
}

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

using namespace std;

int main(void)
{
	int n, x;

	cin >> n >> x;

	vector<int> list;

	for (int i = 0; i < n; i++)
	{
		int m;
		cin >> m;

		list.push_back(m);
	}

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

	int num = 0;

	for (int i = list.size() - 1; i >= 0; i--)
	{
		x -= list[i];
		num++;
	}

	while (x - list[0] >= 0)
	{
		x -= list[0];
		num++;
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 256
import math

def rank_checker(P):
  rank = 1
  N = len(P)
  L = list(range(1, N + 1))
  for i in range(N):
    weight = L.index(P[i])
    penalty = math.factorial(len(L) - 1)
    rank += weight * penalty
    L.pop(weight)
  return rank


_ = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

rankP = rank_checker(P)
rankQ = rank_checker(Q)
print(abs(rankP - rankQ))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int x=0;
        int max=0;
        int n = sc.nextInt();
        char[] input = sc.next().toCharArray();

        for(char c: input){
            if(c == 'I'){
                x++;
            } else if(c == 'D'){
                x--;
            }

            max = Math.max(max, x);
        }

        System.out.println(max);
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,c=0;
  long long x,y,D;
  cin >> N >> D;
  for(int i=0; i<N; i++){
    cin >> x;
    cin >> y;
    if(x*x+y*y <= D*D){
      c++;
    }
  }
  cout << c;
}

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

int main() {
  int l, r, d;

  cin >> l >> r >> d;
  int count = 0;
  for (int i = l; i <= r; i += 1) {
    if (i%d == 0) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


int n;
vvll va, dp;

void init()
{
	cin >> n;
	va.resize(n, vll(3));
	REP(i, n) cin >> va[i][0] >> va[i][1] >> va[i][2];

	dp.resize(n + 1, vll(3, 0));
}

int main()
{
	init();

	REP(i, n)
	{
		REP(j, 3)
		{
			REP(k, 3)
			{
				if (j != k)
					chmax(dp[i + 1][j], dp[i][k] + va[i][j]);
			}
		}
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}


Measured memory_bytes: 11136
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
ans = 100
def colsum(s):
    ret = 0
    for i in s:
        ret += int(i)
    return ret

for i in range(1,n):
    cand = colsum(str(i))+colsum(str(n-i))
    ans = min(cand,ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  char s;
  REP(i,n){
    cin >> s;
    if(s=='Y'){
      cout << "Four";
      return 0;
    }
  }
  cout << "Three";
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	cin >> N;
	int arr[3*N] = {0};
	REP(i, 0, 3*N) cin >> arr[i];
	sort(arr, arr+3*N);
	
	ll ans = 0, index = 0;
	REP(i, N, 3*N){
		if(index % 2 == 0) ans+= arr[i];
		++index;
	}
	cout << ans;
}


Measured memory_bytes: 1408
n=int(input())
def div(h):
    y=[]
    for i in range(1,int(h**0.5)+1):
        if n%i==0:
            y.append((i,n//i))
    m=float("inf")
    for a,b in y:
        m=min(m,a+b-2)
    return m
print(div(n))

Measured memory_bytes: 9488
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n; string headline;

const int MAXC = 26;
int mincnt[MAXC], cnt[MAXC];

int main() {
    GI(n);

    fill(mincnt, mincnt + MAXC, INF);

    FORN(i, n) {
        cin >> headline;

        memset(cnt, 0, sizeof cnt);

        for (auto& c : headline) cnt[c - 'a']++;

        FORN(j, MAXC) {
            mincnt[j] = min(mincnt[j], cnt[j]);
        }
    }

    FORN(j, MAXC) {
        FORN(k, mincnt[j]) {
            printf("%c", (char)('a'+j));
        }
    }
    printf("\n");
    
    return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 998244353;
const int MX = 500010;

inline void add(ll &x, ll y) {
	x += y;
	if (x >= MOD) x -= MOD;
}

ll inv[MX], fact[MX], ifact[MX];

void init() {
    inv[1] = 1;
    for (int i = 2; i < MX; ++i) {
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    }
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < MX; ++i) {
        fact[i] = fact[i-1] * i % MOD;
        ifact[i] = ifact[i-1] * inv[i] % MOD;
    }
}

ll comb(int n, int r) {
    if (n < 0 || r < 0 || r > n) return 0;
    return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

int main() {
	init();

	int N, M; cin >> N >> M;

	vector<ll> pn(M + 1), pm(N + 1);
	pn[0] = pm[0] = 1;

	for (int i = 1; i <= M; ++i)
		pn[i] = pn[i-1] * (N + 1) % MOD;
	for (int i = 1; i <= N; ++i)
		pm[i] = pm[i-1] * (M + 1) % MOD;

	ll ans = 0;
	for (int i = 0; i <= N && i <= M; ++i) {
		ll val = comb(N, i) * comb(M, i) % MOD * fact[i] % MOD * pn[M - i] % MOD * pm[N - i] % MOD;
		if (i & 1) val = MOD - val;
		if (val == MOD) val = 0;
		add(ans, val);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 19840
library = """
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool

cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "atcoder":
    cdef cppclass fenwick_tree[T]:
        fenwick_tree()
        fenwick_tree(int n)
        void add(int p, T x)
        T sum(int l, int r)

ctypedef long ValueType
cdef class BIT:
    cdef fenwick_tree[ValueType] *_thisptr
    def __cinit__(self, int n = 0):
        if n == 0:
            self._thisptr = new fenwick_tree[ValueType]()
        else:
            self._thisptr = new fenwick_tree[ValueType](n)  
    def __dealloc__(self):
        del self._thisptr
    cpdef void add(self, int p, ValueType x):
        self._thisptr.add(p, x)
    cpdef ValueType sum(self, int l, int r):
        return self._thisptr.sum(l, r)
"""
import os,sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('atcoder.pyx','w').write(library)
    os.system('cythonize -i -3 -b atcoder.pyx')
 
# ↑ここまでライブラリ↓ここから解法
 
import sys
import atcoder
input = sys.stdin.buffer.readline
n, q = map(int, input().split())
dummy = atcoder.BIT()
bit = atcoder.BIT(n)
*map(bit.add, range(n), map(int, input().split())),
res = []
for i in range(q):
    t, u, v = map(int, input().split())
    if t: res.append(bit.sum(u, v))
    else: bit.add(u, v)
print('\n'.join(map(str, res)))

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

public class Main {


    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] s = str.split(" ");
        int[] n = new int[s.length];
        for (int i = 0; i < n.length; i++) {
            n[i] = Integer.parseInt(s[i]);
        }
        if ( n.length == 2 ) {
            if ( n[0] > n[1]){
                System.out.println("a > b");
            } else if ( n[0] == n[1] ) {
                System.out.println("a == b");
            } else if ( n[0] < n[1] ) {
                System.out.println("a < b");
            }
        }
    }
}

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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		string S = Console.ReadLine();
		int m1 = S[5] - '0';
		int m2 = S[6] - '0';
		int m = 10 * m1 + m2;
		string ans = "TBD";
		if (m <= 4) { ans = "Heisei"; }
		Console.WriteLine(ans);
	}
}


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

int main() {
     string O,E;
     cin >> O >> E;

     if(O.size()==E.size()){
         for(int i=0; i<O.size(); i++){ 
             cout << O.at(i) << E.at(i);
         }
     }

     else{
         for(int i=0; i<E.size(); i++){
             cout << O.at(i) << E.at(i);
         }
         cout << O.at(O.size()-1);
     }

       
     
 }

Measured memory_bytes: 256
/*
 * Coder: @SumitRaut
 */
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#define ll long long
#define debug1(x) fprintf(stderr, #x "--> %d\n", x);
#define debug2(x,y) fprintf(stderr, #x "--> %d  " #y "--> %d\n", x,y);
#define dprintarr(x,n,arr) for(i=x;i<n;++i) {fprintf(stderr,"%d ",arr[i]);} fprintf(stderr,"\n");
#define scanarr(x,n,arr) for(i=x;i<n;++i) {scanf("%d ",&arr[i]);}
#define printarr(x,n,arr) for(i=x;i<n;++i) {printf("%d ",arr[i]);}printf("\n");
ll mod=1e9+7;
#ifndef ONLINE_JUDGE
#define getchar_unlocked getchar
#endif
int scan() {
    register int vl = 0;
    char c;
    bool ng = 0;
    c = getchar_unlocked();
    if (c == '-')
        ng = 1;
    while (c < '0' || c > '9') c = getchar_unlocked();
    while (c >= '0' && c <= '9') {
        vl = (vl << 3) + (vl << 1) + c - '0';
        c = getchar_unlocked();
    }
    if (ng)
        vl = -vl;
 
    return vl;
}

int gcdsh(int x,int y) { /* return y==0?x:gcd(y,x%y); */ while(x && y) { x%=y; if(x) y%=x; } return x+y; }
int main()
{
	int k=scan()+1,ans=0;
	for(int i=1;i<k;++i) {
		for(int j=1;j<k;++j) {
			for(int l=1;l<k;++l) {
				ans+=gcdsh(gcdsh(i,j),l);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String noun = sc.next();
		int len = noun.length();
		if(noun.charAt(len - 1) == 's') {
			System.out.println(noun+"es");
		} else {
			System.out.println(noun+"s");
		}
	}
}


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

int main() {
  int n,q;

  cin >> n;
  int S[n];
  for(int i = 0; i < n; i++) {
    cin >> S[i];
  }


  cin >> q;
  int T[q];
  for(int i = 0; i < q; i++) {
    cin >> T[i];
  }

  int ans = 0;

  for(int i = 0; i < q; i++) {
    for(int j = 0;j < n; j++) {
      if(S[j] == T[i]) {
        ans++;
        break;
      }
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 3104
#include <stdio.h>

int main(void){
	int N;
	int A[201];
	scanf("%d", &N);

	for(int i = 0;i < N;++i){
		scanf("%d", A+i);
	}
	
	int s = 0;
	while(true){
		for(int i = 0;i < N;++i){
			if(A[i] % 2 != 0){
				printf("%d\n", s);
				return 0;
			}

			A[i] = A[i] / 2;
		}
		++s;
	}

	return 0;
}

Measured memory_bytes: 128
N = int(input())
t = []
x = []
y = []
for i in range(N):
    temp = list(map(int, input().split()))
    t.append(temp[0])
    x.append(temp[1])
    y.append(temp[2])

flag = True
position = [0, 0]
tc = 0
for n in range(N):
    pdiff = sum([x[n] - position[0], y[n] - position[1]])
    tdiff = t[n] - tc
    if tdiff < pdiff:
        flag = False
        break
    elif tdiff == pdiff:
        pass
    elif (pdiff - tdiff) % 2 != 0:
        flag = False
        break

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


Measured memory_bytes: 11852
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int n;
vector<vector<int> > tree;

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  tree = vector<vector<int> > (n);
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    p--;
    tree[p].pb(i);
  }
  return true;
}

int dfs(int v) {
  vector<int> tosort;
  for (auto i : tree[v]) {
    tosort.pb(dfs(i));
  }
  sort(tosort.begin(), tosort.end(), greater<int> ());
  int res = sz(tosort);
  for (int i = 0; i < sz(tosort); i++) {
    res = max(res, tosort[i] + i + 1);
  }
  return res;
}

void solve() {
  printf("%d\n", dfs(0));
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,train,bus;
  cin >> a >> b >> c >> d;
  if(a > b)
     train = b;
  else
    train= a;
  if(c > d)
    bus = d;
  else
    bus = c;
  cout << train + bus << endl;
}
  

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




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<ll,ll>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;
string f(ll n) {
	if (n == 0)return "";
	n--;
	return f(n / 26) + string(1, 'a' + n % 26);
}


int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	ll b = 0;
	rep(i, n)b ^= a[i];
	rep(i, n)a[i] ^= b;
	rep(i, n)cout << a[i] << endl;
	return 0;
}













Measured memory_bytes: 4772
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i,j,a[2][105],dp[105],s,mx;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=0;i<2;i++)for(j=1;j<=n;j++)cin>>a[i][j];
	for(i=n;i>=1;i--)dp[i]=dp[i+1]+a[1][i];
	for(i=1;i<=n;i++)
	{
		s+=a[0][i];
		mx=max(mx,s+dp[i]);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 256
N = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
INF = 10**9

ans = 0
while True:
    if sum(H) == 0:
        break
    s, e = 0, len(H)
    for i, h in enumerate(H):
        if h != 0:
            s = i
            break
    for i, h in enumerate(H):
        if i <= s:
            continue
        if h == 0:
            e = i
            break
    H[s:e] = [h-1 for h in H[s:e]]
    ans += 1

print(ans)


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

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	n = INT()
	a = sorted(LIST())
	b = sorted(LIST())
	c = sorted(LIST())

	ans = 0

	for i in range(n):
		j = bisect.bisect_left(a, b[i])
		k = bisect.bisect_right(c, b[i])
		ans += j * (n-k)
	print(ans)

if  __name__=='__main__':
	main()


Measured memory_bytes: 24512
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int c1, c2, c4;
    c1 = c2 = c4= 0;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(S[i]);
      int count = 0;
      while(true){
        if(n % 2 == 0){
          n /= 2;
          count++;
        }else{
          break;
        }
      }
      
      if(count == 0){
        c1++;
      }else if(count == 1){
        c2++;
      }else{
        c4++;
      }
    }
    String ans = "";
    if(c2 > 0){
      c1++;
    }
    if(c4+1 >= c1){
      ans = "Yes";
    }else{
      ans = "No";
    }
    
    System.out.println(ans);
  }
}

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

int main() {
  int x;

  for (int i = 0; i < 5; i++) {
    cin >> x;
    if (x == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3636
c,d[4010]={1},j;main(t){t?j--?:(j=getchar(d[c<t?t:c-t]=0),t+=j>10?c+=j%3,1:-1,j=c),d[j]=(d[j]+d[j-1])%998244353,main(t):printf("%d",d[c]);}

Measured memory_bytes: 187520
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
    double a, b, c, d, e, f, x, y;
    while (cin >> a >> b >> c >> d >> e >> f) {
        y = (f - c * d / a) / (e - b * d / a);
        x = (c - b * y) / a;
        int inty = y * 10000;
        int intx = x * 10000;
        if (intx % 10000 >= 5) x = (intx + 5) / (10000.0);
        if (inty % 10000 >= 5) y = (inty + 5) / (10000.0);
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 1236
fun main(args: Array<String>) {
    val (N, A, B, C) = readLine()!!.split(" ").map(String::toInt)
    val l = Array(N) { readLine()!!.toInt() }

    // 合成なし、またはいずれかと合成した結果の全パターン考える。
    // 合成結果からほしい長さとの差分を導き出して、その中で一番差分が少ないものを採用する
    fun dfs(index: Int, a: Int, b: Int, c: Int): Int {
        if (index == N) {
            // 1本目は合成扱いではないことを考慮して-30
            val result = Math.abs(A - a) + Math.abs(B - b) + Math.abs(C - c) - 30

            return if (listOf(a, b, c).any { it == 0 }) {
                return 100000000
            } else {
                result
            }
        }

        val r1 = dfs(index + 1, a, b, c)
        val r2 = dfs(index + 1, a + l[index], b, c) + 10
        val r3 = dfs(index + 1, a, b + l[index], c) + 10
        val r4 = dfs(index + 1, a, b, c + l[index]) + 10

        return listOf(r1, r2, r3, r4).min()!!
    }
    println(dfs(0, 0, 0, 0))
}

Measured memory_bytes: 49300
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int a,b;
  cin>>a>>b;
  if(a<=8&&b<=8){
    cout<<"Yay!"<<endl;
  }else{
    cout<<":("<<endl;
  }



  return 0;
}

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

void displayA(int A[], int N) {
	for (int i = 0; i < N - 1; i++)
		cout << A[i] << " ";
	cout << A[N - 1] << endl;
}

//int bubbleSort(int A[], int N) {
//	bool flag = true;
//	int num_of_exchange = 0;
//	while (flag) {
//		flag = false;
//		for (int j = N - 1; j >= 1; j--) {
//			if (A[j - 1] > A[j]) {
//				int temp = A[j];
//				A[j] = A[j - 1];
//				A[j - 1] = temp;
//				flag = true;
//				num_of_exchange++;
//			}
//		}
//	}
//	return num_of_exchange;
//}

int bubbleSort(int A[], int N) {
	bool flag = true;
	int num_of_exchange = 0;
	int i = 1;
	while (flag) {
		flag = false;
		for (int j = N - 1; j >= i; j--) {
			if (A[j - 1] > A[j]) {
				int temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				flag = true;
				num_of_exchange++;
			}
		}
		i++;
	}
	return num_of_exchange;
}

int main() {
	int N;
	int A[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int num_of_exchange = bubbleSort(A, N);
	
	displayA(A, N);
	
	cout << num_of_exchange << endl;

	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(0);
	for (int i = 0; i < n; ++i) {
		int b;
		cin >> b;
		a.push_back(b);
	}
	int t = 0;
	for (int i = 0; i < a.size(); i += 2) {
		if (a[i] % 2 == 1) {
			++t;
		}
	}
	cout << t << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

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

int main(void)
{
    int Q;    
    int  b;
    string n, m;
    bool ques = true;
    

    cin >> n >> Q;

 
    rep(i, Q)
    {
        
        cin >> b;
        if (b == 1)
        {
            ques = !ques;
        }
        if (b == 2)
        {
            cin >> b >> m;
            if (ques)
            {
                if (b == 1)
                {
                    n.insert(0, m);
                }
                else
                {
                    n += m;
                }
            }
            else
            {
                if (b == 1)
                {
                    n += m;
                }
                else
                {
                    n.insert(0, m);
                }
            }
        }
    }

    if (ques)
    {
        cout << n << endl;
    }
    else
    { 
        reverse(n.begin(), n.end());
        cout << n << endl;
    }
   
}

   

Measured memory_bytes: 900
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
class Counting():
    def __init__(self,maxim,mod):
        maxim += 1

        self.mod = mod
        self.fact = [0]*maxim
        self.fact[0] = 1
        for i in range(1,maxim):
            self.fact[i] = self.fact[i-1] * i % mod

        self.invfact = [0]*maxim
        self.invfact[maxim-1] = pow(self.fact[maxim-1],mod-2,mod)
        for i in reversed(range(maxim-1)):
            self.invfact[i] = self.invfact[i+1] * (i+1) % mod


    def nCk(self,n,r):
        if n < 0 or n < r: return 0
        return self.fact[n] * self.invfact[r] * self.invfact[n-r] % self.mod

    def nPk(self,n,r):
        if n < 0 or n < r: return 0
        return self.fact[n] * self.invfact[n-r] % self.mod

        

def main():
    N,M=mi()
    MOD=10**9+7

    if N == 1:
        print(1)
        exit()
    
    def prime_factorize(n):
        P = []
        P_set = set()
        while n % 2 == 0:
            P.append(2)
            P_set.add(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                P.append(f)
                P_set.add(f)
                n //= f
            else:
                f += 2
        if n != 1:
            P.append(n)
            P_set.add(n)

        P_count = {p:0 for p in P_set}
        for p in P: P_count[p] += 1

        return P_count


    
    ans = 1
    counting = Counting(3*10**5+10,MOD)
    for p,e in prime_factorize(M).items():
        ans *= counting.nCk(e+N-1,e)
        ans %= MOD

    
    print(ans % MOD)



if __name__ == "__main__":
    main()

Measured memory_bytes: 32716
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int k;
    string s;
    cin >> k >> s;
    int l = s.length();
    if (l <= k)
        cout << s << endl;
    else {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int INF = -1e18;
const int N = 16;
ll cost[1<<N];
ll dp[1<<N];
int n;

ll f(int mask) {
    if (mask == 0) return 0;
    ll &r = dp[mask];
    if (r != -1) return r;
    
    r = -INF;
    for (int sub = mask; sub; sub = (sub-1)&mask) {
        int next = mask&~sub;
        r = max(r, f(next) + cost[sub]);
    }
    return r;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> n;
    int g[n][n];
    forn(i, 0, n) {
        forn(j, 0, n) {
            cin >> g[i][j];
        }
    }
    
    forn(mask, 1, 1<<n) {
        forn(i, 0, n) if ((mask>>i)&1) {
            forn(j, i, n) if ((mask>>j)&1) {
                cost[mask] += g[i][j];
            }
        }
    }
    
    int mask = (1<<n)-1;
    memset(dp, -1, sizeof dp);
    ll ans = f(mask);
    
    cout << ans << endl;
}


Measured memory_bytes: 4672
n = int(input())
a = [int(i) for i in input().split()]
alice = 0
bob = 0
 
a.sort()
for i in range(1, n+1, 2):
  alice += a[n-i]
  if n-i-1 >= 0:
    bob += a[n-i-1]

    
print(alice-bob)

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

int main()
{
    string s; cin >> s;
    ll k; cin >> k;
    
    int pos = 0;
    while(s[pos] == '1') pos++;

    if (k <= pos) cout << '1' << endl;
    else cout << s[pos] << endl;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    // A[i] + A[j] = j - i -> A[i] + i = j - A[j]
    long long ans = 0;
    map<int, int> count;
    for (int i = 0; i < N; ++i) {
        if (count.count(i - A[i])) {
            ans += count[i - A[i]];
        }
        ++count[A[i] + i];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 13428
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long int> a(3*n);
	for(int i=0;i<3*n;i++){
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	long long int ans = 0;
	for(int i=1;i<=n;i++){
		ans += a.at(n+2*(i-1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
R,r=range,raw_input
N,K=map(int,r().split())
L=K+1
P,Q=R(K),R(L)
D=[L*[0]for i in Q]
a=b=0
for i in R(N):
 x,y,c=r().split()
 x,y=int(x),int(y)
 p=(x/K+y/K+ord(c))%2
 D[y%K+1][x%K+1]+=1-2*p
 b+=p
for i in P:
 for j in Q:D[i+1][j]+=D[i][j]
for i in Q:
 for j in P:D[i][j+1]+=D[i][j]
for i in Q:
 for j in Q:
  S=D[i][K]+D[K][j]-D[i][j]*2
  a=max(a,S,D[K][K]-S)
print a+b

Measured memory_bytes: 23024
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int t,n,k;
ll sx,sy,sz,sq;
string s;
int main(){
	in(n);
	cin>>s;
	in(t);
	int len=s.size();
	while(t--){
		in(k);
		int x=0,y=0;
		sx=sy=sz=sq=0;
		while(x<k){
			if(s[x]=='D')sx++;
			if(s[x]=='M')sy++,sz+=sx*1;
			if(s[x]=='C')sq+=sz*1;
			x++;
		}
		while(x<len){
			y=x-k;
			if(s[y]=='D')sx--,sz-=sy*1;
			if(s[y]=='M')sy--;
			if(s[x]=='D')sx++;
			if(s[x]=='M')sy++,sz+=sx*1;
			if(s[x]=='C')sq+=sz*1;
			x++;
		}
		printf("%lld\n",sq);
	}
	return 0;
}

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

int main() {
    long long n, ret = 0, t;
    std::cin >> n;
    std::map<long long, long long> v;
    for (auto i = 0ll; i < n; i++) {
        std::cin >> t;
        v[t]++;
    }
    for (auto& p : v) {
        if (p.first <= p.second) ret += p.second - p.first;
        else ret += p.second;
    }
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 6272