akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
   int n,S[10000],q,T[1000],i,j,cnt=0;
   scanf("%d",&n);
   for(i=0;i<n;i++)
      scanf("%d",&S[i]);

   scanf("%d",&q);
   for(i=0;i<n;i++)
      scanf("%d",&T[i]);

   for(i=0;i<q;i++){
      for(j=0;j<n;j++){
         if(S[j]==T[i]){
            cnt++;
            break;
         }
      }
   }
   printf("%d\n",cnt);
   return 0;
}


Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, s;
  cin >> a;
  s = a % 10;
  a = a / 10;
  s = s + a%10;
  a = a / 10;
  s = s + a%10;
  cout << s << endl;
}

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

typedef long long ll;

const int N = 100 + 10, W = 1e5 + 10;
ll dp[N][W], w[N], v[N];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, wei;
    cin >> n >> wei;
    for (int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= wei; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i])
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
        }
    cout << dp[n][wei] << "\n";
    return 0;
}

Measured memory_bytes: 79360
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    long a;
    long A[N];
    long C[N]; fill(C, C + N, 0);
    for (int i=0; i<N; i++){
        cin >> a;
        a--;
        A[i] = a;
        C[a] ++;
    }
    long sum = 0;
    for(int i=0; i<N; i++){
        sum += C[i] * (C[i] - 1) / 2;
    }
    for(int i=0; i<N; i++){
        cout << sum - C[A[i]] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			int ope = Integer.parseInt(br.readLine());
			DoublyLinkedList(ope, br);
		} catch (NumberFormatException | IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
	//enum宣言
	public static enum Operate{
		insert("insert"),
		delete("delete"),
		deleteFirst("deleteFirst"),
		deleteLast("deleteLast");
		
		private final String name;
		
		Operate(String name){
			this.name = name;
		}
		
		String getName(){
			return this.name;
		}

		public static Operate getEnumName(String str){
			for(Operate v : values()){
				if(v.getName().equals(str)){
					return v;
				}
			}
			throw new IllegalArgumentException("undefined : " + str);
		}
	}
	//キューで処理
	public static void DoublyLinkedList(int ope, BufferedReader br){
		ArrayDeque<String> que = new ArrayDeque<String>();
		int i;
		
		for ( i = 0; i < ope; i++) {
			String[] key;							//キーと命令の格納先
			try {
				key = br.readLine().split(" ");		//キーと命令を分割
			 
				switch( Operate.getEnumName(key[0]) ){ //命令によって処理
				case insert:
					que.addFirst(key[1]);			//キューに追加
					break;
				case delete:
					que.remove(key[1]);				//キューから削除
					break;
				case deleteFirst:
					que.removeFirst();				//キューの先頭削除
					break;
				case deleteLast:
					que.removeLast();				//キューの末端削除
					break;
				}
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		}
		System.out.print(que.remove());				//出力処理
		while (que.isEmpty() == false) {            //
			System.out.print(" " + que.remove());   //
		}
		System.out.println();
	}
}


Measured memory_bytes: 221544
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;
using System.Threading;

namespace Atcoder
{
	class Program
	{
		//string s = Console.ReadLine();
		//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		//int H = intArray[0];
		//int W = intArray[1];
		//int N = int.Parse(Console.ReadLine());
		//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
		//Boolean ok = false;
		//List<int> dp = Enumerable.Repeat(個数, 値).ToList();

		//Console.WriteLine(ans);
		//Console.WriteLine("Yes");
		//Console.WriteLine("No");
		//Console.ReadKey();
		//Console.WriteLine(cnt);

		//string[] strArray = Console.ReadLine().Split(' ').ToArray();
		//string S = strArray[0];
		//string T = strArray[1];
		static void Main(string[] args)
		{
			int[] ND = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int N = ND[0];
			double D = (double)ND[1];

			int cnt = 0;

			for(int i = 0;i < N; i++)
            {
				double[] XY = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();
				double K = Math.Sqrt(Math.Pow(XY[0], 2) + Math.Pow(XY[1], 2));
				if(K <= D)
                {
					cnt++;
                }
			}
			Console.WriteLine(cnt);
		}

		/// <summary>
		/// 回文
		/// </summary>
		/// <param name="Target"></param>
		/// <param name="len"></param>
		/// <returns></returns>
		static bool Palindrome(string Target , int len)
        {
			bool yes = true;

			for(int i = 0;i < len; i++)
            {
				if(Target[i] != Target[len - 1 - i])
                {
					yes = false;
					break;
                }
            }
			return yes;
        }

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}
		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Lcm(BigInteger a, BigInteger b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Gcd(BigInteger a, BigInteger b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

Measured memory_bytes: 46908
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << "ABC" << n << endl;


  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(a < 10 && b < 10 ? a * b : - 1);
    }
}

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

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> a(m);
  for(int i=0;i<m;i++)
    cin >> a.at(i);
  
  sort(a.begin(),a.end());
  
  int p=0;
  int q=0;
  for(int i=0;i<m;i++){
    if(a.at(i)<x)
      p++;
    else
      q++;
  }
  cout << min(p,q) << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var max = ab.Max();
            var min = ab.Min();

            Console.WriteLine(max + Math.Max(max - 1, min));
        }
    }
}


Measured memory_bytes: 13780
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
typedef long long ll;
using namespace std;

int n, a[100000], b[100000], mx, cnt;
ll s;
int main() {
	cin >> n;
	s = 0;
	lp(n) {
		cin >> a[i];
		s += a[i];
	}
	if (s % (ll(n)* ll(n + 1) / 2) != 0) {
		cout << "NO" << endl;
		return 0;
	}
	s /= ll(n)*ll(n + 1) / 2;
	mx = -intmax;
	lp(n - 1) {
		b[i] = a[i + 1] - a[i];
		mx = max(mx, b[i]);
	}
	b[n - 1] = a[0] - a[n - 1];
	mx = max(mx, b[n - 1]);
	cnt = 0;
	lp(n)
		if ((mx - b[i]) % n != 0) {
			cout << "NO" << endl;
			return 0;
		}
		else cnt += (mx - b[i]) / n;
	if (s < cnt || (cnt - s) % n != 0)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}


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

using namespace std;

#define int long long

const int mod = 1e9 +7, MAX = 5e5 + 5;
int has1[MAX], has2[MAX], n, pow27[MAX];
bool pre[MAX], suf[MAX], same = 1;
string s;

int gethas1(int i, int j) {
    return (has1[j] - (has1[i - 1] * pow27[j - i + 1]) % mod + mod) % mod;
}

int gethas2(int i, int j) {
    return (has2[i] - (has2[j + 1] * pow27[j - i + 1]) % mod + mod) % mod;
}

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    n = s.size(); s = '*' + s;
    pow27[0] = 1; for (int i = 1; i < MAX; ++i) pow27[i] = (pow27[i - 1] * 27) % mod;
    for (int i = 1; i <= n; ++i) {
        if(s[i] != s[1]) same = 0;
    }
    if(same) {
        cout << n << '\n' << 1;
        return 0;
    }
    for (int i = 1; i <= n; ++i) has1[i] = (has1[i - 1] * 27 + s[i] - 'a' + 1) % mod;
    for (int i = n; i > 0; --i) has2[i] = (has2[i + 1] * 27 + s[i] - 'a' + 1) % mod;
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j + i - 1 <= n; j += i) {
            if(has1[i] != gethas1(j, j + i - 1) ) break;
            pre[j + i - 1] = 1;
        }
    }

    for (int i = n; i > 0; --i) {
        for (int j = n - i; j - i + 1 > 0; j -= i) {
            if(gethas2(n - i + 1, n) != gethas2(j - i + 1, j) ) break;
            suf[j - i + 1] = 1;
        }
    }

    if(!pre[n]) cout << "1\n1";
    else {
        cout << 2 << '\n';
        int cnt = 0;
        for (int i = 1; i < n; ++i) if(!pre[i] && !suf[i + 1]) cnt ++;
        cout << cnt;
    }

    return 0;
}


Measured memory_bytes: 13616
n, m = map(int, input().split())
broken = [0] * (n + 1)

for i in range(m):
    a = int(input())
    broken[a] = 1

dp = [0] * (n + 1)
dp[0] = 1
mod = 1000000007

for i in range(1, n+1):
    if broken[i]:
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % mod

print(dp[n])

Measured memory_bytes: 13496
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

#define INF ((i64)(1e18))
#define MOD ((i64)(1e9+7))
#define REP(i, n) for(i64 i = 0; i < (n); i++)
#define RREP(i, n) for(i64 i = (n)-1; i >= 0; i--)
#define RANGE(i, a, b) for(i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for(i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

int main() {
  i64 n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<i64> l(n);
  REP(i, n) cin >> l.at(i);
  sort(ALL(l));

  i64 ans = INF;
  do {
    RANGE(i, 0, n-2) {
      RANGE(j, i+1, n-1) {
        RANGE(k, j+1, n) {
          i64 sum1 = 0, sum2 = 0, sum3 = 0;
          RANGE(ii, 0, i+1) sum1 += l[ii];
          RANGE(jj, i+1, j+1) sum2 += l[jj];
          RANGE(kk, j+1, k+1) sum3 += l[kk];
          chmin(ans, abs(a-sum1)+abs(b-sum2)+abs(c-sum3)+10*(k+1)-30);
        }
      }
    }
  } while (next_permutation(ALL(l)));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define MOD 1000000007
#define mod9 1000000009
#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define ct ll t;cin>>t;while(t--)
#define bi begin()
#define ei end()
#define fi first 
#define se second  
#define foe(i,a,b) for(ll i=a;i<b;i++)
#define rfoe(i,a,b) for(ll i=a;i>=0;i--)
#define sz(s) s.size() 
#define mem(a,s) memset(a,s,sizeof(a)) 
#define all(v) v.bi,v.ei
#define MAX             8000000000000000064LL
#define MIN            -8000000000000000064LL  
// ll MOD; 
// ll add(ll a, ll b){return (a%MOD + b%MOD + ((MAX)/MOD)*MOD)%MOD;}
// ll sub(ll a, ll b){return (a%MOD - b%MOD + ((MAX)/MOD)*MOD)%MOD;}
// ll mul(ll a, ll b){return ((a%MOD)*(b%MOD) + ((MAX)/MOD)*MOD)%MOD;}
// ll fact[1000007]={0};
// ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
// y=y>>1;x=(1ll*x*x)%MOD;} return res;}
// void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%MOD;}
// ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],MOD-2)))%MOD; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res;}
// ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
int const N=2e5+9;
ll const INF = 2e18+5;
 
void solve()
{ 
    ll k;
    cin>>k;
    if(k%2==0||k%5==0)
    {
        cout<<"-1\n";
        return;
    }
    set<ll>s;
    ll t=7,r=7,ans=0;
    while(1)
    {
        if(s.count(r)==1)
        {
            cout<<"-1\n";
            return;
        }
        r=r%k;

        if(r==0)
        {
            cout<<ans+1<<"\n";
            return;
        }
        ans++;
        s.insert({t,r});
        r=r*10+7;
    }
    cout<<"-1\n";
}
int main()
{
    fast
    // ct
    { 
        solve();
    }
}

Measured memory_bytes: 50516
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int n;
  cin >> n;
  cout << (n - 2) * 180 << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
#include <stdio.h>

const int zyoutai[10]={
	     /*    abcdefg */
	0x7E,/* 0: 1111110 */
	0x30,/* 1: 0110000 */
	0x6D,/* 2: 1101101 */
	0x79,/* 3: 1111001 */
	0x33,/* 4: 0110011 */
	0x5B,/* 5: 1011011 */
	0x5F,/* 6: 1011111 */
	0x72,/* 7: 1110010 */
	0x7F,/* 8: 1111111 */
	0x7B,/* 9: 1111011 */
};

int main(void) {
	int current_status;
	int change_status;
	int kosuu,nowkosuu;
	int input;
	int i;
	while(1) {
		scanf("%d",&kosuu);
		if(kosuu==-1)break;
		current_status=0;
		for(nowkosuu=0;nowkosuu<kosuu;nowkosuu++) {
			scanf("%d",&input);
			change_status=current_status ^ zyoutai[input];
			current_status=zyoutai[input];
			for(i=0;i<7;i++) {
				putchar((change_status & (1<<i))?'1':'0');
			}
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

# C - Subarray Sum
n, k, s = map(int, input().split())
ans = ''
str_s = str(s)

if s < pow(10, 9):
	str_another = str(s + 1)
else:
	str_another = '1'

for i in range(n):
	if i < k:
		ans += str_s + ' '
	else:
		ans += str_another + ' '

print(ans[:len(ans)-1])

Measured memory_bytes: 7444
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Duplex Printing
            int N = int.Parse(Console.ReadLine());

            if (N % 2 == 1)
            {
                N++;
            }

            Console.WriteLine(N / 2);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<functional>
using namespace std;

int main(void)
{
	string str;
	stringstream ss;

	int maxValue;
	int minValue;
	int n;
	cin >> n;
	while(n--)
	{
		cin >> str;

		sort(str.begin(), str.end());
		ss.str(str);
		ss >> minValue;
		ss.clear();

		reverse(str.begin(), str.end());
		ss.str(str);
		ss >> maxValue;
		ss.clear();

		cout << (maxValue-minValue) << endl;
	}
	return 0;
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

vector<int> primes;

void fill(){
	primes.push_back(2);

	for(int i = 3; i <= 55555; i += 2){
		bool ok = true;
		for(int j : primes){
			if(j * j > i) break;
			if(i % j == 0){
				ok = false;
				break;
			}
		}
		if(ok){
			primes.push_back(i);
		} 
	}
}



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

	int n;
	cin >> n;

	fill();

	int psize = primes.size();
	vector<int> ans;
	for(int p : primes){
		if(p % 5 == 1) {
			ans.push_back(p);
			if(ans.size() == 55) break;
		}
	}

	rep(i, n) cout << ans[i] << (i == n-1 ? "\n" : " ");
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////


struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

int first = 300000;
int second = 200000;
int third = 100000;
int bonus = 400000;

int getPrizeMoney(int prize) {
	if (prize == 1)return first;
	else if (prize == 2)return second;
	else if (prize == 3)return third;
	else return 0;
}

int main() {
	int x, y;
	cin >> x >> y;
	int ans = 0;
	ans += (getPrizeMoney(x)+getPrizeMoney(y));
	if (x == y && x == 1)ans += bonus;
	cout << ans;
}



Measured memory_bytes: 256
a, b, k = gets.chomp.split.map(&:to_i)
turn = 1
while turn <= k
  if turn % 2 == 1
    b += a / 2
    a /= 2
  else
    a += b / 2
    b /= 2
  end
  turn += 1
end
puts "%d %d" % [a, b]

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String scLine = sc.nextLine();
        int result = 0;
        int maxResult = 0;

        for (int i = 0; i < scLine.length(); i++){
        	if(scLine.substring(i,i + 1).equals("R")){
        		result = ++result;
        		if(result > maxResult){
        			maxResult = result;
        		}
        	}
        	else if(scLine.substring(i, i + 1).equals("S")){
        		result = 0;
        	}
        }

        System.out.println(maxResult);
	}
}


Measured memory_bytes: 35580
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int i, j, k;
    int L, N = 0;
    cin >> L;
    while(1<<N <= L) N++;
    vector<vector<int>> ans;
 
    // 2進数の辺を作る
    for(i=1; i<N; i++){
        ans.push_back({i, i+1, 1<<(i-1)});
        ans.push_back({i, i+1, 0});
    }
 
    // 今できている経路の最大長。これをL-1にするまで経路を足す。
    int now = (1<<(N-1)) - 1;
 
    for(i=N-1; i>=1; i--){
        if(now == L-1) break;
        
        // 頂点iからのショートカット追加で増える経路数
        int gain = 1<<(i-1);
 
        if(now + gain <= L-1){
            ans.push_back({i, N, now+1});
            now += gain;
        }
    }
 
    int M = ans.size();
    cout << N << " " << M << endl;
    for(auto v : ans){
        cout << v[0] << " " << v[1] <<  " " << v[2] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    string s,t;
    vector<bool> a(26,false);
    cin >> s;
    rep0(i, s.size())a[s[i] - 'a'] = true;
    
    if (s.size() < 26) {
        rep0(i, 26){
            if (!a[i]) {
                cout << s << (char)(i + 'a') << endl;
                return 0;
            }
        }
    }else{
        t = s;
        rrep0(i, s.size()){
            a[s[i] - 'a'] = false;
            t.pop_back();
            nfor(j, s[i] - 'a' + 1, 26){
                if (!a[j]) {
                    cout << t << (char)('a' + j) << endl;
                    return 0;
                }
            }
        }
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
  
  int N,A[20],B[20],C[20];
  
  //標準入力
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &B[i]);
  }
  for (int i = 0; i < N - 1; i++) {
    scanf("%d", &C[i]);
  }
  
  //満足度の合計
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += B[A[i] - 1];
    if (A[i+1] - A[i] == 1) {
      sum += C[A[i] -1];
    }
  }
  
  //出力
  printf("%d", sum);
  
  return 0;
}

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

using namespace std;

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

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

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

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin>>n>>m;
    vi a(m);
    ll sum =0;
    REP(i,m) {
        cin>>a[i];
        sum += a[i];
    }

    ll ans = n-sum;
    if(ans < 0) cout << "-1" << endl;
    else cout << ans << endl;
    return 0;
}

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

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * N;

N root,NIL;
int maxh;

void insert(int k){
  int H;
  N y = NIL;
  N x = root;
  N z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else {
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else {
    if(z->key < y->key){
      y->l = z;
    }
    else {
      y->r = z;
    }
  }
}

void inorder(N z){
  if(z == NIL)return;
  inorder(z->l);
  printf(" %d",z->key);
  inorder(z->r);
}
void preorder(N z){
  if(z == NIL)return;
  printf(" %d",z->key);
  preorder(z->l);
  preorder(z->r);
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  maxh = 0;
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,"insert") == 0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,"print")== 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
	
        
  
    



Measured memory_bytes: 25184
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 100000000001
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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


int main()
{
    int n, sum = 0;
    cin >> n;
    int l[n];
    REP(i, n) cin >> l[i];
    SORT(l, n);
    REP(i, n-1) sum += l[i];
    if(sum > l[n-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
N = gets.to_i
numbers = gets.strip.split(nil).map(&:to_i)
i = 0
pr = 1
unless numbers.include?(0) then
  while i < N do
    if pr <= 10**18 then
      pr *= numbers[i]
      i += 1
    else
      pr = -1
      break
    end
  end
  if pr <= 10**18 then
    puts pr
  else
    puts "-1"
  end
else
  puts "0"
end

Measured memory_bytes: 23496
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define part cout<<"---------------------\n";
#define debug(x) cout<<#x<<" : "<<x<<endl;
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

LL POW(LL x,LL y)
{
    LL ans=1;
    LL base=x;
    while(y)
    {
        if(y&1)
        {
            ans*=base;
            ans%=MOD;
        }
        base=base*base;
        base%=MOD;
        y=y>>1;
    }
    return ans%MOD;
}

int main()
{    
    fastinput;
    LL n,i,j,k,t,temp;
    cin>>n;
    LL ans=0,one=1;
    LL ones[62]={0},zeroes[62]={0};
    for(i=0;i<n;i++)
    {
        //debug(i);
        
        cin>>j;
       // debug(j);
        for(t=0;t<62;t++)
        {
            if((j&(one<<t))==0)
            {
                zeroes[t]++;
            }
            else
            {
                ones[t]++;
            }            
        }
        //part;
    }
    for(i=0;i<62;i++)
    {
       // debug(i);
       // debug(zeroes[i]);
       // debug(ones[i]);
        //debug(POW(2,i));
        LL add=(POW(2,i)*((zeroes[i]*ones[i])%MOD))%MOD;
       // debug(add);
        ans=(ans+add+MOD)%MOD;
       // part;
    }
    cout<<(ans+100*MOD)%MOD<<endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

class Main{
     public static void main(String[] args){

        Scanner as = new Scanner(System.in);
        int a = as.nextInt();
        int b = as.nextInt();
        int c = as.nextInt();
        int tr;

        if(a>b){
          tr=a;
          a=b;
          b=tr;
 
        
         }
        if(b>c){
        
          tr=b;
          b=c;
          c=tr;
             
               }
        if(a>b){

          tr=a;
          a=b;
          b=tr;
               
        }  
                  System.out.println(a+" "+b+" "+c);
              
 
 
   }
 
 
}

Measured memory_bytes: 26168
from collections import deque
import math
N,K=map(int,input().split())
table=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    table[a].append(b)
    table[b].append(a)


t=K//2
s=K%2
def dfs(i):
    visit=[-1]*N
    h=deque()
    h.append(i)
    visit[i]=0
    num=0
    a=0
    while h:
        x=h.popleft()
        for y in table[x]:
            if visit[y]==-1:
                visit[y]=visit[x]+1
                h.append(y)
    for k in range(N):
        if 0<=visit[k]<=t:
            num+=1
    #print(a,num,visit)
    return num

def dfs2(i,j):
    visit=[-1]*N
    h=deque()
    h.append(i)
    h.append(j)
    visit[i]=0
    visit[j]=0
    num=0
    while h:
        x=h.popleft()
        for y in table[x]:
            if visit[y]==-1:
                visit[y]=visit[x]+1
                h.append(y)
    for k in range(N):
        if 0<=visit[k]<=t:
            num+=1
    #print(a,num,visit)
    return num
if s==0:
    ans=0
    for i in range(N):
        ans=max(ans,dfs(i))
    print(N-ans)
elif s==1:
    ans=0
    for i in range(N):
        for j in table[i]:
            if j>i:
                ans=max(ans,dfs2(i,j))
    print(N-ans)

Measured memory_bytes: 52176
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		if (a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 2984
S = list(input())

if S[0] == 'A' and S[2:-1].count('C') == 1:
    S.pop(S[2:-1].index('C')+2)
    S.pop(0)
    if ''.join(S) == ''.join(S).lower():
        print('AC')
    else:
        print('WA')
else:
    print('WA')


Measured memory_bytes: 8988
n = int(input())
a = list(map(int, input().split()))
data = sorted(a, reverse = True)    # aを降順にソート
Alice = 0
Bob = 0
for i in range(n):
    if i % 2 == 0:
        Alice += data[i]
    else:
        Bob += data[i]
print(Alice - Bob)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

a = [a for a in input()]
b = [a for a in input()]

l = ["".join(sorted(a)), "".join(sorted(b, reverse=True))]

if l[0] == l[1]:
    print("No")
elif l == sorted(l):
    print("Yes")
else:
    print("No")

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

using namespace std;

#define mp make_pair
#define fi first
#define se second

const int maxn = (1 << 18) + 5;

int N, n;
int a[maxn];
pair<pair<int, int>, pair<int, int> > has[maxn];

int cntbit(int u) {
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if ((u & (1 << i)) != 0) cnt++;
  }
  return cnt;
}

int main() {
  cin >> N;

  n = (1 << N);

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    has[i].fi = mp(a[i], i);
    has[i].se = mp(0, -1);
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < N; j++) {
      if ((i & (1 << j)) != 0) {
        int now = (i ^ (1 << j));
        if (has[i].fi.se != has[now].fi.se) {
          if (has[i].fi.fi < has[now].fi.fi) {
            if (has[i].fi.fi < has[now].se.fi) {
              has[i].se = has[now].se;
            } else {
              has[i].se = has[i].fi;
            }
            has[i].fi = has[now].fi;
          } else {
            if (has[now].fi.se != has[i].se.se) {
              if (has[now].fi.fi > has[i].se.fi) {
                has[i].se = has[now].fi;
              }
            }
          }
        } else {
          if (has[i].se.se != has[now].se.se) {
            if (has[i].se.fi < has[now].se.fi) {
              has[i].se = has[now].se;
            }
          }
        }
      }
    }
//    cout << i << ' ' << has[i].fi.fi << ' ' << has[i].se.fi << endl;
  }

  for (int k = 1; k < n; k++) {
    int cur = (1 << N) - 1;
    int now = 0;
    int ans = 0;
    // case all 1
    ans = has[k].fi.fi + has[k].se.fi;
    for (int i = N - 1; i >= 0; i--) {
      cur >>= 1;
      if ((k & (1 << i)) != 0) {
        // off 1
        int val = now + cur;
//        if (k == 3) cout << val << endl;
        ans = max(ans, has[val].fi.fi + has[val].se.fi);
        now += (1 << i);
      }
//      if (k == 1) cout << "here " << ans << endl;
    }
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 8192
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		sc.close();
		
		int[] arr = {1,2,3};
		
		for(int i : arr)
		{
			if(i == a || i == b)
			{
				
			}
			else
			{
				System.out.println(i);
			}
		}
	}
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int ans = N / 2;
        if (N % 2 == 1) {
            ans += 1;
        }
        System.out.println(ans);
    }
}


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

using namespace std;

int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0) cnt++;
    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 3556
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;

	long A, B, T; cin >> A >> B >> T;

	res = (T / A) * B;

	cout << res << endl;
}

Measured memory_bytes: 256
import           Control.Monad

main :: IO ()
main = do
  [a, b, c] <- replicateM 3 readLn :: IO [Int]
  mapM_ (putStrLn . unwords . map show) $ solve a b c

solve :: Int -> Int -> Int -> [[Int]]
solve a b c = f
  where
    n = 3 * c
    f = [ [a, b, n - (a + b)]
        , [2 * n - (2*a + b + 2*c),  c, 2 * a + b + c - n]
        , [a + b + 2*c - n, n - (b + c) , n - (a + c)]]



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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    ll sta = 100;
    ll x;
    cin >> x;
    int res = 0;
    while(sta < x){
        sta += (sta/100);
        res++;
    }
    cout << res << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int a, b;

int solve() {
    if (a >= 13) return b;
    else if (a >= 6) return b/2;
    else return 0;
}

int main() {
    cin >> a >> b;
    cout << solve() << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int arr[] = new int[n];
    for(int i = 0 ; i<n ; i++ ) {
      arr[i] = s.nextInt();
    }
    int dp[] = new int[n];
    dp[0] = 0;
    dp[1] = Math.abs(arr[1]-arr[0]);
    for (int i =2 ; i< n ;i++) {
        dp[i] = Math.min(Math.abs(-arr[i-1]+arr[i])+dp[i-1],Math.abs(-arr[i-2]+arr[i])+dp[i-2]);
        //System.out.print(dp[i]+" ");
    }
      
 	System.out.println(dp[dp.length-1]);
  }
}

Measured memory_bytes: 50284
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

const long double PI = (acos(-1));

int main() {
  double a, b, x;
  cin >> a >> b >> x;

  double ans;

  if (x >= (a * a * b) / 2.0) {
    ans = atan((2.0 * (a * a * b - x)) / (a * a * a));
  } else {
    ans = PI / 2 - atan((2.0 * x) / (a * b * b));
  }

  cout << setprecision(15) << ans * 180.0 / PI << endl;
}


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

const int N = 3e2 + 5;

#define st first
#define nd second

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

int odl[N][N];

long long licz(int n) {
	long long wynik = 0;
	for (int i = 0; i < n; i ++) {
		for (int j = i + 1; j < n; j ++) {
			int wklad = odl[i][j];
			if (odl[i][j] != odl[j][i]) return -1;
			for (int k = 0; k < n; k ++) {
				if (k != i && k != j) {
					if (odl[i][k] + odl[k][j] < odl[i][j]) {
						return -1;
					}
					if (odl[i][k] + odl[k][j] == odl[i][j]) wklad = 0;
				}
			}
			wynik += wklad;
		}
	}
	return wynik;
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < n; j ++) {
			scanf("%d", &odl[i][j]);
		}
	}
	printf("%lld\n", licz(n));
}


Measured memory_bytes: 640
import numpy as np
h, w = map(int, input().split())

amap = []
# 横一列に"#"が含まれている場合はamapにappendする
for _ in range(h):
  a = input()
  if "#" in a:
    amap.append(a)

bmap = []
# 縦一列に"#"が含まれている場合はbmapにappendする
for wid in range(w):
  b = [amap[hei][wid] for hei in range(len(amap))]
  if "#" in b:
    bmap.append(b)

bmap = np.array(bmap)
tbmap = bmap.T

for i in tbmap:
  print(''.join(i))

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N, K;
const int MAX_N = 100005;

signed main()
{
  cin >> N >> K;
  int ans = 0;
  REP(n,N) {
    int h; cin >> h; if(h >= K) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
type t = { mutable x : int; mutable y : int }

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let readln () = read_line () |> split_on_char ' ' |> List.map int_of_string

let find_set s x =
  let rec doit x =
    if x <> s.(x).x then s.(x).x <- doit (s.(x).x);
    s.(x).x in
  doit x

let unite s x y =
  let (a, b) = (find_set s x, find_set s y) in
  if s.(a).y > s.(b).y then s.(b).x <- a
  else begin
    s.(a).x <- b;
    if s.(a).y = s.(b).y then s.(b).y <- s.(b).y + 1
  end

let solve n q =
  let s = Array.init n (fun i -> { x = i; y = 0 }) in
  for i = 0 to q - 1 do
    match readln () with
    | n :: x :: y :: _ ->
      if n = 0 then unite s x y
      else print_endline (if find_set s x = find_set s y then "1" else "0")
    | _ -> assert false
  done

let () =
  match readln () with
  | [n; q] -> solve n q
  | _ -> assert false

Measured memory_bytes: 4664
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll a,b,c;
    std::cin >> a>>b>>c;
    if(a == b && b==c && a%2 == 0){
        std::cout << -1 << std::endl;
        return 0;
    }
    ll result = 0;
    
    while(a%2==0 && b%2==0 && c%2==0){
        ll na,nb,nc;
        na = b/2+c/2;
        nb = c/2+a/2;
        nc = a/2+b/2;
        a = na;
        b = nb;
        c = nc;
        if(a == b && b==c && a%2 == 0){
            std::cout << -1 << std::endl;
            return 0;
        }
        result++;
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x) upper_bound(all(v),x)
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }
    return gcd(b%a,a);
}

const int N = 105;

ll dp[N][100005];

int main(){
    IOS
    
    int n,W;
    cin>>n>>W;
    ll w[n+1],v[n+1];
    FOR(i,1,n+1){
        cin>>w[i]>>v[i];
    }
    FOR(i,1,n+1){
        FOR(j,1,W+1){
            if(w[i]<=j){
                dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
    cerr<<1.0/CLOCKS_PER_SEC<<endl;
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(0);

    int n,l;
    cin >> n >> l;
    vector<string>a(n);
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a.begin(),a.end());
    for(auto s:a) cout << s;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int heap[250];

int main() {
  int i,n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &heap[i]);
  }

  for (i = 1; i <= n; i++) {
    printf("node %d: key = %d, ", i, heap[i]);
    if (i / 2 > 0)printf("parent key = %d, ", heap[i / 2]);
    if (2 * i <= n)printf("left key = %d, ", heap[2 * i]);
    if (2 * i + 1 <= n)printf("right key = %d, ", heap[2 * i + 1]);
    printf("\n");
  }
  return 0;
}

 



Measured memory_bytes: 2056
N, A, B, C = map(int, input().split())
L_list = [int(input()) for i in range(N)]

import itertools

Target = itertools.product([0, 1, 2, 3], repeat=N)

INF = 10 ** 9
#Target = [(1,2,2,2,3)]
ans = INF
for T in Target:
    A_sum = 0
    B_sum = 0
    C_sum = 0
    A_cost = 0
    B_cost = 0
    C_cost = 0
    for i in range(N):
        if T[i] == 0: continue
        if T[i] == 1:
            if A_sum == 0:
                A_sum += L_list[i]
            else:
                A_sum += L_list[i]
                A_cost += 10
        if T[i] == 2:
            if B_sum == 0:
                B_sum += L_list[i]
            else:
                B_sum += L_list[i]
                B_cost += 10
        if T[i] == 3:
            if C_sum == 0:
                C_sum += L_list[i]
            else:
                C_sum += L_list[i]
                C_cost += 10

    if min(A_sum, B_sum, C_sum) == 0: continue

    ans = min(ans, abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum)+C_cost)
print(ans)


Measured memory_bytes: 9200