akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	static int N, K, L;
	//所謂Union Find木を配列で表現
	//それぞれインデックスの根を格納する
	static UnionFind ufRoad;
	static UnionFind ufRail;

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');
		N = int.Parse(S[0]);
		K = int.Parse(S[1]);
		L = int.Parse(S[2]);

		//union find木
		//便宜上、インデックス0は使用しない
		ufRoad = new UnionFind(N);
		ufRail = new UnionFind(N);

		//読み込む
		for(int i=0; i<K; i++){
				string[] line = Console.ReadLine().Split(' ');
				int p = int.Parse(line[0])-1;
				int q = int.Parse(line[1])-1;

				ufRoad.MergeUF(p,q);

				/*
				if(p-1 < q-1){
						ufRoad[q-1] = p-1;
				}else{
						ufRoad[p-1] = q-1;
				}
				*/
		}
		for(int i=0; i<L; i++){
				string[] line = Console.ReadLine().Split(' ');
				int r = int.Parse(line[0])-1;
				int s = int.Parse(line[1])-1;

				ufRail.MergeUF(r,s);

				/*
				if(r<s){
						ufRail[s] = r;
				}else{
						ufRail[r] = s;
				}
				*/
		}

		/*
		//上から順に根を確定
		for(int i=0; i<N; i++){
				ufRoad.FindRoot(i);
				ufRail.FindRoot(i);
		}
		*/

		/*デバッグ
		for(int i=1; i<N+1; i++){
				Console.Write(i + "," + ufRoad[i] + " ");
		}
		Console.WriteLine(" ");
		for(int i=1; i<N+1; i++){
				Console.Write(i + "," + ufRail[i] + " ");
		}
		*/

		//特定の根のペアの個数を格納するディクショナリ
		Dictionary<string,int> pairDic = new Dictionary<string,int>();

		for(int i=0; i<N; i++){
				string key = ufRoad.FindRoot(i).ToString() + "," + ufRail.FindRoot(i).ToString();
				//既に当該keyが存在する場合
				if(pairDic.ContainsKey(key)){
						//valueを加算
						pairDic[key] ++;
				}
				//まだ存在しない場合
				else{
						pairDic.Add(key, 1);
				}
		}

		//ペアの個数を出力
		//1 ~ N-1まで
		for(int i=0; i<N; i++){
				string key = ufRoad.FindRoot(i).ToString() + "," + ufRail.FindRoot(i).ToString();
				Console.Write(pairDic[key] + " ");
		}

		/*デバッグ
		Console.WriteLine("");
		for(int i=1; i<N; i++){
				string key = ufRoad[i].ToString() + "," + ufRail[i].ToString();
				Console.Write(key + " ");
		}
		string keyN2 = ufRoad[N].ToString() + "," + ufRail[N].ToString();
		Console.WriteLine(keyN2);

		foreach(KeyValuePair<string, int> item in pairDic) {
			Console.WriteLine("[{0}:{1}]", item.Key, item.Value);
		}
		*/

	}
}



//自作クラス
//ジェネリック（タイプを指定可能）ではなく、取り敢えずintに限定して作成
class UnionFind
{
		public readonly int[] Array;

		public UnionFind(int capacity)
		{
				this.Array = new int[capacity];

				//自身を根として初期化
				for(int i=0; i<capacity; i++){
						this.Array[i] = i;
				}
		}

		//unionFindへの追加
		public void MergeUF(int a, int b){
			//根を決定
			int rootA = FindRoot(a);
			int rootB = FindRoot(b);
			int newRoot = Math.Min(rootA, rootB);

			//より小さい方に根を変化させる
			this.Array[rootA] = newRoot;
			this.Array[rootB] = newRoot;
		}

		public int FindRoot(int ind){
			int root = 0;

			if(this.Array[ind] == ind){
					root = ind;
			}else{
					root = FindRoot(this.Array[ind]);
			}

			return this.Array[ind] = root;
		}
}



Measured memory_bytes: 40208
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
 int R[MAX],n;

 cin >> n;
 for (int i=0; i<n; i++)cin >> R[i];
  
 int maxm = -2000000000;
 int minm = R[0];

 for ( int i=1; i<n; i++){
 maxm = max(maxm, R[i] - minm);
 minm = min(minm, R[i]);
}

 cout <<maxm <<endl;
 
 return 0;
}


Measured memory_bytes: 3884
import math
def isPalindrome(string):
    # print("str: {}".format(string))
    flg = True
    rev = string[::-1]
    return (rev == string)

S = input()

res1 = isPalindrome(S)
a = math.floor((len(S)-1)/2)
res2 = isPalindrome(S[:a])
a = math.floor((len(S)+3)/2)
res3 = isPalindrome(S[a-1:])
if (res1 and res2 and res3):
    print("Yes")
else: print("No")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int i,j,H,W;
    cin>>H>>W;
    char arr[H][W];
    for(i=0;i<H;i++){
        for(j=0;j<W;j++)
            cin>>arr[i][j];
    }
    
   for(i=0;i<H;i++){
        for(j=0;j<W;j++)
            cout<<arr[i][j];
        cout<<endl;
        for(j=0;j<W;j++)
            cout<<arr[i][j];
        cout<<endl;}

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

vector<int> CountDiv(int n) {
    vector<int> v(n+1, 0);
    for (int i = 2; i <= n; ++i) {
        int cur = i;
        for (int j = 2; j <= i+1; ++j) {
            while (cur % j == 0) {
                v[j]++; cur /= j;
            }
        }
    }
    
    return v;
}

ll cnt75(vector<int> divcnt) {
    ll cnt = 0;
    for (int i = 0; i < divcnt.size(); ++i) {
        if (divcnt[i] >= 74) cnt++;
    }

    for (int i = 0; i < divcnt.size(); ++i) 
    for (int j = 0; j < divcnt.size(); ++j) {
        if (i == j) continue;
        if (divcnt[i] >= 2 && divcnt[j] >= 24) cnt++;
        if (divcnt[i] >= 4 && divcnt[j] >= 14) cnt++;
    }

    for (int i = 0; i < divcnt.size(); ++i) 
    for (int j = 0; j < divcnt.size(); ++j)
    for (int k = j+1; k < divcnt.size(); ++k) {
        if (i == j || i == k) continue;
        if (divcnt[i] >= 2 && divcnt[j] >= 4 && divcnt[k] >= 4) cnt++;
    }

    return cnt;
}

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    auto cntDiv = CountDiv(N);
    cout << cnt75(cntDiv) << endl;
}

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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    ll n;
    cin >> n;
    vector<ll> p;

    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0 && i % 5 == 0)
        {
        }
        else if (i % 3 == 0)
        {
        }
        else if (i % 5 == 0)
        {
        }
        else
        {
            p.push_back(i);
        }
    }

    ll total = accumulate(ALL(p), 0.0);
    cout << total << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

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

signed main(){
	int q;cin>>q;
	for(int z=0;z<q;z++){
	double x[4],y[4];
	rep(i,4)cin>>x[i]>>y[i];
	double a1,b1,c1,a2,b2,c2;
	a1=y[1]-y[0],a2=y[3]-y[2];
	b1=x[0]-x[1],b2=x[2]-x[3];
	c1=x[1]*y[0]-x[0]*y[1],c2=x[3]*y[2]-x[2]*y[3];
	double ax=(b1*c2-b2*c1)/(a1*b2-a2*b1);
	double ay=(c1*a2-c2*a1)/(a1*b2-a2*b1);
	printf("%.10lf %.10lf\n",ax,ay);
	}
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s, hours, minutes, seconds;
    cin >> s;

    hours = s / 3600;
    minutes = (s % 3600) / 60;
    seconds = s % 60;

    cout << hours << ":" << minutes << ":" << seconds << endl;
    return 0;
    
}

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

using namespace std;

int main()
{
    int n,i,cnt=0;
    string s;
    set<string> vc;
    scanf("%d",&n);
    while(n--){
        cin>>s;
        vc.insert(s);
    }
    printf("%d\n",vc.size());
}


Measured memory_bytes: 19332
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 5e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int main(){
    FIN;
    string s;
    cin >> s;
    int cnt = 0;
    int mx = 0;
    for(int i = 0; i < sz(s); i++){
        if(s[i] == 'R')
            cnt++;
        else{
            mx = max(cnt, mx);
            cnt = 0;
        }
    }
    mx = max(mx , cnt);
    cout << mx << '\n';
    //EjecuteTime;
    return 0;
}       


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

public class Main {
	public static void main(String[] arg)throws IOException{
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		 //br.readline(); = 入力された１行分を日本語変換して返してくれる。
		 String str = br.readLine();

		 /*配列の型(intとかStringとか) [] 配列名 = 配列を用意
		  *今回はstrAryって配列にstrを入れてる。
		  *str.split = splitってのはString内に用意されてるメソッド
		  *文字列を分割するときに使用。今回は空白で区切ってって仕様なので
		  *split(" ")としてます。*/
		 String[] strAry = str.split(" ");

		 /*おなじみの文字列から数値への変換。
		  *ただし今回は指定先が配列の何番って風になってる。*/
		 int W = Integer.parseInt(strAry[0]);
		 int H = Integer.parseInt(strAry[1]);
		 int x = Integer.parseInt(strAry[2]);
		 int y = Integer.parseInt(strAry[3]);
		 int r = Integer.parseInt(strAry[4]);

		 /*複数条件の記述。if(条件 && 条件)は「かつ」だったが、
		  * if(条件 || 条件)で「または」の条件指定ができるらしい。
		  * 今回は半径(r)が円の中心座標(x,yそれぞれ)を上回ってしまうと枠を
		  * はみ出してしまうので条件で指定
		  * また、半径(r)と円の中心座標(x,yそれぞれ)の合計が外枠の座標(W,Hそれぞれ)を
		  * 上回ると枠をはみ出してしまうので条件指定
		  * それらを満たさない場合枠内に円が入りきる。
		  */
		 if(x-r<0 || y-r<0 || x+r>W || y+r>H){
	            System.out.println("No");
	        }
	        else{
	            System.out.println("Yes");
	        }
	}
}

Measured memory_bytes: 17048
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a1:
        a1[a1.index(b)] = 0
    elif b in a2:
        a2[a2.index(b)] = 0
    elif b in a3:
        a3[a3.index(b)] = 0

if a1.count(0) == 3 or a2.count(0) == 3 or a3.count(0) == 3:
    print('Yes')
elif a1[0] == 0 and a2[0] == 0 and a3[0] == 0:
    print('Yes')
elif a1[1] == 0 and a2[1] == 0 and a3[1] == 0:
    print('Yes')
elif a1[2] == 0 and a2[2] == 0 and a3[2] == 0:
    print('Yes')
elif a1[0] == 0 and a2[1] == 0 and a3[2] == 0:
    print('Yes')
elif a1[2] == 0 and a2[1] == 0 and a3[0] == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <queue>
using namespace std;
queue<int> qu;
int v[101][101];
int dis[101], n;
int d = 0;
int tf;
inline void b1(int t) {
	for (int i = 1; i <= n; i++) {
		if (v[t][i]) {
			tf = 1;
			qu.push(i);
			dis[i] = d + 1;
			for (int j = 1; j <= n; j++)
				v[j][i] = 0;
		}
	}
}
inline void b2() {
	tf = 0;
	for (int i = 1; i <= n; i++)
		if (dis[i] == d) {
			b1(i);
			qu.pop();
		}
	d++;
}
inline void bfs() {
	tf = 1;
	b1(1);
	d++;
	qu.pop();
	while (tf) {
		b2();
	}
}
int main() {
	int u, k, s;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		dis[i] = -1;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			v[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> s;
			v[u][s] = 1;
		}
	}
	qu.push(1);
	for (int i = 1; i <= n; i++)
		v[i][1] = 0;
	bfs();
	for (int i = 1; i <= n; i++) {
		cout << i << " " << dis[i] << endl;
	}
	return 0;
}

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

#define For(i, l, r) for (register int i = (l), i##end = int(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = int(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

typedef long long ll;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

const ll baseans = 123;

inline string tostr(ll x) {
	string res;
	for (; x; x /= 10) res += (x % 10) + '0';
	reverse(res.begin(), res.end());
	return res;
}

inline bool ask(ll x) {
	cout << "? " << x << endl;
////bool res = (x <= baseans) == (tostr(x) <= tostr(baseans));
////cout << (res ? "Y" : "N") << endl;
////return res;
	char ans[1]; scanf ("%s", ans);
	return ans[0] == 'Y';
}

int main () {

	ll ans = 0; int dig = 0;

	for (ll tmp = 1; dig <= 10 && ask(tmp); tmp *= 10) ++ dig;

	if (dig > 10) {
		dig = 0; for (ll tmp = 2; !ask(tmp); tmp = tmp * 10 + 2) ++ dig; 
		if (!dig) { cout << "! 1" << endl; return 0; }
		++ dig;
	}

	For (i, 1, dig) {
		int l = 0, r = 9, res = -1;
		while (l <= r) {
			int mid = (l + r) >> 1;
			if (ask(ans * 10ll + mid)) res = mid, l = mid + 1; else r = mid - 1;
		}
		ans = ans * 10ll + res; 
	}

	int l = 0, r = 9, res = -1; ans /= 10;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (ask((ans * 10ll + mid) * 10ll)) res = mid, r = mid - 1; else l = mid + 1;
	}
	ans = ans * 10 + res;

	cout << "! " << ans << endl;

	return 0;

}

Measured memory_bytes: 716
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <map>
#include <numeric>

using namespace std;

int n;
int a, b, c;
int *l;
int ans = INT_MAX;

void dfs(int u, int a0, int b0, int c0, int score){
  if(u == n){
    if(a0 == 0 || b0 == 0 || c0 == 0) return;

    score -= 30;//the score added for initializing all a0,b0,c0
    score += abs(a0 - a);
    score += abs(b0 - b);
    score += abs(c0 - c);

    ans = min(ans, score);
    return;
  }

  dfs(u + 1, a0 + l[u], b0, c0, score + 10);
  dfs(u + 1, a0, b0 + l[u], c0, score + 10);
  dfs(u + 1, a0, b0, c0 + l[u], score + 10);
  dfs(u + 1, a0, b0, c0, score);
}

int main() {

  cin >> n;
  cin >> a >> b >> c;

  l = new int [n];

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

  dfs(0, 0, 0, 0, 0);

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include <limits.h>
#define exchange(a, b){tmp=a;a=b;b=tmp;}
   
int A[2000000], n,tmp;
int parent(int i){
    return i / 2;
}
   
int left(int i){
    return 2 * i;
}
   
int right(int i){
    return 2 * i + 1;
}
   
void maxHeapify(int i){
    int largest, tmp;
    int l = left(i);
    int r = right(i);
    if (l <= n && A[l] > A[i])
        largest = l;
    else{
        largest = i;
    }
    if (r <= n && A[r] > A[largest])
        largest = r;
    if (largest != i){
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(largest);
   
    }
}
   
void heapIncreaseKey(int i,int key){
    if (key < A[i]){
        //error 新しいキーは現在のキーより小さい
        //return;
    }
    A[i] = key;
    while (i > 1 && A[parent(i)] < A[i]){
        exchange(A[i], A[parent(i)]);
        i = parent(i);
    }
}
   
void maxHeapInsert(int key){
    n++;
    A[n] = INT_MIN;
    heapIncreaseKey(n, key);
}
   
   
int heapExtractMax(){
    if (n < 1)
        return;// error ヒープアンダーフロー
    int max = A[1];
    A[1] = A[n];
    n = n - 1;
    maxHeapify(1);
    return max;
}
   
int main(){
       
    int i,max=INT_MIN;
    char s[10];
    while (1){
        scanf("%s", &s);
           
        if (s[2] == 's'){
            scanf("%d",&i);
            maxHeapInsert(i);
        }
        else if (s[2] == 't'){
            printf("%d\n", heapExtractMax());
        }
        else{
            break;
        }
    }
   
    return 0;
}

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

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

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 5)


def main():
    import heapq
    from collections import defaultdict
    INF = float('INF')

    n, m, s, t = map(int, readline().split())

    edge = defaultdict(list)

    for _ in range(m):
        u, v, a, b = map(int, readline().split())
        edge[u].append((v, a, b))
        edge[v].append((u, a, b))

    dist_s = defaultdict(lambda: float("INF"))
    dist_t = defaultdict(lambda: float("INF"))

    dist_s[s] = 0
    dist_t[t] = 0

    hq = []
    heapq.heappush(hq, (0, s))

    while hq:
        cost, cur = heapq.heappop(hq)
        for nx, a, _ in edge[cur]:
            nc = cost + a
            if nc < dist_s[nx]:
                dist_s[nx] = nc
                heapq.heappush(hq, (nc, nx))

    heapq.heappush(hq, (0, t))

    while hq:
        cost, cur = heapq.heappop(hq)
        for nx, _, b in edge[cur]:
            nc = cost + b
            if nc < dist_t[nx]:
                dist_t[nx] = nc
                heapq.heappush(hq, (nc, nx))

    res = [0] * (n + 1)
    for i in range(n - 1, -1, -1):
        res[i] = max(res[i + 1], 10 ** 15 - (dist_s[i + 1] + dist_t[i + 1]))

    for i in range(n):
        print(res[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 140984
import java.util.*;

import javax.lang.model.util.ElementScanner6;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int[] arr = { a, b, c };
    Arrays.sort(arr);
    if (arr[0] + arr[1] == arr[2]) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

}


Measured memory_bytes: 22484
#include <functional>  
#include <algorithm>  
#include <iostream>  
#include <fstream>  
#include <sstream>  
#include <iomanip>  
#include <numeric>  
#include <cstring>  
#include <cassert>  
#include <cstdio>  
#include <string>  
#include <vector>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <cmath>  
#include <ctime>  
#include <list>  
#include <set>  
#include <map>  

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 1000000007  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

int main()
{
    string a;
    cin >> a;
    if (a == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<lint> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int n, k;
    cin >> n >> k;
    vi x(n);
    vi y(n);
    rep(i, n)
    {
        cin >> x[i] >> y[i];
    }
    auto xtemp = x;
    auto ytemp = y;
    sort(all(xtemp));
    sort(all(ytemp));
    vvi sum(n + 1, vi(n + 1, 0));
    rep(i, n)
    {
        rep(j, n)
        {
            int flag = false;
            rep(k, n)
            {
                if (xtemp[i] == x[k] && ytemp[j] == y[k])
                {
                    flag = true;
                    break;
                }
            }
            sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + int(flag);
        }
    }
    lint ans = LLONG_MAX;
    rep(x1, n - 1)
    {
        repi(x2, x1 + 1, n)
        {
            rep(y1, n - 1)
            {
                repi(y2, y1 + 1, n)
                {
                    int count = sum[x2 + 1][y2 + 1] - sum[x2 + 1][y1] - sum[x1][y2 + 1] + sum[x1][y1];
                    if (count >= k)
                    {
                        lint area = (xtemp[x2] - xtemp[x1]) * (ytemp[y2] - ytemp[y1]);
                        ans = min(ans, area);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int N;
	bool ans = true;
	//vector <int> H(100000);
	int h, now=0;
	cin >> N;
	for(int i= 0; i<N; i++)
	{
		cin >> h;
		if (now > h){
			ans = false;
			break;
		}
		else if(now == h)now = h;
		else now = h-1;
		
	}
	if(!ans) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int main()
{
    int n, m, s, g1, g2;
    while(1){
        cin >> n >> m >> s >> g1 >> g2;
        if(n == 0) break;
        int road[102][102];
        for(int i = 1; i < n + 1; i++){
            for(int j = 1; j < n + 1; j++){
                if(i == j) road[i][j] = 0;
                else road[i][j] = 100000000;
            }
        }
        for(int i = 0; i < m; i++){
            int a, b, c;
            cin >> a >> b >> c;
            road[a][b] = c;
        }
        for(int k = 1; k < n + 1; k++){
            for(int i = 1; i < n + 1; i++){
                for(int j = 1; j < n + 1; j++){
                    road[i][j] = min(road[i][j], road[i][k] + road[k][j]);
                }
            }
        }
        int ans = 100000000;
        for(int i = 1; i < n + 1; i++){
            ans = min(ans, road[s][i] + road[i][g1] + road[i][g2]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N, M;
	cin >> N >> M;
	
	int cnt[200000] = {};
	
	for(int i = 0; i < M; i++){
		int num1, num2;
		cin >> num1 >> num2;
		cnt[num1]++;
		cnt[num2]++;
	}
	
	bool ans = true;
	
	for(int i = 1; i <= N; i++){
		ans = (ans && cnt[i] % 2 == 0);
	}
	
	if(ans){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1148
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize
    };
    let mut rs = 1usize;
    for i in 1..=n {
        rs = (rs * i) % 1_000_000_007;
    }
    println!("{}", rs);
}


Measured memory_bytes: 2120
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    h = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(n):
        if h[i] >= k:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 51440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  int A;
  int B;
  int C;
  int ans=0;
  int oikoshi=0;
  int D;
  cin >> N >> A >> B >> C >> D;
  string S;
  cin >>S;
  for(int i=B-1; i<(D-1) && i<(N-1);i++){
   if(S.at(i)=='#'){
     if(S.at(i+1)=='#'){
       ans=1;
     }
   }
      if(S.at(i-1)=='.'){
        if(S.at(i)=='.'){
          if(S.at(i+1)=='.'){
            oikoshi=1;
          }
             }
             }
             }
   if(oikoshi==0){
     S.at(D-1)='#';
   }
   for(int i=A-1; i<(C-1) && i<(N-1);i++){
   if(S.at(i)=='#'){
     if(S.at(i+1)=='#'){
       ans=1;
     }
   }
   }
          if(ans==0){
            cout << "Yes" << endl;
          }
     else{
       cout << "No" << endl;
     }
}

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

b = [0]*(N+1)
l = [i for i in range(N+2)] # 最初と最後に番兵の役割
r = [i for i in range(N+2)]

ans = 0
for i in range(N):
  b[A[i]] = i#各数字がAのどこに入っているかをリストbにメモ
  
for i in range(N, 0, -1)  :
  m = b[i]#大きな数字がどこに入っているかを探す
  x, y = l[m], r[m] #その時の左右に動ける大きさをとってくる
  ans += i * (m- x+1) * (y - m+1) #その数が何回使えるかを計算し、答えに追加
  l[y + 1], r[x - 1] = x, y #動ける範囲を次の場所に代入
print(ans)  
  

Measured memory_bytes: 35776
h, w = gets.chomp.split(" ").map(&:to_i)

if h % 3 == 0 || w % 3 == 0
    puts 0
    exit
end

# 横に3等分
ans = w

# 縦に3等分
ans = h if h < ans

# 横に1/3してから残りを縦に2等分
h = h.to_f
w = w.to_f


s = [(h/3).ceil * w, (h-(h/3).ceil)*((w/2).ceil), (h-(h/3).ceil)*((w/2).floor)]
ans = s.max - s.min if s.max - s.min < ans

s = [(h/3).floor * w, (h-(h/3).floor)*(w/2).ceil, (h-(h/3).floor)*(w/2).floor]
ans = s.max - s.min if s.max - s.min < ans

# 縦に1/3してから残りを横に2等分
s = [(w/3).ceil * h, (w-(w/3).ceil)*(h/2).ceil, (w-(w/3).ceil)*(h/2).floor]
ans = s.max - s.min if s.max - s.min < ans

s = [(w/3).floor * h, (w-(w/3).floor)*(h/2).ceil, (w-(w/3).floor)*(h/2).floor]
ans = s.max - s.min if s.max - s.min < ans

puts ans.to_i


Measured memory_bytes: 1788
import java.io.*;
import java.util.function.*;
import java.util.stream.*;

class Main
{
    /**
     * ABC 062 B: Picture Frame
     *     (周囲1ピクセルを'#'で囲む)
     */ 
    public static void main(String[] args) throws IOException
    {
        // 入力
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));
        int[] HW = Stream.of(br.readLine().split(" ")).mapToInt(
                item -> new Integer(item)).toArray();
        Stream<String> lines = br.lines();
        
        // データ部分を抽出
        Stream<String> a = lines.filter(item -> item.indexOf(" ") < 0);

        // 枠線を決める
        // Streamは同じインスタンスで2度処理を実行できないため、Supplierを通す
        Supplier<Stream<String>> frame = () ->
                Stream.of(new String(new char[HW[1]]).replace("\0", "#"));
        Stream<String> out = Stream.concat(frame.get(), Stream.concat(a, frame.get())).map(
                item -> "#" + item + "#") ;        

        // 出力(末尾は改行を入れない)
        System.out.println(out.collect(Collectors.joining("\n")).replaceFirst("\n$", ""));
    }
}


Measured memory_bytes: 28116
n = int(input())
L = [0 for i in range(10**4+1)]
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            r = x**2 + y**2 + z**2 + x*z + x*y + z*y
            if r <= 10000:
                L[r] += 1
for i in range(1, n+1):
    print(L[i])


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

int main() {
  ll n, m, ans;
  cin >> n >> m;
  if (n == 1 && m == 1)
    ans = 1;
  else if (n == 1)
    ans = m - 2;
  else if (m == 1)
    ans = n - 2;
  else
    ans = (n - 2) * (m - 2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[19];
  
  for(int i=0;i<19;i++) cin >> s[i];
  s[5]=' ';
  s[13]=' ';
  for(int i=0;i<19;i++) cout << s[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ld long double
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
void wf(vector<vector<ll>> &k){
  int n=k.size();//存在しない辺をinfで渡す
  rep(o,n)rep(i,n)rep(j,n)k[i][j]=min(k[i][j],k[i][o]+k[o][j]);
  //rep(i,n)rep(j,n)rep(o,n)k[i][j]=min(k[i][j],k[i][o]+k[o][j]);
}
int main(){
  int n,m,r;
  cin >> n >> m >> r;
  vector<int> u(r,0);
  rep(i,r){
    int y;
    cin >> y;
    y--;
    u[i]=y;
  }
  vector<vector<ll>> k(n,vector<ll>(n,100000000000000000));
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    ll c;
    cin >> c;
    k[a][b]=c;
    k[b][a]=c;
  }
  wf(k);
  //rep(i,n)rep(j,n)cout << k[i][j] << endl;
  int a[r];
  rep(i,r)a[i]=i;
  ll ans=2000000000000000000;
  do {
   //cout << a[0] << a[1] << a[2] << ans << endl;
    ll p=0;
    rep(i,r-1){
      //cout << k.at(u[a[i]]).at(u[a[i+1]]) << u[a[i]] << u[a[i+1]] << endl;
      p+=k.at(u[a[i]]).at(u[a[i+1]]);
    }
    if(p<0){
      while(true){
        p++;
      }
    }
    ans=min(ans,p);
  } while(next_permutation(a, a + r));
  cout << ans << endl;
}


Measured memory_bytes: 512
n = int(raw_input())
A = map(int, raw_input().split())
d = {}
 
def soleve(i, m, n):
    if m == 0:
        return True
    if i >= n:
        return False
    if d.has_key((i, m)):
        return d[(i, m)]
    res = soleve(i + 1, m, n) or soleve(i + 1, m - A[i], n)
    d[(i, m)] = res
    return res
 
 
q = int(raw_input())
M = map(int, raw_input().split())
for m in M:
    if soleve(0, m, n):
        print 'yes'
    else:
        print 'no'
 

Measured memory_bytes: 11964
#include<stdio.h>

int main(){
    int N;
    int h[110];
    int i, j, k;
    int nmin=110, nmax=-1;
    int count = 0;
    int tmp = 0;

    scanf("%d", &N);
    for(i=0; i<N;i++){
        scanf("%d", &h[i]);
        if(h[i]<nmin){
            nmin = h[i];
        }
        if(nmax<h[i]){
            nmax = h[i];
        }
    }
    for(i=0; i<nmax; i++){
        tmp = 0;
        for(j=0; j<N; j++){
            if(h[j]>0){
                tmp = 1;
            }
            if(h[j]<=0 && tmp>0){
                tmp = 0;
                count +=1;
            }
            h[j] = h[j] -1;
            //printf("%d ", h[j]);
        }
        if(tmp>0){
            tmp=0;
            count +=1;
        }
        //printf("%d\n", count);
    }

    printf("%d", count);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 0x7fffffff;
const int tINF = INF>>2;
const ll LINF = 0x7fffffffffffffff;
const ll tLINF = LINF>>2;
const int maxn = 1e5;
const int modn = 1e9+7;

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

	int n,m,l,r;
	cin>>n>>m;
	l = 1;
	r = n;
	int L,R;
	while (m-- && r>=l){
        cin>>L>>R;
        l = max(L,l);
        r = min(R,r);
	}
	if (r>=l) cout<<r-l+1<<endl;
	else cout<<0<<endl;

	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x = read().rstrip().decode()

def solve(x):
    if x.count('RRR'):
        return 3
    if x.count('RR'):
        return 2
    if x.count('R'):
        return 1
    return 0

print(solve(x))

Measured memory_bytes: 9040
while True:
    count = 0
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    for a in range(1,n-1):
        for b in range(a+1,n):
            for c in range(b+1,n+1):
                if a+b+c == x:
                    count += 1
    print(count)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;

//↓combination(ll a, ll b) でaCr計算。
//------------------------------------------------------------------------------------------
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}
//---------------------------------------------------------------------------------------------
//↑combination(ll a, ll b) でaCr計算。

int main(){
    string S;
    cin >> S;
    if(S.at(2)==S.at(3) and S.at(4)==S.at(5)){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

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

    return true;
}

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

    int q;
    cin >> q;

    vector<int> p_cnt(100001, 0);
    rep1(i, 100002){
        p_cnt[i] = p_cnt[i-1];
        if(i%2==1 && is_prime(i) && is_prime((i+1)/2)) ++p_cnt[i];
    }

    rep(_, q){
        int l, r;
        cin >> l >> r;

        cout << p_cnt[r] - p_cnt[l-1] << "\n";
    }


    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ll N, tmp, ans = 0;
    cin >> N;
    vector<ll> A, B;
    for (int i = 0; i < N+1; i++) {
        cin >> tmp;
        A.push_back(tmp);
    }
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        B.push_back(tmp);
    }
    B.push_back(0);

    // モンスターの方が多かった場合，モンスターを減らして，勇者0が次に殺せるモンスターの数を0にする
    if (A[0] > B[0]) {
        ans += B[0];
        A[0] -= B[0];
        B[0] = 0;
    }
    // 勇者が殺せるモンスターの方が多かった場合，モンスターを0にし，勇者0が次に殺せるモンスターの数を減らす
    else {
        ans += A[0];
        B[0] -= A[0];
        A[0] = 0;
    }

    for (int i = 1; i < N+1; i++) {
        // 前の勇者
        // モンスターの方が多かった場合，モンスターを減らして，勇者が次に殺せるモンスターの数を0にする
        if (A[i] > B[i-1]) {
            ans += B[i-1];
            A[i] -= B[i-1];
            B[i-1] = 0;
        }
        // 勇者が殺せるモンスターの方が多かった場合，モンスターを0にし，勇者が次に殺せるモンスターの数を減らす
        else {
            ans += A[i];
            B[i-1] -= A[i-1];
            A[i] = 0;
        }

        // この街の勇者
        // モンスターの方が多かった場合，モンスターを減らして，勇者が次に殺せるモンスターの数を0にする
        if (A[i] > B[i]) {
            ans += B[i];
            A[i] -= B[i];
            B[i] = 0;
        }
            // 勇者が殺せるモンスターの方が多かった場合，モンスターを0にし，勇者が次に殺せるモンスターの数を減らす
        else {
            ans += A[i];
            B[i] -= A[i];
            A[i] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2548
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,c=0; cin>>n; 
    vi a(n);
    for (int &i: a) cin>>i;
    sort(a.begin(),a.end());
    for (int i=1;i<n;i++){
        if (a[i]>a[i-1]*2) c=i;
        a[i] += a[i-1];
    }
    cout <<n-c << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main(){
  string s,t; cin>>s>>t;
 
  vector<char> v1(s.size()),v2(t.size());
  rep(i,s.size()){v1[i]=s.at(i);}
  sort(v1.begin(),v1.end());
  string s_="";
  rep(i,s.size()){s_+=v1[i];}

  rep(i,t.size()){v2[i]=t.at(i);}
  sort(v2.begin(),v2.end(),greater<char>());
  string t_="";
  rep(i,t.size()){t_+=v2[i];}
  vector<string> vec(2);
  vec[0]=s_;vec[1]=t_;
  sort(vec.begin(),vec.end());
  if(vec[0]==vec[1]){cout<<"No";}
  else if(vec[0]==s_){cout<<"Yes";}
  else{cout<<"No";}
}



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

constexpr ll INF = ll(1e+18) + 1;

ll dist(ll a, ll b, ll c, ll d) {
    return abs(a-c) + abs(b-d);
}

int main() {
    int c[3][3];
    int buf;

    rep(i, 3) {
        rep(j, 3) {
            cin >> buf;
            c[i][j] = buf;
        }
    }

    rep (i, 3) {
        rep (j, 3) {
            if (c[i%3][j%3]+c[(i+1)%3][(j+1)%3] != c[(i+1)%3][j%3]+c[i%3][(j+1)%3]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CAlchemist solver = new CAlchemist();
        solver.solve(1, in, out);
        out.close();
    }

    static class CAlchemist {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            double[] v = new double[n];
            for (int i = 0; i < n; i++) v[i] = in.nextDouble();
            Arrays.sort(v);
            double sum = (v[0] + v[1]) / 2;
            for (int i = 2; i < n; i++) {
                sum = (sum + v[i]) / 2;
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 22612
#include<stdio.h>
#define N 101
#define W 2001
 
int main(){
  int A[N][N],B[N],key[N],p[N];
  int i,j,n,count=0,o,u=0;
 
  scanf("%d",&n);
 
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      scanf("%d",&A[i][j]);
    }
  }
  
  for(i=0 ; i<n ; i++){
    B[i] = 0;
    p[i] = -1;    
    if(i==0)key[i] = 0;
    else key[i] = W;
  }  
  
  while(o != W){
    o = W;
    for(i=0 ; i<n ; i++){
      if(B[i]!=2 && key[i]<o){	
	o = key[i];
	u = i;
      }
    }
    
    B[u]=2;
    for(i=0 ; i<n ; i++){
      if(A[u][i] != -1 && B[i] != 2 && A[u][i]<key[i]){
	p[i] = u;
	key[i] = A[u][i];
	B[i] = 1;
      }
    }
  }
  
  for(i=0 ; i<n ; i++)
    if(p[i] != -1) count += A[i][p[i]];    
   
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 640
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = []
X = []
for i in range(M):
    p, x = map(int, input().split())
    P.append(p)
    X.append(x)
sumT = sum(T)
for i in range(M):
    result = sumT - (T[P[i]-1] - X[i])
    print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2000005;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,K,a[N];
char ch[N];
struct node{int c,r;};
vector<node> cur,nex;
void push(int c,int r){
	if ((nex.size()!=0)&&(nex.back().c==c)){nex.back().r=r;return;}
	nex.push_back((node){c,r});
}
int main(){
	n=read();m=read();K=read();
	scanf(" %s",ch+1);
	for (int i=0;i<n;i++) a[i]|=ch[n-i]-'0';
	scanf(" %s",ch+1);
	for (int i=0;i<m;i++) a[i]|=(ch[m-i]-'0')*2;	
	push(0,K);
	for (int i=0;i<=max(n,m)+K;i++){
		swap(cur,nex);nex.clear();
		int j=0;
		for (auto t : cur){
			if (t.c==0){
				if (a[i]==3){push(3,j+1);a[i]=0;if (t.r!=j+1) push(0,t.r);}
				else push(0,t.r);
			}
			else if (t.c==3){
				if (a[i]==3) push(3,t.r);
				else if (a[i]){
					while (j<t.r){
						j++;
						if (a[i]==3) {push(3,j);a[i]=0;}
						else push(a[i]&t.c,j);
						a[i]^=t.c;
					}
				}
				else{push(0,j+1);if (t.r!=j+1) push(3,t.r);a[i]=3;}
			}
			else{
				while (j<t.r){
					j++;
					if (a[i]==3) {push(3,j);a[i]=0;}
					else push(a[i]&t.c,j);
					a[i]^=t.c;
				}
			}
			j=t.r;
		}
	}
	int fl=0;
	for (int i=n+K;i>=0;i--){
		if (a[i]&1) fl=1;
		if (fl) putchar('0'+(a[i]&1));
	}
	putchar('\n');
	fl=0;
	for (int i=m+K;i>=0;i--){
		if (a[i]>>1) fl=1;
		if (fl) putchar('0'+(a[i]>>1));
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 12928
#include<stdio.h>

int main()
{
    int a, b;
    char ch;
    scanf("%d %c %d", &a, &ch, &b);
    if(ch == '+') {
        printf("%d\n", a + b);
    }
    else {
        printf("%d\n", a - b);
    }
    return 0;
}


Measured memory_bytes: 128
#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(non_snake_case)]
fn main() {
    input![S: String, K: usize];
    let mut cnt = 0;
    let mut search = 'A';
    for c in S.chars() {
        if search == c {
            cnt += 1;
            search = 'A';
        } else {
            search = c;
        }
    }

    let mut cnt_first = 0;
    let search = S.chars().nth(0).unwrap();
    for c in S.chars() {
        if search == c {
            cnt_first += 1;
        } else {
            break;
        }
    }

    if cnt_first == S.len() {
        println!("{}", K * S.len() / 2);
        std::process::exit(0);
    }

    let mut cnt_last = 0;
    for c in S.chars().rev() {
        if search == c {
            cnt_last += 1;
        } else {
            break;
        }
    }

    let a = if cnt_first % 2 == 1 && cnt_last % 2 == 1 {
        1
    } else {
        0
    };
    let ans = cnt * K + (K - 1) * a;
    println!("{}", ans);
}


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

int main() {
   int n,k,d;
  cin>>n>>k;
  vector<int>v(n,0),a(n);
  for(int i=1;i<=k;i++){
    cin>>d;
    rep(j,d){
      cin>>a[j];
      v[a[j]-1]++;
    }
  }
  
  int ans=0;
  rep(i,n){
    if(v[i]==0)ans++;
  }
  cout<<ans<<endl;
}

  


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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  long long n;
  while(cin >> n, n) {
    int cnt = 0;
    while(n != 1) {
      if(n%2 == 0) n /= 2;
      else n = 3*n + 1;
      cnt++;
    }
    cout << cnt << endl;
  }
}

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

using namespace std;

int r,g,b,n;
int dp[3001];

void solve(){
    int i,j;
    string str;
    cin >> r >> g >> b >> n;
    for(i = 0;i <= n;i+=r) dp[i] = 1;
    for(i = n-1;i >= 0;i--){
        for(j = i+g;j <= n;j+=g){
            dp[j] += dp[i];
        }
    }
    for(i = n-1;i >= 0;i--){
        for(j = i+b;j <= n;j+=b){
            dp[j] += dp[i];
        }
    }
    long long ans = dp[n];
    cout << ans << endl;
}

int main(){
    solve();
}


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

# See:
# http://drken1215.hatenablog.com/entry/2018/06/08/210000
max_value = 500050
mod = 10 ** 9 + 7

fac = [0 for _ in range(max_value)]
finv = [0 for _ in range(max_value)]
inv = [0 for _ in range(max_value)]


def com_init():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1

    for i in range(2, max_value):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod


def com(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    n, k = map(int, input().split())
    # abst: 数列の並び順が問題にならない場合は、ソートするのも選択肢に入れる
    a = sorted(list(map(int, input().split())))
    com_init()
    ans = 0

    # KeyInsight
    # Σf(x) = Σmax(x) - Σmin(x)と置き換えられる
    # abst: 等価な性質を利用して、シンプルな問題に
    # See:
    # https://www.youtube.com/watch?v=1oLDDdWRu6Y&feature=youtu.be
    # 最大値が選ばれるパターン
    for index, ai in enumerate(a):
        # abst: ◯◯◯◯◯◯◯ (昇順に並び替えた数字のイメージ)
        #            ↑
        # 矢印の位置が最大値となる場合、左から5つのうちk - 1個を自由に選べる
        # この例だと、5Ck-1個
        # abst: 視点をある位置に固定する
        # abst: 条件を満たす場合は二項係数を使うことで組み合わせを高速に数えられる
        # nCrを高速に計算する&ライブラリ化
        now = com(index, k - 1)
        ans += now * ai

    # 最小値が選ばれるパターン
    # abst: 数列の並びを逆順に
    for index, ai in enumerate(a[::-1]):
        now = com(index, k - 1)
        ans -= now * ai

    print(ans % (10 ** 9 + 7))


if __name__ == '__main__':
    main()


Measured memory_bytes: 94552