akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t s;
  cin >> s;
  int64_t k = s;
  int64_t cnt = 1;
  while(!(k == 1 || k == 2 || k == 4)){
    if(k % 2 == 0){
      k = k / 2;
    }else{
      k = 3*k + 1;
    }
    cnt++;
    //cout << k << "<";
  }
  cout << cnt+3 << endl;
      
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    cin>>N;
    vec c(N-1), s(N-1), f(N-1);
    rep(i,N-1){
        cin>>c[i]>>s[i]>>f[i];
    }
    rep(i,N-1){
        ll time = 0;
        reps(j,i,N-1){
            if(time < s[j]){
                time = s[j] + c[j];
            }else{
                while(time%f[j] != 0) ++time;
                time += c[j];
            }
            //cout<<i<<' '<<j<<' '<<time<<endl;
        }
        cout<<time<<endl;
    }
    cout<<0<<endl;
}

Measured memory_bytes: 256
from collections import deque
def vec(ap):
    query = list(map(int, input().split()))
    if query[0] == 0:
        if query[1] == 0:
            ap.appendleft(query[2])
        elif query[1] == 1:
            ap.append(query[2])
            
    elif query[0] == 1:
        print(ap[query[1]])
        
    elif query[0] == 2:
        if query[1] == 0:
            ap.popleft()
        elif query[1] == 1:
            ap.pop()

x = []
ap = deque()
input_num = int(input())
for a in range(input_num):
    vec(ap)


Measured memory_bytes: 21988
using System;
class p0002
{
    static void Main(string[] args)
    {
        string s;
        while ( (s = Console.ReadLine()) !=null)
        {
            var x = s.Split(' ');
            Console.WriteLine(
                (int.Parse(x[0]) + int.Parse(x[1])).ToString().Length);
        }
       
    }
}

Measured memory_bytes: 5580
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.Char

readInt = readLn :: IO Int
readInts = map read . words <$> getLine :: IO [Int]
cond t f c = if c then t else f
-- end of templete

f n = length . filter (==n) . foldr (<*>) [0..9] . flip replicate fs $ 3
  where
    fs = map (+) [0..9]

main = map read . words <$> getContents >>= mapM_ (print . f)

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

int mp[111][111];
int d[111][111];
int w, h;
int dy[6] = {0, 0, 1, 1, -1, -1,};
int dx[2][6] = {{-1, 1, 0, -1, 0, -1}, {1, -1, 1, 0, 1, 0}};
int cnt;

void dfs(int x, int y){
  d[y][x] = 1;
  for(int i = 0; i < 6; i++){
    int nx = x + dx[y%2][i], ny = y + dy[i];
    // cout << nx << "  " << ny << endl;
    if(nx >= 0 && nx <= w+1 && ny >= 0 && ny <= h+1 && d[ny][nx] == 0){
      if(mp[ny][nx] == 0) dfs(nx, ny);
      else cnt++;

    }
  }
}

int main(){
  cin >> w >> h;

  memset(d,0,sizeof(d));

  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      cin >> mp[i][j];
    }
  }
  dfs(0,0);
  //
  // for(int i = 1; i <= h; i++){
  //   for(int j = 1; j <= w; j++){
  //     cout << mp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  //

  cout << cnt << endl;

}

Measured memory_bytes: 1504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  string S,T; cin>>S>>T;
  vector<int> c1(26,0), c2(26,0);
  rep(i,S.length()) c1[S[i]-'a']++;
  rep(i,T.length()) c2[T[i]-'a']++;
  sort(c1.begin(),c1.end());
  sort(c2.begin(),c2.end());
  if(c1==c2) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int x, n;
  cin >> x >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s.emplace(a);
  }
  for (int i = 0; i <= 1000; i++) {
    if (s.count(x - i) == 0) {
      cout << x - i << "\n";
      return 0;
    } else if (s.count(x + i) == 0) {
      cout << x + i << "\n";
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map> 

int main(void){
    long long N, M, A[100005], x, i;
    scanf("%lld%lld", &N, &M);
    for (i=0; i<N; i++) {
        scanf("%lld", &A[i]);
    }
    
    while (M>0) {
        //if (M!=3) break;
        
        for (i=0; i<N; i++) A[i]*=-1;
            std::sort(A, A+N);
        for (i=0; i<N; i++) A[i]*=-1;
        
        i=0;
        x=A[0];
        while (A[i]>=x/2 && M>0) {
            A[i]/=2;
            i++;
            M--;
            //printf("[]");
        }
    }
    
    x=0;
    for (i=0; i<N; i++) {
        x+=A[i];
        // printf("%lld, ", A[i]);
    }
    printf("%lld", x);
    return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   long f(long x) {
      if( x % 2 == 1 ) return 0;
      if( x % 4 != 0 and x % 2 == 0 ) return 1;
      if( x % 4 == 0 ) return 2;
      assert(0);
      return 0;
   }
   void solve() {
      long n; scan(n);
      LI xs(n); for(long &x : xs) scan(x);
      long as[3] = {};
      for(long x : xs) {
         as[f(x)] += 1;
      }
      long last = 2;
      for(long i = 0; i < n; ++i) {
         bool done = false;
         for(long k = 0; k < 3; ++k) {
            if( last + k >= 2 and as[k] > 0 ) {
               as[k] -= 1;
               last = k;
               done = true;
               break;
            }
         }
         if( not done ) {
            puts("No"); return;
         }
      }
      puts("Yes");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 1024
while True:
    (n, x) =  [int(i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    for a in range(1, n+1):
        for b in range(a+1, n+1):
            for c in range(b+1, n+1):
                if (a + b + c) == x:
                    count += 1
    print(count)

Measured memory_bytes: 6728
/**
 *   created: 16 November 2019  10:01:14
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		string s;
		cin>>s;
		string res="";
		res += s[0];
		int ind =1;
		while(ind<n){
			while(ind<n && s[ind]==s[ind-1])
				ind++;
			// trace2(ind,s[ind]);
			if(ind<n)
				res += s[ind];
			ind++;

			// trace1(res);
		}
		cout<<res.size();
	}
	return 0;
}


Measured memory_bytes: 592
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_money = 2500;
const int max_n = 100;
int N,M,S;
using pll = pair<Int,Int>;
using Edge = pair<int,pll>;

vector<Int> C,D;
vector<Edge> G[max_n];

int main(void) {
    cin>>N>>M>>S;

    for(int i = 0;i < M;i++) {
        Int u,v,a,b;
        cin>>u>>v>>a>>b;
        u--;
        v--;
        G[u].push_back(Edge(v,pll(a,b))); //node, money, time
        G[v].push_back(Edge(u,pll(a,b)));
    }

    for(int i = 0;i < N;i++) {
        Int c,d;
        cin>>c>>d;
        C.push_back(c);
        D.push_back(d);
    }

    Int inf = 1LL<<60;
    S = min(S,max_money);
    vector<vector<Int>> dp(N+1, vector<Int>(max_money+1, inf));
    priority_queue<pair<Int,pll>, vector<pair<Int,pll>>,greater<pair<Int,pll>>> que;
    dp[0][S] = 0;
    que.push(make_pair(0,pll(0,S))); //time, node, money
    while(!que.empty()) {
        auto p = que.top();que.pop();

        Int time = p.first;
        int v = p.second.first;
        Int s = p.second.second;
        if(time > dp[v][s])
            continue;

        if(s + C[v] <= max_money) {
            Int ns = s+C[v];
            Int ntime = time+D[v];
            if(dp[v][ns] > ntime) {
                dp[v][ns] = ntime;
                que.push(make_pair(ntime,pll(v,ns)));
            }
        }


        for(auto e: G[v]) {
            if(s < e.second.first)
                continue;
            int nv = e.first;
            Int ns = s-e.second.first;
            Int ntime = time+e.second.second;
            if(dp[nv][ns] > ntime) {
                dp[nv][ns] = ntime;
                que.push(make_pair(ntime,pll(nv,ns)));
            }
        }
    }

    for(int v = 1;v < N;v++) {
        Int res = inf;
        for(int s = 0;s <= max_money;s++) {
            res = min(res,dp[v][s]);
        }
        cout<<res<<endl;
    }

    return 0;
}


Measured memory_bytes: 6864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const int MAX_N = 2e5;
int par[MAX_N];//親
int pank[MAX_N];//木の深さ

//n要素で初期化
void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        pank[i]=0;
    }
}

//木の根を求める
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x==y)return;
    if(pank[x]<pank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(pank[x]==pank[y])pank[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}
int main(void){
   ll n,m;cin>>n>>m;
   init(n);
   rep(i,m){
       ll x,y,z;cin>>x>>y>>z;x--;y--;
       unite(x,y);
   }
   ll res=0;
   rep(i,n){
       ll roo=find(i);
       if(i==roo)res++;
   }
   cout<<res<<endl;
}

Measured memory_bytes: 4372
#include <iostream>

int main() {

    int w, h, x, y, r;
    std::cin >> w >> h >> x >> y >> r;

    r <= x && x <= w - r && r <= y && y <= h - r

    ? std::cout << "Yes" << std::endl
    : std::cout <<  "No" << std::endl ;

    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
	int p,q,r;
	cin>>p>>q>>r;
	if(p>q)
	{
		if(p>r)
			cout<<q+r;
		else
			cout<<p+q;
	}
	else
	{
		if(q>r)
			cout<<p+r;
		else
			cout<<p+q;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    e = [[] for _ in range(n)]
    for _ in range(m):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)

    s, t = ns()
    s, t = s - 1, t - 1

    visited = [[True] * 3 for _ in range(n)]

    que = collections.deque()
    que.append([0, s])
    visited[s][0] = False
    cnt = 0
    ans = -1
    flg = True

    while que and flg:
        cnt += 1
        for _ in range(len(que)):
            i, q = que.popleft()
            for ei in e[q]:
                tmp = (i + 1) % 3
                if tmp == 0 and ei == t:
                    ans = cnt // 3
                    flg = False
                    break
                elif visited[ei][tmp]:
                    visited[ei][tmp] = False
                    que.append([tmp, ei])

    print(ans)


if __name__ == '__main__':
    main()


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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	while(1){
		int n, a, b, c, x;
		vector<int> stop;
		cin >> n >> a >> b >> c >> x;
		if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0) break;

		for(int i=0; i<n; i++){
			int t;
			cin >> t;
			stop.pb(t);
		}

		int now = 0;
		int ans = 0;
		int i;
		if(x == stop[now]){
			now++;
			if(now == n){
				ans = 0;
				cout << ans << endl;
				continue;
			}
		}
		for(i=1; i<=10000; i++){
			x = (a*x + b) % c;

			if(x == stop[now]){
				now++;
				if(now == n){
					ans = i;
					break;
				}
			}
			
		}
		if(i > 10000){
			cout << "-1" << endl;
		}else{
			cout << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N = 100005;
const int mod = 1e9 + 7;
int n, m;
bool a[N];
LL dp[N];

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

    cin >> n >> m;
    REP(i, m) {
        int j; cin >> j;
        a[j] = true;
    }

    dp[0] = 1;
    REP1(i, 1, n) {
        if(a[i]) continue;
        if(i-1>=0 && !a[i-1]) dp[i] = (dp[i] + dp[i-1]) % mod;
        if(i-2>=0 && !a[i-2]) dp[i] = (dp[i] + dp[i-2]) % mod;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
// const long long INF = 1LL << 60;
int INF = 10000;
using namespace std;

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

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  int ans[5000] = {};
  repi(i, 1, n)
  {
    repi(j, i+1, n+1) {
      int cost = min(j - i, abs(x - i) + 1 + abs(y - j));
      ans[cost]++;
    }
  }

  repi(i, 1, n)
  {
    cout << ans[i] << endl;
  }
  return 0;
}

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

int main()
{
    string S; 
    cin >> S;
    int f = 0;
    for(int i = 0; i < S.size(); i++)
    {
        if((i + 1) % 2 == 0 && S.at(i) == 'R')  f++;
        if((i + 1) % 2 == 1 && S.at(i) == 'L')  f++;
    }
    
    if(f == 0)  cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/* Press F to pay respects */
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey baitch!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;
struct seg_tree 
{

    vector<int> bit;
    vector<int> a;
    int n;
    seg_tree(int n) {
    	this-> n = n;
    	bit.assign(4*n+1,0);
    }
    seg_tree(vector<int> a) : seg_tree(a.size())
    {
    	this-> a = a;
    	build(0,0,(int)a.size()-1);
    }
	int merge(int x, int y) {
		// Function to return 
		return max(x,y);
	}
	void build(int node, int start, int end)
	{
		if(start == end)
		{
			bit[node] = a[start];
			return;
		}
		int lch = 2*node+1;		//Left Child
		int rch = 2*node+2;		//Right Child
		int mid = (start+end)/2;
		build(lch,start,mid);
		build(rch,mid+1,end);
		bit[node] = merge(bit[lch],bit[rch]);
		return;	
	}
	void update(int node, int start, int end, int pos, int val)
	{	
		if(start==end)
		{
			bit[node] = val;
			return;
		}
		int mid = (start + end)/ 2;
		int lch = 2*node + 1;
		int rch = 2*node + 2;
		if(pos<=mid)
			update(lch,start,mid,pos,val);
		else
			update(rch,mid+1,end,pos,val);
		bit[node] = merge(bit[lch],bit[rch]);
	}
	int query(int node,int start,int end, int l, int r)
	{
		if(l>end or r<start or start>end)
			return -INF;
		if(l<=start and r>=end)
			return bit[node];
		int lch = 2*node+1;		//Left Child
		int rch = 2*node+2;		//Right Child
		int mid = (start+end)/2;
		return merge(query(lch,start,mid,l,r),query(rch,mid+1,end,l,r));
	}
};
int32_t main()
{
	SYNC
	int n; cin >> n;
	vi h(n),a(n);
	for(auto &it : h)	cin >> it;
	for(auto &it : a)	cin >> it;
	for(auto &it : h)	it--;
	vi v(n,0);
	v[h[0]] = a[0];
	seg_tree sg(v);
	//cout << sg.query(0,0,n-1,0,n-1);
	for(int i = 1; i < n; i++) {
		int mx = sg.query(0,0,n-1,0,h[i]-1);
		mx = max(0LL,mx);
		a[i] += mx;
		sg.update(0,0,n-1,h[i],a[i]);
	}
	cout << sg.query(0,0,n-1,0,n-1);
    return 0;
}

Measured memory_bytes: 14336
using System;
using System.Collections.Generic;

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{

	int n;
  	int[] a, b;
	
    public void AtCoder(){
        string[] input;
		input = Console.ReadLine().Split(' ');
		n = int.Parse(input[0]);
      	a = new int[n+1];
      	b = new int[n];
      	input = Console.ReadLine().Split(' ');
		for (int i=0; i<n+1; i++) a[i] = int.Parse(input[i]);
      	input = Console.ReadLine().Split(' ');
		for (int i=0; i<n; i++) b[i] = int.Parse(input[i]);
        
        long ans = 0;
        for (int i=0; i<n; i++) {
          ans += Math.Min(a[i], b[i]);
          b[i] = Math.Max(b[i] - a[i], 0);
          ans += Math.Min(a[i+1], b[i]);
          a[i+1] = Math.Max(a[i+1] - b[i], 0);
        }
        
        Console.WriteLine(ans);
    }
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}


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

int main(){
  long long n,m,v,p,i;
  cin >> n >> m >> v >> p;
  vector<long long> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  long long s;
  s=n-1;
  while(a.at(s)+m<a.at(p-1)){
    s--;
  }
  s++;
  
  long long t,V;
  V=n*m;
  t=p-1;
  while(V>=m*v&&t<s){
    t++;
    if(t==n){
      break;
    }
    V=V-(a.at(t-1)-a.at(t))*(t-p+1);
  }
  
  cout << t << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
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 (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n,x,d;
    cin>>n>>x>>d;

    if(d==0) {
        cout<<(x==0 ? 1 : n+1)<<endl;
        return 0;
    }

    map<ll, vector<pair<ll,ll>>> mp;
    for(ll k = 0; k <= n; k++) {
        ll l=k*(k-1)/2;
        ll r=k*(2*n-k-1)/2;
        ll c=k*x+d*l;

        mp[(c+(d<<30))%d].emplace_back((c-(c+(d<<30))%d)/d,1);
        mp[(c+(d<<30))%d].emplace_back((c-(c+(d<<30))%d)/d+r-l+1,-1);
    }

    ll ans=0;
    for(auto vv:mp) {
        auto ev=vv.second;
        sort(all(ev));
        ll cnt=0,pre=-LINF;
        for(auto p:ev) {
            if(cnt>0) ans+=p.first-pre;
            cnt+=p.second;
            pre=p.first;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c,k,ans=0;
  cin>>n>>c>>k;
  vector<int>v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v.begin(),v.end());
  for(auto it=v.cbegin();it!=v.cend();){
    int x=*it;
    for(int i=0;*it<=x+k&&i<c&&it!=v.cend();++i)++it;
    ans++;
  }
  cout<<ans;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    vector<int> x(3);
    cin >> x.at(0);
    cin >> x.at(1);
    cin >> x.at(2);
    sort(all(x));
    cout << x.at(0) * x.at(1) / 2 << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <cstring>

#define ll long long
#define ld long double
#define HS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 0x3f3f3f3f3f3f3f3f
#define point complex <double> 
#define pi acos(-1)
#define mod 1000000007


using namespace std;
ll arr[200005],brr[200005];


int main() {
	HS
		int n;
	cin >> n;
	for (int i = 0; i < n+1; i++)
		cin >> arr[i];
	for (int i = 0; i < n; i++)
		cin >> brr[i];
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		
		if (arr[i] <= brr[i])
		{
			ans += arr[i];
			brr[i] -= arr[i];
		}
		else
		{
			ans += brr[i];
			brr[i] = 0;
		}
		if (brr[i] && arr[i + 1] - brr[i] >= 0)
		{
			ans += brr[i];
			arr[i + 1] -= brr[i];
			brr[i] = 0;
		}
		else if (brr[i] && arr[i + 1] - brr[i] < 0)
			ans += arr[i + 1], arr[i + 1] = 0;
		//cout << arr[i] << " " << brr[i] << " " << ans << endl;

	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    int N, Y;
    scanf("%d %d", &N, &Y);
    bool flg = false;
    int x, y, z;
    for (int i = 0; i <= min(2000, N); i++) {
        for (int j = 0; j <= min(4000, N); j++) {
            int m = 10000 * i + 5000 * j + 1000 * (N - i - j);
            if (i + j <= N && m == Y) {
                flg = true;
                x = i;
                y = j;
                z = N - i - j;
            }
        }
    }
    if (flg) printf("%d %d %d\n", x, y, z);
    else printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    X, Y, Z, K = map(int, input().split())
    A = sorted(map(int, input().split()), reverse=True)
    B = sorted(map(int, input().split()), reverse=True)
    C = sorted(map(int, input().split()), reverse=True)
    h = []
    for i in A:
        for j in B:
            if len(h) < K:
                heappush(h, i + j)
            elif h[0] < i + j:
                heappush(h, i + j)
                heappop(h)
    AB = h[:]
    AB.sort(reverse=True)
    h = []
    for i in AB:
        for j in C:
            if len(h) < K:
                heappush(h, i + j)
            elif h[0] < i + j:
                heappush(h,i + j)
                heappop(h)
    ABC = h[:]
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])

main()


Measured memory_bytes: 83544
A, B, AB, X, Y = map(int, input().split())
res = 0
if A + B > 2 * AB:
  res += min(X, Y) * AB * 2
  m = min(X, Y)
  X -= m
  Y -= m
if A > 2 * AB and X > 0:
  res += X * AB * 2
  X -= X
  Y -= X
if B > 2 * AB and Y > 0:
  res += Y * AB * 2
  X -= Y
  Y -= Y
print(res + max(0, X * A) + max(0, Y * B))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

const int MAXC = 1e3 * 5 + 5;
const int MOD = 1e9 + 7;
const int MAXN = 2 * 1e5 + 10;

struct point
{
    int x, y;

    bool operator<(point other)const
    {
        return x < other.x || (x == other.x && y < other.y);
    }
};

int n, m, c;
point a[MAXC];
int fact[MAXN];

int mul(int f, int s)
{
    long long temp = 1LL * f * s;
    temp %= MOD;
    return temp;
}

void read_input()
{
    scanf("%d %d %d", &n, &m, &c);

    for(int i = 0; i < c; i++)
    {
        scanf("%d %d", &a[i].y, &a[i].x);
    }

    fact[0] = 1;
    fact[1] = 1;
    for(int i = 2; i <= n + m; i++)
    {
        fact[i] = mul(i, fact[i - 1]);
    }

    sort(a, a + c);
}

int power(int x, int y)
{
    int index = 0;
    int temp = x;
    int ans = 1;
    while((1 << index) <= y)
    {
        if(((1 << index) & y))
        {
            ans = mul(ans, temp);
        }
        index++;
        temp = mul(temp, temp);
    }
    return ans;
}

int T[MAXC];

int inv(int x)
{
    return power(x, MOD - 2);
}

int comb(int N, int K)
{
    return mul(mul(fact[N], inv(fact[K])), inv(fact[N - K]));
}

int sub(int f, int s)
{
    f -= s;
    if(f < 0) f += MOD;
    return f;
}

map <pair<int,int>, bool> block;

void solve()
{
    int cnt = comb(n + m - 2, m - 1);
    //int cnt = comb(n + m - 2, n - 1);
    //printf("%d\n", cnt);

    for(int i = 0; i < c; i++)
    {
        int tempF = comb(a[i].x + a[i].y - 2, a[i].y - 1);
        //printf("%d %d %d\n", a[i].y, a[i].x, temp);
        //printf("%d %d %d\n", a[i].y, a[i].x, temp);
        for(int j = 0; j < i; j++)
        {
            if(a[j].y <= a[i].y)
            {
                int tempS = comb(a[i].x + a[i].y - a[j].x - a[j].y, a[i].x - a[j].x);
                tempS = mul(tempS, T[j]);
                tempF = sub(tempF, tempS);
            }
        }
        int temp = mul(tempF, comb(m - a[i].x + n - a[i].y, m - a[i].x));
        T[i] = tempF;
        //printf("%d\n", temp);
        cnt = sub(cnt, temp);
    }
    printf("%d\n", cnt);
}

int main()
{
    read_input();
    solve();

    return 0;
}

/*
5 7 4
1 2
3 2
5 3
4 5
210
*/


/*
5 7 3
5 6
4 7
4 6
*/


Measured memory_bytes: 1024
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int h,w;
char buf[505][505];
int main(){
  cin>>h>>w;
  REP(i,h){
    scanf("%s",buf[i]);
  }

  {
    string sh(w,'#');
    sh[w-1]='.';
    REP(i,h){
      buf[i][0]='#';
      buf[i][w-1]='.';
      printf("%s\n",i&1?sh.c_str():buf[i]);
    }
  }
  puts("");
  {
    string sh(w,'#');
    sh[0]='.';
    REP(i,h){
      buf[i][0]='.';
      buf[i][w-1]='#';
      printf("%s\n",(i&1)==0?sh.c_str():buf[i]);
    }
  }


  return 0;
}





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

using namespace std;

void solve() {
    long long x, ans;
    cin >> x;
    if (x <= 6) {
        ans = 1;
    } else if (x <= 11) {
        ans = 2;
    } else if (x % 11 == 0) {
        ans = 2 * (x / 11);
    } else {
        ans = 2 * (x / 11) + (x % 11 > 6 ? 2 : 1);
    }
    cout << ans;

}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 3164
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int a, b;
  sc.scan(a, b);
  string aS = to!string(a);
  string bS = to!string(b);

  string abS = aS ~ bS;

  int ab = to!int(abS);

  int i = 1;
  while (i * i <= ab) {
    if (i * i == ab) {
      writeln("Yes");
      return;
    }
    i++;
  }

  writeln("No");
}


Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    x, y = IS().split()
    if x < y:
        print('<')
    elif x > y:
        print('>')
    else:
        print('=')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>

long long int count_tuple(long long int count) {
	return count * (count - 1) * (count - 2) +
		count * (count - 1) * 3 +
		count;
}
int main() {
	int n, k; std::cin >> n >> k;
	if (k % 2 == 0) {
		std::cout << count_tuple(n / k) + count_tuple((n + k / 2) / k) << std::endl;
	}
	else {
		std::cout << count_tuple(n / k) << std::endl;
	}
}


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

int main()
{
	char _ch;
	int ch[26]={};

	while(cin >> _ch){
		if(_ch >= 'a' && _ch <= 'z'){
			++ch[_ch - 97];
		}
		if(_ch >= 'A' && _ch <= 'Z'){
			++ch[_ch - 65];
		}
	}

	for(char i='a';i<='z';++i){
		cout << i << " : " << ch[i-97] << endl;
	}

	return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
#define Mod 1000000007
int main() {
  int n, m, a, t=0,s=0;
  scanf("%d %d", &n, &m);
  vector<int> v(m+1);
  rep(i,m)
  {
    scanf("%d", &a);
    v[s++]=a-t;
    t=a+1;
  }
  v[s++]=n+1-t;
  sort(v.begin(),v.end());
  if(v[0]){
     ll f[max(3,v[m])]={1,1,2};
     for (int i = 3; i < v[m]; ++i){
        f[i]=f[i-1]+f[i-2];
        if(f[i]>Mod)
          f[i]-=Mod; 
     }
     ll ans=1;
     rep(i,m+1)
       ans=(ans*f[v[i]-1])%Mod;
     cout << ans;
  }else
    cout<<0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	string n;
	cin >> n;
	int counter = 0;
	for (int i = 0; i < 4; i++) {
		if (n.at(i) == '2') counter++;
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String x = scanner.next();
			String y = scanner.next();
			int compare = x.compareTo(y);
			System.out.println((compare > 0) ? ">" : (compare < 0) ? "<" : "=");
		}
	}
}


Measured memory_bytes: 23252
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int cnt = 1;
        for (int i = 0 ; i < n ; i++) cnt = Math.min(cnt + k , cnt * 2);
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val seq1 = for(i<-1 to 9) yield List(i,i,i)
  val seq2 = for(i<-1 to 7) yield List(i,i+1,i+2)

  def check(m:List[Int], count:Int,u:Int,v:Int):Boolean =
    if(m.length != count) false
    else if(count==2) { if(m.head==m.last) true else false }
    else
      (u to 8).exists(i=> check(m diff seq1(i),count-3,i+1,v)) || (0 to 6).exists(i=> check(m diff seq2(i),count-3,u,i))

  Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
    val l = line.map(_.asDigit).toList
    val m = (1 to 9).filter { i => l.count( _==i ) < 4 && check(i::l,14,0,0) }
    if(m.length>0) println(m.mkString(" ")) else println(0)
  }
}

Measured memory_bytes: 86904
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::pair;
using std::sort;
using std::vector;
using std::for_each;

int main() {
	int n;
	cin >> n;
	vector< pair<int,int> > pv(n);
	for_each(pv.begin(),pv.end(),[](pair<int,int> &_p){cin >> _p.first >> _p.second;});
	sort(pv.begin(),pv.end(),[](pair<int,int> _p1,pair<int,int> _p2){
		return _p1.first < _p2.first || (_p1.first == _p2.first && _p1.second < _p2.second);
	});
	for_each(pv.begin(),pv.end(),[](pair<int,int> _p){cout << _p.first << " " << _p.second << endl;});
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    char a; cin >> a;
    if(a == 'A') cout << 'T' << endl;
    if(a == 'T') cout << 'A' << endl;
    if(a == 'G') cout << 'C' << endl;
    if(a == 'C') cout << 'G' << endl;
}

Measured memory_bytes: 256
def CountingSort(A, k):
    C = [0]*(k+1)
    n = len(A)
    
    for a in A:
      C[a] += 1
      
    for i in range(1, k+1):
      C[i] += C[i-1]
      
    B = [0]*n
    for a in A:
      B[C[a]-1] = a
      C[a] -= 1
      
    return B
    
n = int(input())
a = list(map(int, input().split()))
ans = CountingSort(a, 10000)
print(' '.join(map(str, ans)))


Measured memory_bytes: 240328
#T=(0,0,...,0)
#に変換するためのコストの2^N倍
N=int(input())
c=sorted([int(i) for i in input().split()])
mod=10**9+7
if N==1:
    print((2*c[0])%mod)
    exit()
ans=0
for k in range(N):
    a1=pow(2,N-2,mod)
    a2=(N-k+1)
    tmp=(a1*a2)%mod
    ans+=(c[k]*tmp)%mod
    ans%=mod
    #print(k,tmp)
ans=ans*pow(2,N,mod)
ans%=mod
print(ans)


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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    bool w[31], s[3001];
    rep(i, 31) w[i] = false;
    rep(i, 3001) s[i] = false;
  	rep(i, 3001) if (s[i]) cout << i << endl;
    rep(i, 31) {
        if (i * A > F) break;
        rep(j, 31) {
            int x = i * A + j * B;
            if (x * 100 > F) break;
            w[x] = true;
        }
    }
  	//rep(i, 3001) if (s[i]) cout << i << endl;
    rep(i, 3001) {
        if (i * C > F) break;
        rep(j, 3001) {
            int x = i * C + j * D;
            if (x > F) break;
            s[x] = true;
        }
    }
  	//rep(i, 3001) if (s[i]) cout << i << endl;
    double ansx = 0;
    int ansy = 100 * A, ansz = 0;
    for (int i = F / 100; i > 0; i--) {
        if (!w[i]) continue;
        //cout << i << endl;
        for (int j = min(F - i * 100, i * E); j >= 0; j--) {
            if (!s[j]) continue;
            double p = 1.0 * j / (i * 100 + j);
            if (p <= ansx) break;
            ansx = p;
            ansy = i * 100 + j;
            ansz = j;
          	//cout << i << " " << j << endl;
            //cout << ansx << " " << ansy << " " << ansz << endl;
            break;
        }
    }
    cout << ansy << " " << ansz << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string a,b;
cin>>a>>b;
if(a.at(0)==b.at(2)&&a.at(1)==b.at(1)&&a.at(2)==b.at(0)){
    cout<<"YES"<<endl;
}else{
    cout<<"NO"<<endl;
}
}









Measured memory_bytes: 256