akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}

int fa[2000];
int id[2000];
int sta[2000];
vector<pii> G[200];
int dp[55][1100000];

void dfs(int x,int f,int p){
    fa[x]=f;id[x]=p;
    for(auto &i:G[x]){
        if(i.fi!=f)dfs(i.fi,x,i.se);
    }
}
int vis[200];
signed main()
{
    io;
    int n;cin>>n;
    rep(i,1,n-1){
        int l,r;cin>>l>>r;
        G[l].pb(mp(r,i));G[r].pb(mp(l,i));
    }
    dfs(1,0,0);
    int m;cin>>m;
  //  puts("11111");
    for (int x = 0; x < m; x++)
    {
        int u,v;cin>>u>>v; int lca;
        memset(vis,0,sizeof vis);
        for(int i=u;i;i=fa[i])vis[i]=1;
        lca=v;
        for(int i=v;i&&!vis[i];i=fa[i])lca=fa[i];
      //  cout<<"lca: "<<lca<<endl;
        for(int i=u;i!=lca;i=fa[i])sta[id[i]]|=(1ll<<x);
        for(int i=v;i!=lca;i=fa[i])sta[id[i]]|=(1ll<<x);
    }

 //   puts("11111");
    dp[0][0]=1;
    for(int i=1;i<n;i++){
        for(int j=0;j<(1<<m);j++){
            dp[i][j] += dp[i-1][j];
            dp[i][j|sta[i]] += dp[i-1][j];
        }

    }
    cout<<dp[n-1][(1<<m)-1]<<endl;
  



    getchar(); //
    getchar();
}


Measured memory_bytes: 422144
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();

        if(a>=3200){
        System.out.println(s);
        }else{
            System.out.println("red");
        }


    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>

using BoxBitset = uint32_t;  // 宝箱のビットセット
using Price = uint32_t;  // 値段

// 鍵
struct Key {
  Price price;  // 値段
  BoxBitset box_bitset;  // 開けられる宝箱のビットセット
};

int main() {
  size_t N = 0;  // 宝箱の個数
  size_t M = 0;  // 鍵の個数
  std::cin >> N >> M;

  // 鍵の情報を取得する
  std::vector<Key> keys(M);
  for (auto& key : keys) {
    size_t box_count = 0;
    std::cin >> key.price >> box_count;

    // 開けられる宝箱をビットセットにまとめる
    for (size_t i = 0; i < box_count; ++i) {
      size_t box = 0;
      std::cin >> box;
      key.box_bitset |= 1 << (box - 1);
    }
  }

  // 宝箱を開けるための最小費用を計算する
  std::unordered_map<BoxBitset, Price> price_map;  // 開けた宝箱のビットセットから最小費用を探すためのマップ
  price_map.emplace(0, 0);  // 初期状態はどれも開けていない状態
  for (int box_bitset = 0; box_bitset < (1 << N); ++box_bitset) {
    // box_bitsetのように宝箱を開けるパターンが存在するなら、追加の鍵で宝箱を開けた状態を計算して記録する
    const auto price_iter = price_map.find(box_bitset);  // box_bitsetのように宝箱を開けるために現時点で必要な費用
    if (price_iter != price_map.end()) {
      for (const auto& key : keys) {
        // next_box_bitsetのように宝箱を開けるのに必要な最小費用を累積的に計算する
        const auto next_box_bitset = box_bitset | key.box_bitset;  // keyで宝箱を開けた後の状態
        const auto next_price_iter = price_map.find(next_box_bitset);  // keyで宝箱を開けた後に必要な費用
        if (next_price_iter == price_map.end()) {
          price_map.emplace(next_box_bitset, price_iter->second + key.price);
        } else {
          next_price_iter->second = std::min(next_price_iter->second, price_iter->second + key.price);
        }
      }
    }
  }

  // すべての宝箱を開けたときの費用を表示する
  const auto price_iter = price_map.find((1 << N) - 1);
  if (price_iter == price_map.end()) {
    std::cout << "-1";
  } else {
    std::cout << price_iter->second;
  }

  return 0;
}


Measured memory_bytes: 384
n = int(input())
p_list = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if p_list[i - 1] < p_list[i] < p_list[i + 1] or p_list[i - 1] > p_list[i] > p_list[i + 1]:
        ans += 1
print((ans))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>


using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	int N;
	vector<int> a;

	cin >> N;
	a.resize(N);

	rep(i, 0, N) {
		cin >> a.at(i);
	}
	
	sort(a.begin(), a.end(), std::greater<int>());

	int bo = 0;
	int al = 0;
	rep(i, 0, N) {
		if (i % 2 == 0) {
			al += a[i];
		}
		else {
			bo += a[i];
		}
	}


	cout << al - bo << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++)cin>>p[i];
  
  int ans=1;
  int m=p[0];
  for(int i=1;i<n;i++){
    if(p[i]<=m){
      ans++;
      m=p[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4048
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n;
	vector<ll> v;
	map<ll, pair<ll, ll>> m;
	ll ans = 0;

	cin >> n;

	REP(i, n) {
		ll a;
		cin >> a;
		v.push_back(a);
		m[a] = make_pair(i + 1, 0);
	}

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

	REP(i, n) {
		m[v[i]] = make_pair(m[v[i]].first, i + 1);
	}

	REP(i, n) {
		if (m[v[i]].first % 2 == 1 && m[v[i]].second % 2 == 0) {
			ans++;
		}
	}

	cout << ans << endl;
}

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

int main(){
    
    int l,r;
    cin >> l >> r;
    int ans=2018;
    
    if(l/2019 != r/2019) cout << 0 << endl;
    else{
        l%=2019;
        r%=2019;
        for(int i=l; i<r; i++){
            for(int j=l+1; j<=r; j++){
                if(i!=j) ans=min(ans,(i*j)%2019);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3552
H, W = map(int, input().split())
C = [[0] * (W + 2) for _ in [0] * (H + 2)]
for i in range(1, H + 1):
    C[i][1:-1] = input()
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if C[i][j] == '.':
            continue
        if '#' not in [C[i - 1][j], C[i][j - 1], C[i][j + 1], C[i + 1][j]]:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
from itertools import permutations

def WarshallFloyd(M):
    N = len(M)
    for k in range(N):
        for j in range(N):
            for i in range(N):
                M[i][j] = min(M[i][j], M[i][k] + M[k][j])
    return M

INF = 1e10

N, M, K = map(int, input().split())
R = [int(i) - 1 for i in input().split()]
E = [[INF] * N for _ in range(N)]
for a, b, c in (map(int, input().split()) for _ in range(M)):
    a -= 1; b -= 1
    E[a][b] = E[b][a] = c

E = WarshallFloyd(E)
ans = min(sum(E[p[i]][p[i + 1]] for i in range(K - 1)) for p in permutations(R))
print(ans)


Measured memory_bytes: 61912
n = int(input())
s = input()
 
num_rgb = {'R':0, 'G':0, 'B':0}
num_list = []
for i in range(n):
    num_rgb[s[i]] += 1
    num_list.append(num_rgb.copy())
 
total = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] == s[j]:
            continue
        target = ''
        if not (s[i] == 'R' or s[j] == 'R'):
            target = 'R'
        elif not (s[i] == 'G' or s[j] == 'G'):
            target = 'G'
        elif not (s[i] == 'B' or s[j] == 'B'):
            target = 'B'
        num = num_list[n-1][target]-num_list[j][target]
        if 2*j-i < n and s[j+j-i] == target:
            num -= 1
        total += num
print(total)

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[][] paper = new int[14][14];
		byte x, y, size;
		int whites = 0, blot = 0;

		while ((line = br.readLine()) != null) {

			x = Byte.parseByte(line.split(",")[0]);
			y = Byte.parseByte(line.split(",")[1]);
			size = Byte.parseByte(line.split(",")[2]);

			x += 2;
			y += 2;

			if (size == 1) {
				paper[x - 1][y]++;
				paper[x][y - 1]++;
				paper[x][y]++;
				paper[x][y + 1]++;
				paper[x + 1][y]++;
			} else if (size == 2) {
				paper[x - 1][y - 1]++;
				paper[x - 1][y]++;
				paper[x - 1][y + 1]++;
				paper[x][y - 1]++;
				paper[x][y]++;
				paper[x][y + 1]++;
				paper[x + 1][y - 1]++;
				paper[x + 1][y]++;
				paper[x + 1][y + 1]++;
			} else if (size == 3) {
				paper[x - 2][y]++;
				paper[x - 1][y - 1]++;
				paper[x - 1][y]++;
				paper[x - 1][y + 1]++;
				paper[x][y - 2]++;
				paper[x][y - 1]++;
				paper[x][y]++;
				paper[x][y + 1]++;
				paper[x][y + 2]++;
				paper[x + 1][y - 1]++;
				paper[x + 1][y]++;
				paper[x + 1][y + 1]++;
				paper[x + 2][y]++;
			}

		}
		for (int i = 2; i < 12; i++) {
			for (int j = 2; j < 12; j++) {
				if (paper[i][j] == 0)
					whites++;
				if (paper[i][j] > blot)
					blot = paper[i][j];
			}
		}
		System.out.println(whites + "\n" + blot);
	}
}

Measured memory_bytes: 16980
n = int(input())
tree = [[] for _ in range(n+1)]

for i in range(n-1):
    a, b, c = map(int, input().split())
    tree[a].append([b, c])
    tree[b].append([a, c])

q, k = map(int, input().split())

from collections import deque
que = deque([k])
visit = [-1 for _ in range(n+1)]
visit[k] = 0
while que:
    pos = que.popleft()
    for i, j in tree[pos]:
        if visit[i] < 0:
            visit[i] = visit[pos]+j
            que.append(i)
for i in range(q):
    x, y = map(int, input().split())
    print(visit[x]+visit[y])

Measured memory_bytes: 51536
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  vector<int64_t> vecR(N);
  int64_t sum = 0;
  rep(i, N) {
    cin >> vec.at(i);
    vecR.at(i) = vec.at(i);
    sum += vec.at(i);
  }
  sort(vec.begin(), vec.end());
  sort(vecR.begin(), vecR.end());
  reverse(vecR.begin(), vecR.end());
  int64_t A, B, C, D;
  A = B = C = D = 0;
  int64_t X, Y;
  X = Y = 0;
  if(N % 2 == 0) {
    rep(i, N/2) {
      A += vec.at(i);
      B += vecR.at(i);
    }
    cout << B * 2 - A * 2 - vec.at(N/2) + vecR.at(N/2) << endl;
  }
  else {
    rep(i, N/2) {
      A += vecR.at(i+N/2); 
      B += vecR.at(i);
    }
    rep2(i, N/2, N/2+2) {
      X += vec.at(i);
      Y += vecR.at(i);
    }
    rep(i, N/2) {
      C += vec.at(i+N/2);  
      D += vec.at(i);       
    }
    cout << max(B * 2 - (sum - B) * 2 + Y, (sum - D) * 2 - X - 2 * D) << endl;
  }
}

Measured memory_bytes: 4860
n = int(input())
A = list(map(int,input().split()))
ans = 10**9
tmp = 0
for i in range(n):
  while True:
    if A[i]%2==0:
      A[i] = A[i]//2
      tmp += 1
    else:
      ans = min(ans,tmp)
      tmp = 0
      break

print(ans)
      

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const int SIZE = 100020;
const int BSIZE = 1000020;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ll MOD = 1E9 + 7;
#define rep(i,n) for (long long i=0;i<(n);++i)
#define repp(i,a,b) for (long long i=(a);i<(b);++i)
#define per(i,x) for(long long i = (x) ; i >= 0 ; --i)
#define perr(i,x,y) for(long long i = (x) ; i >= (y) ; --i)
#define mem(x,y) memset((x),(y),sizeof(x))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fbo find_by_order
#define ook order_of_key
#define all(a) (a).begin(),(a).end()
#define lla(a) (a).rbegin(),(a).rend()
#define p(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define p2(x,y) cout<<x<<" "<<y<<"\n"
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define p4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
#define p5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<"\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
 
 
//template<class T>
//bool isPrime(T n){
//    if(n==1)return false;
//    T i = 2;
//    while(i*i<=n){
//       if(n%i==0)return false;
//       i+=1;
//    }
//    return true;
//}
 
// bool prime[100005];
// void seive()
// {
//     memset(prime,true,sizeof(prime));
//     prime[0]=0;
//     prime[1]=0;
//     for(ll p=2;p*p<=100000;p++)
//     {
//         if(prime[p]==true)
//         {
//             for(ll i=p*2;i<=100000;i+=p)
//             prime[i]=false;
//         }
//     }    
// }
 
// ll power(ll n,ll k, ll mod){
//     if(k==0)
//         return 1;
//     if(k==1)
//         return n%mod;
 
//     ll get=power(n,k/2,mod);
//     ll ret = ((get%mod)*(get%mod))%mod;
 
//     if(k%2)
//         ret = ((ret%mod)*(n%mod))%mod;
 
//     return ret%mod;
// }
 
int main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    FAST;

    int n; cin>>n;
    ll x;
    if(n&1)x = n/2+1;
    else x = n/2;
    double ans = x/(n*1.0);
    cout<<setprecision(16)<<fixed<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = c - a - b;
	if (d > 0 && 4 * a * b < d * d) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;

int main()
{
	int n,m,i,j;
	char ch[64];
	string str;
	
	for(;;)
	{
		cin >> m >> n  ;
		if(n==0 && m==0)
			break;
		
		int ans[1024]={0};
		for(i=0;i<m;i++)
			ans[i]=i+1;
		
		j=0;
		int flag=m;
		for(i=1;i<=n;i++)
		{
			cin >> str ;
			
			sprintf(ch,"%d",i);
			if(flag>1)
			{
				if(i%3==0 && i%5==0)
				{
					if(str!="FizzBuzz")
					{
						ans[j]=0;
						flag--;
					}
				}
				else if(i%3==0)
				{
					if(str!="Fizz")
					{
						ans[j]=0;
						flag--;
					}
				}
				else if(i%5==0)
				{
					if(str!="Buzz")
					{
						ans[j]=0;
						flag--;
					}
				}
				else
				{
					if(str!=ch)
					{
						ans[j]=0;
						flag--;
					}
				}
				j++;
				int c;
				for(c=j;ans[c]==0;)
				{
					c++;
					if(c>m-1)
						c=0;
				}
				j=c;
			}
		}
		int las;
		for(i=m-1;ans[i]==0;--i){}
		
		las=i;
		
		for(i=0;i<m;i++)
		{
			if(ans[i]!=0)
			{
				cout << ans[i] ;
				if(i<las)
					cout << " " ;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 960
#include <stdio.h>
 
int main(void){
int N, M, H[100001], i, A[100001], B[100001];
int frag[100001]={0}, ans=0;

    scanf("%d %d",&N,&M); 

    for(i=1;i<=N;i=i+1){
       scanf("%d",&H[i]);
    }
    for(i=0;i<M;i=i+1){
       scanf("%d %d",&A[i],&B[i]);
    }
    
    for(i=0;i<M;i=i+1){
       if(H[A[i]]>H[B[i]]){
         frag[B[i]]++;
       }
       else if(H[A[i]]<H[B[i]]){
         frag[A[i]]++;
       }
       else{
         frag[A[i]]++;
         frag[B[i]]++;
       }
    }

    for(i=1;i<=N;i=i+1){
       if(frag[i]==0){
         ans++;
       }
    }

printf("%d",ans);

}

Measured memory_bytes: 3284
import java.util.Scanner;

public class Main {
    private static char[][] m;
    private static Scanner SC = new Scanner(System.in);
    private static int row, col;
    private static final int[] DX = {-1, 1, 0, 0}, DY = {0, 0, -1, 1};

    public static void dfs(int r, int c) {
        char cur = m[r][c];
        m[r][c] = 'x';
        for (int i = 0; i < 4; i++) {
            int tr = r + DX[i];
            int tc = c + DY[i];
            if (0 <= tr && tr < row && 0 <= tc && tc < col && m[tr][tc] == cur) {
                dfs(tr, tc);
            }
        }
    }

    public static void main(String[] args) {
        while (true) {
            row = SC.nextInt();
            col = SC.nextInt();
            SC.nextLine();
            if (row == 0 && col == 0) {
                break;
            }
            m = new char[row][];
            for (int i = 0; i < row; i++) {
                m[i] = SC.nextLine().toCharArray();
            }
            int count = 0;
            for (int i = 0; i < row; i++) {
                for (int j = 0; j < col; j++) {
                    if (m[i][j] != 'x') {
                        dfs(i, j);
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

    }
}



Measured memory_bytes: 28424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int n;
ld ans=0,x;
string str;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cout << fixed << setprecision(12);
	cin >> n;
	rep(n){
		cin >> x >> str;
		ans+=(str=="BTC"?x*380000:x);
	}
	print1(ans);
	return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
MOD = 10**9+7
for i in range(N):
    l = 0
    r = 0
    for j in range(N):
        if i<j:
            if A[i]>A[j]:
                r += 1
            else:
                pass
        elif i>j:
            if A[i]>A[j]:
                l += 1
            else:
                pass
    ans += l*max(0,(K-1)*(K)//2)
    ans %= MOD
    ans += r*(K+1)*K//2
    ans %= MOD
print(ans)

Measured memory_bytes: 42732
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void insertion_sort(vector<int> &list, int interval, int &count) {
  for (int i = interval; i < list.size(); ++i) {
    int key = list[i];
    int j = i - interval;
    while (j >= 0 && list[j] > key) {
      list[j+interval] = list[j];
      j = j - interval;
      count++;
    }
    list[j+interval] = key;
  }
}

void shell_sort(vector<int> &list, int &count) {
  int index = max(0, (int)(log10(list.size())/log10(2)) - 1);
  vector<int> intervals;
  while (index >= 0) {
    intervals.push_back(pow(2, index));
    index--;
  }
  cout << intervals.size() << endl;
  for (auto iter = intervals.begin(); iter != intervals.end() - 1; ++iter) {
    cout << *iter << " ";
  }
  cout << intervals.back() << endl;
  for (int interval : intervals) {
    insertion_sort(list, interval, count);
  }
}

int main() {
  int N;
  cin >> N;
  string str;
  vector<int> list;
  for (int i = 0; i < N; ++i) {
    cin >> str;
    list.push_back(stoi(str));
  }

  int count = 0;
  shell_sort(list, count);
  cout << count << endl;
  for (auto iter = list.begin(); iter != list.end(); ++iter) {
    cout << *iter << endl;
  }
}

Measured memory_bytes: 7028
#include<iostream>
#include<string>
#include<cmath>
#include <algorithm>
using namespace std;
 
int main(){
  int N;
  int L;
  
  cin >> N >> L;

  int ans = 100000;
  
  for(int i=0;i<N;++i){
    if(abs(ans) > abs(i+L)) ans = i+L;
  }
  
  
  int total = (L+N+L-1)*N/2 - ans;
  cout << total << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int x, i;
	for (i = 1;; i++)
	{
		scanf("%d",&x);
		if (x == 0)
		{
			break;
		}
		else
		{
			printf("Case %d: %d\n",i,x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e3+2;

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

      string s;
      cin>>s;
      if(s[0]=='M')
      {
        cout<<6;
      }      
      else if(s[0]=='T')
      {
        if(s[1]=='U')
        {
          cout<<5;
        }
        else{
          cout<<3;
        }
      }
      else if(s[0]=='W')
      {
        cout<<4;
      }
      else if(s[0]=='F')
      {
        cout<<2;
      }
      else if(s[0]=='S')
      {
        if(s[1]=='U') cout<<7;
        else cout<<1;
      }

}
// I never lose. I either win or I learn

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,i,sum=0,a,left=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a;
		sum+=(left+a)/2;
		left=(left+a)%2;
		if(!a)
			left=0;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *start coding only after you have clear idea. Otherwise you will waste time to change your code frequently and debug
 */

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    bool flag=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='7')
            flag=1;
    }
    if(flag)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n,h;
    cin >> n >> h;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    ll amax = *max_element(a.begin(),a.end());

    sort(b.begin(),b.end(),greater<ll>());
    ll ans = INF;
    ll sumb = 0;
    rep(k,n+1){
        ll tmp_ans = k;
        tmp_ans += max(0.,ceil((double)(h-sumb)/amax));
        sumb += b[k];
        ans = min(ans,tmp_ans);
    }
    cout << ans;
}


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

using namespace std;

int main() {
   // freopen("in.txt", "r", stdin);

    string a,b;
    cin >> a >> b;
    sort(a.begin(),a.end());
    sort(b.rbegin(),b.rend());
    if(a<b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    
    int h,a;
    cin >> h >> a;
    
    int ans=0;
    for(int i=0;h>0;i++){
        h=h-a;
        ans=ans+1;
    }
        
    
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 256
H, W = map(int, input().split())
P = [ int(input()) for _ in range(H) ]
Q = [ int(input()) for _ in range(W) ]
E = [(p, 0) for p in P] + [(q, 1) for q in Q]
E.sort()
ans = 0
for e in E:
  if e[1] == 0:
    ans += e[0] * (W+1)
    H -= 1
  if e[1] == 1:
    ans += e[0] * (H+1)
    W -= 1
print(ans)


Measured memory_bytes: 26964
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  int N = 0,D = 0,X = 0,ans = 0;
  cin >> N >> D >> X;
  vector<int>A(N);
  rep(i,N){
    cin >> A[i];
    if(D % A[i] == 0){
      ans += D/A[i];
    }
    else{
      ans += D/A[i] + 1;
    }
  }
  cout << ans + X;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#include <map>
#define pb push_back
#define ll long long
#define pii pair <int,int>
#define eb emplace_back
#define pll pair <long, long>
using namespace std;
ll n,W;
int a,b;
ll S;
typedef struct
{
    ll w,v,q;
 }triplet;
pll v[110];
ll dp[110][100010];
//const int inf = LONG_MAX;
const int mod = 1e9+7;
void knapSack()
{
   int i,j;
 //     cout<<"A";
   for(i=0;i<=n;i++)
        for(j=0;j<=100000;j++)
   {
       dp[i][j]=1e10;
   }
   dp[n][0]=0;
   //cout<<"A";
   for(i=n-1;i>=0;i--)
   {
       for(j=0;j<=100000;j++)
       {
           dp[i][j]=dp[i+1][j];
           if(j>=v[i].second)
           {
               dp[i][j]=min(dp[i][j],dp[i+1][j-v[i].second]+v[i].first);
           }
       }
   }
   for(i=100000;i>=0;i--)
   {
       if(dp[0][i]<=W)
       {
           cout<<i;
           break;
       }
   }
   return;
}
int main()
{
    int i;
    cin>>n>>W;
    for(i=0;i<=n-1;i++)
    {
          triplet t;
          cin>>t.w>>t.v;
          v[i]={t.w,t.v};
          //S+=t.v;
    }
//    for(i=0;i<=n-1;i++)
//    {
//        cout<<v[i].first<<" "<<v[i].second<<"\n";
//    }
   // cout<<v[0].first<<" "<<v[0].second;
    knapSack();
    return 0;
}


Measured memory_bytes: 80128
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
//#include <cassert>
#include <vector>
//#include <array>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <stack>
//#include <queue>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
using namespace std;

#define MAXN 1000

int main() {
	const int m = 31;
	const ll maxu = (ll)pow(2, m) - 1;

	int N;
	cin >> N;
	unsigned int U[MAXN + 1], V[MAXN + 1];
	bool is_even;

	REP1(i_arm, N) {
		int X, Y;
		cin >> X >> Y;
		if (i_arm == 1) {
			is_even = ((X + Y) % 2 == 0);
		}
		else {
			if (!(is_even == ((X + Y) % 2 == 0))) {
				cout << -1 << endl;
				return 0;
			}
		}
		U[i_arm] = (unsigned int)((((ll)X + Y) + maxu) / 2);
		V[i_arm] = (unsigned int)((((ll)X - Y) + maxu) / 2);
	}

	int m_ans = m;
	if (is_even)
		m_ans++;
	cout << m_ans << endl;
	REP(j, m) {
		cout << (ll)pow(2, j) << " ";
	}
	if (is_even) {
		cout << 1;
	}
	cout << endl;
	REP1(i, N) {
		int u = U[i];
		int v = V[i];
		REP(j, m) {
			char c;
			if ((u & 1) == 1) {
				if ((v & 1) == 1) {
					c = 'R';
				}
				else {
					c = 'U';
				}
			}
			else {
				if ((v & 1) == 1) {
					c = 'D';
				}
				else {
					c = 'L';
				}
			}
			cout << c;
			u = u >> 1;
			v = v >> 1;
		}
		if (is_even) {
			cout << 'R';
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let n: usize = read();
    let w:Vec<i64> = (0..n).map(|_| read()).collect();
    let mut ans:i64 = std::i64::MAX;
    let sum:i64 = w.iter().sum();
    let mut s1 = 0;
    for i in w.into_iter(){
        s1 += i;
        ans = std::cmp::min(ans,(sum-2*s1).abs());
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int,int> pii;
typedef long long LL;
const double PI=acos(-1.0);

int main(void)
{
    int a,b,c;
    while (cin>>a>>b>>c)
    {
        int ans=0;
        int flag=0;
        while (ans<=100000)
        {
            if(a&1||(b&1||(c&1)))
            {
                flag=1;
                break;
            }
            int A=(a>>1);
            int B=(b>>1);
            int C=(c>>1);
            a=B+C;
            b=A+C;
            c=A+B;
            ++ans;
        }
        printf("%d\n",!flag?-1:ans);
    }
    return 0;
}


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

int main() {
    int n; cin >> n;
    int t[n + 1];
    int sum = 0;
    for (int i = 0; i < n; i++) { cin >> t[i]; sum += t[i]; }
    int m; cin >> m;
    int p[m + 1], x[m + 1];
    for (int i = 0; i < m; i++) cin >> p[i] >> x[i];

    for (int i = 0; i < m; i++) {
        int ans = sum - t[p[i] - 1] + x[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <sstream>
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
int main() {
    
    
  
    long long int a;
    long double b;
      cin >> a >> b;
    long long int sum;
    sum = (a*b);
   
  
    cout << sum << endl;
    
} 

Measured memory_bytes: 3752
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
#include<unordered_map>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(int i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/
int main(){
  int n,l; cin >> n >> l;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  vi ans;
  
  int start;
  rep(i,n-1){
    if(a[i] + a[i+1] >= l){
      start = i+1;
      break;
    }
    if(i == n-2){
      cout << "Impossible" <<endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
  ans.pb(start);
  while(start != 1)
    ans.pb(--start);
  start = ans[0];
  while(start != n-1)
    ans.pb(++start);
  reverse(ALL(ans));
  rep(i,n-1)
    cout << ans[i] << endl;
}

Measured memory_bytes: 1784
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
#define dd double
int n,m;
int main()
{
	scanf("%d",&n);
	m=(n+1)/2;
	dd gl=(dd)1.0*m/n;
	printf("%.8lf\n",gl);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main()
{
  int A[1000],i,j,k,num,key;

  while(1)
    {
      scanf("%d", &num);
      if(num >= 0 && num <= N) break;
    }
  
  for(i=0;i<num;i++)
    {
      scanf("%d", &A[i]);
    }

  //表示文(1行目)
  for(k=0;k<num;k++)
	{
	  if(k<num-1) printf("%d ",A[k]);
	  else printf("%d\n",A[k]);
    }
  
  for(i=1;i<num;i++)
    {      
      key = A[i];
      j = i - 1;
      while(j >= 0 && A[j] > key)
	{
	  A[j + 1] = A[j];
	  j--;
	  A[j + 1] = key;
	}

      //表示文(2行目以降)
      for(k=0;k<num;k++)
	{
	  if(k<num-1) printf("%d ",A[k]);
	  else printf("%d\n",A[k]);
	}
    }
  
  return 0;
}



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

using Pi = pair<int, int>;

template < typename T >
struct Edge {
    int from, to;
    T cost;
    Edge () {}
    Edge (int from, int to, T cost) : from(from), to(to), cost(cost) {}
    Edge (int to, T cost) : from(-1), to(to), cost(cost) {}
};

template < typename T >
vector<T> Dijkstra(int V, vector<vector<Edge<T>>> &G, int s) {
    using Node = pair<T, int>;
    constexpr T INF = numeric_limits<T>::max();
    vector<T> d(V, INF);
    priority_queue<Node, vector<Node>, greater<Node>> pq;

    d[s] = 0;
    pq.emplace(0, s);
    while (!pq.empty()) {
        Node node = pq.top(); pq.pop();
        for (auto &e : G[node.second]) {
            T cost = e.cost + node.first;
            if (cost < d[e.to]) {
                d[e.to] = cost;
                pq.emplace(cost, e.to);
            }
        }
    }

    return (d);
}

int main() {
    int N, M;
    map<Pi, int> ha;
    int cnt = 0;
    vector<vector<Edge<int>>> G(500005);
    vector<vector<int>> stp(100005);
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int p, q, c;
        int u, v;
        cin >> p >> q >> c; --p, --q;
        if (ha.find(Pi(p, c)) == ha.end()) ha[Pi(p, c)] = cnt++;
        if (ha.find(Pi(q, c)) == ha.end()) ha[Pi(q, c)] = cnt++;
        u = ha[Pi(p, c)]; 
        v = ha[Pi(q, c)]; 
        G[u].emplace_back(v, 0);
        G[v].emplace_back(u, 0);
        stp[p].push_back(c);
        stp[q].push_back(c);
    }

    for (int i = 0; i < N; i++) {
        ha[Pi(i, -1)] = cnt++;
        int home = cnt - 1;
        for (auto &c : stp[i]) {
            int u = ha[Pi(i, c)];
            G[u].emplace_back(home, 0);
            G[home].emplace_back(u, 1);
        }
    }

    vector<int> ans = Dijkstra<int>(cnt, G, ha[Pi(0, -1)]);
    int ansv = ans[ha[Pi(N - 1, -1)]];
    if (ansv == numeric_limits<int>::max()) {
        cout << -1 << endl;
    } else {
        cout << ansv << endl;
    }
    return (0);
}

Measured memory_bytes: 72312
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    ll sum=0;
    for(ll i=0;i<n;i++)
        for(ll j=i+1;j<n;j++)
            sum+=a[i]*a[j];
    cout<<sum<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


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

int N,W;

long long knapsack(vector<int> w, vector<int> v){
    vector<vector<long long> > dp(N+1, vector<long long>(W+1,0));

    for(int i=1;i<=N;i++){
        for(int j=1;j<=W;j++){
            dp[i][j] = dp[i-1][j];
            if(j-w[i]>=0)
                dp[i][j] = max(dp[i][j], v[i]+dp[i-1][j-w[i]]);
        }
    }
    return dp[N][W];
}

int main(){
    cin>>N>>W;
    vector<int> w(N+1,0), v(N+1,0);
    for(int i=1;i<=N;i++)
        cin>>w[i]>>v[i];
    cout<<knapsack(w,v)<<endl;
    return 0;
}


Measured memory_bytes: 82996
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String a1 = scan.next();
    int t = a1.length();
    for (int i=0;i<t;i++){
      System.out.print("x");
    }
    System.out.println("");
  }
}


Measured memory_bytes: 35476
n, k = map(int, input().split())
li_p = list(map(int, input().split()))

li_kitai = list()
d_kitai_memo = dict()
for l in li_p:
    if l not in d_kitai_memo:
        val = sum(range(1, l + 1)) / l
        d_kitai_memo[l] = val
        li_kitai.append(val)
    else:
        li_kitai.append(d_kitai_memo[l])

answer = 0
memo = 0
for idx, v in enumerate(li_kitai[:len(li_kitai) - k + 1]):
    if idx == 0:
        memo = sum(li_kitai[idx:idx + k])
    else:
        memo = memo - li_kitai[idx - 1] + li_kitai[idx + (k - 1)]
    answer = max(answer, memo)

print(answer)




Measured memory_bytes: 24804
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    x = int(input())

    print('ABC') if x < 1200 else print('ARC')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=2e5+5,MOD=1e9+7;
//did u check when n=1?
//is mxN correct?
int n,vis[mxN];
int dp[2][mxN];
vi adj[mxN];
void solve(int i,int p){
    if(dp[0][i]!=-1)return;
    int cnt1=1,cnt2=1;
    for(int j:adj[i]){
        if(j!=p){
            solve(j,i);
            cnt1=(cnt1*dp[0][j])%MOD;
            cnt2=(cnt2*(dp[0][j]+dp[1][j])%MOD)%MOD;
        }

    }
    dp[1][i]=cnt1%MOD;
    dp[0][i]=cnt2%MOD;
    return;
}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;a--;b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    solve(0,-1);
    cout<<(dp[0][0]+dp[1][0])%MOD<<"\n";
}

Measured memory_bytes: 18560
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, m] <- getIntList
  hs <- getIntVec n

  v <- VM.new n
  VM.set v True -- True means "good."

  replicateM m $ do
    [a, b] <- getIntList
    let (i, j) = (a-1, b-1)
        hi = hs V.! i
        hj = hs V.! j
    when (hi >= hj) $ VM.write v j False
    when (hj >= hi) $ VM.write v i False

  v' <- V.freeze v

  let ans = V.length $ V.filter id v'

  print ans


Measured memory_bytes: 11388
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
 
int main() {
    int n;
    cin >> n;
    map<string, int> memo;
    rep(i, n) {
        string s;
        cin >> s;
        memo[s]++;
    }
    int maxvalue = 0;
    for (auto v : memo) maxvalue = max(maxvalue, v.second);
    for (auto v : memo) {
        if (v.second != maxvalue) continue;
        cout << v.first << endl;
    }
    return 0;
}


Measured memory_bytes: 25216
#include <iostream>
using namespace std;
template<class T,class C> T max(T a,C b){ return ((a)>(T)(b) ? (a) : (T)(b)); }
int main(){
  int p,q,r;
  cin >> p >> q >> r;
  cout << p+q+r-max(p,max(q,r)) << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>

int main(void)
{
    int h, w, i, j;

    scanf("%d %d", &h, &w);

    while((h != 0) && (w != 0)) {
        for (i=0; i<w;i++)
            printf("#");
        printf("\n");
        for (i=0; i < h-2; i++) {
            printf("#");
            for (j=0; j<w-2; j++) {
                printf(".");
            }
            printf("#");
            printf("\n");
        }
        for (i=0; i<w;i++)
            printf("#");
        printf("\n");

        scanf("%d %d", &h, &w);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 2500
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <cstring>

#define f first
#define s second
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 wefkljekfjwek

using namespace std;

const ll mod=1000000007;
int kilk[26];
string s;
ll ans=1;
int n;

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("INPUT.txt","r",stdin);
    cin>>n>>s;
    for(int i=0;i<s.size();i++)
        kilk[s[i]-'a']++;
    for(int i=0;i<26;i++)
        ans=(ans*(kilk[i]+1))%mod;
    cout<<(ans-1+mod)%mod;
        
}



Measured memory_bytes: 512
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;

inline int ceiling(int n, int d) {
	return n % d == 0 ? n / d : n / d + 1;
}


int N, M;
bool match(int offset, vector<char>& A, vector<char>& B) {
	for (size_t i = 0; i < M; i++) {
		for (size_t j = 0; j < M; j++) {
			if (A[i*N + j + offset] != B[i*M + j])return false;
		}
	}
	return true;
}

int main() {
	cin >> N >> M;
	auto A = vector<char>(N*N);
	for (size_t i = 0; i < A.size(); i++) cin >> A[i];
	auto B = vector<char>(M*M);
	for (size_t i = 0; i < B.size(); i++) cin >> B[i];
	for (size_t i = 0; i <= N - M; i++) {
		for (size_t j = 0; j <= N - M; j++) {
			if (match(i*N + j, A, B)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
//public static swap(){}
	public static void maxHeapify(int[] A, int i){
		  int H = A.length;
		  int largest;
	      int l = 2*(i+1)-1;
	      int r = 2*(i+1);	      
	      // select the node which has the maximum value
	      if (l < H && A[l] > A[i])
	          largest = l;
	      else 
	          largest = i;
	      if (r < H && A[r] > A[largest])
	          largest = r;
	
	      if (largest != i)// value of children is larger than that of i
	      {
	    	  int temp = A[i];
	    	  A[i] = A[largest];
	    	  A[largest] = temp;
	    	  maxHeapify(A, largest); // call recursively
	      }	      
}

	public static void main(String[] argv) {
		int n;
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		int[] tree = new int[n];
		for(int i = 0; i < n; i ++) {
			tree[i] = in.nextInt();
//			System.out.println(tree[i]);
		}
		for(int i = (n-1)/2; i >= 0; i--) {
			maxHeapify(tree, i);
		}
		for(int i = 0; i < n; i ++) {
			System.out.print(" " + tree[i]);
		}
		System.out.println();
		in.close();
	}
}



Measured memory_bytes: 167368
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int bynary = 0;
    for (int i=1;i<10;i++) {
      if(N%i==0 && N/i<10){
        System.out.println("Yes");
        bynary = 1;
        break;
      }
    }
    if(bynary == 0){
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
 
struct edge{int from,to; ll cost;};
 
void add_edge(int x,int y,ll c,vector<edge> &G){
    edge e;
    e.from = x;
    e.to   = y;
    e.cost = c;
    G.push_back(e);
}
 
ll negative_cycle(int s,int t,int V,int E,const vector<edge> &G){
    vector<ll> d(V,INF);d[s]=0;
    vector<ll> drev(V,INF);drev[t]=0;
    vector<bool> updated(V,false);
    REP(i,V){
        REP(j,E){
            edge e=G[j];
            if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                if(i==V-1) updated[e.to] = true;
            }
            if(drev[e.to]!=INF && drev[e.from]>drev[e.to]+e.cost){
          	    drev[e.from]=drev[e.to]+e.cost;
            }
        }
    }
    bool res = false;
    REP(i,V) {
        if(d[i]!=INF && drev[i]!=INF && updated[i]==true) res = true;
    }
    return res?-INF:d[t];
}
 
int main(){
    int N, M; ll P;
    cin>>N>>M>>P;
    vector<edge> G;
    int a,b; ll c;
    REP(i,M){
        cin>>a>>b>>c;a--;b--;
        add_edge(a,b,-c+P,G);
    }
	ll ans = negative_cycle(0,N-1,N,M,G);
    cout << (ans==-INF?-1:max(0LL,-ans)) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll X;
    cin >> X;
    for (ll i = 0; i < 100000; i++) {
        if (X <= i * (i + 1) / 2) {
            cout << i << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 256