akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

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

signed main() {
  init();
  ll N;
  cin >> N;
  vp A(N);
  cin >> A;

  SORT(A);
  // REVERSE(A);
  ll ans = A.back().first + A.back().second;
  ANS;

  return 0;
}

Measured memory_bytes: 4720
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define INF 100000000
#define mod 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

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


int main() {
    ll n, k, i, j=0;
    cin >> n >> k;
    ll a[n], cnt[n], ans=0;
    
    for(i=0; i<n; i++)
        cin >> a[i];
    
    sort(a, a+n);
    
    
    for(i=0; i<n; i++) {
        cnt[j]=1;
        while(a[i]==a[i+1]) {
            cnt[j]++;
            i++;
        }
        j++;
    }
    
    sort(cnt, cnt+j);
    
    for(i=0; i<j-k; i++)
        ans+=cnt[i];
    cout << ans << endl;
}


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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int n;
    string s;
    cin >> n >> s;
    vector<int> cnt_r, cnt_g, cnt_b;
    rep(i, n) {
        if (s[i] == 'R') cnt_r.push_back(i);
        if (s[i] == 'G') cnt_g.push_back(i);
        if (s[i] == 'B') cnt_b.push_back(i);
    }

    ll ans = cnt_r.size() * cnt_g.size() * cnt_b.size();

    rep(i, cnt_r.size()) {
        rep(j, cnt_g.size()) {
            int r = cnt_r[i];
            int g = cnt_g[j];
            int diff = max(r, g) - min(r, g);
            if (diff % 2 == 0) {
                if (find(all(cnt_b), diff / 2 + min(r, g)) != cnt_b.end()) ans--;
            }
            if (find(all(cnt_b), diff + max(r, g)) != cnt_b.end()) ans--;
            if (find(all(cnt_b), min(r, g) - diff) != cnt_b.end()) ans--;
        }
    }

    out(ans);

    return 0;
}


Measured memory_bytes: 3696
S = input()
count = 0
kisu = ["R", "U", "D"]
dusu = ["L", "U", "D"]
H = 0

for c in S:
    count += 1
    if count % 2 == 1:
        if c in kisu:
            pass
        else:
            H = 1
    else:
        if c in dusu:
            pass
        else:
            H = 1

if H == 0:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：Breadth First Search
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_11_C
// 所要時間：30分
// 学んだこと：グラフの表現方法
// ------------------

// ----ここから本問のソースコード----
static const ll N_MAX = 110;

// グローバル変数（入力）
ll n,A[N_MAX][N_MAX];

// 入力
void input() {
  cin >> n;
}

void solve() {
  // 隣接リストを隣接行列に変換して二次元配列Aに格納
  rep(i,n){
    ll v,k;
    cin >> v >> k;
    rep(j,k){
      ll v2;
      cin >> v2;
      A[v][v2]=1;
    }
  }

  // 隣接行列を出力
  rep(i,n){
    rep(j,n){
      cout << A[i+1][j+1];
      if (j<n-1){
        cout << " ";
      } else {
        cout << endl;
      }
    }
  }
}

int main() { 
  input();
  solve();
  return 0; 
}



Measured memory_bytes: 3132
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] p = new int[m];
		ArrayList<City> city = new ArrayList<>(m);
		for (int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
			city.add(new City(i, sc.nextInt()));
		}
		city.sort(new CityComparator());
		String[] ans = new String[m];
		int[] count = new int[n];
		for (int i = 0; i < m; i++) {
			City tmp = city.get(i);
			count[p[tmp.number] - 1]++;
			ans[tmp.number] = String.format("%06d%06d",p[tmp.number], count[p[tmp.number] - 1]);
		}
		for (int i = 0; i < m; i++) {
			System.out.println(ans[i]);
		}
	}
}

class City {
	int number;
	int year;

	City(int number, int year) {
		this.number = number;
		this.year = year;
	}
}

class CityComparator implements Comparator<City> {
	@Override
	public int compare(City c1, City c2) {
		return c1.year - c2.year;
	}
}

Measured memory_bytes: 150856
l, r = map(int, input().split())
mod = 2019
frem = []
srem = []
if r - l + 1 >= 2019:
    ans = 0
else:
    for i in range(l, r+1):
        frem.append(i % mod)
    for i in range(len(frem)):
        for j in range(i+1, len(frem)):
            # print(frem[i], frem[j])
            srem.append(frem[i]*frem[j] % mod)
    srem.sort()
    ans = srem[0]

print(ans)

Measured memory_bytes: 81404
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		double weight;
		
		while(scan.hasNext()){
			weight = scan.nextDouble();
			if(weight <= 48.00){
				System.out.println("light fly");
			}else if(48.00 < weight&& weight <= 51.00){
				System.out.println("fly");
			}else if(51.00 < weight&& weight <= 54.00){
				System.out.println("bantam");
			}else if(54.00 < weight&& weight <= 57.00){
				System.out.println("feather");
			}else if(57.00 < weight&& weight <= 60.00){
				System.out.println("light");
			}else if(60.00 < weight&& weight <= 64.00){
				System.out.println("light welter");
			}else if(64.00 < weight&& weight <= 69.00){
				System.out.println("welter");
			}else if(69.00 < weight&& weight <= 75.00){
				System.out.println("light middle");
			}else if(75.00 < weight&& weight <= 81.00){
				System.out.println("middle");
			}else if(81.00 < weight&& weight <= 91.00){
				System.out.println("light heavy");
			}else{
				System.out.println("heavy");
			}
		}
		
		scan.close();
	}
}

Measured memory_bytes: 19308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
int parent[25], sibling[25], degree[25], depth[25], height[25];
vector<int> g[25];

int dfs(int curr, int d) {
  depth[curr] = d;
  int max_height = 0;
  for (int ch : g[curr]) {
    max_height = max(max_height, dfs(ch, d + 1) + 1);
  }
  return height[curr] = max_height;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  fill_n((int*)parent, 25, -1);
  fill_n((int*)sibling, 25, -1);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int id, l, r;
    cin >> id >> l >> r;
    if (l != -1) {
      g[id].emplace_back(l);
      parent[l] = id;
    }
    if (r != -1) {
      g[id].emplace_back(r);
      parent[r] = id;
    }
    if (l != -1 && r != -1) {
      sibling[l] = r;
      sibling[r] = l;
    }
    degree[id] = g[id].size();
  }
  int root = 0;
  while (parent[root] != -1) root = parent[root];
  dfs(root, 0);
  for (int i = 0; i < n; i++) {
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, parent[i], sibling[i], degree[i], depth[i], height[i]);
    if (parent[i] == -1) puts("root");
    else if (g[i].empty()) puts("leaf");
    else puts("internal node");
  }

  return 0;
}


Measured memory_bytes: 3280
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	fastio;

	int n; cin>>n;
	int a[n]; forn(i,n) cin>>a[i];

	int ans = 0;
	forsn(i,1,n){
		if(a[i] == a[i-1]){
			ans++;
			if(i == n-1) continue;
			a[i] = 1000001-a[i+1];
		}
	}
	cout<<ans<<ln;

	return 0;
}

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

int main(){
    int N, B, A;
    cin >> N >> A >> B ;

    int plan1 = N * A;
    int plan2 = B;

    if(plan1<plan2){
        cout << plan1 <<endl;
    }else if(plan1==plan2){
        cout <<  plan1 << endl;
    }else{
        cout << plan2 <<endl;   
    }

}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import itertools

def main():
    mod=10**9+7
    N,M=MI()
    adj=[[] for _ in range(N)]
    for _ in range(M):
        a,b=MI()
        a-=1
        b-=1
        adj[a].append(b)
        adj[b].append(a)
        
        
    ans=0
    for ite in itertools.permutations(range(1,N), N-1):
        v=0
        f=1
        for nv in ite:
            if nv in adj[v]:
                v=nv
            else:
                f=0
                break
        ans+=f
        
    print(ans)
        
            
    

main()


Measured memory_bytes: 39024
#include<bits/stdc++.h>
using namespace std;
int st[200005];
vector<int>v;
main()
{
	int cal=9;
    for(int i = 0;cal <= 100000;i++)
    {
        v.push_back(cal);
        cal*=9;
    }
    cal=6;
    for(int i = 0;cal <= 100000;i++)
    {
        v.push_back(cal);
        cal*=6;
    }
    v.push_back(1);
    sort(v.begin(),v.end());
    for(int i = 1;i < 200005;i++)
    {
        st[i]=1e9;
    }

    for(int i = v.size()-1;i >= 0;i--)
    {
        for(int j = 0;j < 100005;j++)
        {
            st[j+v[i]]=min(st[j+v[i]],st[j]+1);
        }
    }
    int p;
    scanf("%d",&p);
    printf("%d",st[p]);
}


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

int main(){
    string s; cin >> s;
    int max=0;
    int count=0;

    for (int i=0;i<s.size();i++){
        if (s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G') {
            count++;
            if (count > max) {
                max = count;
            }
            continue;
        }
        count = 0;
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import bisect


def main():
  input()
  values = list(map(int, input().split()))
  values.sort()
  result = 0

  for i in range(len(values) - 2):
    for j in range(i + 1, len(values) - 1):
      targets = values[j + 1:]
      index = bisect.bisect_left(targets, values[i] + values[j])
      result += index

  print(result)


if __name__ == '__main__':
  main()


Measured memory_bytes: 62192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,a,b,x;
  char s[LIMIT1];
  
  scanf("%lld %lld %lld",&a,&b,&x);
  //rep(i,n) scanf("%d",&a[i]);
  if(a<=x && x<=a+b) result=1;
  
  if(result==1) printf("YES");
  else printf("NO");
  
  return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[405];
ll dp[405][405];
ll S[405];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    memset(S, 0, sizeof(S));
    REP(i, N) {
        cin >> A[i];
        S[i] += A[i];
        S[i + 1] += S[i];
    }

    FOR(len, N, 1) {
        REP(i, N) {
            if (i + len >= N)
                break;
            dp[i][i + len] = INF;
            ll cost = S[i + len];
            if (i > 0)
                cost -= S[i - 1];
            REP(j, len) {
                dp[i][i + len] = std::min(dp[i][i + len], cost + dp[i][i + j] + dp[i + j + 1][i + len]);
            }
        }
    }

    cout << dp[0][N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main(){
	int n, i, j, k, l, C = 0;
	while (cin >> n){
		C = 0;
		for (i = 0; i < 10; i++){
			for (j = 0; j < 10; j++){
				for (k = 0; k < 10; k++){
					for (l = 0; l < 10; l++){
						if (n == i + j + k + l){
							C = C+1;
						}
					}
				}
			}
		}
		cout << C << endl;
	}
	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  int j = 0;
  for(int i = 0; i < N; ++i){
    if(A[i] < A[j]) j = i;
  }
  if(N == K){
    cout << 1 << endl;
    return 0;
  }
  int ans = 2*N;
  for(int i = 0; i < K; ++i){
    int l = max(0,j-i), r = min(N,j-i+K-1);
    //cout << l << " " << r << " " << (N-1-r+K-2)/(K-1) + (l+K-2)/(K-1) + 1 << endl;
    ans = min(ans,(N-1-r+K-2)/(K-1) + (l+K-2)/(K-1) + 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
n = int(input())
a = [int(x) for x in input().split()]

ans = True
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            ans = False
            break


if ans:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
import sys
from heapq import heappush,heappop
from collections import defaultdict
MA = 10000
def dijkstra(s,g):
    d = defaultdict(lambda : MA)
    q = [(0,s,1,0)]
    d[(s,1,0)] = 0
    while q:
        dx,x,b,day = heappop(q)
        day_ = day+1
        if eve[x] > 0:
            b = b|(1<<eve[x])
            if dx+1 < d[(s,b,0)]:
                d[(s,b,0)] = dx+1
                heappush(q,(d[(s,b,0)],s,b,0))
        if day_ <= r:
            for i in range(e):
                if (1<<i)&b:
                    for y in v[x][i]:
                        dist = dx+1
                        if dist < d[(y,b,day_)]:
                            d[(y,b,day_)] = dist
                            heappush(q,(d[(y,b,day_)],y,b,day_))
    res = MA
    for i in range(1<<e):
        for day in range(r+1):
            res = min(res,d[(g,i,day)])
    if res == MA:
        res = -1
    return res

n,m,e,s,t,r = [int(x) for x in sys.stdin.readline().split()]
v = [[[] for i in range(e+1)] for i in range(n)]
for i in range(m):
    a,b = [int(x) for x in sys.stdin.readline().split()]
    v[a][0].append(b)
    v[b][0].append(a)
eve = [0 for i in range(n)]

for i in range(e):
    a,b,c = [int(x) for x in sys.stdin.readline().split()]
    eve[c] = i+1
    v[a][i+1].append(b)
    v[b][i+1].append(a)
e += 1
print(dijkstra(s,t))



Measured memory_bytes: 20280
n ,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
total = 0
for i in a:
  total += i
ok = 0
for i in range(1, m + 1):
  if a[-i] >= total / (4 * m):
    ok += 1

if ok != m:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]

ok=10**9
ng=0

while abs(ok-ng)>1:
 mid=(ok+ng)//2

 l=[i-(mid*b) for i in h]
 cnt=0
 for j in l:
  if j<=0:
   continue
  cnt+=(j+a-b-1)//(a-b)

 if cnt<=mid:
  ok=mid
 else:
  ng=mid

print(ok)

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

#define int long long
#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)
#define print(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1> void __f(const char* name, Arg1&& arg1){
  cout << name << ": " << arg1 << '\n';
}

template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

int32_t main(){
    
    fast;
    int a,b,t; cin >> a >> b >> t;
    cout << t/a*b;
  
 
    return 0;
} 

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

int main() {
    /* Input */
    string S;
    cin >> S;
    
    /* Main Logic */   
    int ans = 0;
    if (S == "SSS") ans = 0;
    
    if (S == "RSS") ans = 1;
    if (S == "SRS") ans = 1;
    if (S == "SSR") ans = 1;

    if (S == "RRS") ans = 2;
    if (S == "SRR") ans = 2;    
    if (S == "RSR") ans = 1;
    
    if (S == "RRR") ans = 3;

    /* Output */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

main(){
  int i,b,c, A[251];

  scanf("%d", &c);

  for(i = 1; i <= c; i++) scanf("%d", &A[i]);

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



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sz 4040

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

    int b[sz],g[sz],r[sz];

    memset(b,0,sizeof b);
    memset(g,0,sizeof g);
    memset(r,0,sizeof r);

    int cntb=0,cntg=0,cntr=0;
    ll ans=0;
    for(int i=n-1;i>=0;--i){
        if(str[i]=='R') cntr++;
        else if(str[i]=='G') cntg++;
        else cntb++;

        b[i]=cntb, g[i]=cntg, r[i]=cntr;
    }

    for(int i=0;i<str.size()-2;i++){
        for(int j=i+1;j<str.size();j++){
            if(str[i]=='R' && str[j]=='G'){
                ans+=b[j];
                if(j+(j-i)<n) if(str[j+(j-i)]=='B') ans--;
            }
        }
    }
    for(int i=0;i<str.size()-2;i++){
        for(int j=i+1;j<str.size();j++){
            if(str[i]=='G' && str[j]=='R'){
                ans+=b[j];
                if(j+(j-i)<n) if(str[j+(j-i)]=='B') ans--;
            }
        }
    }
    for(int i=0;i<str.size()-2;i++){
        for(int j=i+1;j<str.size();j++){
            if(str[i]=='G' && str[j]=='B'){
                ans+=r[j];
                if(j+(j-i)<n) if(str[j+(j-i)]=='R') ans--;
            }
        }
    }
    for(int i=0;i<str.size()-2;i++){
        for(int j=i+1;j<str.size();j++){
            if(str[i]=='B' && str[j]=='G'){
                ans+=r[j];
                if(j+(j-i)<n) if(str[j+(j-i)]=='R') ans--;
            }
        }
    }

    for(int i=0;i<str.size()-2;i++){
        for(int j=i+1;j<str.size();j++){
            if(str[i]=='B' && str[j]=='R'){
                ans+=g[j];
                if(j+(j-i)<n) if(str[j+(j-i)]=='G') ans--;
            }
        }
    }
    for(int i=0;i<str.size()-2;i++){
        for(int j=i+1;j<str.size();j++){
            if(str[i]=='R' && str[j]=='B'){
                ans+=g[j];
                if(j+(j-i)<n) if(str[j+(j-i)]=='G') ans--;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

int main() {
	string s;
  	cin >> s;
  
  if(s.at(0) != s.at(1) && s.at(1) != s.at(2) && s.at(0) != s.at(2)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>/*M_PI*/
int main(void){
    double r;
    double s,l;
    scanf("%lf",&r);
    s=r*r*M_PI;
    l=r*2*M_PI;
    printf("%f %f\n",s,l);

    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  vector<ll> a,b,c;
  ll x,y,z;

  for(int i=0;i<n;i++) cin>>x,a.push_back(x);
  for(int i=0;i<n;i++) cin>>y,b.push_back(y);
  for(int i=0;i<n;i++) cin>>z,c.push_back(z);

  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  ll ans=0;
  for(int i=0;i<n;i++){
    ll it,itt;
    it=lower_bound(a.begin(),a.end(),b[i])-a.begin();
    itt=upper_bound(c.begin(),c.end(),b[i])-c.begin();
    //if(it<0||itt<0) continue;
    ans+=(it)*(n-itt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int h, w, n, res, e;
vector<pair<int,int> > p;

signed main() {
	cin >> h >> w >> n;
	p.resize(n);
	res = h;
	rep(i,n) cin >> p[i].first >> p[i].second;
	sort(all(p));
	each(i,p) {
		if (i.first==i.second+e) e++;
		else if (i.first>i.second+e) {
			res = i.first - 1;
			break;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class Program {
    static void Main(string[] args) {
        int H, N;
        Input(out H, out N);
        int[] A = new int[N];
        int[] B = new int[N];
        for(int i = 0; i < N; i++) {
            Input(out A[i], out B[i]);
        }
        int[] min = new int[H + 1];
        min[0] = 0;
        for(int i = 1; i <= H; i++) {
            int _min = 1000000000;
            for(int j = 0; j < N; j++) {
                if(i < A[j]) {
                    if(_min > B[j]) {
                        _min = B[j];
                    }
                } else {
                    if(_min > min[i - A[j]] + B[j]) {
                        _min = min[i - A[j]] + B[j];
                    }
                }
            }
            min[i] = _min;
        }
        Console.WriteLine(min[H]);
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
}

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

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

  int ans=10*10*10*10*10;
  for (int i = 1; i < n;i++)
  { 

    int a=i;
    int b=n-a;
    int sum,sum2,dig;
    while(a){
      dig=a%10;
      sum+=dig;
      a/=10;
    }
    while(b){
      dig=b%10;
      sum2+=dig;
      b/=10;
    }
    if(sum+sum2<ans){
      ans=sum+sum2;
    }
    sum=0;
    sum2=0;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, k;
ll ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> k;
    erep(b, 1, n) {
        int p = n / b, r = n % b;
        ans += p * max(0, (b-k)) + max(0, r - k + 1);
        if (k == 0) ans--;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[101][101],b[101][101];
int main()
{
    memset(a,0,sizeof(a));memset(b,0,sizeof(b));
    int n,m,flag=1;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        scanf("%s",a[i]);
    for(int i=0;i<m;i++)
        scanf("%s",b[i]);
    if(m>n){
        cout<<"No"<<endl;
        return 0;
    }
    else {
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(a[i][j]==b[0][0]){
                    flag = 0;
                    for(int x=0;x<m;x++){
                        for(int y=0;y<m;y++){
                            if(a[i+x][j+y]!=b[x][y]){
                                flag = 1;
                                break;
                            }
                        }
                    }
                    if(flag==0){
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    boolean cnt = false;
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= N; j++) {
        if (i * 4 + j * 7 == N) {
          cnt = true;
        }
      }
      if (cnt) {
        break;
      }
    }
    if (cnt) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 24020
#include <stdio.h>
#include <string.h>
 
  int i,j,k,l,m;
  int n,e,s,w,un,up;
  int a[7];
int t;
 
 
void input() {
 for(i=0;i<6;i++){
   
    scanf("%d",&a[i+1]);
   
  }
}
 
 void N() {
   t = a[1];
   a[1] = a[2];
   a[2] = a[6];
   a[6] = a[5];
   a[5] = t;
 }
 
 void S() {
   t = a[1];
   a[1] = a[5];
   a[5] = a[6];
   a[6] = a[2];
   a[2] = t;
}
 
 void E() {
   t = a[1];
   a[1] = a[4];
   a[4] = a[6];
   a[6] = a[3];
   a[3] = t;
 }
 
 void W() {
   t = a[1];
   a[1] = a[3];
   a[3] = a[6];
   a[6] = a[4];
   a[4] = t;
 }
 
int main() {
 
  input();
  //  strlen(?) 文字の長さ(数)を表示
 char str[110];  
 scanf("%s",str);
 
 for(i=0;i<strlen(str);i++) {
 
   if(str[i] == 'N') {
     N();
   } else if(str[i] == 'S') {
     S();
   } else if(str[i] == 'W') {
     W();
   } else if(str[i] == 'E') {
     E();
   }
 }
 
 printf("%d\n",a[1]);
 
 return 0;
}


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

using namespace std;

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


Measured memory_bytes: 3072
//Beta tumse na ho payega
#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 ll long long int
#define ld long double
#define int long long
#define pb push_back 
#define mod 1000000007
#define mod2 998244353
#define Z(c) (int)(c).size()
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
//#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define clber cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);(i)++)
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define pi 3.1415926536
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define FO find_by_order
#define OK order_of_key
#define tr(it,ct) for(auto &(it) : (ct))
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    baap;
 
int power(int a,int n,int lelo)
{
        if(n==0)
                return 1;
        if(n==1)
                return a;
        if(n==2)
                return (a*a)%lelo;
        if(n%2)
                return (a*power(a,n-1,lelo))%lelo;
        else
                return power(power(a,n/2,lelo),2,lelo)%lelo;
}
ld dpower(ld a,int n)
{
        if(n==0)
                return 1;
        if(n==1)
                return a;
        if(n==2)
                return (a*a);
        if(n%2)
                return (a*dpower(a,n-1));
        else
                return dpower(dpower(a,n/2),2);
}
 
 
void swap(int &a,int &b)
{ auto tm=a; a=b; b=tm; }
 
 const int N=1e5+1;   //Take care of duplicates
 const int INF=1e16;
 
 void solve()
 { 
    int n; cin>>n; vi v(n); rep(i,0,n) cin>>v[i];
    int ans=0,mx=1;
    rep(i,1,n)
    {
      if(v[i]<=v[i-1])
        mx++;
      else
      { ans=max(ans,mx);
        mx=1;
      }
    }
    ans=max(ans,mx);
    cout<<ans-1;

 } 
signed main()
{  
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
  

 
  int t=1;
   
 // cin>>t;
  rep(i,1,t+1)
  { // cout<<"Scenario #"<<i<<":\n";
   solve();
 
   if(i<t)
   cout<<nl;
  }
 
 return 0; 
}


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

using namespace std;

const int maxn = 300 + 5;
int ans;
int n, m;
int a[maxn][maxn];
int vis[maxn], cnt[maxn];
void solve(int M) {
    int res = 0, pos = 0;
    memset(cnt, 0, sizeof(cnt));
    for(int i = 1; i <= n; i++) {
        int j = 1;
        while(j <= m && vis[a[i][j]]) j++;
        cnt[a[i][j]]++;
    }
    for(int i = 1; i <= m; i++) {
        if(!vis[i] && res < cnt[i]) {
            res = cnt[i];
            pos = i;
        }
    }
    vis[pos] = 1;
    ans = min(ans, res);
    if(M > 1) solve(M - 1);
}
int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    ans = n;
    solve(m);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>


int main(){
  long long n, a, b;
  std::cin >> n >> a >> b;
  long long loop = n/(a+b);
  std::cout << loop*a+std::min(n%(a+b), a) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];

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


Measured memory_bytes: 256
#include <stdio.h>
#include <functional>
#include <algorithm>
int main(){ int mt[10], i;
for (i = 0; i < 10; i++)
scanf("%d",&mt[i]);
std::sort(mt, mt + 10);
for (i = 9; i > 6; i--)
  printf("%d\n", mt[i]);
return 0; }



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

#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

int main(){
	optimizar_io;
	int N;
	cin >> N;
	int data[N+1];
	for (int i = 1; i <= N; i++){
		int v;
		cin >> v;
		data[v] = i;
	}
	for (int i = 1; i <= N; i++){
		cout << data[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define re register
#define int long long
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int a[200002],b,c,n,ans=1000;
signed main(){
	n=read();
	for(re int i=1;i<=n;++i)a[i]=read();
	for(re int i=2;i<=n;++i)if(a[i]>a[i-1])ans=ans%a[i-1]+ans/a[i-1]*a[i];
	printf("%lld",ans);
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int from[111111];
int to[111111];
bool visited[111111];
int pare[111111];
vector<vector<P>> v(111111);

bool dfs(int now){
    //cout << "dfs " << now << endl;
    int cou = 0;
    REP(i, v[now].size()){
        int id = v[now][i].FI;
        int aite = v[now][i].SE;
        if(aite == pare[now]){
            continue;
        }

        if(pare[aite] == now){
            if(dfs(aite)){
                swap(from[id], to[id]);
            }
        }
        else if(from[id] == -1){
            from[id] = now;
            to[id] = aite;
        }
    }

    REP(i, v[now].size()){
        int id = v[now][i].FI;
        int aite = v[now][i].SE;
        if(from[id] == now){
            cou++;
        }
    }
    //cout << " " <<  now << " " << cou << endl;
    return (cou % 2 == 1);
}

void first(int now){
    //cout << "first " << now << endl;
    visited[now] = true;
    REP(i, v[now].size()){
        int id = v[now][i].FI;
        int aite = v[now][i].SE;
        if(!visited[aite]){
            pare[aite] = now;
            from[id] = now;
            to[id] = aite;
            first(aite);
        }
    }
}

int main(){

    REP(i, 111111){
        from[i] = -1;
        to[i] = -1;
        pare[i] = - 1;
    }

	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

    ll n, m;cin >> n >> m;
    REP(i, m){
        int a, b;cin >> a >> b;
        a--;b--;
        v[a].EB(i, b);
        v[b].EB(i, a);
    }

    first(0);
    //SHOW1d(pare, n);
    if(dfs(0)){
        cout << -1 << endl;
    }
    else {
        REP(i, m){
            cout << from[i] + 1 << " " << to[i] + 1 << endl;
        }
    }

	return 0;
}


Measured memory_bytes: 14848
inputs = input()

H1, M1, H2, M2, K = [int(f) for f in inputs.split(" ")]

elapsedHour = H2 - H1
elapsedMin = M2 - M1

maxStudyStartTimeLength = elapsedHour * 60 + elapsedMin - K

print(maxStudyStartTimeLength)

Measured memory_bytes: 9172
#include<stdio.h>
int main(void){
    int n;
    scanf("%d", &n);
    switch(n % 10){
        case 0:
            printf("pon");
            break;
        case 1:
            printf("pon");
            break;
        case 2:
            printf("hon");
            break;
        case 3:
            printf("bon");
            break;
        case 4:
            printf("hon");
            break;
        case 5:
            printf("hon");
            break;
        case 6:
            printf("pon");
            break;
        case 7:
            printf("hon");
            break;
        case 8:
            printf("pon");
            break;
        case 9:
            printf("hon");
            break;

    }
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, x);
  out(set({7, 5, 3}).count(x) ? "YES" : "NO");
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
const int N=2e5+7;
const int inf=1e9+7;
const int mod=1e9+7;
int n;
int a[N],bit[N];
int lowbit(int x){
    return x & (-x);
}
void add(int i, int x){
    while(i <= n){
        bit[i] += x;
        i += lowbit(i);
    }
}
int sum(int i){
    int res = 0;
    while(i > 0){
        res += bit[i];
        i -= lowbit(i);
    }
    return res;
}
int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    ll ans = 0;
    for(int i=1;i<=n;i++){
        if(sum(a[i])==0)
            ans ++;
        add(a[i], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int h,w;
    cin>>h>>w;
    vector<int> v(26,0);
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        for(auto a:s){
            v[a-'a']++;
        }
    }
    if(h%2==0&&w%2==0){
        bool flag=false;
        for(auto a:v){
            if(a%4!=0){
                flag=true;
                break;
            }
        }
        if(flag){
            cout<<"No";
        }else{
            cout<<"Yes";
        }
    }else if(h%2==0||w%2==0){
        bool flag=false;
        for(auto a:v){
            if(a%2!=0){
                flag=true;
                break;
            }
        }
        if(flag){
            cout<<"No";
        }else{
            int tmp=0;
            for(auto a:v){
                if(a%4==2){
                    tmp++;
                }
            }
            int ev;
            if(h%2==0){
                ev=h;
            }else{
                ev=w;
            }
            if(ev/2>=tmp){
                cout<<"Yes";
            }else{
                cout<<"No";
            }
        }
    }else{
        int od=0;
        int tmp=0;
        int b=(h-1)/2+(w-1)/2;
        for(auto a:v){
            if(a%2==1){
                od++;
            }
            if(a%4==2){
                tmp++;
            }
        }
        if(od!=1){
            cout<<"No";
        }else if(tmp<=b){
            cout<<"Yes";
        }else{
            cout<<"No";
        }
    }
}


Measured memory_bytes: 256