akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  private static final long MOD = 1000000007L;

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    long k = sc.nextLong();

    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    long result = 0;
    for (int i = 0; i < n; i++) {
      long l = 0;
      long r = 0;

      for (int j = 0; j < i; j++) {
        if (a[i] > a[j]) {
          l++;
          result += (k - 1 ) * k / 2;
          result %= MOD;
        }
      }

      for (int j = i + 1; j < n; j++) {
        if (a[i] > a[j]) {
          r++;
          result += k * (k + 1) / 2;
          result %= MOD;
        }
      }
//      result += calc(r, k, r + l);
//      result %= MOD;
    }

    os.println(result);
  }

  private static long calc(long a, long n, long d) {
    return ((n * (2 * a + (n - 1) * d)) / 2) % MOD;
  }
}

Measured memory_bytes: 27120
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<endl //to debug values of variables
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define pb push_back
#define mod 1000000007
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
lld power(lld b, lld e)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(b*b,(e-1)/2);
	else
		return power(b*b,e/2);
}
 
int nDig(lld n)
{
	return floor(log10(n) + 1);
}

//--------------------------------------------------------------------------------
 
int main()
{
    SPEEDUP;
    lld n,ai;
    bool flag=true;
    cin>>n;

    FORZ(i,n)
    {
    	cin>>ai;
    	if(ai%2==0)
		{
			if(ai%3==0 || ai%5==0) 
				flag=true;
			else
			{
				 flag=false;
				 break;
			}
		}
    }


		if(flag==true)
    		cout<<"APPROVED";
    	else
    		cout<<"DENIED";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100010
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
struct Info{int a[N];}a[2],p,q,an;
int n,k;
Info ni(Info x){
	Info y;
	for (int i=1;i<=n;i++) y.a[x.a[i]]=i;
	return y;
}
Info work(Info x,Info y){
	Info z;
	for (int i=1;i<=n;i++) z.a[i]=x.a[y.a[i]];
	return z;
}
Info get(Info x,int y){
	Info z;
	bool vi[N];int a[N],na;
	for (int i=1;i<=n;i++) vi[i]=1;
	for (int i=1;i<=n;i++){
		if (vi[i]){
			na=0;
			for (int j=i;vi[j];j=x.a[j]){a[na++]=j;vi[j]=0;}
			for (int i=0;i<na;i++)z.a[a[i]]=a[(i+y)%na];
		}
	}
	return z;
}
int main(){
	read(n);read(k);
	for (int i=1;i<=n;i++) read(a[0].a[i]);
	for (int i=1;i<=n;i++) read(a[1].a[i]);
	if (k%6==1)q=a[0];
	if (k%6==2)q=a[1];
	if (k%6==3)q=work(a[1],ni(a[0]));
	if (k%6==4)q=ni(a[0]);
	if (k%6==5)q=ni(a[1]);
	if (k%6==0)q=work(ni(a[1]),a[0]);
	p=a[1];p=work(p,ni(a[0]));
	p=work(p,ni(a[1]));p=work(p,a[0]);
	p=get(p,(k-1)/6);
	if (k%6>=4||k%6==0)p=work(p,a[1]);
	if (k%6==5||k%6==0)p=work(p,ni(a[0]));
	an=work(p,q);an=work(an,ni(p));
	for (int i=1;i<=n;i++) cout<<an.a[i]<<' ';cout<<endl;
	return 0;
}

Measured memory_bytes: 20480
def inpl(): return list(map(int, input().split()))
N, M, X = inpl()
A = inpl()
c0, cN = 0, 0
for i in range(X):
    if i in A:
        c0+=1
for i in range(X, N):
    if i in A:
        cN+=1
print(min(c0, cN))

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    ll N;
    cin>>N;
    string MARCH="MARCH";
    vector<string> S(N);
    map<string,ll> mp;
    rep(i,N){
        cin>>S[i];
        mp[S[i].substr(0,1)]++;
    }

    ll ANS=0;
    ll A,B,C;

    rep(i,5){
        A=mp[MARCH.substr(i,1)];
        REP(j,i+1,5){
            B=mp[MARCH.substr(j,1)];
            REP(k,j+1,5){
                C=mp[MARCH.substr(k,1)];
                ANS+=(A*B*C);
            }
        }
    }
    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    ll n,m;cin >> n >> m;
    vector<ll> x(n),y(m);
    rep(i,n)cin >> x[i];
    rep(i,m)cin >> y[i];
    const int mod = 1e9+7;
    ll xsum=0,ysum=0;
    for(int i=0;i<n-1;i++){
        xsum+=(x[i+1]-x[i])*(i+1)*(n-i-1)%mod;
        xsum%=mod;
    }
    for(int i=0;i<m-1;i++){
        ysum+=(y[i+1]-y[i])*(i+1)*(m-i-1)%mod;
        ysum%=mod;
    }
    cout << xsum*ysum%mod << endl;
    
    return 0;
}

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

using namespace std;
pair<int,int> a[200005]; 
int main()
{
	int n,h;
	cin>>n>>h;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i*2-1].first>>a[i*2].first;
		a[i*2-1].second=1;
		a[i*2].second=2;
	}
	sort(a+1,a+1+2*n,greater<pair<int,int> >() );
	int res=0;
	for(int i=1;i<=2*n;i++)
	{
		if(a[i].second==2) {h-=a[i].first;res++;if(h<=0) break;}
		else 
		{res+=(h-1)/a[i].first+1;break;}
	}
	cout<<res<<endl;
	return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<vector<int>> G(N, vector<int>());
    vector<pair<int, int>> edges;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        edges.emplace_back(a, b);
    }
    vector<bool> visited(N, false);
    map<pair<int, int>, int> color;
    int K = 0;
    function<void(int, int)> f = [&](int index, int parent_color) {
        if (K < G[index].size()) K = G[index].size();
        int cur_color = 1;
        for (int a: G[index]) {
            if (visited[a]) continue;
            if (cur_color == parent_color) cur_color++;
            color[make_pair(index, a)] = cur_color;
            color[make_pair(a, index)] = cur_color;
            visited[a] = true;
            f(a, cur_color);
            cur_color++;
        }
    };
    visited[0] = true;
    f(0, -1);
    cout << K << endl;
    for (auto& e: edges) {
        cout << color[e] << endl;
    }
    return 0;
}

Measured memory_bytes: 22772
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
long long MOD = 1000000007;

int main(){
  int n,w;
  while(cin>>n>>w){
    int a[10002]={};
    int s[10002]={};
    REP(i,n)cin>>a[i+1];
    sort(a, a+(n+1));
    REP(i,n)s[i+1] = s[i] + a[i+1];
    int dp[201][10001];
    long long ans = 0;
    REP(i,n+1){
      memset(dp,0,sizeof(dp));
      int b = w-a[i+1];
      int e = w-a[i];
      //printf("%d: %d,%d\n",i,b,e);
      if(b == e) continue;
      if(s[i] > e) break;
      dp[i][s[i]] = 1;
      for(int j = i + 1; j <= n; j++){
        for(int k = e; k >= 0; k--){
          dp[j][k] = dp[j-1][k] + ((k-a[j]>=0)?(dp[j-1][k-a[j]]):0);
          //printf("%d,%d:%d\n",j,k,dp[j][k]);
          dp[j][k] %= MOD;
        }
      }
      for(int j = b + 1; j <= e; j++){
        ans += dp[n][j];
        ans %= MOD;
      }
      //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    //cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REREASE

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M))
#define ALL(v) v.begin()+1, v.end()-9

int main(){
    int N,K;
    cin>>N>>K;
    //vector<vector<ll>> C(N+10,vector<ll>(N));
    int t=0;
    while(true){
        N/=K;
        t++;
        if(N<1)break;
    }
    cout<<t;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
struct Node {
	int key;
	Node *p, *l, *r;
};
Node *root;
void insert(int key_) {
	Node *x = root, *y = 0, *z;
	z = (Node*)malloc(sizeof(Node));
	z->key = key_, z->l = 0, z->r = 0;
	while (x) y = x, x = (z->key < x->key) ? x->l : x->r;
	z->p = y;
	if (!y) root = z;
	else if (z->key < y->key) y->l = z;
	else y->r = z;
}
bool find(int key_) {
	Node *x = root;
	while (x) {
		if (key_ < x->key) x = x->l;
		else if (key_ > x->key) x = x->r;
		else return true;
	}
	return false;
}
void walk1(Node *x) { if (!x) return; walk1(x->l); printf(" %d", x->key); walk1(x->r); }
void walk2(Node *x) { if (!x) return; printf(" %d", x->key); walk2(x->l); walk2(x->r); }
int n, v; char c[8];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", &c);
		if (c[0] == 'i') scanf("%d", &v), insert(v);
		else if (c[0] == 'f') scanf("%d", &v), printf("%s\n", find(v) ? "yes" : "no");
		else walk1(root), printf("\n"), walk2(root), printf("\n");
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,pair<int,int>>;
int main(){
	int n,m;
	cin >> n >> m;
	auto x = vector<p>(); 
	for (int i = 0; i < m; i++)
	{
		int p,y;
		cin >> p >> y;
		x.push_back(make_pair(p,make_pair(y,i+1)));
	}

	
	sort(x.begin(),x.end());
	
	int c =1;
	for (int i = 0; i < m; i++)
	{
		if(m-1!=i){
			if(x[i].first == x[i+1].first)
			x[i].second.first=c++;
			else{
				x[i].second.first = c;
				c=1;
			}
		}else{
			x[i].second.first = c;
		}
	}
	
	sort(x.begin(),x.end(),[](p i1,p i2){
		return i1.second.second < i2.second.second;
	});

	for (int i = 0;i<m;i++)
	{
		cout << std::setfill('0') << std::right << std::setw(6)<<x[i].first;
      	cout << std::setfill('0') << std::right << std::setw(6)<<x[i].second.first<<endl;
	}
}

Measured memory_bytes: 2804
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let N = parseInt(input[0][0], 10);
	let K = parseInt(input[0][1], 10);
	let R = parseInt(input[1][0], 10);
	let S = parseInt(input[1][1], 10);
	let P = parseInt(input[1][2], 10);
	let T = input[2][0];
	
	let v_k = Array.from({length: K}, () => []);
	for (let i = 0; i <= K - 1; i++){
		for (let j = 0; j <= (N - 1 - i) / K; j++){
			v_k[i].push(T[i + j*K]);
		}
	}

	let tmp;
	let ans = 0;
	for (let x of v_k){
		tmp = 1;
		for (let i = 1; i < x.length; i++){
			if (x[i] === x[i - 1]){
				tmp ++;
			} else {
				if (x[i - 1] === 'r') ans += Math.ceil(tmp / 2) * P;
				else if (x[i - 1] === 's') ans += Math.ceil(tmp / 2) * R;
				else ans += Math.ceil(tmp / 2) * S;
				tmp = 1;
			}
		}
		if (x[x.length - 1] === 'r') ans += Math.ceil(tmp / 2) * P;
		else if (x[x.length - 1] === 's') ans += Math.ceil(tmp / 2) * R;
		else ans += Math.ceil(tmp / 2) * S;
	}

	console.log(ans);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 63668
#include <iostream>


int main(int argc, char** argv) {
    int A, B, C, X;
    std::cin >> A;
    std::cin >> B;
    std::cin >> C;
    std::cin >> X;
    int cnt;
    int sum = 0;
    int sumA = 0;
    int sumB = 0;
    int sumC = 0;
    for (int ia = 0; ia <= A; ia++) {
        sumA = ia * 500;
        if (sumA > X) continue;
        for (int ib = 0; ib <= B; ib++) {
            sumB = sumA + ib * 100;
            if (sumB > X) continue;
            for (int ic = 0; ic <= C; ic++) {
                sumC = sumB + ic * 50;
                if (sumC == X) {
                    cnt++;
                    break;
                }
            }
        }
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void findDivisor(int n, vector<int>& divisor)
{
    divisor.clear();
    stack<int> stk;
    for(int i=1; i*i<=n; ++i){
        if(n % i == 0){
            divisor.push_back(i);
            if(i * i < n)
                stk.push(n / i);
        }
    }
    while(!stk.empty()){
        divisor.push_back(stk.top());
        stk.pop();
    }
}

const int MOD = 1000000007;

long long power(long long a, long long b)
{
    long long ret = 1;
    long long tmp = a;
    while(b > 0){
        if(b & 1){
            ret *= tmp;
            ret %= MOD;
        }
        tmp *= tmp;
        tmp %= MOD;
        b >>= 1;
    }
    return ret;
}

int getDigit(int x)
{
    int digit = 0;
    while(x > 0){
        x /= 10;
        ++ digit;
    }
    return digit;
}

long long solve(int n)
{    
    int left = 0;
    int right = n;
    while(left < right){
        int cnt = (left + right + 1) / 2;
        int digit = n / cnt;
        if(digit < 8)
            right = cnt - 1;
        else
            left = cnt;
    }
    long long ans = left;

    vector<int> div;
    findDivisor(n, div);
    for(int cnt : div){
        int digit = n / cnt;
        if(digit < 8)
            continue;

        long long tmp = 9;
        for(int i=1; i<digit; ++i){
            tmp *= 10;
            if(tmp >= cnt)
                break;
        }

        -- ans;
        if(cnt <= tmp){
            ans += 9 * power(10, digit - 1) - cnt + 1;
            ans %= MOD;
        }
    }
    ans += MOD;
    ans %= MOD;

    int k = 1;
    int m = 0;
    for(int i=1; i<10000000; ++i){
        while(m < n){
            m += getDigit(k);
            ++ k;
        }
        if(m == n){
            ++ ans;
            ans %= MOD;
        }
        m -= getDigit(i);
    }

    return ans;
}

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

    cout << solve(n) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
  }

  vector<vl> graph(n, vl(n));
  rep(i, n) {
    rep(j, n) {
      if (s[i][j] == '1') {
        graph[i][j] = 1;
      }
    }
  }

  ll ans = -1;
  rep(i, n) {
    vl dis(n, -1);
    queue<ll> que;
    que.emplace(i);
    dis[i] = 1;

    bool f = true;
    while (que.size()) {
      ll now = que.front();
      que.pop();
      rep(j, n) {
        if (s[now][j] == '1') {
          if (dis[j] == -1) {
            que.push(j);
            dis[j] = dis[now]+1;
          } else if((dis[now] != dis[j]+1) && (dis[now] != dis[j]-1)) {
            f = false;
            break;
          }
        }
      }
    }

    if (f) {
      rep(i, n) {
        cmax(ans, dis[i]);
      }
    }
  }
  cout << ans << endl;
}


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

namespace Competition
{
    class Program
    {
        static void Main(string[] args)
        {
            var nx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = nx[0]; var x = nx[1];
            var l = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var len = 0;
            var res = 1;
            for(var i = 0; i < n; i++)
            {
                len += l[i];
                if (len > x) break;
                res++;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    long k;
    cin >> k;
    long n = 50;
    VI v;
    REP(i,n) v.push_back(i + k / n);
    for (int i = 0; i < k % n; i++) {
        REP(j,n) {
            if (j == i) v[j] += n;
            else v[j]--;
        }
    }
    cout << n << endl;
    REP(i,n-1) cout << v[i] << " ";
    cout << v.back() << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<iostream>
#include<stack>
using namespace std;
stack<long> s;
int main() {
	string str;
	while (cin >> str) {
		if (str[0] == '+' || str[0] == '-' || str[0] == '*') {
			char ch = str[0];
			long b = s.top(); s.pop();
			long a = s.top(); s.pop();
			if (ch == '+') s.push(a + b);
			else if (ch == '-') s.push(a - b);
			else if (ch == '*') s.push(a*b);
		}
		else {
			long tmp = atoi(str.c_str());
			s.push(tmp);
		}
	}
	cout << s.top() << endl;
}

Measured memory_bytes: 1196
import java.io.PrintWriter
import kotlin.math.max

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}


fun main() {
    val (N, M, Q) = nextIntList()
    val R = Array(Q) { nextIntList() }
    val tmp = arrayOf(1)
    fun dfs(A: Array<Int>): Int {
        if (A.size == N + 1) {
            var score = 0
            for ((a, b, c, d) in R) {
                if (A[b] - A[a] == c) score += d
            }
            return score
        }
        var ans = 0
        val AA = A.clone() + A.last()
        while (AA.last() <= M) {
            ans = max(ans, dfs(AA))
            AA[AA.size - 1]++
        }
        return ans
    }

    val ans = dfs(tmp)
    println(ans)
}

Measured memory_bytes: 52420
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {  
	ll kazu=1;
	while(1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N,R;cin >> N >> R;
	if (N >= 10) cout << R << endl;
	else cout << R + (10 - N)*100 << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> x(n);

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 0; j < a; j++){
            pair<int,int> tmp;
            cin >> tmp.first >> tmp.second;
            tmp.first--;
            x[i].push_back(tmp);
        }
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        vector<int> status(n, 0);
        int tmpans = 0;
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                status[i] = 1;
                tmpans++;
            }
        }

        bool contradict = false;

        for(int i = 0; i < n; i++){
            if(status[i]){
                for(int j = 0; j < x[i].size(); j++){
                    if(status[x[i][j].first] != x[i][j].second){
                        contradict = true;
                        break;
                    }
                }
                if(contradict) break;
            }
        }

        if(!contradict) ans = max(ans, tmpans);
        
    }

    cout << ans << endl;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
template<class T> int size(T &&x) {
  return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
  return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
  out << '{';
  for(auto it = x.begin(); it != x.end(); ++it)
    out << *it << (it == prev(x.end()) ? "" : ", ");
  return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
  cerr << x << ";  ";
  dump(args...);
}
struct Nl{~Nl(){cerr << '\n';}};
# define print(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#define int long long


int32_t main(){
    
  fast;
  int n; cin >> n;
  int num = n/2 + n%2;
  long double ans = num/(long double)n;
  cout << ans;


  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n,y;
  scanf("%d%d",&n,&y);

  int a,b,c;
  a = y/10000;
  b = y/5000;

  int count =0;
  for(int i=0; i<=n; i++){
    for(int j=0; j<=n; j++){
        if((i*10000+ j*5000+ (n-i-j)*1000==y)&&(n-i-j>=0)){
          printf("%d %d %d",i,j,n-i-j);
          return 0;
      }
    }
  }

  printf("-1 -1 -1");


  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{
	int a, b;

	//input
	cin >> a >> b;



	//calc
	int ans = -1;

	if (a <= 9 && b <= 9){
		ans = a * b;
	}

	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 15:18:03 2020

@author: liang
"""
N, K, Q = map(int, input().split())
A = [0]*N
for i in range(Q):
    t = int(input())
    A[t-1] += 1

#print(A)
for i in range(N):
   # print(Q-A[i])
    if Q - A[i] <  K:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9932
class Hash
	alias :orig_ref :[]
	alias :orig_sub :[]=

	def [](x)
		y = orig_ref(x)
		raise "uninitialized" if !y
		y
	end

	def set_size(s)
		@s = s
	end

	def []=(i, x)
		raise "range exceed" if i >= @s
		orig_sub(i, x)
	end
end

loop do 
	((?a..?z).to_a + (?A..?Z).to_a).each do |char|
		self.instance_eval "@#{char} = {}"
	end

	line = gets.chomp
	i = 1
	occured = false
	break if line =~ /^\.$/
	loop do
		if line =~ /^([a-zA-Z])\[(\d+)\]$/
			eval "@#{$1}.set_size(#{$2})"
		else
			s = line.gsub(/([a-zA-Z])/, '@\1')
			begin
				eval(s)
			rescue
				puts i if !occured
				occured = true
			end
		end
		line = gets.chomp
		break if line =~ /^\.$/
		i += 1
	end
	puts 0 if !occured
end	

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

using namespace std;
int c[505], s[505], f[505], ans[505];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++)
        cin >> c[i] >> s[i] >> f[i];

    for (int i = 1; i < n; i++)
    {
        int tek = s[i];
        for (int j = i + 1; j <= n; j++)
        {
            if (tek < s[j - 1]) tek = s[j - 1] + c[j - 1];
            else
                tek = ((tek - 1) / f[j - 1] + 1) * f[j - 1] + c[j - 1];
        }
        ans[i] = tek;
    }
    for (int i = 1; i <= n; i++)
        cout << ans[i] << '\n';
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){int n,m,x,i,j,t,k,mx,ans=100000000,cst;
cin>>n>>m>>x;
int c[n];
int sk[n][m];
for(i=0;i<n;i++){cin>>c[i];
    for(j=0;j<m;j++){
      cin>>sk[i][j];
    }
}mx=1;
for(i=0;i<n;i++){mx*=2;}
vector<int>v;
for(i=1;i<mx;i++){cst=0;
    v.clear();
    k=1;
    for(j=0;j<n;j++){
        if(i&k)v.push_back(j);
        k*=2;
    }int a[m]={0};
    int l=v.size();
    for(j=0;j<l;j++){
        k=v[j];
        cst+=c[k];
        for(int i1=0;i1<m;i1++){a[i1]+=sk[k][i1];}
    }
    int ok=1;
    for(j=0;j<m;j++){//cout<<a[j]<<" "<<x<<" "<<cst<<" "<<ok<<endl;
        if(a[j]<x){ok=0;}}
    if(ok==1){ans=min(ans,cst);}
}
if(ans==100000000){cout<<"-1";}
else{cout<<ans;}
    return 0;}

Measured memory_bytes: 3624
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const LL INF = 1LL<<55;
int N;
LL X[100011], Y[100011];
char D[100011];

int calc(LL t) {
    LL right = -INF;
    int ans = 0;

    REP (i, N) {
	LL x = -INF;
	if (D[i] == 'U' || D[i] == 'D') {
	    x = X[i];
	} else if (D[i] == 'R') {
	    x = X[i] + t;
	} else if (D[i] == 'L') {
	    x = X[i] - t;
	}
	if (right < x) {
	    right = x;
	    ans = i;
	}
    }
    return ans;
}

using Double = long double ;
Double solve(Double t) {
    Double left = INF, right = -INF, up = -INF, down = INF;
    REP (i, N) {
	Double x = 0, y = 0;
	if (D[i] == 'U') {
	    y = Y[i] + t;
	    x = X[i];
	} else if (D[i] == 'D') {
	    y = Y[i] - t;
	    x = X[i];
	} else if (D[i] == 'R') {
	    y = Y[i];
	    x = X[i] + t;
	} else {
	    y = Y[i];
	    x = X[i] - t;
	}

	amin(left, x);
	amax(right, x);
	amin(down, y);
	amax(up, y);
    }
    return (right - left) * (up - down);;
}

const long double GR = (sqrt(5L) - 1.0) / 2.0; // GR == 0.618
// Func = double(*)(double);
template<class Func> Double argmax(Func f, Double lo = -INF, Double hi = INF, const int LOOP = 200) {
    Double x = hi - GR * (hi - lo), y = lo + GR * (hi - lo);
    Double vx = f(x), vy = f(y);
    for (int i=0; i<LOOP; i++) {
	if (vx < vy) { lo = x; x = y; vx = vy; y = lo + GR * (hi - lo); vy = f(y); }
	else { hi = y; y = x; vy = vx; x = hi - GR * (hi - lo); vx = f(x); }
    }
    return (x+y)/2.0;
}

Double ans;
Double f(Double t) {
    Double ret = solve(t);
    amin(ans, ret);
    return -ret;
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld%lld%s", X+i, Y+i, D+i);

    vector<LL> tm;
    tm.push_back(0);
    ans = solve(0);
    Double t = argmax(f, 0, 5e9);
    amin(ans, solve(t));
    amin(ans, solve(max(0.0L, t-0.1)));
    amin(ans, solve(t+0.1));
    printf("%.12f\n", (double)ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2048
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void){
    int N;
    scanf("%d",&N);
    char w[N][11];
    scanf("%s",w[0]);
    for(int i=1; i<N; i++){
        scanf("%s",w[i]);
        if(w[i-1][strlen(w[i-1])-1] != w[i][0]){puts("No"); return 0;}
    }

    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            if(!strcmp(w[i], w[j])){puts("No"); return 0;}
        }
    }
    
    puts("Yes");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using intl = long long;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
#define debug(x) cout << #x << ":" << x << endl
using namespace std;
int main(){
    intl a;
    cin >> a;
    intl cnt = 0;
    rep(i,a+1){
        cnt += i; 
    }
    cout << cnt << endl;
    return 0;
}

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

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	string s;
	cin >> s;
	bool flag = false;
	for(int i = 0; i < 3; i++)
		flag |= (s[i] == '7');
	cout << (flag ? "Yes" : "No");			
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int, int> PII;

int main(){
    FIO;
    ll k, x;
    cin >> k >> x;
    for(ll i = x-k+1 ; i < x ; i++){
        cout << i << " ";
    }
    cout << x << " ";
    for(ll i = x+1 ; i <= x+k-1 ; i++){
        cout << i << " ";
    }
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}


bool check(int ans, int ng) {
  string s = to_string(ans);
  for (int i = 0; i < (int)s.size(); i++) {
    if ((ng >> (s[i] - '0')) & 1) 
      return false;
  }
  return true;
}
int main2() {
  int N = nextInt();
  int K = nextInt();

  int ng = 0;
  REP(i, K) {
    int x = nextInt();
    ng |= 1 << x;
  }
  int ans = N;
  for (;; ans++) {
    if (check(ans, ng)) 
    {
      cout << ans << endl;
      break;
    }
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] hikakuStr = line.split("[\\s]+");

		int syo = Integer.parseInt(hikakuStr[0]);
		int chu = Integer.parseInt(hikakuStr[1]);
		int dai = Integer.parseInt(hikakuStr[2]);

		if ((syo < chu) && (chu < dai)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24372
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

vector<int> convert(const string &s) {
	vector<int> ans;
	for (const char &c : s) {
		if (c == '(') ans.push_back(1);
		else ans.push_back(-1);
	}
	return ans;
}

pair<int, int> f (const vector<int> &a) {
	int nin = 1e9, val = 0;
	for (const int &e : a) {
		val += e;
		chmin(nin, val);
	}
	return make_pair(nin, val);
}


int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(n);
	vector<int> nin(n), last(n);
	vector<int> type(n);
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		a[i] = convert(s);
		tie(nin[i], last[i]) = f(a[i]);
		if (last[i] >= 0) type[i] = 0;
		else type[i] = 1;
	}
	
	auto com = [&] (int l, int r) {
		if (type[l] != type[r]) return type[l] < type[r];
		if (type[l] == 0) return nin[l] > nin[r];
		return last[l] - nin[l] > last[r] - nin[r];
	};
	
	vector<int> idx(n);
	iota(idx.begin(), idx.end(), 0);
	sort(idx.begin(), idx.end(), com);
	
	int sum = 0;
	bool ok = true;
	for (int &i : idx) {
		for (const int &e : a[i]) {
			sum += e;
			if (sum < 0) ok = false;
		}
	}
	
	if (ok == true and sum == 0) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 73400
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;
typedef pair<ll,int> P;


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(a+b,min(b+c,c+a))<<endl;;
}


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

int main() {
	int N;
	cin >> N;
	
	int L[N];
	
	for(int i=0;i < N; i++){
		cin >> L[i];
	}
	
	int max = L[0];
	int index = 0;
	for(int i = 1; i < N; i++){
		if(max < L[i]) {
			max = L[i];
			index = i;
		}
	}

	int sum = 0;
	for(int i=0; i<N; i++){
		if(i != index) sum += L[i];
	}
	
	
	
	if(sum > max) {cout << "Yes" << endl;}
	else {cout << "No" << endl;}
	
	
	return 0;
}

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

inline int sgn(int n){
  int ans= (n==0) ? 0
                  : n/abs(n);
  return ans;
}

int main(){
  int N;
  cin >> N;
  
  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int ans= 0;
  int ref= 0;
  for(int left=0; left<N;){
    while(ref+1 < N && sgn(data.at(ref+1)- data.at(ref))==0){
      ref++;
    }
    int right= ref;
    while(right+1 < N && sgn(data.at(right+1)- data.at(right))* sgn(data.at(ref+1)- data.at(ref)) >= 0){
      right++;
    }

    ans++;
    left= right+ 1;
    ref = right+ 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3788
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int a = sc.nextInt();
   int b = sc.nextInt();
 
   if(a<=b) System.out.println(a);
   else System.out.println(a-1);
 }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstring>
#include<string>
using namespace std;

int n, m, MOD = 1000000007;
string s[60];
int dp[51][51][21][27];

int solve(int l, int r, int p, int c){
	if(l == r || (l+1 == r && s[l].size() == p && !c)) return 1;
	if(s[l].size() == p){
		if(c) return 0;
		else if(l+1 == r) return 1;
		else if(l+1 < r && s[l+1].size() > p) return solve(l+1, r, p, c);
	}
	if(c >= 26) return 0;
	int &res = dp[l][r][p][c];
	if(res != -1) return res;
	res = 0;
	for(int i=l;i<=r;i++){
		res = (res + (long long)solve(l, i, p+1, 0) * solve(i, r, p, c+1)) % MOD;
		if(s[i].size() <= p || (s[i][p] != '?' && s[i][p] != 'a' + c)) break;
	}
	return res;
}

int main(){
	memset(dp, -1, sizeof(dp));
	cin >> n;
	for(int i=0;i<n;i++) cin >> s[i];
	cout << solve(0, n, 0, 0) << endl;
	return 0;
}

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

typedef long long ll;

ll  xorw2(ll x) {
	if (x < 0) return 0;
	ll y = 0;
	if ((x%4)== 1 || (x%4)==2)
		y = 1;
	ll m = 2;
	for (int i = 0; i < 40; ++i) {
		if (((x & m) != 0)&&((x % 2) == 0))
			y |= m;

		m <<= 1;
	}

	return y;
}

ll  xorworld(ll x) {
	if (x < 0) return 0;
	switch (x%4) {
		case 0: return x;
		case 1: return 1;
		case 2: return x | 1;
		case 3: return 0;
	}
}
int main() {
	ll a, b;

	cin >> a >> b;
	// cout << (xorworld(b) ^ xorworld(a-1)) << endl;
	cout << (xorw2(b) ^ xorw2(a-1)) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, a, b, h);
  print((a + b) * h / 2);
}


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

struct Node {
  int value = -1;
  Node *parent = NULL;
  Node *left = NULL;
  Node *right = NULL;
};

Node *tree;

Node *find(Node *node, int p) {
  if (node == NULL) {
    return NULL;
  } else if (node->value == p) {
    return node;
  } else if (node->value < p) {
    return find(node->right, p);
  } else {
    return find(node->left, p);
  }
}

Node *successor(Node *node) {
  node = node->right;
  while (node->left != NULL) {
    node = node->left;
  }
  return node;
}

void remove(Node *node) {
  if (node->left == NULL && node->right == NULL) {
    if (node->parent->right == node) {
      node->parent->right = NULL;
    } else {
      node->parent->left = NULL;
    }
    free(node);
  } else if (node->left == NULL) {
    if (node->parent->right == node) {
      node->parent->right = node->right;
    } else {
      node->parent->left = node->right;
    }
    node->right->parent = node->parent;
    free(node);
  } else if (node->right == NULL) {
    if (node->parent->right == node) {
      node->parent->right = node->left;
    } else {
      node->parent->left = node->left;
    }
    node->left->parent = node->parent;
    free(node);
  } else {
    Node *y = successor(node);
    node->value = y->value;
    remove(y);
  }
}

void insert(Node *node) {
  if (tree == NULL) {
    tree = node;
    return;
  }

  Node* y = NULL;
  Node* x = tree;

  while (x != NULL) {
    y = x;
    if (node->value < x->value) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  node->parent = y;

  if (y == NULL) {
    tree = node;
  } else if (node->value < y->value) {
    y->left = node;
  } else {
    y->right = node;
  }
}

void postorder(Node* node) {
  if (node == NULL) return;
  postorder(node->left);
  postorder(node->right);
  cout << " " << node->value;
}

void inorder(Node* node) {
  if (node == NULL) return;
  inorder(node->left);
  cout << " " << node->value;
  inorder(node->right);
}

void preorder(Node* node) {
  if (node == NULL) return;
  cout << " " << node->value;
  preorder(node->left);
  preorder(node->right);
}

int main() {
  int N; cin >> N;
  string queue;
  int p;

  for (int i = 0; i < N; i++) {
    cin >> queue;
    if (queue == "insert") {
      cin >> p;
      Node *n = new Node();
      n->value = p;
      insert(n);
    } else if (queue == "find") {
      cin >> p;
      cout << (find(tree, p) != NULL ? "yes" : "no") << endl;
    } else if (queue == "delete") {
      cin >> p;
      Node *n = find(tree, p);
      remove(n);
    } else if (queue == "print") {
      inorder(tree);
      cout<<endl;
      preorder(tree);
      cout<<endl;
    }
  }
}




Measured memory_bytes: 21892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n;cin>>n;
    bool ans=true;
    vector<ll> v(n);
    rep(i,n)cin>>v[i];
    v[0]--;

    for(int i=1;i < n;i++)
    {
        if(v[i-1]<v[i]){
            v[i]--;
        }
    }

    for(int i=0;i < n-1;i++)
    {
        if(v[i]>v[i+1])ans=false;
    }

    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
	
	public class Main {
	
		public static void main(String[] args) {
			execute18_1();
		}
		
		private static void execute18_1() {
			try 
			(Scanner sc = new Scanner(System.in)) {
				int n = sc.nextInt();
				long[] t= new long[n];
				
				for(int i=0;i<n;i++) {
					t[i] = sc.nextLong();
				}
				
				long ans=t[0];
				
				for(int i=1;i<n;i++) {
					ans=lcm2(ans, t[i]);
				}
				
			System.out.println(ans);
			}
		}
		
		private static long gcd2(long a, long b) {
	        if (b == 0) return a;
	        return gcd2(b, a % b);
	    }
		
		private static long lcm2(long m, long n) {
	        return m / gcd2(m, n) * n;
	    }
    }

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

int main(){
	int n;
	cin >> n;
	
	for(int i = 1; i <= 9; ++i){
	  for(int j = 1; j <= 9; ++j){
	    if(i*j == n){
	      cout << "Yes" << endl;
	      return 0;
	    }
	  }
	}
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
ll a[3];
int k;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 3) cin >> a[i];
  cin >> k;
  sort(a, a+3);
  cout << a[0] + a[1] + (a[2]<<k) << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: i32 = iter.next().unwrap().parse().unwrap();
    let q: usize = iter.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..q)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();
    let mut b = vec![0; n];
    for x in a {
        b[x - 1] += 1;
    }
    for i in 0..n {
        println!("{}", if (k + b[i] - q as i32) > 0 { "Yes" } else { "No " });
    }
}


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

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

    int d[n];
    for(int i=0;i<n;i++)    cin >> d[i];

    int x(0);
    for(int i=0;i<n-1;i++){
        if(d[i]<10){
            if(x<=0){
                cout << "no" << endl;
                return 0;
            }
        }

        x--;
        if(x<=d[i]/10-1){
            x = d[i]/10-1;
        }
    }

    x = 0;
    for(int i=n-1;i>0;i--){
        if(d[i]<10){
            if(x<=0){
                cout << "no" << endl;
                return 0;
            }
        }

        x--;
        if(x<=d[i]/10-1){
            x = d[i]/10-1;
        }
    }

    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 4304