akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
inline ll LCM(ll a, ll b){return a / GCD(a, b) * b;}
inline ll powint(ll x, ll y){ll r=1;while(y){if(y&1)r*=x;x*=x;y>>=1;}return r;}
inline ll powmod(ll x, ll y, ll m = MOD){ll r=1;while(y){if(y&1)r*=x;x*=x;r%=m;x%=m;y>>=1;}return r;}
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    bool ans = 0;
    if(n % 3 == 0){
        sort(ALL(a));
        bool f1 = 1;
        bool f2 = 1;
        bool f3 = 1;
        repr(i, 0, n/3){
            if(a[i] != a[0]) f1 = 0;
        }
        repr(i, n/3, 2*n/3){
            if(a[i] != a[n/3]) f2 = 0;
        }
        repr(i, 2*n/3, n){
            if(a[i] != a[2*n/3]) f3 = 0;
        }
        if(f1 && f2 && f3 && (a[0] ^ a[n/3] ^ a[2*n/3]) == 0){
            ans = 1;
        }
    }else{
        bool f1 = 1;
        repr(i, 0, n){
            if(a[i] != 0) f1 = 0;
        }
        if(f1) ans = 1;
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//??????????????°
		double bmi;
		String [][] kiroku = new String[50][3];
		double [][] date = new double[50][3];

		//????????£????????????
		Scanner scan = new Scanner(System.in);

		//BMI??????
		int i = 0;
		int j=0;

		//????????????
		while(scan.hasNext()){
		//?¨??????????
				String str = scan.next();
				kiroku[i] = str.split(",");
				date [i][1]= Double.parseDouble(kiroku[i][1]);
				date [i][2]= Double.parseDouble(kiroku[i][2]);
			i++;

		}
		for(int x = 0 ; x < date.length ; x++){
			bmi = date[x][1] / (date[x][2] * date[x][2]);
			if(bmi >= 25){
				System.out.println(kiroku[x][0]);
			}
		}
	}
}

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

using namespace std;

int main(void)
{
    int N, M;
    cin >> N >> M;
    int pena = 0;
    int ans = 0;
    vector<bool> ac(N, false);
    vector<int> wa(N, 0);
    for(int i = 0; i < M; i++){
        string S;
        int x;
        cin >> x >> S;
        if(ac[x-1]) continue;
        if(S == "AC"){
            ac[x-1] = true;
            ans++;
            pena += wa[x-1];
        }else{
            wa[x-1]++;
        }
    }
    
    cout << ans << " " << pena << endl;
    return 0;
}

Measured memory_bytes: 640
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

string l,r;
int dp[62][2][2][2];
int a,b;
int brute(){
	int ans=0;
	rep(i,a,b+1){
		rep(j,i,b+1){
			if(j%i==(j^i)){	
				++ans;
			}
		}
	}
	return ans;
}
int go(int idx,int sm,int bg,int eq){
	if(idx==62)
		return 1;
	if(dp[idx][sm][bg][eq]!=-1){
		return dp[idx][sm][bg][eq];
	}
	int mnsm=0;
	int mxsm=0;
	if(!sm) mxsm=r[idx]-'0';
	else mxsm=1;
	int mnbg=0;
	int mxbg=1;
	if(!bg) mnbg=l[idx]-'0';
	else mnbg=0;
	int ans=0;
	//cout<<idx<<' '<<sm<<' '<<bg<<' '<<mxsm<<' '<<mnsm<<' '<<mxbg<<' '<<mnbg<<endl;
	rep(i,mnbg,mxbg+1){
		rep(j,max(i,mnsm),mxsm+1){
			int new_sm=sm;
			int new_bg=bg;
			if(!new_sm){
				new_sm=(j<mxsm);
			}
			if(!new_bg){
				new_bg=(i>mnbg);
			}
			if(eq)
			ans+=go(idx+1,new_sm,new_bg,eq);
			else{
				if(i==j){
					ans+=go(idx+1,new_sm,new_bg,(i==1 and j==1));
				}
			}		
		}
	}
	return dp[idx][sm][bg][eq] = (ans%hell);
}

void solve(){  
	cin>>a>>b;
	memset(dp,-1,sizeof dp);
	l="",r="";
	rep(i,0,62){
		l+=(((a>>i)&1)+'0');
	} 
	rep(i,0,62){
		r+=(((b>>i)&1)+'0');
	} 
	reverse(all(l));
	reverse(all(r));
	cout<<go(0,0,0,0)<<endl;
	//cout<<brute()<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, K;
  cin >> N >> K;
  vi A(N);
  i64 a;
  rep(i,N){
    cin >> a;
    a--;
    A.at(i) = a;
  }

  vi P(N,INF);
  P[0] = 0;
  i64 pre = 0;
  i64 nxt = A[0];
  i64 i = 0;
  while(P[nxt]==INF){
    P[nxt] = ++i;
    if(P[nxt]==K) {
      cout << nxt+1 << "\n";
      return;
    }
    pre = nxt;
    nxt = A[pre];
  }

  i64 p = (K-P[nxt]) % (P[pre] - P[nxt] + 1) + P[nxt];

  rep(i,N){
    if(P[i]==p){
      cout << i+1 << "\n";
      return;
    }
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  vector<int> num(110,0); //1要素の大きさは100までだが余裕を取る
  for (int i = 0; i < N; i++) {
    num.at(vec.at(i))++; //vecの要素の値がj(i <= j <= 100)ならjを1個カウントする
  }
  int ans = 0;
  for (int i = 0; i <= 100; i++) {
    if (num.at(i) > 0) ans++; //1から100までの数を調べ、少なくとも1つあればカウントする
  }
  
  cout << ans << endl;
}

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

int n;

bool is753(string &s)
{
  if (s.empty())
    return false;
  set<char> st;
  for (auto c : s)
    st.insert(c);
  int num = stoi(s);
  return (num <= n && st.size() == 3);
}

char add[] = {'3', '5', '7'};
int dfs(string &s)
{
  int sum = 0;
  sum += is753(s);
  if (s.length() == 9)
    return sum;
  for (int i = 0; i < 3; i++)
  {
    s.push_back(add[i]);
    sum += dfs(s);
    s.pop_back();
  }
  return sum;
}

int main()
{
  cin >> n;
  string s;
  cout << dfs(s) << endl;
  return 0;
}


Measured memory_bytes: 256
N,A,B,C = map(int, input().split())
l = [int(input())for i in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    # 全ての竹に対して４択の選択が完了したら、延長もしくは合成魔法で竹の調整を行う
    # n本を合成するのに必要な合成回数はn-1回なので、A,B,Cに対して1回ずつ余分に１０を足している
    # よって１０＊３を引いてあげる
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

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

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;
int f(ll a,ll b){
	int aa=0,bb=0;
	while(a>0){aa++;a/=10;}
	while(b>0){bb++;b/=10;}
	return max(aa,bb);
}
int main(){
	ll n;
	cin>>n;
	int ans=INF;
	for(ll i=1;i*i<=n;i++){
		if(n%i!=0)continue;
		ll tmp=n/i;
		ans=min(f(i,tmp),ans);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector< vector<int> > v(h+2);
    rep(i, h+2){
        v[i].resize(w+2);
    }
    rep(i, w+2){
        v[0][i] = 0;
        v[h+1][i] = 0;
    }
    rep(i, h+2){
        v[i][0] = 0;
        v[i][w+1] = 0;
    }

    reps(i, h){
        reps(j, w){
            char tmp;
            cin >> tmp;
            if(tmp == '.') v[i][j] = 0;
            else if(tmp == '#') v[i][j] = 1;
        }
    }

    reps(i, h){
        reps(j, w){
            if(v[i][j]==1){
                int f = 1;
                if(v[i+1][j]==1) f*=0;
                if(v[i-1][j]==1) f*=0;
                if(v[i][j+1]==1) f*=0;
                if(v[i][j-1]==1) f*=0;

                if(f == 1){
                    cout << "No";
                    return 0;
                }
            }
        }
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

int main(){
  int n,m;
  int t[102],h[102];
  while(scanf("%d%d",&n,&m),n | m){
  int tsum=0,hsum=0;
    rep(i,n) {scanf("%d",&t[i]); tsum+=t[i];}
    rep(i,m) {scanf("%d",&h[i]); hsum+=h[i];}
    int mama=1;
    rep(i,n){
      rep(j,m){
        if(tsum - t[i] + h[j] == hsum - h[j] + t[i] && mama){
          mama=0;
          printf("%d %d\n",t[i],h[j]);
        }
      }
    }
    if(mama) printf("-1\n");
  }


  return 0;

}

Measured memory_bytes: 3228
#include<iostream>
 
using namespace std;
 
int main(void) {
	int a;
	int b;
	int c;
	int d;
	int times;
	int timee;
	int p;
 
	cin >> a >> b >> c >> d;
	if (a > c) {
		times = a;
	}
	else {
		times = c;
	}
	if (b > d) {
		timee = d;
	}
	else {
		timee = b;
	}
	p = timee - times;
	if (p < 0) {
		cout << "0" << endl;
	}
	else {
		cout << p << endl;
	}
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i=0;i<n;i++)cin>>A[i];
    for(int i=1;i<n;i++){
        for(int k=0;k<n-1;k++)cout<<A[k]<<" ";
        cout << A[n-1] << endl;
        int v=A[i];
        int j=i-1;
        while(j>=0  && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
    A[j+1]=v;
    }
    for(int k=0;k<n-1;k++)cout<<A[k]<<" ";
    cout << A[n-1] << endl;
    return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>

int main()
{
    int matrix[100][100],i,j,input,n,m,matrix1[100],sum=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&matrix[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&matrix1[i]);
    }
    for(i=0;i<n;i++){
        sum=0;
        for(j=0;j<m;j++){
            sum+=matrix[i][j]*matrix1[j];
        }
        printf("%d\n",sum);
    }
    return 0;
}



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

const int maxn = 1e5 + 17;

int n, timer = 0, q, k;
vector < pair < int, int > > g[maxn];
int tin[maxn], tout[maxn];
int64_t d[maxn];

void dfs (int u, int p) {
  tin[u] = ++timer;
  for (auto pr: g[u]) {
    int v = pr.first, w = pr.second;
    if (v != p) {
      d[v] = d[u] + w;
      dfs(v, u);
    }
  }
  tout[u] = ++timer;
}

bool is_ancestor (int u, int v) {
  return tin[u] >= tin[v] && tout[u] <= tout[v];
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
  }
  cin >> q >> k;
  dfs(k, -1);
  for (int i = 0; i < q; ++i) {
    int u, v;
    cin >> u >> v;
    cout << d[u] + d[v] << '\n';
  }
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> brick(n);
  for(int i = 0; i < n; ++i) cin >> brick[i];
  int next = 1;
  int break_bricks = 0;
  for(int i = 0; i < n; ++i){
    if(brick[i] != next) break_bricks++;
    else next++;
  }
  cout << (next == 1 ? -1 : break_bricks) << endl;
}

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

int N;
int alice = 0;
int bob = 0;
vector<int> v_list;

//priority_queue<int,vector<int>,greater<int>> que;
priority_queue<int,vector<int>> que;

int main() {
  cin >> N;
  v_list.resize(N);
  for(int i=0;i<N;i++) {
    cin >> v_list[i];
    que.push(v_list[i]);
  }
  int cnt = 0;
  while(!que.empty()) {
    if (cnt%2==0) {
      alice += que.top();
    } else {
      bob += que.top();
    }
    ++cnt;
    que.pop();
  }
  cout << (alice-bob) << "\n";
#if 0
  while(!que.empty()) {
    printf("%d\n",que.top());
    que.pop();
  }
#endif

#if 0
  cout << N << "\n";
  for(auto s: v_list) cout << s << " "; 
  cout << "\n";
#endif
  return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

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

    int *num;
    num = new int [200010];
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        num[a-1]++;
    }

    sort(num,num+n);
    int ans = 0;
    for(int i=0;i<n-k;i++){
        ans += num[i];
    }

    cout << ans << endl;


    delete [] num;

    return 0;
}

Measured memory_bytes: 1024
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

import itertools

all_list=list(itertools.permutations(range(1,n+1)))
perm_p=all_list.index(tuple(p))
perm_q=all_list.index(tuple(q))

print(abs(perm_p-perm_q))

Measured memory_bytes: 8052
K, N = map(int, input().split())
Alist = list(map(int, input().split()))
  
#for each house, traverse clock/anti-clock wise
Alen = len(Alist)
min_distance = 10000000
for s in range(Alen):
  distance = 0
  current_p = s
  #clock-wise distance
  if (current_p == (Alen-1)):
    next_p = 0
    distance = Alist[current_p]-Alist[next_p]
  else:
    next_p = current_p+1
    distance = K-(Alist[next_p]-Alist[current_p])
  if (distance < min_distance):
    min_distance = distance
  #anti clock-wise distance
  if (current_p == 0):
    next_p = Alen-1
    distance = Alist[next_p]-Alist[current_p]
  else:
    next_p = current_p-1
    distance = K-(Alist[next_p]-Alist[current_p])
  if (distance < min_distance):
    min_distance = distance
print(min_distance)

Measured memory_bytes: 100924
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <pii> ar(n);
	int i=1;
	for(pii &x: ar){
		cin >> x.fi;
		x.sc = i++;
	}
	sort(ALL(ar));
	for(pii x: ar) cout << x.sc << " ";
	
//	cenkinamı 
//=sik /yarrak if (input) output : am


	return 0;
}

Measured memory_bytes: 1664
import math
n, m = map(int, input().split())
ans = 0
if n > 1:
    ans += math.factorial(n) // math.factorial(n - 2) // math.factorial(2)
if m > 1:
    ans += math.factorial(m) // math.factorial(m - 2) // math.factorial(2)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n,w;
    cin>>n>>w;
    vector<pair<int, int> > v;
 v.push_back(make_pair(-1,-1));
    for(int i=0;i<n;i++)
    {
        int  x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
        
    }
    vector<vector <long long  >> dp(n+1,vector<long long>(w+1));
    for(int i=1;i <=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
dp[i][j]=dp[i-1][j];
          if(j>=v[i].first) dp[i][j]=max(dp[i][j],dp[i-1][j-v[i].first]+v[i].second); 
        }
    }
   long long ans=0;
     for(int j=0;j<=w;j++){ans=max(ans,dp[n][j]);}
     cout<<ans;
    
return 0;
}


Measured memory_bytes: 80256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;  cin >> s;
    int k;  cin >> k;
    vector<string> ve;
    rep(i, s.size()) {
      FOR(j, 1, k + 1) {
        string st;
        st = s.substr(i, j);
        ve.push_back(st);
      }
    }
    sort(ve.begin(), ve.end());
    ve.erase(unique(ve.begin(), ve.end()), ve.end());
    cout << ve[k - 1] << '\n';

    return 0;
}


Measured memory_bytes: 1660
A, B, C, D = map(int, input().split())

t_kai = (A // D)
if A % D != 0:
    t_kai += 1

a_kai = (C // B)
if C % B != 0:
    a_kai += 1

if t_kai >= a_kai:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61768
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    R, G = map(int, read().split())

    print(2 * G - R)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9004
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  const double PI = acos(-1);
  int a;
  cin >> a;
  cout << a*2*PI << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int ans = 0;
   rep(i, 0, 3) {
      if (s[i] == '1') ans++;
   }
   cout << ans << endl;
   return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int point;
    int maxPoint = -1;
    int A[2][100];
    for (int i = 0; i < N; i++)
    {
        cin >> A[0][i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> A[1][i];
    }

    for (int i = 0; i < N; i++) // 曲がる場所
    {
        point = 0;
        for (int j = 0; j <= i; j++) // 1行目の和
        {
            point += A[0][j];
        }
        for (int j = i; j < N; j++) // 2行目の和
        {
            point += A[1][j];
        }
        if (point > maxPoint)
        {
            maxPoint = point;
        }
    }

    cout << maxPoint << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools

n, m = map(int, input().split())
path = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True
ans = 0

for i in itertools.permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j + 1]]:
                break

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{   int a, b, c, temp;
    scanf("%d %d %d", &a, &b, &c);
   if (a > b)
   { temp = a; a = b; b = temp;}
    if (b > c)
    {temp = b; b = c; c = temp;}
    if (a > b)
    {temp = a; a = b; b = temp;}
    printf("%d %d %d\n", a, b, c);
    return 0;
}



Measured memory_bytes: 2100
n=int(input())
c=0
a=[int(i) for i in input().split()]
for i in range(1,n-1):
    if ((a[i-1]<=a[i] and a[i]<=a[i+1]) or (a[i-1]>=a[i] and a[i]>=a[i+1])):
        c+=1
print(c)

Measured memory_bytes: 3060
from collections import deque
import sys
input = sys.stdin.readline

N = int(input())
A = []
for _ in range(N):
    # 選手番号を0-indexにする
    line = list(map(lambda x: int(x) - 1, input().split()))
    A.append(line)

# cnt[i] = 選手iが現在までに何試合したか
cnt = [0] * N
# recent[i] = 選手iが最後に試合をした日
recent = [0] * N

# Qの初期値 = [0, 1, ..., N-1]
Q = deque(range(N))

while Q:
    # ある選手(p1)について
    p1 = Q.popleft()
    # p1がまだ全試合(N-1試合)を終えていない場合
    # p2 = p1が次に当たるべき選手
    if cnt[p1] < N - 1:
        p2 = A[p1][cnt[p1]]
        # p2もまだ全試合を終えていない場合
        if cnt[p2] < N - 1:
            # p2が次に当たるべき選手がp1の場合 -> (p1,p2)の試合を行うことが可能
            if A[p2][cnt[p2]] == p1:
                # day = (p1,p2)の試合を行う日
                day = max(recent[p1], recent[p2]) + 1
                recent[p1] = day
                recent[p2] = day
                cnt[p1] += 1
                cnt[p2] += 1
                Q.append(p1)
                Q.append(p2)

if min(cnt) != N - 1:
    print(-1)
else:
    print(max(recent))


Measured memory_bytes: 90868
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int w = Integer.parseInt(sc.next());
    long[][] chose = new long[n+1][w+1];
    int[] weight = new int[n];
    int[] value = new int[n];
    for(int i = 0; i <= n; i++) {
      for(int j = 0; j <= w; j++) {
        chose[i][j] = 0;
      }
    }
    for(int i = 0; i < n; i++) {
      weight[i] = Integer.parseInt(sc.next());
      value[i] = Integer.parseInt(sc.next());
    }
    for(int i = 0; i < n; i++) {
      for(int j = 0; j <= w; j++) {
        chose[i+1][j] = chose[i][j];
        if(j >= weight[i]) {
          chose[i+1][j] = Math.max(chose[i+1][j], chose[i][j-weight[i]] + value[i]);
        }
      }
    }
    System.out.println(chose[n][w]);
  }
}


Measured memory_bytes: 126404
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> x(N);
    vector<ll> y(N);
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i];
    }

    ll maxf0 = -10000000000000000;
    ll minf0 = 10000000000000000;
    ll maxf1 = -10000000000000000;
    ll minf1 = 10000000000000000;
    for(int i=0; i<N; i++){
        if(x[i] - y[i] > maxf0){
            maxf0 = x[i] - y[i];
        }
        if(x[i] + y[i] > maxf1){
            maxf1 = x[i] + y[i];
        }
        if(x[i] - y[i] < minf0){
            minf0 = x[i] - y[i];
        }
        if(x[i] + y[i] < minf1){
            minf1 = x[i] + y[i];
        }
    }

    if(maxf0 - minf0 > maxf1 - minf1){
        cout << maxf0 - minf0 << endl;
    }else{
        cout << maxf1 - minf1 << endl;
    }

    return 0;

}

Measured memory_bytes: 6416
bingo = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
num = [int(input()) for _ in range(n)]
ans = [[0]* 3 for _ in range(3)]
for x in num:
    for i, row in enumerate(bingo):
        for j, bn in enumerate(row):
            if bn == x:
                ans[i][j] = 1
w = "No"
for i in range(3):
    if ans[0][i] == ans[1][i] == ans[2][i] == 1:
        w = "Yes"
        break
for i in ans:
    if sum(i) == 3:
        w = "Yes"
        break

if ans[0][0] == ans[1][1] == ans[2][2] == 1:
    w = "Yes"

if ans[0][2] == ans[1][1] == ans[2][0] == 1:
    w = "Yes"

print(w)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll n, k;
vector<vector<int> > g;
vector<ll> deg, num;

void rec(int now, int pre){
    if(pre == -1) num[now] = k;
    else{
        num[now] = max(0LL, k-deg[pre]-1);
        deg[pre]++;
        deg[now]++;
    }
    for(auto to : g[now]){
        if(to == pre)continue;
        rec(to, now);
    }
}

int main() {
    cin >> n >> k;
    g.resize(n+1);
    deg.resize(n+1,0);
    num.resize(n+1);
    REP(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rec(0,-1);
    ll ans = 1;
    REP(i,n){
        ans = ans*num[i]%MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10752
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e9

int main()
{
	string s;
	cin >> s;
	bool b = false;
	rep(i, s.size()) {
		string t;
		for (int j = i; j < s.size();j++) {
			t = s.substr(0, i);
			t += s.substr(j);
			if (t == "keyence") {
				b = true;
			}
		}
	}
	cout << (b ? "YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, k;
P p[114514];
signed main() {
	cin >> n >> k;
	rep(i, n) {
		cin >> p[i].first >> p[i].second;
	}
	int ans = 0;
	rep(i, 32) {
		int q;
		q = (k >> i) << i;
		q += ((int)1 << (i - 1)) - 1;
		if (q > k)continue;
		int sum = 0;
		rep(j, n) {
			if ((q | p[j].first) == q)sum += p[j].second;
		}
		chmax(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
		
signed main(){
	fast
	int n,m;
	cin>>n>>m;
	
	int s1=0,s2=0;
	if(n<2)
	 s1=0;
	else{
		s1=(n*(n-1))/2;
	}
	if(m<2)
	 s2=0;
	else
	 s2=(m*(m-1))/2;
	cout<<s1+s2;	  
}



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

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

	ll x;cin >> x;
	ll k;cin >> k;
	ll d;cin >> d;

	ll absx = x;
	if(absx < 0){
		absx *= -1;
	}

	if(absx/d > k){
		cout << (absx - k*d) << endl;
	}else{
		ll tk = k - (absx/d);
		ll ans;
		if(tk%2==0){
			ans = absx%d;
		}else{
			ans = absx%d - d;
		}
		if(ans < 0){
			ans *= -1;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    ll N, M; cin >> N >> M;
    vl A(M), B(M), C(M);
    REP(i, M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
    }

    vvl es(N);
    map<pll, ll> mp;
    REP(i,M){
        es[A[i]].push_back(B[i]);
        mp[pll(A[i], B[i])] = C[i];
    }

    // Bellman-Ford
    vl pt(N, -((ll)0x01)<<60);

    pt[0] = 0;
    REP(i, N-1) { // relaxing
        REP(j, N) {
            for (ll t : es[j]) {
                pt[t] = max(pt[t], pt[j] + mp[pll(j, t)]);
            }
        }
    }
    ll ans = pt[N - 1];
    REP(j, N) {
        for (ll t : es[j]) {
            pt[t] = max(pt[t], pt[j] + mp[pll(j, t)]);
        }
    }

    if (ans != pt[N-1]) {
        cout << "inf" << endl;
    } else {
        cout << pt[N-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
const int V=100000;

int N,W,w[105],v[105];
int dp[V+5];

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>N>>W;
    memset(dp,0x3f,sizeof dp);
    dp[0]=0;
    for (int i=0;i<N;++i) cin>>w[i]>>v[i];
    for (int i=0;i<N;++i)
    for (int j=V;j>=v[i];--j)
        dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    for (int j=V;j>=0;--j)
        if (dp[j]<=W) return cout<<j<<'\n',0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
 
int main() {
    int W,H,x,y,r;
    cin >>W>>H>>x>>y>>r;
    if (x+r<=W&&x-r>=0&&y+r<=H&&y-r>=0) {
          cout << "Yes" << endl;
 
     } else{cout<< "No"<<endl;
     }
   return 0;
    }


Measured memory_bytes: 3092
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main(){
  string s;

  cin >> s;

  bool N = false,S = false,E = false,W = false;

  for(int i=0;i<s.size();i++){

    if(s[i]=='N') N=true;
    if(s[i]=='E') E=true;
    if(s[i]=='S') S=true;
    if(s[i]=='W') W=true;
  
  }

  if((N^S) == false && (E^W) == false){
    puts("Yes");
  }else{
    puts("No");
  }
  
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc173/tasks/abc173_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  ll V = 0;
  rep1(i, N) V += i * (N - i + 1);

  ll E = 0;

  rep(i, N - 1) {
    ll u, v;
    cin >> u >> v;

    if (u > v) swap(u, v);

    E += u * (N - v + 1);
  }

  ll res = V - E;
  cout << res << "\n";
}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n; cin >> n;
    vector<int> hoge(n);
    rep_i(i, n) cin >> hoge[i];
    
    int q; cin >> q;
    int cmd, b, e;
    rep_i(i, q){
        cin >> cmd >> b >> e;
        if(cmd == 0){
            cout << *min_element(&hoge[b], &hoge[e]) << endl;
            continue;
        }
        if(cmd == 1){
            cout << *max_element(&hoge[b], &hoge[e]) << endl;
            continue;
        }
    }
}


Measured memory_bytes: 3172
program prob2
    implicit none
    integer(8)::n, i, j, t, a, ans, tmp
    integer(8), allocatable::h(:)
    read(*,*) n, t, a
    a = a * 1000
    t = t * 1000
    tmp = 1e9
    allocate(h(n))
    read(*,*) h
    do i = 1, n
        if(abs(t - h(i) * 6 - a) < tmp) then
            ans = i
            tmp = abs(t - h(i) * 6 - a)
        end if
    end do
    print*, ans
    stop
end program

Measured memory_bytes: 2964
#include <iostream>
#include <stdio.h>
#include <string>
#include<algorithm>
using namespace std;
 

int main(){
    long long N,A;
    string inp;
    cin >> inp ;;
    //int k=inp.find("FESTIVAL");
    long long k=inp.length();
    string ans="";
    for(int i=0;i<k-8;i++){
        ans+=inp[i];
    }
    cout << ans << endl;


    return 0;
}

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

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


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        HashSet<Integer> hs = new HashSet<>();
        for (int i = 0; i < k; i++) {
            int d = Integer.parseInt(sc.next());
            for (int j = 0; j < d; j++) {
                hs.add(Integer.parseInt(sc.next()));
            }
        }
        int answer = n - hs.size();
        System.out.println(answer);
        sc.close();
    }

}


Measured memory_bytes: 41032
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int sum=0;
  cin>>s;
  for(int i=0; i<(int)s.size(); i++){
    int a='A';
    if(i)a=s[i-1];
    int ju = s[i] - a;
    if(ju<=0)ju+=26;
    sum+=ju;
    //cout<<sum<<endl;
  }
  cout<<sum/26<<endl;
}




Measured memory_bytes: 3232
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, bool> pib;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<double> vf;

typedef long double ld;

#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

#define printItr(A) for(auto itr = A.begin(); itr != A.end(); ++itr){cout << * itr << ", ";}cout << endl;

const double PI = 3.141592653589793;

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	string S;
	cin >> S;

	ll a = 0;
	if(S == "SUN")
		a = 7;
	if(S == "MON")
		a = 6;
	if(S == "TUE")
		a = 5;
	if(S == "WED")
		a = 4;
	if(S == "THU")
		a = 3;
	if(S == "FRI")
		a = 2;
	if(S == "SAT")
		a = 1;
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
for e in iter(input,'0 0'):
 r=int(e.split()[0])
 d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
 a=[]
 for i in range(1<<r):
  b=0
  for j in d:
   c=bin(i^j).count('1')
   b+=c if c>r//2 else r-c
  a+=[b]
 print(max(a))


Measured memory_bytes: 6828
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;



int main(){
	string s;
	cin >> s;
	if (s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba"){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return  0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    cin >> n;
    int ans=0;
    rep(i,n){
        int a=i+1,b=n-i-1;
        if (a>=b) break;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

  long long int a,b,c,d,ans=0;
  cin>>a>>b>>c>>d;
  if(a>=d)
  {
      ans=d;
  }
  else
  {

      ans=a-(d-a-b);

  }
  cout<<ans;
    return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <string>

using namespace std;

int main(){
    string S;
    cin >> S;
    int size = S.length();
    int ans = 0;
    for (int i = 0; i < size/2;i++){
        if(S[i] != S[size-1-i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

map<int, int> res;

void prime_factor(int n){
	for(int i=2; i*i<=n; ++i){
		while(n%i==0){
			++res[i];
			n/=i;
		}
	}
	++res[n];
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	FOR(i, 2, n+1){
		prime_factor(i);
	}
	ll ans=1;
	FOR(i, 2, n+1){
		ans=ans*(res[i]+1)%MOD;
	}
	cout<<ans<<'\n';
	return 0;
}


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

Int n, ans;
vector<Int> b;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	b.resize(n-1);
	for(auto &i:b) cin >> i;
	ans += b[0] + b[n-2];
	for(Int i=1; i<n-1; ++i){
		ans += min(b[i], b[i-1]);
	}
	cout << ans << "\n";
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

const ll N= 1e6+55,mod = 1e9+7;

int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	ll i,j,k,x,y,z,a,b,c;
	sc(x);sc(y);
	z=x;
	c=0;
	while(z<=y){
		//printf("%lld ",z);
		z=z*2;
		c++;
	}
	pr(c);	

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int abs(int x){ x > 0 ? x : -x; }

int main(){
	int m, n, d;
	while(cin >> m >> n >> d, m){
		vector< vector<int> > v(n*m, vector<int>(n*m+1,0));
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin >> v[i*m+j][n*m];
				for(int ii=0;ii<n;ii++){
					for(int jj=0;jj<m;jj++){
						int dist = abs(i-ii)+abs(j-jj);
						if(dist==0||dist==d) v[ii*m+jj][i*m+j] = 1;
					}
				}
			}
		}
		int cur = 0;
		for(int i=0;i<n*m;i++){
			int chg = cur;
			while(chg<n*m && v[chg][i]==0) chg++;
			if(chg == n*m) continue;
			swap(v[cur], v[chg]);
			for(int j=cur+1;j<n*m;j++){
				if(v[j][i]){
					for(int k=i;k<n*m+1;k++)
						v[j][k] = (v[j][k]+v[cur][k])%2;
				}
			}
			cur++;
		}
		int res = 1;
		for(int i=cur;i<n*m;i++)
			if(v[i][n*m] == 1) res = 0;
		cout << res << endl;
	}
}

Measured memory_bytes: 2444