akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
    int ans = 0;
    string s;
    cin >> s;
    map<string, bool> mp;
    mp["A"] = true;
    mp["T"] = true;
    mp["C"] = true;
    mp["G"] = true;
    for(int i=0; i<s.size(); i++){
        int counter = 0;
        for(int j=i; j<s.size(); j++){
            string atcg = string(1, s[j]);
            if(mp[atcg]){
                counter++;
            }
            else break;
        }
        if(counter > ans)ans = counter;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

int main(){
	init();
	ll N;
	cin>>N;
	vector<ll>A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A.begin(),A.end(),greater<ll>());
	vector<ll>ans;
	for(int i=0;i<N-1;i++){
		if(A[i]==A[i+1]){
			ans.push_back(A[i]);
			i++;
		}
		if(ans.size()==2){
			cout<<ans[0]*ans[1]<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
}


Measured memory_bytes: 1152
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
    I am too dumb to realize that i am too dumb.
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
lli rev(lli n)
{
    lli val=0;
    while(n)
    {
        val*=10;
        val+=n%10;
        n/=10;
    }
    return val;
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli a,b;
    cin>>a>>b;
    lli i,ans=0;
    rep(i,a,1+b)
    {
        if(i==rev(i))
        {
            ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int a;cin>>a;
	cout<<a + a*a + a*a*a<<endl;
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    vector<int>color={a,b,c};
    sort(color.begin(),color.end());
    int x=color.at(0);
    int y=color.at(1);
    int z=color.at(2);
    if(x==z){cout<<1<<endl;}
    else if(x==y||y==z){cout<<2<<endl;}
    else{cout<<3<<endl;}
    return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//int n;
unsigned long long n,k,a[200010],f[200010],m;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		f[i]=-1;
	}
	int town=1;
	f[1]=0;
	while(m<k)
	{
		m++;
		town=a[town];
		if(f[town]!=-1) break;
		
		f[town]=m;		
	}
	if(m==k){
		cout<<town;
		exit(0);
	}
	unsigned long long  x;
	x=(k-m)%(m-f[town]);
	for(int i=1;i<=x;i++)
	town=a[town];
	
	cout<<town;
	
	
}


Measured memory_bytes: 6728
// D - Integer Cards
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);i++)

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

	vector<ll> A(N);
	rp(i,N) cin>>A[i];
	sort(A.begin(), A.end());

	vector<pair<ll,int>> B;
	rp(i,M){
		int b; ll c; cin>>b>>c;
		B.push_back(make_pair(c,b));
	}
	sort(B.begin(), B.end());

	ll ans = 0;
	int ans_count = 0;
	int n = N-1;
	ll value; int count;
	for(int m=M-1; m>=0 && ans_count<N; --m){
		tie(value, count) = B[m];

		while(ans_count<N && n>=0 && value <= A[n]){
			ans += A[n--];
			++ans_count;
		}
		if(n<0 || ans_count>=N) break;

		count = min(count, max(0, N - ans_count));
		ans += value * count;
		ans_count += count;
		if(ans_count>=N) break;
	}

	if(ans_count<N)
		while(n && ans_count<N){ ans += A[n--]; ++ans_count; }

	cout<< ans <<endl;
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip> // setprecisionを使用するのに必要
using namespace std;

int main()
{
    static const double pi = 3.141592653589793;
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double alpha;
    h = h * 30.0 + m * 0.5;
    m = m * 6.0;
    // cout << h << "," << m << endl;

    if (h >= 180 || m >= 180)
    {
        alpha = ((360.0 - abs(h - m)) * pi) / 180.0;
    }
    else
    {
        alpha = (abs(h - m) * pi) / 180.0;
    }

    // cout << cos(alpha) << endl;
    cout << fixed << setprecision(9) << sqrt(a * a + b * b - 2.0 * a * b * cos(alpha)) << endl;
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
const int N=1e5+5;



void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(auto &x:a)cin>>x;
    vector<int>v;
    for(auto x:a)v.pb(x);
    for(int i=n-2;i>=0;i--)a[i]+=a[i+1];
    
    for(int i=0;i<n;i++)a[i]%=mod;
    
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(i+1<n)
        {
            int t=(v[i]*a[i+1]);
            ans+=t;
            ans%=mod;
        }
    }
    cout<<ans;
    
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--)solve();
	    
  
}




Measured memory_bytes: 6888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
    long long N, M;
    cin >> N >> M;
    vector<long long> A(N);
    int sum=0;
    for (int i=0; i<M; i++) {
        cin >> A.at(i);
        sum+=A.at(i);
    } 
    if (N<sum) {
        cout << "-1" <<endl;
        return 0;
    }
    cout << N-sum <<endl;
} 

Measured memory_bytes: 10744
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int nums = sc.nextInt();

			ArrayList<Integer> list = new ArrayList<Integer>();

			for(int i =0;i<nums;i++) {
				list.add(sc.nextInt());
			}


			Collections.sort(list);

			int num = list.get(list.size()-1) - list.get(0);

			System.out.println(num);



	}


}




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

//#include "../../template-proj/myMente.h"

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int a,b;
	cin>>a>>b;
	if(a>=13){ote(b);return 0;}
	if(a<6){ote(0);return 0;}
	ote(b/2);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); ++i)
	{
		if(s[i] == '7')
		{
			cout << "Yes" << endl;
			return;
		}
	}

	cout << "No" << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  cout << 0 << endl;
  string a;
  cin >> a;
  if (a == "Vacant") return 0;
  string sLo = a;
  string sHi = a;
  int iLo = 1;
  int iHi = N - 1;
  while (1) {
    DLOG("%s %d %d %s\n", sLo.c_str(), iLo, iHi, sHi.c_str());
    int i = (iLo + iHi) / 2;
    cout << i << endl;
    cin >> a;
    if (a == "Vacant") return 0;
    if (   ((i - iLo) % 2 == 0 && sLo != a) ||
	   ((i - iLo) % 2 == 1 && sLo == a) ) {
      sLo = a;
      iLo = i + 1;
    }else {
      sHi = a;
      iHi = i - 1;
    }
  }

  return 0;
}



Measured memory_bytes: 852
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  string s;
  cin >> s;
  if (s == "RRR") cout << 3 << endl;
  else if (s.substr(0,2) == "RR" || s.substr(1,2) == "RR") cout << 2 << endl;
  else{
    rep(i,3){
      if (s[i] == 'R'){
        cout << 1 << endl;
        return 0;
      }
    }
    cout << 0 << endl;
  }


  return 0;
}


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


signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  
  int cnt = 0;
  for( int i = 0; i < N; i++ ){
    if( A.at(i) == cnt+1 ) cnt++;
  }
  if( cnt > 0 ) cout << N-cnt << endl;
  else cout << -1 << endl;
    
    
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    int i,a,count[4]={0};
    char s[10]={0};

    while(scanf("%d,%s",&a,s)!=EOF){
        switch(s[0]+s[1]){
            case 'A'+'\0':
                count[0]++;
                break;
            case 'B'+'\0':
                count[1]++;
                break;
            case 'A'+'B':
                count[2]++;
                break;
            case 'O'+'\0':
                count[3]++;
                break;
        }
    }
    for(i=0;i<4;i++)printf("%d\n",count[i]);
    return 0;
}

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

using namespace std;

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

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

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

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

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,r;
    cin>>n>>r;
    int ans=0;
    if(n>=10){
        ans =r;
    }else{
        ans = r + 100*(10-n);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (long long i = (a); i < (b); i++)
#define rep(i, b) for (long long i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

int n;
char s[205][205];

int main() {
	cin >> n;
	vector<vector<int>> to(n);
	rep(i, n) rep(j, n) {
		char c;
		cin >> c;
		s[i][j] = c;
		if (c == '1') { to[i].emplace_back(j); }
	}

	int ans = -1;
	rep(i, n) {
		bool used[205] = {};
		used[i]		   = true;

		vector<int> cur;
		cur.emplace_back(i);

		int cnt  = 1;
		int step = 1;
		while (cnt < n) {
			vector<int> nxt;
			for (auto i : cur) {
				for (auto j : to[i]) {
					if (not used[j]) {
						used[j] = true;
						cnt++;
						nxt.emplace_back(j);
					}
				}
			}
			for (auto i : nxt) {
				for (auto j : nxt) {
					if (s[i][j] == '1') { goto END; }
				}
			}

			cur = nxt;
			step++;
		}

		ans = max(ans, step);

	END:;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, a[1010];

int main(){
	cin >> n;
	int c = 0;
	for(int i = 0; i < n; i++){cin >> a[i]; c += a[i];}
	
	int cnt = 0, ans = INF;
	for(int i = 0; i < n; i++){
		cnt += a[i];
		ans = min(ans, abs(c - cnt - cnt));
	}
	cout << ans << 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);
    String s = sc.next();
    
    if(s.equals("ARC")){
      System.out.println("ABC");
    }else if(s.equals("ABC")){
      System.out.println("ARC");
    }
  }
}

Measured memory_bytes: 35464
#include <bits/stdc++.h>
using namespace std;
typedef double dbl;
#define double long double
typedef complex<double> P;
typedef vector<P> G;
#define REP(i,n) for(int i = 0 ; i < n ; i++)


map<int,int> cur;

int count(int x){
	auto it = cur.find(x);
	if( it == cur.end() ) return 0;
	else return it->second;
}
void dec(int x){
	if( --cur[x] == 0 ) cur.erase(x);
}
void decv(int x,int v){
	if( (cur[x]-=v) == 0 ) cur.erase(x);
}
void inc(int x){
	cur[x]++;
}
void incv(int x,int v){
	cur[x]+=v;
}
int n;
vector<int> v;
set< vector<int> > ans;
int chk;

void dfs(int x){

	if( x == n ) {
		//cout << v.size() << "<" << endl;
		vector<int> t = v;
		sort(t.begin(),t.end());
		
		{		
			vector<int> r;
			for(int i = 1 ; i < t.size() ; i++)
				r.push_back(t[i]-t[i-1]);
			ans.insert(r);
		}
		reverse(t.begin(),t.end());
		{		
			vector<int> r;
			for(int i = 1 ; i < t.size() ; i++)
				r.push_back(t[i-1]-t[i]);
			ans.insert(r);
		}
		return;
	}
	auto f = [&](int x){
		map<int,int> req;
		for(int i = 0 ; i < v.size() ; i++){
			req[abs(v[i]-x)]++;
		}
		return req;
	};
	auto ok = [&](map<int,int> &req){
		for(auto && i : req ){
			if( count(i.first) < i.second ) return false;
		}
		return true;
	};
	auto go = [&](map<int,int> &req){
		for(auto && i : req ){
			decv(i.first,i.second);
		}
	};
	auto back = [&](map<int,int> &req){
		for(auto && i : req ){
			incv(i.first,i.second);
		}
	};
	
	auto r1 = f(chk-cur.rbegin()->first);
	if( ok(r1) ){
		v.push_back(chk-cur.rbegin()->first);
		go(r1);
		dfs(x+1);
		v.pop_back();
		back(r1);
		
	}
	auto r2 = f(cur.rbegin()->first);
	if( ok(r2) ){
		v.push_back(cur.rbegin()->first);
		go(r2);
		dfs(x+1);
		v.pop_back();
		back(r2);
	}
	
	
}
int main(){
	while(cin >> n && n ){
		cur.clear();
		ans.clear();
		v.clear();
		//cout << n*(n-1)/2 << endl;
		for(int i = 0 ; i < n*(n-1)/2 ; i++){
			int t;
			cin >> t;
			inc(t);
		}
		chk = cur.rbegin()->first;
		dec(cur.rbegin()->first);
		v.push_back(0);
		v.push_back(chk);
		dfs(2);	
		sort(v.begin(),v.end());
		for(auto v : ans ){
			for(int i = 0 ; i < v.size() ; i++){
				cout << v[i];
				cout << (char)(i+1==v.size()?10:32);
			}
		}
		cout << "-----" << endl;
	}
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
using graph = vector<vector<int>>;

int main(){
    ll n; cin >> n;
    vector<ll> a(n), A(n+1);
    A.assign(n, 0);
    for(ll i=0; i<n; ++i){
        cin >> a[i];
      a[i]--;
        A[a[i]]++;
    }
    ll sum = 0;
    for(ll i=0; i<n; ++i){
        if(A[i]>=2){
            sum += A[i] * (A[i]-1) / 2;
        }
    }
    for(ll i=0; i<n; ++i){
        ll ans = sum;
        ans -=  (A[a[i]] - 1);
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
#define N 200005

int n, a[N], cnt[N];

ll ans = 0;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		ans += cnt[a[i]];
		cnt[a[i]]++;
	}
	for(int i = 1; i <= n; i++)
	{
		printf("%lld\n", ans - cnt[a[i]] + 1);
	}
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
using namespace std;
using llong = long long;

string s, t;

int main() {
    cin >> s >> t;

    t.pop_back();

    if (s == t) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

#define long long long int
using namespace std;


#ifdef JUDGE
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
using std::cin;
using std::cout;
#endif

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(6);


    int n, m;
    cin >> n >> m;
    vector<int> a;
    for (int i = 1; a.size() < n; ++i) {
        if (i % 2 == 0) {
            a.push_back(i);
        }
    }
    for (int i = 1; a.size() < n + m; ++i) {
        if (i % 2) {
            a.push_back(i);
        }
    }
    int cnt = 0;
    for (int i = 0; i < a.size(); ++i) {
        for (int j = i + 1; j < a.size(); ++j) {
            if(i == j) continue;
            if ((a[i] + a[j]) % 2 == 0) cnt++;
        }
    }
    cout << cnt;
    return 0;


}


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

using namespace std;

int cmp(const void *a,const void *b)
{
	return *(int *)a-*(int *)b;
}

int main()
{
	int a[100001];
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	qsort(a,n,sizeof(int),cmp);
	int m=0;
	for (int i=0;i<n;i++)
	{
		int temp=0;
		if (i==n-1 || a[i]!=a[i+1])
		{
			for (int j=i;j!=-1 && a[i]-a[j]<3;j--)
				temp++;
		}
		if (temp>m)
			m=temp;
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

set<int> isi;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    while(n--)
    {
        int inp;
        cin>>inp;
        if(isi.count(inp)==0)
        {
            isi.insert(inp);
        }
        else
        {
            isi.erase(inp);
        }
    }
    cout<<isi.size()<<endl;
    return 0;
}


Measured memory_bytes: 4992
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    N = list(sys.stdin.readline().rstrip())
    if N[:3].count(N[0]) == 3 or N[1:].count(N[1]) == 3:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  for(int i = a;i<=a*b;i+=a){
    if(i%b==c){
       cout << "YES" << endl;
       return 0;
     }
  }
  cout << "NO" << endl;
}


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

#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,n)  for(int i=0;i<n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;



int main(){
    cinsc;
    int n;
    cin>>n;
    VI a;
    FOR(i,n){
        int x;
        cin>>x;
        x--;
        a.PB(x);
    }
    int c=0,curr_lighten=0;
    while(1){
        if(curr_lighten==1)
            return cout<<c<<endl,0;
        if(c>=n)
            return cout<<-1<<endl,0;
        c++;
        curr_lighten=a[curr_lighten];
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 892
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();

		int sum = 0;

		for(int i=a;i<t+0.5;i += a){
			sum += b;
		}
		

		// 出力
		System.out.println(sum);
	}
}

Measured memory_bytes: 23764
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 47280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int n,lst,a[maxn];
string s;
int main()
{
	cin>>s;
	n=s.length();
	s="#"+s;
	for(int i=1;i<=n;i++)
		if(s[i]=='L')
			a[lst+(i-lst)%2]++;
		else
			lst=i;

	for(int i=n;i>=1;i--)
		if(s[i]=='R')
			a[lst-(lst-i)%2]++;
		else
			lst=i;

	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";

	cout<<endl;
	return 0;
}


Measured memory_bytes: 1020
#include<stdio.h>

int main() {
    int n, i;
    int fib[45];
    fib[0] = fib[1] = 1;
    
    scanf("%d", &n);
    for ( i = 2; i <= n; i++ )
        fib[i] = fib[i - 1] + fib [i - 2];
    
    printf("%d\n", fib[n]);

    return 0;
    
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll A, B, K;
    cin >> A >> B >> K;
    vec ans;
    rep1(i, 100){
        if(A % i == 0 and B % i == 0) ans.pb(i);
    }
    reverse(ALL(ans));
    print(ans[K - 1]);

    return 0;
}

Measured memory_bytes: 256
# abc116_b.py
# https://atcoder.jp/contests/abc116/tasks/abc116_b

# ★ RE:4
# 07.txt
# 08.txt
# 09.txt
# s3.txt

# B - Collatz Problem /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 数列 a={a1,a2,a3,......}は、以下のようにして定まります。
#     初項 sは入力で与えられる。
#     関数 f(n)を以下のように定める: n が偶数なら f(n)=n/2、n が奇数なら f(n)=3n+1。
#     i=1のとき ai=s、i>1 のとき ai=f(ai−1)である。
# このとき、次の条件を満たす最小の整数 mを求めてください。
#     am=an(m>n)を満たす整数 nが存在する。

# 制約
#     1≦s≦100
#     入力はすべて整数である。
#     aのすべての要素、および条件を満たす最小の m は 1000000以下となることが保証される。

# 入力
# 入力は以下の形式で標準入力から与えられます。
# s

# 出力
# 条件を満たす最小の整数 mを出力してください。

# 入力例 1
# 8

# 出力例 1
# 5

# a={8,4,2,1,4,2,1,4,2,1,......}です。a5=a2 なので、答えは 5です。

# 入力例 2
# 7

# 出力例 2
# 18

# a={7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......}です。

# 入力例 3
# 54

# 出力例 3
# 114


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # X = lines[0]
    s = int(lines[0])
    # values = list(map(int, lines[0].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))

    values = [s]

    for i in range(1000000):
        s = func_f(values[i])
        if s in values:
            return [i+2]
        values.append(s)


def func_f(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return 3*n + 1


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['8']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['7']
        lines_export = [18]
    if pattern == 3:
        lines_input = ['54']
        lines_export = [114]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    if FLAG_LOG:
        log(f'lines_input=[{lines_input}]')
        log(f'lines_export=[{lines_export}]')
        log(f'lines_result=[{lines_result}]')
        if lines_result == lines_export:
            log('OK')
        else:
            log('NG')
    finished = time.time()
    duration = finished - started
    log(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
import java.util.*;

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

Measured memory_bytes: 21460
/*
Original problem: https://atcoder.jp/contests/abc134/tasks/abc134_d
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
    void main() {
        int n;
		cin >> n;
		VI A(n + 1);
		REP(i,1,n+1){
			cin >> A[i];
		}

		int onecount = 0;
		VI ans(n + 1);
		RREP(i, n, 1) {
			int c = 0;
			// check forward and see what had been set
			for (int mult = 2 * i; mult <= n; mult += i) {
				c += ans[mult];
			}
			c %= 2;
			ans[i] = c != A[i];
			if (ans[i] == 1) {
				onecount++;
			}
		}

		cout << onecount << endl;
		REP(i, 1, n+1) {
			if (ans[i] == 1) {
				cout << i << ' ';
			}
		}
		cout << endl;
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

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

int main() {
  string N; cin >> N;
  int L = N.size();
  int ans = 0;
  ans = max(ans, (N.at(0) - '0') - 1 + 9 * (L - 1));
  int tmp = 0;
  for (int i = 0; i < L; i++) tmp += (N.at(i) - '0');
  ans = max(ans, tmp);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <complex>
#include <vector>
using namespace std;
typedef complex<int> P;
typedef vector<P > Poly;
int n;
bool operator == (const Poly& a,const Poly& b){
  if(a.size()!=b.size()) return false;
  for(int i=0;i<a.size();++i) if(a[i]!=b[i]) return false;
  return true;
}

vector<int> solve(vector<Poly> D){
  Poly s = D[0];
  vector<int> ret;
  for(int u=0;u<2;++u){
    for(int t=0;t<4;++t){
      for(int i=1;i<=n;++i)
	if(s==D[i]) ret.push_back(i);
      for(int i=0;i<s.size();++i){
	s[i]*=P(0,1);
      }
    }
    reverse(s.begin(),s.end());
    for(int i=s.size()-1;i>=0;--i) s[i]-=s[0];
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int main(){
  while(cin>>n,n){
    vector<Poly> inp(n+1);
    for(int i=0;i<=n;++i){
      int m;cin>>m;
      for(int j=0;j<m;++j){
	int a,b;
	cin >> a >> b;
	inp[i].push_back(P(a,b));
      }
      for(int j=m-1;j>=0;--j) inp[i][j]-=inp[i][0];
    }
    vector<int> ans = solve(inp);
    for(int i=0;i<ans.size();++i) cout << ans[i] << endl;
    cout << "+++++" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
int k=0,n=0, m=0, l=0,a=0, b=0, c=0, d=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    //cin >> n;
    cin >> x >> y;
    //cin >> s >> t;
    if(x>=10||y>=10){
    cout <<-1;
    }else{
    cout <<x*y;
    }
}

Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

            String[] in = br.readLine().split(" ");
            int n = Integer.parseInt(in[0]);
            long k = Long.parseLong(in[1]);
            in = br.readLine().split(" ");
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in[i]) - 1;
            }

            br.close();
            
            int now = 0;
            
            while (k != 0) {
                if (k % 2 == 1) {
                    now = a[now];
                }
                int[] tmp = new int[n];
                for (int i = 0; i < n; i++) {
                    tmp[i] = a[a[i]];
                }
                a = tmp;
                k /= 2;
            }

            PrintWriter pw = new PrintWriter(System.out);

            pw.println(now + 1);

            pw.flush();

        }
    }
}

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

bool isPrime(int n)
{
	if (n < 2)
		return false;
	if (n <= 3)
		return true;
	if (n%2 == 0 || n%3 == 0)
		return false;
	for (int i = 5; i*i <= n; i+= 6)
		if (n%i == 0 || n%(i+2) == 0)
			return false;
	return true;
}

int main()
{
	int N;
	cin >> N;
	int arr[N];
	for (int i = 0; i < N; i++)
		cin >> arr[i];
	int c = 0;
	for (int i = 0; i < N; i++)
		if (isPrime(arr[i]))
			c++;

	cout << c << endl; 
}




Measured memory_bytes: 3160
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/26/20 20:17:32
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  set<string> vs;
  for (int i = 0; i < n; i++) {
    string s; cin>>s;
    vs.insert(s);
  }
  cout << vs.size() << endl;

  return 0;
}


Measured memory_bytes: 19244
#include<bits/stdc++.h>
using namespace std;
#define NitroBoost \
        ios_base::sync_with_stdio(false); \
        cin.tie(NULL);
#define ll long long
#define fori(i,l,n) for(int i=l;i<n;i++)
#define ford(i,n,l) for(int i=n;i>l;i--)
#define All(i,x) for(auto i=x.begin();i!=x.end();++i)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define test int t;cin>>t;while(t--)
#define pb(i) push_back(i)
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n"
#define str(n) to_string(n)
#define fi first
#define sec second
#define prec(n) fixed<<setprecision(n)
#define mp make_pair
const double pi=3.141592653589793;
const int MOD=1e9+7;
ll power(ll x, ll y, ll m) 
{
     ll res = 1;x %= m;
    while (y > 0) {
        if (y & 1)
        res = (res*x) % m;
        y>>=1;
        x = (x*x) % m;
    }
    return res%m;
}
ll look[100001][101];
ll dp(ll w[],ll v[],int W,int n){
    if(n<=0)
    return look[W][n]=0; 
    //string key=str(n)+"|"+str(W);   
    if(look[W][n]==-1){
        if(w[n-1]>W)
        look[W][n]=dp(w,v,W,n-1);
        else 
        look[W][n]=max(dp(w,v,W-w[n-1],n-1)+v[n-1],dp(w,v,W,n-1));
    }
    return look[W][n];
}
void solve(){
    int n,W;
    cin>>n>>W;
    fori(i,0,n+1)
    {
        fori(j,0,W+1)
        look[j][i]=-1;
    }
    ll w[n];
    ll v[n];    
    fori(i,0,n)
    cin>>w[i]>>v[i];
    cout<<dp(w,v,W,n);
}
int main(){  
    NitroBoost
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    //test
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 82452
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 140005;
struct Edge { int v, w; } son[MAXN][2];
struct Data { LL v, w; bool operator<(const Data &e) { return v == e.v ? w < e.w : v < e.v; } } arr[MAXN], brr[MAXN];
int n; LL cur;
void add_son(int u, int v, int w) {
	son[u][son[u][0].v > 0] = Edge { v, w };
}

vector<Data> dfs(int u) {
	if (!son[u][0].v) {
		vector<Data> v;
		v.push_back(Data { 0ll, 0ll });
		return v;
	}
	auto l = dfs(son[u][0].v), r = dfs(son[u][1].v);
	if (l.empty() || r.empty()) return vector<Data>();
	for (auto &p : l) p.v += son[u][0].w, p.w += son[u][0].w;
	for (auto &p : r) p.v += son[u][1].w, p.w += son[u][1].w;
	if (l.size() > r.size()) swap(l, r);
	int sl = l.size(), sr = r.size(), a = 0, b = 0, m = 0;
	for (int i = 0, j = sr - 1; i < sl; i++) {
		while (j >= 0 && r[j].v + l[i].v > cur) --j;
		if (j < 0) break;
		arr[++m] = Data { l[i].w, r[j].w };
		brr[m] = Data { r[j].w, l[i].w };
	}
	reverse(arr + 1, arr + 1 + m);
	vector<Data> vec;
	while (a < m || b < m) {
		Data &e = b == m || (a < m && arr[a + 1] < brr[b + 1]) ? arr[++a] : brr[++b];
		if (!vec.empty() && e.v >= vec.back().v && e.w >= vec.back().w) continue;
		vec.push_back(e);
	}
	return vec;
}

int main() {
	scanf("%d", &n);
	LL l = 0, r = 0;
	for (int i = 1; i < n; i++) {
		int v, w; scanf("%d%d", &v, &w);
		add_son(v, i + 1, w);
		r += w;
	}
	while (l + 1 < r) {
		cur = (l + r) >> 1;
		if (dfs(1).empty()) l = cur;
		else r = cur;
	}
	printf("%lld\n", r);
	return 0;
}

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

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

using namespace std;

using ll = long long int;

const int MOD_NUM = 1e9 + 7;

int main() {
    // Input
    int X, N;
    vector<int> p;

    cin >> X >> N;
    p = vector<int>(N);
    rep(i, N) cin >> p[i];

    // Process
    ll ans;

    if (N == 0) {
        ans = X;
    } else {
        sort(p.begin(), p.end());

        int idx = 0;
        ans = 0;
        for (int i = 1; i <= 101; i++) {
            if (p[idx] == i) {
                idx++;
            } else if (abs(X - i) < abs(X - ans)) {
                ans = i;
            } else {
                break;
            }
        }
    }

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int X;
  cin>>X;
  vector<int>A(40);
  A[0]=1;
  A[1]=4;
  A[2]=8;
  A[3]=16;
  A[4]=32;
  A[5]=64;
  A[6]=128;
  A[7]=256;
  A[8]=512;
  A[9]=9;
  A[10]=27;
  A[11]=81;
  A[12]=243;
  A[13]=729;
  A[14]=25;
  A[15]=125;
  A[16]=625;
  A[17]=36;
  A[18]=216;
  A[19]=49;
  A[20]=100;
  A[21]=1000;
  A[22]=121;
  A[23]=144;
  A[24]=169;
  A[25]=196;
  A[26]=225;
  A[27]=289;
  A[28]=324;
  A[29]=361;
  A[30]=400;
  A[31]=441;
  A[32]=484;
  A[33]=529;
  A[34]=576;
  A[35]=676;
  A[36]=784;
  A[37]=841;
  A[38]=900;
  A[39]=961;
  sort(A.begin(),A.end());
  rep(i,40){
    if(A[i]>X){
      cout<<A[i-1]<<endl;
      return 0;
    }
  }
  cout<<1000<<endl;
}

Measured memory_bytes: 3628
using System;
using System.IO;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        private Scanner sc;

        public void Solve()
        {
            sc = new Scanner();
            int A = sc.NextInt();
            int B = sc.NextInt();
            int C = sc.NextInt();

            Console.WriteLine(Math.Max(0, C - (A - B)));
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

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

#define MAX 128

int dp[MAX][MAX], data[MAX][MAX];
int h, w;

int main(void)
{
	for (int i=0;i<MAX;i++)for(int j=0;j<MAX;j++)dp[i][j]=10000000;
	char c;
	cin >> h >> w;
	
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> c;
			data[i][j] = c - '0';
		}
	}
	
	dp[1][1]=0;
	for (int i = 2; i <= h; i++) dp[i][1] = data[i][1] + dp[i-1][1];
	for (int i = 2; i <= w; i++) dp[1][i] = data[1][i] + dp[1][i-1];
	
	for (int i = 2; i <= h; i++){
		for (int j = 2; j <= w; j++){
			dp[i][j] = data[i][j] + min(dp[i-1][j], dp[i][j-1]);
		}
	}
	
	printf("%d\n", dp[h][w]);
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <iomanip>

using namespace std;

#define mp make_pair
#define int long long

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int x, a, b;
	cin >> x >> a >> b;

	if (a >= b)
		cout << "delicious";
	else if (b - a > x)
		cout << "dangerous";
	else
		cout << "safe";
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

signed main() {
  int a[5];
  rep(i, 5) { cin >> a[i]; }

  rep(i, 5) {
    if (a[i] == 0) {
      cout << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 3584