akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    int n;cin >> n;
    vi x(n);rep(i,n)cin >> x[i];

    int Min = *min_element(ALL(x));
    int Max = *max_element(ALL(x));

    int ans = MINF;
    for(int i=Min;i<=Max;i++){
        int Sum = 0;
        for(int j=0;j<x.size();j++){
            Sum += pow(x[j] - i, 2);
        }
        ans = min(ans, Sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
keyence
)");
#define cin input
#endif

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

	string k = "keyence";

	REP (i, 8)
	{
		if (s.substr(0, i) + s.substr(s.length() - 7 + i) == "keyence")
		{
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
cards_remain=[]
suit=["S","H","C","D"]
cards_set=[]
output=[]

count_card=input()

for l in range(int(count_card)):
        cards_remain.append(input())

for m in suit:
    for n in range(13):
        cards_set.append(m+" "+str(n+1))

for p in cards_set:
    if p not in  cards_remain:
        output.append(p)

for x in output:
        print(x)

Measured memory_bytes: 7632
while line = gets
  break if line.chomp == "0 0"
  ans = []
  n, m = line.split.map(&:to_i)
  q = Array.new(n).map{ gets.split.map(&:to_i) }
  
  q.transpose.map{ |arr| arr.inject(:+) }.each_with_index{ |sum, i| ans << [sum, i] }
  puts ans.sort_by{ |j, _| m - j }.map{ |_, k| k + 1 }.join(" ")
end

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)2e5+5;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll a[N];
ll f[N];
ll n,k;
bool valid(ll t){
    ll need=0;
    for(int i=0;i<n;i++){
        ll x = a[i]*f[i];
        if(a[i]*f[i]>t){need+=a[i]-t/f[i];
        }// ==t we need 
    }
    
    return need<=k;
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    init();
    
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
       
    }
    for(int i=0;i<n;i++){
        cin>>f[i];
    }
    sort(a,a+n);
    sort(f,f+n);
    reverse(f,f+n);
    ll start = 0,end = (ll)1e12+12;
    ll ans=1e18;
    while(start<end){
        ll mid = start+(end-start)/2;
        if(valid(mid)){
            ans=min(ans,mid);
            end=mid;
        }else{
            start=mid+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
int main(void){
    // Your code here!
    int grid[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&grid[i][j]);
        }
    }
    int x[3],y[3];
    x[0]=0;
    for(int i=0;i<3;i++)y[i]=grid[0][i]-x[0];
    for(int i=0;i<3;i++)x[i]=grid[i][0]-y[0];
    int flag=1;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(x[i]+y[j]!=grid[i][j]) flag=0;
        }
    }
    if(flag) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#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 vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll h, n, i, j, k;
	cin >> h >> n;
	ll a[n];
	ll sm = 0;
	fr(i,0,n)
	{
		cin >> a[i];
		sm += a[i];
	}
	if(h <= sm)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <limits.h>
#include<cstdio>
using namespace std;

int n;
int a[200010];

int main(void)
{
    cin >> n;
    for(int i=0;i<n;i++){scanf("%d",&a[i]);}
    int max = INT_MIN, min = a[0];
    for(int i=1;i<n;i++){
        if(a[i] - min > max) max = a[i] - min;
        if(a[i] < min) min = a[i];
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 4024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N + 1];
		for(int i = 0; i < N; i++) {
			h[i + 1] = sc.nextInt();
		}
		sc.close();
		if(N == 2) {
			System.out.println(Math.abs(h[2] - h[1]));
			System.exit(0);
		}
		long[] dp = new long[N + 1];
		long INF = 100000000000l;
		for(int i = 2; i <= N; i++) {
			dp[i] = INF;
		}
		for(int i = 1; i < N; i++) {
			for(int j = 1; j <= K; j++) {
				if(i + j >= N + 1) break;
				long t = dp[i] + Math.abs(h[i + j] - h[i]);
				dp[i + j] = Math.min(dp[i + j], t);
			}
		}
		System.out.println(dp[N]);
	}
}

Measured memory_bytes: 51956
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(void) {
    long long int A,B,C,K;
    long long int ans=0;
    cin >> A >> B >> C >> K;

    if(K<=A)
      ans = K;
    else if(K>A && K<=A+B)
      ans = A;
    else if(K>A+B)
      ans = A+(-1)*(K-A-B);


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B;char op;
  cin >> A >> op >> B;
  if(op=='+') cout << A+B << endl;
  else cout << A-B << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		long X = Long.parseLong(sc.get());
		long current = 100;
		long years = 0;
		while (current < X) {
			current += current / 100;
			years += 1;
		}
		System.out.println(years);
	}
}

class Main {
	public static void main(String... args) {
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 32572
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int a[N];
long long sum[N],asum[N];
int main(){
	int n,k;
	long long ans=-(1LL<<60);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum[i]=a[i]+sum[i-1],asum[i]=max(a[i],0)+asum[i-1];
	for(int i=k;i<=n;i++){
		ans=max(ans,asum[i-k]+max(sum[i]-sum[i-k],0LL)+asum[n]-asum[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int N; cin >> N;
  int A, B; cin >> A >> B;
  vector<int> x, y, z;
  for (int i = 0; i < N; i++) {
    int P; cin >> P;
    if (P <= A) x.push_back(P);
    else if (P <= B) y.push_back(P);
    else z.push_back(P);
  }
  vector<int> v;
  v.push_back(x.size());
  v.push_back(y.size());
  v.push_back(z.size());
  sort(v.begin(), v.end());
  cout << v.at(0) << endl;
}

Measured memory_bytes: 256
import math
import collections
import bisect
from copy import copy


def main():
    N = int(input())

    ans = 0
    for i in range(1, N + 1):
        l = N // i
        ans += int(l * (l + 1) / 2) * i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9616
import collections
N=int(input())
A=collections.Counter(list(map(int,input().split())))

arr=[]
for k,v in A.items():
    if v>1:
        arr.append(k)
    if v>3:
        arr.append(k)

if len(arr)<=1:
    print(0)
else:
    arr_s=sorted(arr,reverse=True)
    print(arr_s[0]*arr_s[1])

Measured memory_bytes: 18600
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int n,k;
vec w,d;

bool check(int mid){
  int sum = 0;
  REP(i,n){
    sum += max(0LL,(mid-w[i]))/d[i];
    if(mid-w[i]>=0) sum++;
    if(sum >= k) return true;
  }
  return false;
}

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

  cin >> n >> k;

  w.resize(n);
  d.resize(n);

  REP(i,n) cin >> w[i] >> d[i];

  int ng = 0, ok = (1LL<<61);
  while (abs(ng-ok)>1) {
    int mid = (ng+ok)/2;
    (check(mid)?ok:ng) = mid;
  }

  cout << ok << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	vector<int> b;
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		b.push_back(tmp);
	}
	vector<int> ans;
	for(int i = b.size(); i >= 0; i--){
		for(int j = b.size() - 1; j >= 0; j--){
			if(j + 1 == b[j] && j + 1 <= b.size()){
				b.erase(b.begin() + j);
				ans.push_back(j + 1);
				j = 0;
			}
		}
	}
	if(b.size() > 0){
		cout << -1 << endl;
	} else {
		for(int i = ans.size() - 1; i >= 0; i--){
			cout << ans[i] << endl;
		}
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[222222];

int s[222222];

bool check(int z){
    memset(s,0,sizeof(s));

    stack<int>st;
    for(int i=1;i<N;i++){
        if(i&&A[i-1]<A[i])continue;
        while(st.size()&&st.top()>A[i]){
            s[st.top()]=0;
            st.pop();
        }
        int k=A[i];
        while(true){
            s[k]++;
            if(st.size()==0||st.top()!=k)st.push(k);
            if(s[k]<z)break;
            s[k]=0;
            st.pop();
            k--;
            if(k==0)return false;
        }
    }
    return true;
}

signed main(){
    cin>>N;
    rep(i,N){
        cin>>A[i];
    }

    bool ok=true;
    rep(i,N-1)if(A[i]>=A[i+1])ok=false;

    if(ok){
        cout<<1<<endl;
        return 0;
    }

    rep(i,N)chmin(A[i],222222-1);

    int lb=1,ub=N;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(check(mid))ub=mid;
        else lb=mid;
    }
    cout<<ub<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size()
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define forn(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n) for (int i = n; i >= 0; i--)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define foreach(itr, c) for (__typeof((c).begin(), (c).end()) itr = c.begin(); itr != c.end(); itr++)
#define fill(a, b) memset(a, b, sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
#define fast()                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<char> vs;
typedef vector<pi> vpi;

using namespace std;

int main()
{
    fast();
    ll X, K, D;

    cin >> X >> K >> D;

    if (X < 0)
    {
        X = -X;
    }

    if (K <= X / D)
    {
        cout << X - (K * D);
    }
    else
    {
        K -= X / D;
        if (K % 2 == 0)
        {
            cout << X % D;
        }
        else
        {
            cout << D - X % D;
        }
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m;
int a[1200], b[1200], c[1200];
signed main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
	int ansi, ansj;
	int w;
	int sxd = 0;
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++) {
			for (int k = 1; k <= n; k++)
				if (c[k] != 0) {
					w = abs(a[k] - i) + abs(b[k] - j) + c[k];
					break;
				}
			bool flag = true;
			for (int k = 1; k <= n; k++) {
				if (c[k] == 0 && abs(a[k] - i) + abs(b[k] - j) > w) continue;
				if (abs(a[k] - i) + abs(b[k] - j) + c[k] != w ) {
					flag = false;
					break;
				}
			}
			if (flag && w != 0) {
				ansi = i;
				ansj = j;
				sxd = 0;
				break;
			}
		}
	for (int k = 1; k <= n; k++)
		if (c[k] != 0) {
			w = abs(a[k] - ansi) + abs(b[k] - ansj) + c[k];
			break;
		}
	if (sxd == 0) cout << ansi << " " << ansj << " " << w << '\n';
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int n, k; cin >> n >> k;
	vint a(n);
	rep(i, k){
		int d; cin >> d;
		rep(j, d){
			int aa; cin >> aa;
			aa--;
			a[aa]++;
		}
	}
	rep(i, n){
		if(a[i] == 0) ans++;
	}

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

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  if (B-A >= 2*K) {
    for (int i = 0; i < K; i++) cout << A+i << endl;
    for (int i = K-1; i >= 0; i--) cout << B-i << endl;
  }
  else {
    for (int i = A; i <= B; i++) cout << i << endl;
  }
}


Measured memory_bytes: 3536
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count=0;
		
		for(int i=1;i<=N;i++) {
			int ilen = String.valueOf(i).length();
			if(ilen%2==1) {
				count++;
			}
		}
		System.out.println(count);
		
	}
}


Measured memory_bytes: 30164
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

void solve() {
    int n;
    ll w;
    cin >> n >> w;
    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));
    vector<ll> weight(n), val(n);
    for(int i=0;i<n;i++) {
        cin >> weight[i] >> val[i];
        for(int j=0;j<=w;j++) {
            if (j - weight[i] >= 0)  
				dp[i+1][j] = max(dp[i][j], val[i] + dp[i][j - weight[i]]); 
			else
				dp[i+1][j] = dp[i][j]; 
        }
    }
    cout << dp[n][w] << endl;
    return;
} 
 
int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}

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

int main(){
	string s;
    cin>>s;
    string ans;
    int k=0;
  
    for(int i=0 ; i < s.size();i++){
    	if(s.at(i)=='0' || s.at(i)=='1'){
           ans+=s.at(i);
        }
        if(s.at(i)=='B' && ans.size()>0){
           ans.pop_back();
        } 
    }
  cout<<ans<<endl;
}    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long 
#define ld long double
#define mod7 1000000007
#define mod9 1000000009
#define mod 1000003
#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define ct ll t;cin>>t;while(t--)
#define bi begin()
#define ei end()
#define fi first 
#define se second

//   ll flag[100005]={0};
	// ll a[100005]={0};
	// ll b[100005]={0}; 
	// vector<ll>v(100005);     	
bool isPrime(ll n) 
{ 
	// Corner case 
	if (n <= 1) 
		return false; 
	
	// Check from 2 to n-1 
	for (ll i = 2; i*i <= n; i++) 
		if (n % i == 0) 
			return false; 
	
	return true; 
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod) * (a%mod);
        a = (a%mod) * (a%mod);
        b >>= 1;
    }
    return res%mod;
}

bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.se<b.se);
}
ll lcm(ll a,ll b)
{
	return(a*b)/__gcd(a,b);
}
void SieveOfEratosthenes() 
{  
	ll n=100005;
    bool prime[100005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        
        if (prime[p] == true) 
        {   
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
	for(ll i=2;i<100005;i++)
	{
		if(prime[i])
		{
			// v.pb(i);
		}
	}
	
} 
ll fact[1000007]={0};
ll expo(ll x, ll y) {ll res=1;x=x%mod7;while(y>0){if(y&1)res=(1ll*res*x)%mod7;
y=y>>1;x=(1ll*x*x)%mod7;} return res;}
void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod7;}
ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod7-2)))%mod7; return res; }
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
 int main()
{
    fast
	string s;
	cin>>s;
	ll i=0,j=s.size()-1;
	while(i<j)
	{
		if(s[i]!=s[j])
		{
			cout<<"No\n";
			exit(0);
		}
		i++;
		j--;
	}
	i=0;
	j=(s.size()-1)/2-1;
	while(i<j)
	{
		if(s[i]!=s[j])
		{
			cout<<"No\n";
			exit(0);
		}
		i++;
		j--;
	}
	i=(s.size()+3)/2-1;
	j=s.size()-1;
		while(i<j)
	{
		if(s[i]!=s[j])
		{
			cout<<"No\n";
			exit(0);
		}
		i++;
		j--;
	}
	cout<<"Yes\n";
	
}




Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp;
    auto T = readln.chomp;
    auto ss = new int[](S.length+1);
    foreach (i, c; S) {
        ss[i+1] = ss[i];
        if (c == 'A') {
            ss[i+1] += 1;
        } else {
            ss[i+1] += 2;
        }
        ss[i+1] %= 3;
    }
    auto tt = new int[](T.length+1);
    foreach (i, c; T) {
        tt[i+1] = tt[i];
        if (c == 'A') {
            tt[i+1] += 1;
        } else {
            tt[i+1] += 2;
        }
        tt[i+1] %= 3;
    }
    auto Q = readln.chomp.to!int;
    foreach (_q; 0..Q) {
        auto abcd = readln.split.to!(int[]);
        auto a = abcd[0]-1;
        auto b = abcd[1];
        auto c = abcd[2]-1;
        auto d = abcd[3];
        writeln((ss[b] - ss[a] + 3) % 3 == (tt[d] - tt[c] + 3) % 3 ? "YES" : "NO");
    }
}

Measured memory_bytes: 4760
x1,y1,x2,y2 = map(int,input().split())
x2_x1 = x2-x1
y2_y1 = y2-y1
ans = []
x4 = x1-y2_y1
y4 = y1+x2_x1
x3 = x2-y2_y1
y3 = y2+x2_x1
print(str(x3)+" " +str(y3)+" "+str(x4)+" "+str(y4))


Measured memory_bytes: 3060
A, B, AB, X, Y = map(int,input().split())
min_sheet = min(X,Y)

if A + B >= AB * 2:
    min_price = min(AB * 2 * min_sheet + A * (X - min_sheet) + B * (Y - min_sheet), AB * 2 * max(X,Y))
else:
    min_price = A * X + B * Y
    
print(min_price)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<char> v;
	for(int i=0;i<n;i++){
		char s; cin >> s;
		v.push_back(s);
	}
	v.erase(unique(v.begin(),v.end()),v.end());
	cout << v.size() << endl;
}

Measured memory_bytes: 512
def c_many_requirements_dfs():
    import sys
    sys.setrecursionlimit(10**6)
    N, M, Q = [int(i) for i in input().split()]
    Queries = [[int(i) for i in input().split()] for j in range(Q)]

    def calc_score(seq):
        return sum(d for a, b, c, d in Queries if seq[b - 1] - seq[a - 1] == c)

    def dfs(seq):
        if len(seq) == N:
            return calc_score(seq)

        ret = 0
        left = seq[-1] if seq else 1
        for i in range(left, M + 1):
            ret = max(ret, dfs(seq + [i]))
        return ret
    return dfs([])

print(c_many_requirements_dfs())

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

char e[128];
int p;

int exp();
int term();
int fact();

int exp(){
  int ret = term();
  while(e[p] == '+' || e[p] == '-'){
    if(e[p] == '+'){
      p++;
      ret += term();
    }else if(e[p] == '-'){
      p++;
      ret -= term();
    }
  }
  return ret;
}

int term(){
  int ret = fact();
  while(e[p] == '*' || e[p] == '/'){
    if(e[p] == '*'){
      p++;
      ret *= fact();
    }else if(e[p] == '/'){
      p++;
      ret /= fact();
    }
  }
  return ret;
}

int fact(){
  int ret = 0;
  if(e[p] == '('){
    p++;
    ret = exp();
    p++;
  }
  while(isdigit(e[p])){
    ret = ret * 10 + e[p] - '0';
    p++;
  }
  return ret;
}

int main(){
  int n;
  scanf("%d", &n);
  while(n--){
    scanf("%s", e);
    p = 0;
    printf("%d\n", exp());
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int main ()
{
    int q;
    cin >> q;
    while (q--) {
        int n, res = 0;
        cin >> n;
        set<int> t;
        while (n / 10) {
            t.insert(n);
            res++;
            int MAX = 0;
            int j = 1, k = 0;
            while (n) {
                k += j * (n % 10);
                n /= 10;
                MAX = max(MAX, k * n);
                j *= 10;
            }
            n = MAX;
            if (t.find(n) != t.end()) {
                res = -1;
                break;
            }
        }
        cout << res << endl;
    }

    return 0;
}

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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
    ll a, b;
    cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0 || (a + b)% 3 == 0)
    {
        println("Possible");
    }
    else
    {
        println("Impossible");
    }
    
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 200005;

int TC;
int n, m;

int d[10][10], a[350][350];

int main() {

	FAST;

	cin >> n >> m;
	for (int i = 0; i <= 9; i ++) {
		for (int j = 0; j <= 9; j ++) {
			cin >> d[i][j];
		}
	}
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) {
			cin >> a[i][j];
		}
	}
	for (int k = 0; k <= 9; k ++) {
		for (int i = 0; i <= 9; i ++) {
			for (int j = 0; j <= 9; j ++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) {
			if (a[i][j] != -1) ans += d[a[i][j]][1];
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int data[10];
  int i,j,tmp;
  i=j=0;
  while(i<10){
    scanf("%d",&data[i]);
    i++;
  }
  for(i=0;i<10;i++){
      for(j=i+1; j<10; j++){
	  if(data[i] < data[j]){
	      tmp = data[i];
	      data[i] = data[j];
	      data[j] = tmp;
	  }
      }
  }
  i=0;
  while(i<3){
      printf("%d\n",data[i]);
      i++;
  }
  return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

ll H,W;

void countBomb(ll h, ll w, vector<string>& f){
  if(f[h][w] == '#')
    return;

  ll sum = 0;
  REP(i, 8){
    //cout << h << w << i << endl;
    if(0<=h+dy[i] && h+dy[i]<H && 0<=w+dx[i] && w+dx[i]<W){
      if(f[h+dy[i]][w+dx[i]] == '#')
        sum++;
    }
  }

  f[h][w] = '0' + sum;
}

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

  cin >> H >> W;
  vector<string> f(H);
  REP(i, H)
    cin >> f[i];

  REP(h, H){
    REP(w, W)
      countBomb(h, w, f);
    cout << f[h] << endl;
  }

}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))

sorted_l = sorted(l)

w = 0

if n % 2 == 0:
    k = 1
    for i in range(n):
        if k != sorted_l[i]:
            w += 1
        
        if i % 2 == 1:
            k += 2
            
else:
    if sorted_l[0] != 0:
        w += 1
    k = 2
    for i in range(1,n):
        if k != sorted_l[i]:
            w += 1
        
        if i % 2 == 0:
            k += 2
            
if w != 0:
    print(0)

else:
    b = n // 2
    ans = 1
    for i in range(1,b+1):
        ans*= 2
        ans%=(10**9)+7
        
    print(ans)
        

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> L, R;
    rep(i, n) {
        if (s[i] == 'o') L.emplace_back(i + 1), i += c;
        if ((int)L.size() == k) break;
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'o') R.emplace_back(i + 1), i -= c;
        if ((int)R.size() == k) break;
    }
    reverse(all(R));
    rep(i, k) if (L[i] == R[i]) cout << L[i] << endl;
}

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


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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    ll ans = 0;
    for (int i = 1; i < N; ++i) {
        int sum = a[i - 1] + a[i];
        int d = sum - x;
        if (d > 0) {
            ans += d;
            a[i] = max(a[i] - d, 0);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans=0;
  vector<int> l(n),r(n);
  for (int i=0;i<n;i++){
    cin>> l[i] >> r[i];
    ans+=r[i]-l[i]+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    char T[128];
    for (int i = 0; i < 128; i++)
      T[i] = char(i);
    for (int i = 0; i < n; i++) {
      char f, t;
      cin >> f >> t;
      T[f] = t;
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
      char c;
      cin >> c;
      cout << T[c];
    }
    cout << endl;
  }
}

Measured memory_bytes: 856
#include <bits/stdc++.h>
using namespace std;
string s;
bool v[256];
int main() {
	cin >> s;
	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		printf("-1\n");
	} else {
		if (s.size() < 26) {
			for (int i = 0; i < s.size(); i++) {
				v[s[i]] = true;
			}
			char c = 0;
			for (char i = 'a'; i <= 'z'; i++) {
				if (!v[i]) {
					c = i;
					break;
				}
			}
			assert(c != 0);
			s += c;
			cout << s << endl;
		} else {
			for (int i = 0; i < s.size(); i++) {
				v[s[i]] = true;
			}
			int i = s.size();;
			while (s[i - 2] > s[i - 1]) {
				v[s[i - 1]] = false;
				i--;
			}
			v[s[i - 1]] = false;
			i--;
			char c = 0;
			for (char j = s[i - 1]; j <= 'z'; j++) {
				if (!v[j]) {
					c = j;
					break;
				}
			}
			assert(c != 0);
			s[i - 1] = c;
			cout << s.substr(0, i) << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long A, B, C, K;
	cin >> A >> B >> C >> K;
	if(K%2 == 0){
		cout << A-B << endl;
	}
	else{
		cout << B-A << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18L+5;
int main(){
    int N,W;
    scanf("%d%d",&N,&W);
    vector<int> weight(N),value(N);
    for(int i=0; i<N; ++i){
        scanf("%d%d",&weight[i],&value[i]);
    }
    int sum_value=0;
    for(int x:value){
        sum_value+=x;
    }
    vector<ll> dp(sum_value+1,INF);
    dp[0]=0;
    //dp[i] = the minimum total weight of items with total value exactly i
    for(int item=0;item<N;++item){
        for(int value_already=sum_value-value[item];value_already>=0;--value_already){
            dp[value_already+value[item]]=min(dp[value_already]+weight[item],dp[value_already+value[item]]);
        }
    }
    ll ans;
    for(int i=0;i<=sum_value;++i){
        if(dp[i]<=W){
            ans=i;
        }
    }
    printf("%lld\n",ans);
    //while(1);
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e17) + 1;
long double eps = 1.0E-14;
// dp[i][j] i番目までに, 「余分な空白」を j 個挟んだとしたときの和の最大値
LL dp[2 * pow10(5)][3];

void solve()
{
    int N;
    cin >> N;
    vector<LL> A(N);
    REP0 (i, N)
    {
        cin >> A[i];
        REP0 (j, 3)
        {
            dp[i][j] = -LLINF;
        }
    }

    if (N % 2 == 0)
    {
        dp[0][0] = A[0];
        dp[1][0] = A[0];
        dp[1][1] = A[1];
        LL ans = -LLINF;

        for (int i = 2; i < N; i++)
        {
            dp[i][1] = max(dp[i][1], dp[i - 2][1] + A[i]);
            if (i - 3 >= 0)
                dp[i][1] = max(dp[i][1], dp[i - 3][0] + A[i]);

            dp[i][0] = max(dp[i][0], dp[i - 2][0] + A[i]);
        }

        // ans = max(ans, dp[N - 1][0]);
        ans = max(ans, dp[N - 1][1]);
        ans = max(ans, dp[N - 2][0]);

        std::cout << ans << endl;
        return;
    }

    dp[0][0] = dp[1][0] = A[0];
    dp[1][1] = A[1];
    dp[2][0] = dp[0][0] + A[2];
    dp[2][2] = A[2];
    LL ans = -LLINF;

    for (int i = 3; i < N; i++)
    {
        dp[i][2] = max(dp[i][2], dp[i - 2][2] + A[i]);
        dp[i][2] = max(dp[i][2], dp[i - 3][1] + A[i]);
        if (i - 4 >= 0)
            dp[i][2] = max(dp[i][2], dp[i - 4][0] + A[i]);

        dp[i][1] = max(dp[i][1], dp[i - 2][1] + A[i]);
        dp[i][1] = max(dp[i][1], dp[i - 3][0] + A[i]);

        dp[i][0] = max(dp[i][0], dp[i - 2][0] + A[i]);
    }

    // ans = max(ans, dp[N - 1][0]);
    // ans = max(ans, dp[N - 1][1]);
    ans = max(ans, dp[N - 1][2]);

    ans = max(ans, dp[N - 2][1]);

    ans = max(ans, dp[N - 3][0]);

    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 9528
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000 + 20 ;
long long inf = 1e18;
long long a[MAXN];
bool vis[MAXN];
vector <int> vec[MAXN];

void dfs(int u, int v) {
	for (int i = 0; i < vec[u].size(); i++)
		if (vec[u][i] != v) {
			a[vec[u][i]] += a[u];
			dfs(vec[u][i], u);
		}
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
	int n, q;
	cin >> n >> q;
	
	int u, v;
	for (int i = 1; i < n; i++) {
		cin >> u >> v;
		
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	
	int val;
	for (int i = 0; i < q; i++) {
		cin >> u >> val; 
		a[u] += val;
	}

	queue <int> qu;
	qu.push(1);

	while (qu.size() > 0) {
		u = qu.front();
		qu.pop();
		vis[u] = 1;
		
		for (int i = 0; i < vec[u].size(); i++)
		if (!vis[vec[u][i]]) {
			a[vec[u][i]] += a[u];
			qu.push(vec[u][i]);
		}
	}
	
	for(int i = 1; i <= n; i++)
		cout << a[i] << " ";
}	

	
 
	

	
	
	

Measured memory_bytes: 36724
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>


#define SIZEMAX 100007

using namespace std;
using ll = long long int;

ll N, M, S, T;

vector<set<ll>> graph(SIZEMAX);

struct entry {
  ll cost;
  ll node;
  ll div3;

  bool operator<(const entry &a) const {
    return cost < a.cost;
  }
};

struct hoge {
  ll node;
  ll div3;

  bool operator<(const hoge &a) const {
    return node < a.node || (node == a.node && div3 < a.div3);
  }

  bool operator==(const hoge &a) const {
    return node == a.node && div3 == a.div3;
  }
};

ll bfs(ll from, ll to) {
  set<hoge> open;
  queue<entry> queue;

  open.insert(hoge {from, 0 });
  queue.push(entry {0, from, 0} );

  while (!queue.empty()) {
    entry e = queue.front();
    queue.pop();

    if (e.node == to && e.div3 == 0) {
      return e.cost;
    }

    for (ll next : graph[e.node]) {
      ll ndiv3 = (e.div3 + 1) % 3;
      if (open.count({hoge { next, ndiv3 }}) > 0) {
        continue;
      }

      open.insert({hoge { next, ndiv3 }});
      queue.push(entry { e.cost + 1, next, ndiv3});
    }
  }

  return -1;
}

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

  for (int i = 0; i < M; i++) {
    ll u, v;
    cin >> u >> v;

    graph[u].insert(v);
  }

  cin >> S >> T;
  ll result = bfs(S, T);

  if (result != -1) {
    cout << result / 3 << endl;
  } else {
    cout << -1 << endl;
  }


  return 0;
}

Measured memory_bytes: 25984
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::*;
//use std::collections::*;
//use std::cmp::*;
// use std::num;
fn main() {
    input! {N:usize, A:[i64;N]}
    let mut ans = -1_000_000_000_000_000_000;
    let mut sodd = vec![0i64; N + 1];
    let mut seven = vec![0i64; N + 1];
    sodd[0] = 0;
    for i in 0..N {
        if i & 1 == 1 {
            sodd[i + 1] = sodd[i] + A[i];
            seven[i + 1] = seven[i];
        } else {
            sodd[i + 1] = sodd[i];
            seven[i + 1] = seven[i] + A[i];
        }
    }
    // 連続する箇所をi,jと置く。
    let mut t = 0;
    //println!("sodd {:?}", sodd);
    //println!("seve {:?}", seven);
    if N & 1 == 0 {
        //偶数個の場合
        for i in (0..=N).step_by(2) {
            //println!("i{},seven={}", i, seven[i]);
            //println!("sodd={}-{}", sodd[N], sodd[i + 1]);
            t = seven[i] + sodd[N] - sodd[i];
            ans = std::cmp::max(ans, t);
        }
    } else {
        //奇数個の場合
        let inf = -1_000_000_000_000_000_000;
        let mut max_over = vec![inf; N + 1];
        // max_over ...j >= i+1の時の、seven[N] + sodd[j] -seven[j] の最大値
        max_over[N] = sodd[N] - seven[N];
        let mut i = N - 2;
        loop {
            max_over[i] = std::cmp::max(max_over[i + 2], sodd[i] - seven[i]);
            if i >= 2 {
                i -= 2;
            } else {
                break;
            }
        }
        //println!("{:?}", max_over);
        for i in (0..=N).step_by(2) {
            //println!("i{},j{},seven={}", i, j, seven[i]);
            //println!("sodd={}-{}", sodd[j], sodd[i + 1]);
            //println!("seven={}-{}", seven[N], seven[j + 1]);
            // t = seven[i]+ sodd[j] - sodd[i] + seven[N] - seven[j];
            t = seven[i] - sodd[i] + seven[N] + max_over[i + 1];
            ans = std::cmp::max(ans, t);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 10376
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    char a,b;
    cin>>a>>b;
    if(a>b)
    cout<<'>';
    if(a<b)
    cout<<'<';
    if(a==b)
    cout<<'=';
    cout<<endl;
    return 0;
}

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

int main()
{
    int a,b,k;

    while(cin>>a>>b>>k)
    {
        int arr[110],x=0;

        for(int i=min(a,b);i>=1;i--)
        {
            if(a%i==0 && b%i==0)
                arr[++x]=i;
        }
        cout<<arr[k]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int x;

int main(){
    cin>>x;
    if(x<1200){
        cout<<"ABC"<<endl;
    }else{
        cout<<"ARC"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int gcd(int x, int y)
{
    return (x % y) ? gcd(y, x % y) : y;
}
int lcm(int x, int y)
{
    return x / gcd(x, y) * y;
}
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);

    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
    return 0;
}


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

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
#define rep(i, n) for(int64_t i = 0; i < (int64_t)(n); i++)
  int64_t x,y;
  cin>>x>>y;
  int64_t answer=1;
  int64_t beta=1;
  int64_t z,a;
  if((x+y)%3 ==0 && (x<=2*y && y<=2*x )){
    z= (x+y)/3;
    a= x-z;
    for(int64_t i=0; i<a; i++){
      answer=answer*(z-i);
      answer=answer%1000000007;
      beta=beta*(i+1);
      beta=beta%1000000007;
      
    }
    answer=answer*modinv(beta,1000000007);
    answer=answer%1000000007;
  }
  else
    answer=0;
  cout<<answer;
  
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x[] = new int[4];
		
		for(int i=0; i<4; i++) {
			x[i] = sc.nextInt();
		}
		int a = x[2] - x[0];
		int b = x[3] - x[1];
		
		System.out.println(x[2] - b);
		System.out.println(x[3] + a);
		System.out.println(x[0] - b);
		System.out.println(x[1] + a);

	}

}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, ans;
    scanf("%lld", &N);
    vector<ll> P(N),Q(N),v(N);
    REP(int,i,0,N) scanf("%lld", &P.at(i));
    REP(int,i,0,N) scanf("%lld", &Q.at(i));
    ll a, b, c;
    iota(v.begin(), v.end(), 1);
    c = 1;
    do {
        REP(int,i,0,N){
            if ( v.at(i) != P.at(i) ) break;
            if ( i == N - 1 ) a = c;
        }
        REP(int,i,0,N){
            if ( v.at(i) != Q.at(i) ) break;
            if ( i == N - 1 ) b = c;
        }
        c++;
    } while( next_permutation(v.begin(), v.end()) ); 
    ans = abs(a-b);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
a, op, b = input().split()
while op!="?":
    a=int(a)
    b=int(b)
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(int(a/b))
    a, op, b = input().split()



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

using namespace std;

#define pb push_back
#define ll long long
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

const ll INF = 1e9 + 5, N = 205;

int main(){
	string s;
	cin >> s;
	int ans = 0;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'R') cnt++;
		else cnt = 0;
		ans = max(ans, cnt);
	}	
	cout << ans << endl;
}

Measured memory_bytes: 3624