akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<functional>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int a,b,c,d;

	cin >> a >> b >> c >> d;

	if ((abs(a-c))<=d) {
		cout << "Yes" << endl;
	}
	else {
		if (((a <= b) && (b <= c)) || ((a >= b) && (b >= c))) {
			if(((abs(a-b)<=d)&&(abs(b-c)<=d))){
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
	

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
const int MOD = 1000000007;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;


int main() {

	int n;
	cin >> n;

	string s;cin >> s;
	string t = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	
	rep(s.size()) {
		for (int j = 0; j < 26; j++) {
			if (s[i] == t[j])cout << t[(j + n) % 26];
		}
	}
	return 0;
}

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

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    int num[110] = {0};  // バケット
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;  // d[i] が 1 個増える
    }

    int res = 0;  // 答えを格納
    for (int i = 1; i <= 100; ++i) {  // 1 <= d[i] <= 100 なので 1 から 100 まで探索
        if (num[i]) {  // 0 より大きかったら
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3148
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int mx = *max_element(a, a + N);
  int mx_ind = max_element(a, a + N) - a;
  int mn = *min_element(a, a + N);
  int mn_ind = min_element(a, a + N) - a;

  cout << 2 * N - 1 << endl;

  if(abs(mx) >= abs(mn)){
    for(int i = 0; i < N; i++){
      a[i] += mx;
      cout << mx_ind + 1 << " " << i + 1 << endl;
    }
  } else {
    for(int i = 0; i < N; i++){
      a[i] += mn;
      cout << mn_ind + 1 << " " << i + 1 << endl;
    }
  }

  if(a[0] > 0){
    for(int i = 0; i < N - 1; i++){
      cout << i + 1 << " " << i + 2 << endl;
    }
  } else {
    for(int i = N; i > 1; i--){
      cout << i << " " << i - 1 << endl;
    }
  }

  return 0;
}

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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

const int INF = 1 << 29;

int s[100004];
signed main() {
	int n;
	while (cin >> n && n) {
		memset(s, 0, sizeof(s));
		rep(i, n) {
			int a, b; cin >> a >> b;
			s[a]++;
			s[b + 1]--;
		}
		rep(i, n + 2) s[i + 1] += s[i];
		int ans = 0;
		rep(i, n + 2) if(s[i] >= i - 1) {
			ans = i - 1;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3468
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
typedef unsigned int u_i;

int main(){

  	string n;
  	cin >> n;
  	u_i sum=0;
  	for(u_i i=0; i<(u_i)n.size(); ++i){
    	sum += n[i]-'0';
    }
  	if(sum%9==0){
    	cout << "Yes" << endl;  
    }else{
      	cout << "No" << endl;
    }
  
	return 0;
}

Measured memory_bytes: 3700
#include<iostream>
using namespace std;
int main(){
    char a,b;
    cin >> a >> b;
    if(a=='H'){
        if(b=='H'){cout << 'H';}
        if(b=='D'){cout << 'D';}
    }
    else if(a=='D'){
        if(b=='H'){cout << 'D';}
        if(b=='D'){cout << 'H';}
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll k;
  cin >> k;
  string ans;
  ll keta = 1;
  auto dfs = [&](auto& Self, int idx) -> void{
    if(idx == keta){
      k--;
      if(!k){
        print(ans);
        exit(0);
      }
      return;
    }
    for(int i = 0; i <= 9; i++){
      if(abs(ans[idx-1] - (i+'0')) <= 1){
        ans[idx] = i+'0';
        Self(Self, idx+1);
      }
    }
  };
  while(1){
    ans = string(keta, '0');
    repr(j, 1, 10){
      ans[0] = j+'0';
      dfs(dfs, 1);
    }
    keta++;
  }
}


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



public struct Job
{
	public string name;
	public int time;
	
	public Job( string[] s )
	{
		name = s[0];
		time = int.Parse( s[1] );
	}
}
public class Test
{
	public static void Main( )
	{
		var queue = new Queue<Job>();
		var line = Console.ReadLine().Trim().Split().Select( x => int.Parse(x) ).ToArray();
		
		int n = line[0];
		int q = line[1];
		Job j;
		for( var i=0; i<n; i++ ) {
			string[] s = Console.ReadLine().Trim().Split();
			queue.Enqueue(  new Job( s ) );
		}
		
		int t = 0;
		while( queue.Count > 0 ) {
			j = queue.Dequeue();
			if( j.time <= q ) {
				t += j.time;
				Console.WriteLine( "{0} {1}", j.name, t );
			} else {
				j.time -= q;
				t += q;
				queue.Enqueue( j );
			}
		}
		
		return;
	}
}


Measured memory_bytes: 26304
#ABC098
n = int(input())
s = input()
l = [0] * n
for i in range(n-1):
    count = 0
    a = s[:i+1]
    b = s[i+1:]
    
    for j in set(a):
        if j in set(b):
            count += 1
    
    l[i] = count
    
print(max(l))



Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vi dp(n, INT_MAX);
    rep(i, n) {
        vi::iterator itr = lower_bound(all(dp), a[i]);
        *itr = a[i];
    }

    cout << (lower_bound(all(dp), INT_MAX)-dp.begin()) << endl;
}


Measured memory_bytes: 3592
from collections import defaultdict as dd
from collections import deque
N = int(input())
D =dd(list)
for i in range(N-1):
  a, b, c = map(int, input().split())
  D[a-1].append((b-1, c))
  D[b-1].append((a-1, c))

Q, K = map(int, input().split())
K -= 1
L = [0 for _ in range(N)]
q = deque([])
q.append(K)
while len(q) > 0:
  a = q.pop()
  for b, c in D[a]:
    if L[b] == 0:
      L[b] = L[a] + c
      q.append(b)

for i in range(Q):
  x, y = map(int, input().split())
  print (L[x-1] + L[y-1])

Measured memory_bytes: 53280
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, W, w, v;
ll DP[100001];

int main() {
	cin >> N >> W;
	memset(DP, 0xe869120e869120, sizeof DP);
	DP[0] = 0;
	for (int i = 0; i != N; ++i) {
		cin >> w >> v;
		for (int j = 100000; j >= v; --j) {
			DP[j] = min(DP[j], DP[j - v] + w);
		}
	}
	for (int i = 100000;; --i) {
		if (DP[i] <= W) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int ans = -n;
		for (int i=0; i<n; i++) ans += scanner.nextInt();
		System.out.println(ans);
	}
}

Measured memory_bytes: 25904
a = []
for i in range(3):
    a.append(list(map(int,input().split())))
n = int(input())
b = [int(input()) for i in range(n)]

c = [[-1,-1,-1],[-1,-1,-1],[-1,-1,-1]]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j] = 1

ans = False

if c[0][0] == 1 and c[0][1] == 1 and c[0][2] == 1:
    ans = True
if c[1][0] == 1 and c[1][1] == 1 and c[1][2] == 1:
    ans = True
if c[2][0] == 1 and c[2][1] == 1 and c[2][2] == 1:
    ans = True
if c[0][0] == 1 and c[1][0] == 1 and c[2][0] == 1:
    ans = True
if c[0][1] == 1 and c[1][1] == 1 and c[2][1] == 1:
    ans = True
if c[0][2] == 1 and c[1][2] == 1 and c[2][2] == 1:
    ans = True
if c[0][0] == 1 and c[1][1] == 1 and c[2][2] == 1:
    ans = True
if c[2][0] == 1 and c[1][1] == 1 and c[0][2] == 1:
    ans = True

if ans:
    print('Yes')
else:
    print('No')

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

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    if((a==1 && b==2) || (a==2 && b==1)){ cout << "3\n"; }
    else if((a==2 && b==3) || (a==3 && b==2)){ cout << "1\n"; }
    else if((a==1 && b==3) || (a==3 && b==1)){ cout << "2\n"; }
    return 0;
}


Measured memory_bytes: 256
import sys
N=int(input())
if N%2==0:
  print(N//2,N,N)
  sys.exit()
for a in range(1,3501):
  for b in range(1,a):
    M=N*a*b
    L=4*a*b-N*(a+b)
    if L>0:
      if M%L==0:
        print(a,b,M//L)
        sys.exit()

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    var r = M
    var n = 2
    var ans = ModInt(1)
    while (n * n <= r) {
        if (r % n == 0) {
            var cnt = 0
            while (r % n == 0) {
                cnt += 1
                r /= n
            }
            ans *= Combi(N + cnt - 1, N - 1)
        }
        n += 1
    }
    if (r != 1) {
        ans *= Combi(N + 1 - 1, N - 1)
    }
    println(ans.toString())
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

fun Combi(n: Int, a: Int): ModInt {
    var x = ModInt(1)
    var y = ModInt(1)
    repeat(a) { i ->
        x *= n - i
        y *= i + 1
    }
    return x / y
}

data class ModInt(private var v: Long) {
    companion object { private const val MOD = 1000000007L }
    init { this.v %= MOD }
    constructor(n: Int): this(n.toLong())
    operator fun plus(other: Int) = ModInt((this.v + other) % MOD)
    operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)
    operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)
    operator fun times(other: Int) = ModInt(this.v * other % MOD)
    operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)
    operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)
    private fun pow(a: Long, b: Long): Long {
        if (b == 0L) return 1L
        if (b % 2 == 0L) {
            val d = pow(a, b / 2)
            return (d * d) % MOD
        }
        return a * pow(a, b - 1) % MOD
    }
    override fun toString() = this.v.toString()
}


Measured memory_bytes: 50268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };
const double eps = 1e-6;
const int N = 1e5 + 7;

ll rep[N], sz[N];
ll nc;

ll find(ll n) {
	if (rep[n] == n)
		return n;
	return rep[n] = find(rep[n]);
}


bool join(ll a, ll b) {
	a = find(a);
	b = find(b);

	if (a == b)
		return false;

	if (sz[a] < sz[b])
		swap(a, b);

	sz[a] += sz[b];
	rep[b] = a;
	nc--;
	return true;
}





int main() {
	fastIO;
	ll n, m;
	cin >> n >> m;
	nc = n;
	for (int i = 1; i <= n; i++) {
		rep[i] = i;
		sz[i] = 1;
	}
	vector<pair<int, int>> edges;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		edges.push_back({u, v});
	}
	reverse(edges.begin(), edges.end());
	vector<ll> ans;
	ll prevInconv = n*(n-1)/2;
	ans.push_back(prevInconv);

	for (int i = 0; i < m-1; i++) {
		ll sz1 = sz[find(edges[i].first)], sz2 = sz[find(edges[i].second)];
		if (join(edges[i].first, edges[i].second)) {
			prevInconv -= sz1*sz2;
		}
		ans.push_back(prevInconv);
	}
	reverse(ans.begin(), ans.end());
	for (auto i : ans) {
		cout << i << '\n';
	}



}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  bool haveP=false,haveW=false,haveG=false,haveY=false;
  string s;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    if(!haveP&&s=="P"){
      haveP=true;
    }else if(!haveW&&s=="W"){
      haveW=true;
    }else if(!haveG&&s=="G"){
      haveG=true;
    }else if(!haveY&&s=="Y"){
      haveY = true;
    }
    if(haveP&&haveW&&haveG&&haveY){
      cout << "Four" << endl;
      return 0;
    }
  }
    cout << "Three" << endl;
    return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 
#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   int N;
   cin>>N;
   vector<int>A(N);
   for(int i=0;i<N;i++)cin>>A[i];
   vector<ll>sum(N+1,0);
   for(int i=1;i<=N;i++)sum[i]=A[i-1];
   for(int i=1;i<=N;i++)sum[i]+=sum[i-1];

   ll Min = INF;
   for(int b=0;b<N;b++){
      if(b<=1)continue;
      ll l1=1;
      ll r1=b;
      ll md1;
      while(r1-l1>1){
         md1=(l1+r1)/2;
         if(sum[md1]<=(sum[b]-sum[md1]))l1=md1;
         else r1=md1;
      }
      ll a;
      if(l1==b-1)a=l1;
      else{
         if(abs(sum[l1]-(sum[b]-sum[l1]))<abs(sum[r1]-(sum[b]-sum[r1])))a=l1;
         else a=r1;
      }

      if(b>=N-1)continue;
      ll l2=b+1;
      ll r2=N;
      ll md2;
      while(r2-l2>1){
         md2=(l2+r2)/2;
         if(sum[md2]-sum[b]<=sum[N]-sum[md2])l2=md2;
         else r2=md2;
      }
      ll c;
      if(N==l2-1)c=N-1;
      else{
         if(abs(sum[l2]-sum[b]-(sum[N]-sum[l2]))<abs((sum[r2]-sum[b])-(sum[N]-sum[r2])))c=l2;
         else c=r2;
      }

      ll P=sum[a];
      ll Q=sum[b]-sum[a];
      ll R=sum[c]-sum[b];
      ll S=sum[N]-sum[c];
      ll Ma=max(P,max(Q,max(R,S)));
      ll Mi=min(P,min(Q,min(R,S)));
      Min=min(Min,Ma-Mi);
      /*
      cout<<P<<" "<<Q<<" "<<R<<" "<<S<<endl;
      cout<<a<<" "<<b<<" "<<c<<" "<<N<<endl;
      cout<<Ma-Mi<<endl;
      */
   }
   cout<<Min<<endl;
   return 0;
}



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

int main(){
  int N;
  int n1, n2;
  int sho, amari1, amari2;
  cin >> N;
  n1 = N / 10;
  n2 = N % 1000;
  if ( (n1 % 111) == 0 || ( n2 % 111) == 0  ){
     cout << "Yes" << endl;
  }
  else {
     cout << "No" << endl;
  }
 }


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



int main(){
    
    int N;
    cin >> N;
    int a=0;
    int b=0;
    int s=1;
    int flag = 0;

   
    for(a=0;a<26;a++){
        for(b=0;b<16;b++){
            s = N - (4*a + 7*b);
            if(s==0){
                flag = 1;
            }
        }
    }
    if(flag == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    
    return 0;
}


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

template <class type> class SegmentTree{
public:
    int size;
    vector<type> tree;
    type def;
    type (*marge)(type, type);

    SegmentTree(int n, type d, type (*m)(type, type)){
        size = 1;
        def = d;
        marge = m;
        n++;

        while(size < n){
            size *= 2;
        }

        tree.resize(2*size);

        for(int i = 0;i < size;i++){
            tree[size-1+i] = def;
        }

        for(int i = size-2;i >= 0;i--){
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    SegmentTree(int n, type array[], type d, type (*m)(type, type)){
        size = 1;
        def = d;
        marge = m;
        n++;

        while(size < n){
            size *= 2;
        }

        tree.resize(2*size);

        for(int i = 0;i < size;i++){
            if(i < n) tree[size-1+i] = array[i];
            else tree[size-1+i] = def;
        }

        for(int i = size-2;i >= 0;i--){
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    void update(int i, type val){
        i = size-1+i;
        tree[i] = val;

        while(i > 0){
            i = (i-1)/2;
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    type get(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return tree[k];

        type vl = get(a, b, 2*k+1, l, (l+r)/2);
        type vr = get(a, b, 2*k+2, (l+r)/2, r);

        return marge(vl, vr);
    }

    type get(int a, int b){
        return get(a, b, 0, 0, size);
    }
};

int marge(int a, int b){
    return min(a, b);
}

int main(){
    int n, q;
    cin >> n >> q;
    SegmentTree<int> tree(n, INT_MAX, marge);

    int com, a, b;
    for(int i = 0;i < q;i++){
        cin >> com >> a >> b;
        if(com == 0){
            tree.update(a, b);
        }else{
            cout << tree.get(a, b+1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    string str;
    cin >> str;
    
    int num = 0;
    
    for(int i=0; i<4; ++i){
        if(str.at(i)=='+') ++num;
        else --num;
    }
    
    cout << num << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,d[100],i,j,s=1,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&d[i]);
    for(i=0;i<n-1;i++){
        for(j=i;j<n;j++){
            if(d[i]<d[j]){
                tmp=d[i]; d[i]=d[j]; d[j]=tmp;
            }
        }
    }
    for(i=1;i<n;i++)
        if(d[i-1]!=d[i])
            s++;
    printf("%d\n",s);
    return 0;
}

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

S = input()
K = input()
K_len = len(K)
K = int(K)

Cn = []
# GOSENCHO = 5000000000000000


for str in S:
    si = int(str)
    if si == 1:
        Cn.append(1)
    else:
        Cn.append(10000000000000000000)

# print(Cn)
tmp = 0
for i,Ci in enumerate(Cn):
    tmp += Ci
    if K <= tmp:
        print(S[i])
        break


Measured memory_bytes: 3060
#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(a) (a).begin(), (a).end()

int N;

int main() {
  cin >> N;

  vector<int> ans(N);
  rep(i, N) {
    int A;
    cin >> A;
    ans[A - 1] = i + 1;
  }

  rep(i, N) {
    if (i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>

#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;


int main(){

    int n;
    cin >> n;

    long long ans = 0,anum = 0,bnum = 0,abnum = 0;

    string s[n];
    for(int i=0;i<n;i++){
        cin >> s[i];
        for(int j=0;j<s[i].length()-1;j++){
            if(s[i][j]=='A' && s[i][j+1]=='B')ans++;
        }
        if(s[i][0]=='B')bnum++;
        if(s[i][s[i].length()-1]=='A')anum++;
        if(s[i][0]=='B' && s[i][s[i].length()-1]=='A')abnum++;
    }

    //cout << s[1][s[1].length()-1]<<endl;
    if(abnum==anum && abnum==bnum && abnum!=0)ans--;
    cout << ans + min(anum,bnum) << endl;
}


Measured memory_bytes: 768
n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
out = [0, 0]
i = n - 1
while i > 0:
    # print("a[{}]:a[i] a[{}]:{}".format(i, a[i], i-1, a[i-1]))
    if a[i] == a[i-1]:
        out[0] = a[i]
        i -= 2
        break
    i -= 1
# print(i)
while i > 0:
    if a[i] == a[i-1]:
        out[1] = a[i]
        break
    i -= 1
print(out[0] * out[1])
"""
maxSquare = 0
for i in range(n-3):
    for j in range(i+1, n-2):
        for k in range(j+1, n-1):
            for l in range(k+1, n):
                # print("i:{} j:{} k:{} l:{}".format(a[i],a[j],a[k],a[l]))
                if a[i] == a[j] and a[k] == a[l]:
                    maxSquare = max(maxSquare, a[i]*a[k])
                    # print("{}*{}*{}*{}".format(a[i], a[j], a[k], a[l]))
                elif a[i] == a[k] and a[j] == a[l]:
                    maxSquare = max(maxSquare, a[i] * a[j])
                    # print("{}*{}*{}*{}".format(a[i], a[j], a[k], a[l]))
                elif a[i] == a[l] and a[j] == a[k]:
                    maxSquare = max(maxSquare, a[i] * a[j])
                    # print("{}*{}*{}*{}".format(a[i], a[j], a[k], a[l]))
print(maxSquare)
"""

Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
int N,K,ans;
int main(){
    cin>>N>>K;
    vector<int>p(N);
    for(int i=0;i<N;i++)cin>>p[i];
    sort(p.begin(),p.end());
    for(int i=0;i<K;i++)ans+=p[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <numeric>
#include <functional>

using namespace std;

const int MOD = 998244353;

int main() {
	int n, s; cin >> n >> s;
	vector<int> a(n);
	for (auto& e : a) cin >> e;
	vector<vector<int> > dp(n + 1, vector<int>(s + 1));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= s; ++j) {
			(dp[i + 1][j] += 2 * dp[i][j] % MOD) %= MOD; // 解説の2,3の場合
			if (j + a[i] <= s) (dp[i + 1][j + a[i]] += dp[i][j]) %= MOD; // 解説の1の場合
		}
	}
	cout << dp[n][s] << endl;

	return 0;
}

Measured memory_bytes: 38608
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,K;
  int a_i,i,ans=0;
  cin >> N >> K;
  int cnt[N] = {};
  
  for(int d=0; d < K; d++) {
    cin >> i;
    for(int a=0; a < i; a++) {
      	cin >> a_i;
		cnt[a_i-1] += 1;
    }
  }
  for(int x : cnt){
    if(x > 0) ans += 1;
  }
  cout << N - ans << endl;
}


Measured memory_bytes: 3632
use std::f64::consts::FRAC_PI_2;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}


fn main() {
    let input = read_vec::<f64>();
    let (a, b, x) = (input[0], input[1], input[2]);

    let volume = a * a * b;
    let air = volume - x;

    let theta = if volume / 2. < x {
        (2. / a.powf(3.) * air).atan()
    } else {
        FRAC_PI_2 - (2. * x / (a * b * b)).atan()
    };

    println!("{}", theta.to_degrees());
}

Measured memory_bytes: 4476
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
int A[N],i,j,k,n,m;
bool an;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

int main()
{
	n=read();
	for (i=1;i<=n;++i) A[i]=read();
	sort(A+1,A+n+1),reverse(A+1,A+n+1);
	for (i=1;i<=n;++i)
		if (i+1>A[i+1])
		{
			for (j=i+1;i==A[j];++j)
				an^=1;
			an|=A[i]-i&1;
			puts(an?"First":"Second");
			return 0;
		}
}

Measured memory_bytes: 1664
#[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 ( 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 , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ 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" ) } ; }

fn main() {
    input! {
        n: usize, mut k: u64,
        mut ab: [(u64, u64); n]
    }
    ab.sort();
    let mut ret = 0;
    for i in 0..n {
        ret = ab[i].0;
        if k > ab[i].1 {
            k -= ab[i].1;
        } else {
            break;
        }
    }
    println!("{}", ret);
}

Measured memory_bytes: 6396
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M;
	cin >> N >> M;
	VI cost(M);
	vector<VI>can(M);
	vector<bool> F(N+1,false);
	REP(i, M) {
		int b;
		cin >> cost[i] >> b;
		REP(j, b) {
			int a;
			cin >> a;
			can[i].push_back(a);
			F[a] = true;
		}
	}
	bool P = true;
	eFOR(i,1, N) {
		if (F[i] == false)P = false;
	}
	if (P==false) {
		cout << -1 << endl;
		return 0;
	}
	
	int dp[5000];
	REP(i, 5000)dp[i] = INF;
	VI ret;
	REP(i, M) {
		int k = 0;
		int tmp = 0;
		
		REP(j, N) {
			if (k!=can[i].size()&&can[i][k] == j+1) {
				tmp++;
				k++;
			}
			tmp *= 2;
		}
		tmp /= 2;
		dp[tmp] = min(dp[tmp],cost[i]);
		//cout << dp[tmp] << endl;
		//REP(j, ret.size()) {
	//		dp[ret[j] | tmp] = min(dp[ret[j] | tmp], dp[ret[j]] + cost[i]);
		//}
		REP(j, (1<<N)) {
			dp[j | tmp] = min(dp[j|tmp], dp[j] + cost[i]);
		}
		ret.push_back(tmp);
		eREP(i, 4) {
			//cout << dp[i] << endl;
		}
		//cout << endl;
	}
	eREP(i, 4) {
	//	cout << dp[i] << endl;
	}
	cout << dp[(1 << N) - 1] << endl;
	return 0;
}



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

int main()
{
    int k;
    cin >> k;
    int x = 7 % k;
    set<int> s;
    int i = 1;
    while(s.count(x) == 0) {
        if(x == 0) {
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x * 10 + 7) % k;
        ++i;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 50532
#include <iostream>

using namespace std;

int so_bun[101][101];
int so_count[101];
int is_sosu[101];
int n;
int ans;

int sosu(int x) {
    for (int i = 2; i < x; i++) {
        if (x % i == 0) {
            return 0;
        }
    }
    return 1;
}

int f_so_bun(int x, int *arr) {
    for (int i = 2; i <= x; i++) {
        if (is_sosu[i] && x % i == 0) {
            arr[i]++;
            for (int j = 0; j <= x; j++) {
                arr[j] += so_bun[x/i][j];
            }
            return 0;
        }
    }
    return 0;
}

int init() {
    cin >> n;
    for (int i = 0; i <= 100; i++) {
        so_count[i] = 0;
        is_sosu[i] = sosu(i);
    }
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            so_bun[i][j] = 0;
        }
        f_so_bun(i, so_bun[i]);
    }
    ans = 0;
}


int solve() {
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 100; j++) {
            so_count[j] += so_bun[i][j];
        }
    }
    int over75 = 0;
    int over25 = 0;
    int over15 = 0;
    int over5 = 0;
    int over3 = 0;
    for (int i = 2; i <= 100; i++) {
        if (so_count[i] >= 75-1)
            over75++;
        if (so_count[i] >= 25-1)
            over25++;
        if (so_count[i] >= 15-1)
            over15++;
        if (so_count[i] >= 5-1)
            over5++;
        if (so_count[i] >= 3-1)
            over3++;
    }
    ans = over75 + over25 * (over3 - 1) + over15 * (over5 - 1) + (over5 * (over5 - 1) / (1 * 2)) * (over3 - 2);
}

int main() {
    init();
    solve();
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define INF 1e15
#define NASH 1e9+7
#define MAXN 200005
using namespace std;
ll n,k,a[1000];
int main(){
    cin>>k;
    for (int i=0; i<=20; i++) a[i]=-1;
    a[0]=0;
    while(k--){
        a[0]++;
        for (int i=0; i<20; i++){
            if (a[i]>9) { a[i+1]=max(1LL,a[i+1]+1LL);  a[i]=max(0LL,a[i+1]-1); continue; }
            if (a[i+1]!=-1 && abs(a[i]-a[i+1])>1) { a[i+1]++; a[i]=max(0LL,a[i+1]-1); continue; }
            for (int j=i-1; j>=0; j--){
                a[j]=max(0LL,a[j+1]-1);
            }
            break;
        }
        // if (1){
        //     for (int i=19; i>=0; i--){
        //         if (a[i]==-1) continue;
        //         cout<<a[i];
        //     } cout<<endl;
        // }
    }
    for (int i=19; i>=0; i--){
        if (a[i]==-1) continue;
        cout<<a[i];
    }
}
/*
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<string> s(n); for (auto&& e : s) cin >> e;
  int res = 0;
  int A = 0, B = 0, AB = 0;
  for (const auto& e : s) {
    int m = e.size();
    for (int i = 0; i < m; ++i) {
      res += e.substr(i, 2) == "AB";
    }
    if (e[0] == 'B' and e.back() == 'A') {
      ++AB;
      continue;
    }
    A += e.back() == 'A';
    B += e[0] == 'B';
  }
  if (A and B) {
    res += min(A, B) + AB;
  } else if (A) {
    res += AB;
  } else if (B) {
    res += AB;
  } else {
    res += max(AB - 1, 0);
  }
  cout << res << '\n';
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  long long int n, i, a[10001], sum = 0;
  
  cin >> n;
  REP(i, n) cin >> a[i];
  sort(a, a + n);
  REP(i, n) sum += a[i];
  cout << a[0] << " "<< a[n - 1] << " " << sum << endl;
}

Measured memory_bytes: 1252
// #include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#define pb emplace_back
#define LOCAL
  
using namespace std;
  
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
typedef long long ll;
typedef pair<int,int> Pii;
 
template <typename T>inline void read(T& t){
    char c=getchar();t=0;
    int f=1;
    while(!isdigit(c)){
       if(c=='-')f=-1;
        c=getchar();
    }
    while(isdigit(c))t=t*10+c-48,c=getchar();
    t=f*t;
}
  
template <typename T,typename... Args> inline void read(T& t,Args&... args){
    read(t);read(args...);
}

int n;
ll a[105];
  
int main(){
    int t=1;
    // read(t);
    while(t--){
        read(n);
        for(int i=0;i<n;i++){
            read(a[i]);
        }
        sort(a,a+n);
        int ans=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(a[j]==a[i])continue;
                for(int k=j+1;k<n;k++){
                    if(a[k]==a[j])continue;
                    if(a[i]+a[j]>a[k]){
                        ans++;
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void){
    int N; cin >> N;
    vector<int> v(N);
    int i = 0;
    int sum = 0;
    while (i < N) {
        cin >> v[i];
        i++;
    }
    i = 0;
    while (i < N) {
        int tmp;
        cin >> tmp;
        if (v[i] - tmp > 0) sum = sum + v[i] - tmp;
        i++;
    }
    cout << sum << endl;
}

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

using namespace std;

set<int> bits(int x)
{
    set<int> bs;

    while (x)
    {
        bs.insert(x & -x);
        x &= (x - 1);
    }

    return bs;
}

vector<int> solve(int N, int K)
{
    if (K >= (1 << N))
        return { };

    vector<int> ans(1 << (N + 1));

    for (int i = 0; i < 1 << N; ++i)
    {
        ans[2*i] = i;
        ans[2*i + 1] = i;
    }

    if (K == 0)
        return ans;

    auto bs = bits(K);

    list<int> xs;
    xs.push_back(K);

    if (bs.size() == 1)
    {
        if (K == 1 and 3 >= (1 << N))
            return { };

        bs.clear();

        if (K == 1)
        {
            bs.insert(2);
            bs.insert(3);
        } else
        {
            if (K + 1 >= (1 << N))
                return { };

            bs.insert(K + 1);
            bs.insert(1);
        }
    }

    for (int i = 0; i < (1 << N); ++i)
        if (bs.count(i) == 0 and i != K)
        {
            xs.push_front(i);
            xs.push_back(i);
        }

    for (auto b : bs)
    {
        xs.push_front(b);
        xs.push_back(b);
    }

    xs.push_back(K); 

    return vector<int>(xs.begin(), xs.end());
}

int main()
{
    int N, K;
    cin >> N >> K;

    auto ans = solve(N, K);

    if (ans.empty())
        cout << "-1\n";
    else
        for (size_t i = 0; i < ans.size(); ++i)
            cout << ans[i] << (i + 1 == ans.size() ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 11004
from collections import deque

def dfs(G, visited, s, n, ans):
  # すべての頂点を訪れた場合の処理
  if all(visited) :
    ans += 1
    return ans
  #　次の頂点の探索
  for i in range(n) :
    if visited[i] == False and (G[s][i] == 1 or G[i][s] == 1) :
      visited[i] = True
      ans = dfs(G, visited, i, n, ans)
      visited[i] = False
  return ans

#　グラフGの入力
n,m = map(int,input().split())
G = [[0 for i in range(n)] for j in range(n)]
for i in range(m) :
  a,b = map(int,input().split())
  G[a-1][b-1] = 1
  G[b-1][a-1] = 1
  

visited = [False for i in range(n)]
visited[0] = True
ans = 0
print(dfs(G, visited, 0, n, ans))

Measured memory_bytes: 3316
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  ll n,m,x;
  cin>>n>>m>>x;
  V<V<ll>> a(n,V<ll>(m));
  V<ll> c(n);
  for(int i=0;i<n;i++){
    cin>>c[i];
  for(int j=0;j<m;j++)cin>>a[i][j];
  }
  ll ans=inf;
  for(int i=0;i<(1<<n);i++){
    ll res=0;V<ll> sum(m,0);
    for(int j=0;j<n;j++){
      if(i&(1<<j)){
        res+=c[j];
        for(int k=0;k<m;k++){
          sum[k]+=a[j][k];
        }
      }
    }
    bool ok=true;
    for(int j=0;j<m;j++)if(sum[j]<x)ok=false;
    if(ok){
      chmin(ans,res);
    }
  }
  if(ans>=inf)cout<<-1<<"\n";
  else cout<<ans<<"\n";
}


Measured memory_bytes: 3664
using System;
using static System.Console;

class Program
{
    public static void Main(string[] args)
    {
        string[] input = ReadLine().Split();
        double a = int.Parse(input[0]);
        double b = int.Parse(input[1]);

        double c = (a + b) / input.Length;
        WriteLine(Math.Ceiling(c));

    }
}

Measured memory_bytes: 11092
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 100010
//cin.ignore (7777, '\n');

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}      
  private:
    bool first;
    string separator;
};
 
template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

ll dp[MAXN][4];
pair<ll,ll>tempp;
ll massiv[MAXN][5];
ll n;
int main(){
FAST_READ;
cin>>n;
for(ll i=1;i<=n;i++)
{
  for(ll j=0;j<3;j++)
  {
	cin>>massiv[i][j];
  }
}
for(ll i=1;i<=n;i++)
{
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+massiv[i][0];
  dp[i][1]=max(dp[i-1][2],dp[i-1][0])+massiv[i][1];
  dp[i][2]=max(dp[i-1][1],dp[i-1][0])+massiv[i][2];
}
cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;


return 0;
} 


Measured memory_bytes: 7424
// cout << endl;
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──████AJ████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/

#include<bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mod 1000000007

vector<vector<int>> adj;
int N;
vector<pair<ll, ll>> dp;

pair<ll, ll> getWays(int node, int parent) {
	if (adj[node].size() == 1 && parent != 0) {
		return make_pair(1, 1);
	}
	if (dp[node].first != -1) return dp[node];
	ll white = 1, black = 1;
	for (int i = 0; i < adj[node].size(); i++) {
		int child = adj[node][i];
		if (child != parent) {
			pair<ll, ll> res = getWays(child, node);
			white = (white * (res.first + res.second)) % mod;
			black = (black * res.first) % mod;
		}
	}
	return dp[node] = make_pair(white, black);
}

int main() {
	cin >> N;
	adj = vector<vector<int>> (N + 1);
	dp = vector<pair<ll, ll>> (N + 1, make_pair(-1, -1));
	int x, y;
	for (int i = 0; i < N - 1; i++) {
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	pair<ll, ll> res = getWays(1, 0);
	cout << (res.first + res.second) % mod << endl;
	return 0;
}

Measured memory_bytes: 17084
#include<bits/stdc++.h>
using namespace std;
const int MX=2005;

int N,K,ans,dep[MX];
vector<int> G[MX];

inline int read()
{
    int x=0,c=getchar();
    while(!isdigit(c))c=getchar();
    while(isdigit(c))x=x*10+c-'0',c=getchar();
    return x;
}
int dfs(int u,int f)
{
    int ans=0;
    dep[u]=dep[f]+1;
    if(dep[u]==K/2+1)ans++;
    for(int i:G[u])if(i!=f)ans+=dfs(i,u);
    return ans;
}

int main()
{
    N=read(),K=read();
    for(int i=1,u,v;i<N;i++)
        u=read(),v=read(),G[u].push_back(v),G[v].push_back(u);
    for(int i=1;i<=N;i++)
    {
        int tmp=0;
        dep[i]=0;
        for(int j:G[i])tmp=max(tmp,dfs(j,i));
        sort(dep+1,dep+N+1);
        int siz=upper_bound(dep+1,dep+N+1,K/2)-dep-1;
        if(K&1)siz+=tmp;
        ans=max(ans,siz);
    }
    printf("%d\n",N-ans);
    return 0;
}


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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int[]> scoreList = new List<int[]>();

            while (true)
            {
                int[] inputScore = Array.ConvertAll(Console.ReadLine().Split(), new Converter<string, int>(s => int.Parse(s)));
                if (inputScore.Sum() == -3)
                {
                    break;
                }
                scoreList.Add(inputScore);
            }

            foreach (int[] score in scoreList)
            {
                int reExam = score[2];
                score[2] = 0;
                if (score.Contains(-1))
                {
                    Console.WriteLine("F");
                }
                else
                {
                    if (80 <= score.Sum())
                    {
                        Console.WriteLine("A");
                    }
                    else if (65 <= score.Sum())
                    {
                        Console.WriteLine("B");
                    }
                    else if (50 <= score.Sum() || 50 <= reExam)
                    {
                        Console.WriteLine("C");
                    }
                    else if (30 <= score.Sum())
                    {
                        Console.WriteLine("D");
                    }
                    else
                    {
                        Console.WriteLine("F");
                    }
                }
            }    
        }
    }
}

Measured memory_bytes: 9272
#include<stdio.h>
	long long a[200000]={0};
	long long b[200000]={0};
	long long c[200000]={0};
    long long sum[200000]={0};
int main(){
	long long n;
	int x,m;
	scanf("%lld %d %d",&n,&x,&m);
	long long ans=0;

	a[1]=x;
	sum[1]=x;
	b[x]=1;
	c[x]=1;
	int i=2;
	while (i<=n){
		a[i]=(a[i-1]*a[i-1])%m;
		sum[i]=sum[i-1]+a[i];
		if (b[a[i]]==0){
			b[a[i]]=1;
			c[a[i]]=i;
			i++;
			continue;
		}else{
		  	int len=i-c[a[i]];
		  	ans=sum[c[a[i]]-1];
		  	long long everycirclesum=sum[i-1]-sum[c[a[i]]-1];
		  	long long times=(n-c[a[i]]+1)/len;
		  	ans+=everycirclesum*times;
		  	long long rest=(n-c[a[i]]+1)%len;
		  	ans=ans+sum[c[a[i]]-1+rest]-sum[c[a[i]]-1];
		  	printf("%lld",ans);
		  	return 0;
		}		
	}
   ans=sum[n];
   printf("%lld",ans);
}

Measured memory_bytes: 4004