akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i) 
using namespace std;
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  rep(i,n) {
    int a;
    cin >> a;
    q.push(a);
  }
  rep(i,m) {
    int a = q.top(); q.pop();
    q.push(a/2);
  }
  ll ans = 0;
  rep(i,n) {
    ans += q.top(); q.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
int n,m;
int a,b,c;
int ans = 0;
vector<int> v,vec;
 
int main(){
  cin >> n;
  cout << "ABC" << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void){
    
    int A[100];
    int N,i,v,j,k;
    
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    for(k=0;k<N;k++){
            printf("%d",A[k]);
        	if(k!=N-1){
        		printf(" ");
        	}
        }
        printf("\n");
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>= 0 && A[j]>v){
            A[j+1] = A[j];
             j--;
        }
        A[j+1] = v;
        for(k=0;k<N;k++){
            printf("%d",A[k]);
        	if(k!=N-1){
        		printf(" ");
        	}
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi = 3.14159265358979323846;
 
int main() {
    string n;
    cin>>n;
    ll cnt=0;
    rep(i,n.size()){
        cnt+=ll(n[i]-'0');
    }
    if (cnt%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3696
#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();
long long  h[110000];
long long dp[110000];//dp[i]:= i番目に行くのに必要なコストの最小値
int main()

{   int n,k;
    cin >> n >> k;
    h[0] = 0;
    rep(i,n){
        cin >> h[i+1];
    }
    dp[0] = 0;
    dp[1] = 0;
    for(int i = 2;i <= 100010;i++){
        dp[i] = 10000000000;
    }
    for(int i = 1;i <= n; i++){
        for(int j = 1;j < k+1;j++){
            if (i+j >n) continue;
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }

    }
    cout << dp[n] << endl;

 

    return 0;
}

Measured memory_bytes: 1792
line = list(input())
ans = int(0)

if line[0] == "R":
	ans += 1
	if line[1] == "R":
		ans += 1
		if line[2] == "R":
			ans+=1
else:
	if line[1] == "R":
		ans += 1
		if line[2] == "R":
			ans+=1
	else:
		if line[2] == "R":
			ans+=1

print(ans)

Measured memory_bytes: 8992
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  ll inf = 1e9;
  map <ll, int> cnt;
  auto f = [&] (string s) {
    for (int i = 0; i < (int) s.size(); i++) {
      if (s[i] == '.') {
        if (i == (int) s.size() - 1) {
          s.insert(s.begin() + i, '0');
        } else {
          swap(s[i], s[i + 1]);
        }
        break;
      }
    }
    return s;
  };
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    bool ok = false;
    for (int i = 0; i < (int) s.size(); i++) {
      if (s[i] == '.') {
        ok = true;
      }
    }
    if (!ok) {
      s += ".0";
    }
    for (int it = 0; it < 9; it++) {
      s = f(s);
    }
    ll x = 0;
    for (auto z : s) {
      if (z == '.') break;
      x = x * 10 + z - '0';
    }
    ll cur = gcd(inf * (ll) inf, x);
    cnt[cur]++;
  }
  ll ans = 0;
  for (auto c : cnt) {
    for (auto d : cnt) {
      if (d.first > c.first && (d.first * (__int128) c.first) % (inf * inf) == 0) {
        ans += c.second * (ll) d.second;
      }
    }
  }
  for (auto c : cnt) {
    if ((c.first * (__int128) c.first) % (inf * inf) == 0) {
      ans += c.second * (ll) (c.second - 1) / 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
N = gets.to_i
NS = N.to_s(2)
NL = NS.length
MOD = 10**9 + 7

dp = Array.new(NL){Array.new(3, 0)}

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

(1...NL).each do |i|
    if NS[i] == '1'
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][0] + dp[i - 1][1]
        dp[i][2] = dp[i - 1][1] * 2 + dp[i - 1][2] * 3
    else
        dp[i][0] = dp[i - 1][0] + dp[i - 1][1]
        dp[i][1] = dp[i - 1][1]
        dp[i][2] = dp[i - 1][1] + dp[i - 1][2] * 3
    end
    dp[i][0] %= MOD
    dp[i][1] %= MOD
    dp[i][2] %= MOD
end

puts dp[NL - 1].inject(:+) % MOD

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

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	
	public void run() {
		while (true) {
			int e = in.nextInt();
			if (e == 0) break;
			
			int m = Integer.MAX_VALUE;
			for (int z = 0; z <= 100; z++) {
				for (int y = 0; y <= 1000; y++) {
					int x = e - z * z * z - y * y;
					if (x >= 0) {
						m = Math.min(x + y + z, m);
					}
				}
			}
			System.out.println(m);
		}
		out.close();
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

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

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 24896
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, m;
	cin >> n >> m;
	int sumi = 0;
	for(int i = 0; i < m; i++){
		int x;
		cin >> x;
		sumi += x;
	}
	
	if(sumi <= n){
		cout << n-sumi;
	}
	else
		cout << -1;

	return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n;
  cin>>n;
  int a[110];
  rep(i,n) cin>>a[i];
  int mn=1000000;

  for(int i=-100;i<=100;i++){
    int sum=0;
    for(int j=0;j<n;j++){
    sum+=(i-a[j])*(i-a[j]);
  }
  if(mn > sum) mn=sum;
  }
  cout<<mn<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;

bool cmp(const P &p, const P &q){
  if(p.S != q.S)return p.second > q.second;
  return p.F < q.F;
}

int main(){
  int n,k,T,ti[110000],Max,Min;
  cin >> T;
  while(T-- > 0){
    vector<P> dif;
    cin >> n >> k;
    Max = 0; Min = 1000000000;
    for(int i=0;i<n;i++){
      cin >> ti[i];
      Max = max(Max,ti[i]);
      Min = min(Min,ti[i]);
      if(i!=0){
	dif.push_back(P(i,ti[i]-ti[i-1]));
      }
    }
    sort(dif.begin(),dif.end(),cmp);
    int sum=0;
   
    
    if(n>k){
for(int i=0;i<k-1;i++)sum+=dif[i].S;
      cout << Max-sum-Min << endl;
    }
    else cout << "0" << endl;

  }
  return 0;
}

Measured memory_bytes: 3300
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    vector <int> v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(all(v));
    cout<<v[0]+v[1]<<endl;
    
    
    return 0;   
}




 
 


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

int main(int argc, const char * argv[]) {
    int n = 0,sum = 0;
    string s;
    cin >> n;
    cin >> s;
    int pt_to_east[3*(int)pow(10,5)], pt_to_west[3*(int)pow(10, 5)];
    for(int i = 0; i < n; i++){
        pt_to_west[i] = sum;
        if(s[i] == 'W'){
            sum++;
        }
    }
    sum = 0;
    for(int j = n - 1; j >= 0; j--){
        pt_to_east[j] = sum;
        if(s[j] == 'E'){
            sum++;
        }
    }
    int min = 1145141919;
    int rev = 0;
    for(int i = 0; i < n; i++){
        rev = pt_to_west[i] + pt_to_east[i];
        if(min > rev){
            min = rev;
        }
    }
    cout << min << endl;
}



Measured memory_bytes: 2948
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  bool bo=true;
  int s=0;
  for(;s<1000;s++)
    if(s*(s+1)/2==N){
      bo=false;
      break;
    }
  if(bo){
    puts("No");
    return 0;
  }
  vector<vector<int>> A(s+1,vector<int>(0));
  int n=1;
  for(int i=0;i<s+1;i++){
    for(int j=A[i].size(),k=i+1;j<s;j++,k++,n++){
      A[i].push_back(n);
      A[k].push_back(n);
    }
  }
  cout<<"Yes"<<endl<<s+1<<endl;
  for(vector<int> &v:A){
    cout<<s<<' ';
    for(int i=0;i<s;i++){
      cout<<v[i];
      if(i==s-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}

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

#define ll long long

signed main(){
   vector<int> a(4);
   for (int i = 0; i < 4; i += 1){
      cin >>a[i];
   }
   sort(a.begin(), a.end());
   int ans = abs((a[0] + a[3]) - (a[1] + a[2]));
   cout << ans << endl;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
    using namespace std;
    struct state
    {
      int link;
      int next[26];
      long long len;
    };
    state st[2*90005];
    int sz;
    int last;
    void init()
    {
      sz = 1;
      last = 0;
      st[0].link = -1;
      st[0].len = 0;
      memset(st[0].next,0,sizeof(st[0].next));
    }
    long long ans;
    const int N = 2*90005; 
    int f[2*90005];
    void topo()
    {
        static int b[N],t[N];
        for (int i = 0; i < sz; ++i) ++b[st[i].len];
        for (int i = 1; i <= st[last].len + 1; ++i) b[i] += b[i - 1];
        for (int i = 0; i < sz; ++i) t[b[st[i].len]--] = i;
        for (int i = sz,v; i; --i) {
            f[v=t[i]] = 1;
            for (int j = 0; j < 26; ++j) {
                f[v] += f[st[v].next[j]];
            }
        }
    }
    void sa_extend(char c)
    {
      int cur = sz++;
      st[cur].len = st[last].len + 1;
      memset(st[cur].next,0,sizeof(st[cur].next));
      int p = last;
      while(p != -1 && !st[p].next[c-'a'])
      {
        st[p].next[c-'a'] = cur;  
        p = st[p].link;
      }
      if(p == -1)
      {
        st[cur].link = 0;
      }
      else
      {
        int q = st[p].next[c-'a'];
        if(st[p].len + 1 == st[q].len)
        {
          st[cur].link = q;
        }
        else
        {
          int clone = sz++;
          st[clone] = st[q];
          st[clone].len = st[p].len+1;
          while( p != -1 && st[p].next[c-'a'] == q )
          {
            st[p].next[c-'a'] = clone;
            p = st[p].link;
          }
          st[cur].link = st[q].link = clone;
        }
      }
      last = cur;
    }
    int path = 0;
    void klex(int k)
    {
      for(int i = 0; k; )
      {
        for(int c = 0; c < 26; c++)
        {
          if(st[i].next[c])
          {
            if(f[st[i].next[c]] >= k)
            {
              putchar('a' + c);
              i = st[i].next[c];
              k--;
              break;
            }
            else
            k-= f[st[i].next[c]];
          }
        }
      }
      puts("");
    }
     
    int main()
    {
      ios_base::sync_with_stdio(0);
      cin.tie(0);
      init();
      string s;
      cin >> s;
     
      for(int i = 0; s[i]; i++)
      {
        sa_extend(s[i]);
      }
      topo();
      int m;
      int a;
      cin >> a;
      path = 0;
      klex(a);
     
      
      return 0;
    } 

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int A, B, C, X, Y;

int main(void){
    
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
    
    int ans = 0;
    int num = min(X, Y);
    
    ans = (A * num + B * num < C * 2 * num) ? A * num + B * num : C * 2 * num;
    
    if(X == Y) printf("%d\n", ans);
    else{
        if(X > Y){
            num = X - Y;
            ans += (A * num < C * 2 * num) ? A * num : C * 2 * num;
        }
        else{
            num = Y - X;
            ans += (B * num < C * 2 * num) ? B * num : C * 2 * num;
        }
        printf("%d\n", ans);
    }
    
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  for(int i = 0;i<3;i++){
    if(n % 10 == 7){
      cout << "Yes" << endl;
      break;
    }
    n /= 10;
    if(i == 2){
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3540
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::f64::consts::PI;

fn main() {
    input!{
        r: f64,
    };
    
    println!("{}", 2.0 * r * PI);
}


Measured memory_bytes: 2180
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

int inf = (1 << 30);
int mod = 1e9;
long long long_inf = (1LL << 60);

int main(){

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

    int ans = 0, now = 0;
    while(true){
        if(now == 1) break;
        if(ans >= N){
            ans = -1;
            break;
        }
        ans++;
        now = a[now] - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import numpy as np
import sys
sys.setrecursionlimit(10 **9)
S = str(input())
A = ['dream', 'dreamer', 'erase', 'eraseer']

N = len(S)
i = 0

def check(i): #i最初の文字
    flag0 = False
    flag1 = False
    flag2 = False
    flag3 = False
    flag4 = False
    flag5 = False
    if S[i:] == 'dream' or S[i:] == 'dreamer' or S[i:] == 'erase' or S[i:] == 'eraser':
        flag1 = True
    if S[i:i+7] == 'dreamer':
        flag2 = check(i+7)
    if S[i:i+5] == 'dream':
        flag3 =  check(i+5)
    if S[i:i+6] == 'eraser':
        flag4 =  check(i+6)
    if S[i:i+5] == 'erase':
        flag5 = check(i+5)
    return flag0 or flag1 or flag2 or flag3 or flag4 or flag5

if check(0):
    print ('YES')
else:
    print ('NO')

Measured memory_bytes: 27136
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	cout << b / x - (a + x - 1) / x + 1 << endl;
}

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

using namespace std;

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for(int i=0; i<N; i++){
        cin >> C[i];
        for(int j=0; j<M; j++){
            cin >> A[i][j];
        }
    }

    int minCost = 100000000;
    for(int k=0; k<1<<N; k++){
        int cost = 0;
        vector<int> a(M, 0);
        for(int i=0; i<N; i++){
            if(k&(1<<i)){
                cost+=C[i];
                for(int j=0; j<M; j++){
                    a[j] += A[i][j];
                }
            }
        }
        int count = 0;
        for(int j=0; j<M; j++){
            if(a[j] >= X){
                count++;
            }
        }

        if(count == M && minCost > cost){
            minCost = cost;
        }
    }
    if(minCost == 100000000){
        cout << -1 << endl;
    }else{
        cout << minCost << endl;
    }
    return 0;
}

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

int main(){
    
    int n, ans=0;
    cin>>n;
    for(int i=1;i<=n;i+=2){
        int cnt=0;
        for(int j=1;j<=i;j+=2){
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans++;
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *   author: malviyanshiv
 *   created: 18 August 2019  17:39:27
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define FORE(a) for(auto ele : a )
#define ALL(a) begin(a), end(a)
#define RPB(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define F first
#define S second
#define TC int t; cin >> t; while(t--)
#define SET(a,b) memset(a,b,sizeof(a))

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

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


void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int main(){
    optimizeIO();

    int n;
    cin >> n;
    vector<double> arr(n);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr.begin(), arr.end());
    double db = 2;
    double sm = arr[0];
    for(int i = 1; i < n; i++){
        sm += arr[i];
        sm = sm/db;
    }
    cout << setprecision(6) << sm << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int C[10001];
    for(int i = 0; i < 10001; i++) C[i] = 0;
    int n;
    scanf("%d",&n);
    int* A = new int[n];
    int* B = new int[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&A[i]);
        C[A[i]]++;
    }
 
    for(int i = 0,j=0; i < 10001; i++){
        if(C[i] != 0){
            for(int k = 0; k < C[i]; k++){
                B[j++] = i;
            }
        }
    }
 
    for(int i = 0; i < n-1; i++) printf("%d ",B[i]);
    printf("%d\n",B[n-1]);
    delete[] A;
    delete[] B;
    return 0;
}


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

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  int lr[q][2];
  int i, j;
  for (i = 0; i < q; i++) {
    cin >> lr[i][0] >> lr[i][1];
  }

  int how_many[n + 1];
  how_many[0] = 0;
  for (i = 1; i < n; i++) {
    if (s.at(i - 1) == 'A' && s.at(i) == 'C') {
      how_many[i] = how_many[i - 1] + 1;
    } else {
      how_many[i] = how_many[i - 1];
    }

  }

  for (i = 0; i < q; i++) {
    cout << how_many[lr[i][1] - 1] - how_many[lr[i][0] - 1] << endl;
  }
  return 0;
}


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

int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int sum=0;
    if(a>2*c && b>2*c) sum+=max(x,y)*c*2;
    else if((a+b)/2>=c){
        sum+=min(x,y)*c*2;
        int d=2*c;
        if(x>y) sum+=(x-y)*min(a,d);
        else if(x<y) sum+=(y-x)*min(b,d);
    }
    else{
        sum+=a*x+b*y;
    }
    cout<<sum<<"\n";
    return 0;
}

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

const int N=200005;
typedef long long ll;
int n,K,a[N],t[N];
ll s[N],x[N];

void ins(int a){for(;a<=x[0];a+=a&-a)++t[a];}
int qry(int a){int ret=0;for(;a;a-=a&-a)ret+=t[a];return ret;}

int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;++i)scanf("%d",a+i),s[i]=s[i-1]+a[i]-K;
	for(int i=0;i<=n;++i)x[++x[0]]=s[i];
	sort(x+1,x+1+x[0]);
	x[0]=unique(x+1,x+1+x[0])-x-1;
	for(int i=0;i<=n;++i)s[i]=lower_bound(x+1,x+1+x[0],s[i])-x;
	ll ans=0;
	ins(s[0]);
	for(int i=1;i<=n;++i)ans+=qry(s[i]),ins(s[i]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4992
import sys

input = lambda: sys.stdin.readline().rstrip()
INF = 10 ** 9 + 7


def solve():

    N, L = map(int, input().split())
    flaver = [0 for _ in range(N)]

    m = INF
    pm = True
    for i in range(1, N + 1):
        n = i + L - 1
        flaver[i - 1] = n
        if abs(n) < m:
            m = abs(n)
            pm = True if n >= 0 else False

    ans = sum(flaver)
    if pm:
        ans -= m
    else:
        ans += m
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?(テァツクツョテ・ツーツ湘ァツ可?

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int M, T, P, R;
int num[60], sum[60], wa[60][15];

struct Elem {
    int team, solved, tm;
};

bool operator<(const Elem &a, const Elem &b) {
    if(a.solved != b.solved) return a.solved > b.solved;
    if(a.tm != b.tm) return a.tm < b.tm;
    return a.team > b.team;
}

signed main() {
    while(cin >> M >> T >> P >> R, M) {
        memset(num, 0, sizeof(num));
        memset(sum, 0, sizeof(sum));
        memset(wa , 0, sizeof(wa ));

        rep(i,0,R) {
            int m, t, p, j; cin >> m >> t >> p >> j;
            // Accepted
            if(j == 0) {
                num[t]++;
                sum[t] += m + 20 * wa[t][p];
            }
            // WA
            else {
                wa[t][p]++;
            }
        }

        vector<Elem> v;
        repq(i,1,T) v.push_back(Elem{i, num[i], sum[i]});
        sort(v.begin(), v.end());

        pii prev = pii(-1, -1);
        rep(i,0,T) {
            pii t = pii(v[i].solved, v[i].tm);
            // printf("num = %lld, sum = %lld\n", num[i], sum[i]);
            bool p = (t == prev);
            if(i != 0) cout << (p ? "=" : ",");
            printf("%lld", v[i].team);
            prev = t;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
ll quick(ll a,ll b,const int mod)
{
    ll ret=1;
    while(b)
    {
        if(b&1) ret=ret*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}
const int maxn=3005;
ll fac[maxn];
ll C[maxn][maxn],S[maxn][maxn];
void db(const int mod)
{
    fac[0]=0;
    for(int i=0;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
        C[i][0]=1;
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
    }
    S[0][0]=1;
    for(int i=1;i<maxn;i++)
    {
        S[i][0]=0;
        for(int j=1;j<=i;j++)
            S[i][j]=(S[i-1][j-1]+(ll)j*S[i-1][j]%mod)%mod;
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    ll ans=0;
    db(m);
    for(int i=0;i<=n;i++)
    {
        ll cur=0;
        for(int j=0;j<=i;j++)
            cur=(cur+S[i+1][j+1]*quick(2,(n-i)*j,m)%m)%m;
        cur=cur*C[n][i]%m*quick(2,quick(2,n-i,m-1),m)%m;
        if(i&1) ans=(ans-cur+m)%m;
        else ans=(ans+cur)%m;
    }
    print(ans);
}

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

#define pi 3.141592653589793
int main(){
  int A,B,H,M;
  cin>>A>>B>>H>>M;
  
  
  double tan_rad,tyo_rad;
  
  tan_rad=(H*30+M*0.5)*pi/180;
  tyo_rad=M*6*pi/180;
  
  double between = abs(tan_rad-tyo_rad);
  
  cout <<fixed<< setprecision(12)<<sqrt(pow(A,2)+pow(B,2)-2*A*B*cos(between))<< endl;
  return 0;
}

Measured memory_bytes: 4148
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	int r;
	cin >> r;
	const double PI=3.14159265358979323846;
	cout << fixed << setprecision(10) << 2 * r * PI << endl;

	return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100005],ans=1e9,x=-1;
int main(){
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]>=0 and x==-1)x=i;
	}
	for(int i=0;i<=n-k;i++){
		int sum=0,y;
		if(i<x and i+k>=x)y=true;
		else y=false;
		if(y==true){
			if(x-i>=i+k-x)
				sum=2*a[i+k-1]-a[i];
			else
				sum=a[i+k-1]-2*a[i];
		}
		else sum=max(abs(a[i]),abs(a[i+k-1]));
		ans=min(ans,sum);
	}
	cout << ans;
	return 0;
}

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

#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 fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
ll nxt(){ll x;cin>>x;return x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	ll n,a,b;
    cin>>n>>a>>b;
    cout<<(n/(a+b)*a+min(a,n%(a+b)));
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans;
    if(a == c) ans = b;
    else if(b == c) ans = a;
    else ans = c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
	int n,i;
	double x1,x2,x3,y1,y2,y3;
	double x,y,r;
	double a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3);
		if(y1==y2){
			a=(x2*x2+y2*y2-(x3*x3+y3*y3))/(2*(y2-y3));
			b=(x3*x3+y3*y3-(x1*x1+y1*y1))/(2*(y3-y1));
			x=(a-b)/((x1-x3)/(y3-y1)-(x3-x2)/(y2-y3));
			y=(x3-x2)/(y2-y3)*x + a;
		}else if(y2==y3){
			a=(x1*x1+y1*y1-(x2*x2+y2*y2))/(2*(y1-y2));
			b=(x3*x3+y3*y3-(x1*x1+y1*y1))/(2*(y3-y1));
			x=(a-b)/((x1-x3)/(y3-y1)-(x2-x1)/(y1-y2));
			y=(x2-x1)/(y1-y2)*x + a;
		}else if(y3==y1){
			a=(x2*x2+y2*y2-(x3*x3+y3*y3))/(2*(y2-y3));
			b=(x1*x1+y1*y1-(x2*x2+y2*y2))/(2*(y1-y2));
			x=(a-b)/((x2-x1)/(y1-y2)-(x3-x2)/(y2-y3));
			y=(x2-x1)/(y1-y2)*x + b;
		}else{
			a=(x2*x2+y2*y2-(x3*x3+y3*y3))/(2*(y2-y3));
			b=(x1*x1+y1*y1-(x2*x2+y2*y2))/(2*(y1-y2));
			x=(a-b)/((x2-x1)/(y1-y2)-(x3-x2)/(y2-y3));
			y=(x2-x1)/(y1-y2)*x + b;
		}
		r=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
		printf("%.3lf %.3lf %.3lf\n",x,y,r);
	}
	return 0;
}

Measured memory_bytes: 664
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	while(cin>>s)
	{
		int cnt=0;
		for(int i=0;i<s.length();i++){
			if(s[i]=='o')
			cnt++;
			}
			cout<<700+cnt*100<<endl;
	}
	return 0;
}

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

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N, M = map(int,input().split())
uf = UnionFind(N)
for k in range(M):
    X, Y, Z = map(int,input().split())
    uf.union(X-1,Y-1)
print(uf.group_count())


Measured memory_bytes: 69592
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <iomanip>
#include <limits>
#include <bitset>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef unsigned long long int ull;
const ll mod = 1000000007;
const ll linf = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = (m); i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<>()
#define SUM(a) accumulate((a).begin(), (a).end(), 0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
template <typename T>
int len(T tmp)
{
	int res = 0;
	while (tmp > 0)
	{
		res++;
		tmp /= 10;
	}
	return res;
}
template <typename T>
T gcd(T a, T b)
{
	T t;
	while (b != 0)
	{
		t = a % b;
		a = b;
		b = t;
	}
	return a;
}
template <typename T>
T recfact(T start, T n)
{
	T i;
	if (n <= 16)
	{
		T r = start;
		for (i = start + 1; i < start + n; i++)
			r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
template <typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
template <typename T>
T fct(T n)
{
	return recfact<T>(1, n);
}
template <typename T>
T ncm(T n, T m)
{
	if (n < m)
		return 0;
	T x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr)
{
	if (firstItr < 0 || secondItr > int(str.size() - 1))
		return str;
	while (firstItr < secondItr)
	{
		swap(str[firstItr], str[secondItr]);
		firstItr++;
		secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str)
{
	int itr = 0;
	std::string res;
	while (itr < int(str.size()))
	{
		char tmp = str[itr++];
		int length = 1;
		while (itr < int(str.size()) && str[itr] == tmp)
		{
			++itr;
			++length;
		}
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
str split(str str, size_t first_itr, size_t second_itr)
{
	string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++)
	{
		tmp.push_back(str.at(i));
	}
	return tmp;
}

int main(void)
{
	double n, k;
	cin >> n >> k;
	double ans = 0;
	REP(i,1,n+1){
		double dice_prob = 1 / n;
		int x = i;
		double coin_prob = 1;
		for (;x<k;){
			x *= 2;
			coin_prob /= 2;
		}
		ans += dice_prob * coin_prob;
	}
	cout << d20 << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

l,r = list(map(int, input().split()))
imin = 10**9+7

if r-l+1 <=2019:
    for i in range(l,r):
        for j in range(i+1,r+1):
            if imin > (i*j)%2019:
                imin = (i*j)%2019
    print(imin)
else:
    print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  char s[50][51];
  int n,f[50][26]={},i,j;
  vector <char> v;
  cin>>n;
  for(i=0;i<n;i++)
    cin>>s[i];
  for(i=0;i<n;i++){
    for(j=0;s[i][j];j++){
      f[i][(s[i][j]-'a')]++;
    }
  }
  for(i=0;i<26;i++){
    int tmp=51;
    for(j=0;j<n;j++){
      if(!f[j][i])
	break;
      else{
	tmp=min(tmp,f[j][i]);
      }
    }
    if(j==n){
      for(int k=0;k<tmp;k++){
	v.push_back((char)(i+'a'));
      }
    }
  }
  sort(v.begin(),v.end());
  for(i=0;i<v.size();i++){
    cout<<v[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
typedef vector<vector<LL>> VVL;
typedef vector<string> VS;

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

LL llRead(){
  LL a;
  cin >> a;
  return a;
};

string stringRead(){
  string a;
  cin >> a;
  return a;
};

vector<LL> vlRead(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> vsRead(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> vvlRead(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 1
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, VL& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, VS& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, VVL& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, char* s) {
  cout << line << ":" << name << ":char* " << s << endl;;
}
void debug1(LL line, const char* name, vector<const char*>& v) {
  cout << line << ":" << name << ":vector<const char*>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, priority_queue<LL>& p) {
  cout << line << ":" << name << ":priority_queue<LL>(" << p.size() << ") ";
  priority_queue<LL> copy = p;
  while(!copy.empty()) {
    cout << copy.top() << " ";
    copy.pop();
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code

  auto n = llRead();

  for (LL i = 1;i<10;i++) {
    auto j = n/i;
    if (j*i == n && j < 10) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int main(){

   int N, T;
   cin >> N >> T;
   int c[N], t[N];
   int c_min = INF;
   vector<int> costs;
   for(int i=0; i < N; i++)
   {
      cin >> c[i] >> t[i];
      if(t[i] <= T)
      {
         costs.push_back(c[i]);
      }
   }
   sort(costs.begin(), costs.end());
   if(costs.empty() == true){
      cout << "TLE" << endl;
    }
   else{
      cout << costs[0] << endl;
   }


   return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
    cin.sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int total = a + b + c;

    if (total % 2 == 1) {
        cout << "No" << endl;
    } else {
        total /= 2;
        if (total == a || total == b || total == c) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int ans = 0;
    for(int i = S.length()-2; i > 0; i-=2){
      S = new String(S.substring(0, i));
      String s1 = S.substring(0, i/2);
      String s2 = S.substring(i/2, i);
      if(s1.equals(s2)){
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		
		Scanner scan = new Scanner(System.in);
		String moji = scan.next();
		
		
		switch(moji){
		case"a":			
			System.out.println("vowel");
			break;
		case"i":
			System.out.println("vowel");
			break;
		case"u":			
			System.out.println("vowel");
			break;
		case"e":			
			System.out.println("vowel");
			break;
		case"o":			
			System.out.println("vowel");
			break;
		default:			
			System.out.println("consonant");
			
		}
		
	}

}


Measured memory_bytes: 21844
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import heapq as hp
import sys

WHITE, GRAY, BLACK = 0, 1, 2


class SingleSourceShortestPath(object):
    # __slots__ = ('adj_table', 'distance', 'parent', 'visited')

    def __init__(self, in_data):
        v_num = int(in_data[0])
        vertices = map(lambda x: x.split(), in_data[1:])
        adj_table = [{} for _ in range(v_num)]

        for v_info in vertices:
            source, v_adj_length, *v_adj_list = map(int, v_info)
            # assert len(v_adj_list) == v_adj_length * 2
            for target, cost in zip(v_adj_list[::2], v_adj_list[1::2]):
                adj_table[source][target] = cost

        self.adj_table = adj_table
        self.distance = [float('inf')] * v_num
        self.parent = [-1] * v_num
        self.visited = [WHITE] * v_num

    def path_heap_dijkstra(self, root):
        # path search init
        self.distance[root] = 0
        path_heap = []
        # heapq: rank by tuple[0], at here it's d[u]
        hp.heappush(path_heap, (0, root))

        while path_heap:
            csp, current = hp.heappop(path_heap)
            self.visited[current] = BLACK

            for adj, cost in self.adj_table[current].items():
                if self.visited[adj] != BLACK:
                    # alt: d[u] + w[u,v]
                    alt_path = self.distance[current] + cost
                    if alt_path < self.distance[adj]:
                        # update path_list
                        self.distance[adj] = alt_path
                        # update heap
                        hp.heappush(path_heap, (alt_path, adj))
                        self.visited[adj] = GRAY
                        self.parent[adj] = current

        return self.distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    case = SingleSourceShortestPath(in_data=_input)
    ans = case.path_heap_dijkstra(root=0)
    for i, v in enumerate(ans):
        print(i, v)

Measured memory_bytes: 62820