akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

//constexpr long long int MOD=1000000007;
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double  EPS=1e-8;

struct Query{
	long double l,r,p,mid;
	Query(const long double a,const long double b,const long double pp,const long double t){
		l=a,r=b,p=pp;
		Cal(t);
		return;
	}
	long double min_error,max_error;
	void Cal(const long double t){
		mid=(l+r)/2;
		max_error=max(abs(t-l),abs(t-r));
		min_error=min(abs(t-l),abs(t-r));
		if(l<=t-EPS&&t<=r+EPS)min_error=0;
		return ;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>K;
	long double l,r;
	cin>>l>>r;
	long double p,e,t;
	cin>>p>>e>>t;
	vector<vector<Query>>query(K+1);
	query[0].emplace_back(Query(l,r,1,t));
	long double ans=0;
	for(int i=0;i<K;i++){
		//cout<<i<<endl;
		for(const auto &j:query[i]){
			//cout<<"l r "<<j.l<<" "<<j.r<<" "<<j.p<<endl;
			//cout<<j.min_error<<" "<<j.max_error<<endl;
			if(j.min_error>e-EPS)continue;
			if(j.max_error<=e+EPS){
				ans+=j.p;
				continue;
			}
			if(j.mid<t){
				query[i+1].emplace_back(j.mid,j.r,j.p*((long double)1-p),t);
				query[i+1].emplace_back(j.l,j.mid,j.p*p,t);
			}
			else{
				query[i+1].emplace_back(j.mid,j.r,j.p*p,t);
				query[i+1].emplace_back(j.l,j.mid,j.p*((long double)1-p),t);
			}
		}
	}
	//cout<<ans<<endl;
	for(const auto &i:query.back()){
		if(abs(t-i.mid)<=e)ans+=i.p;
	}
	cout<<fixed<<setprecision(15)<<ans<<endl;
	return 0;
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << fixed << setprecision(15);
    //freopen("input.txt", "r", stdin);
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        set<char> kek;
        kek.insert(a[i]);
        kek.insert(b[i]);
        kek.insert(c[i]);
        ans += kek.size() - 1;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;
int n;

int main(){
  cin >> n;
  string s = to_string(n);
  int f=0;
  REP(i,s.size()){
    f += s[i]-'0';
  }
  if(n%f==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long  a, b; cin >> a >> b;
	cout << (a * b) / (long long )gcd(a, b);

	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int MAXK = 1e5 + 5;

ll ar[MAXK];

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int k;
    scanf("%d", &k);
    for (int i = 0; i < k; i++) {
        scanf("%lld", &ar[i]);
    }
    bool impossible = false;
    ll a = 2, b = 3;
    if (ar[k - 1] != 2) {
        impossible = true;
    } else {
        for (int i = k - 1; i > 0; i--) {
            if (ar[i - 1] >= a && ar[i - 1] <= b) {
                a = ar[i - 1];
                b = ar[i - 1] * 2 - 1;
            } else if (ar[i - 1] > b) {
                impossible = true;
                break;
            } else {
                ll lo = ceil((double)a / ar[i - 1]) * ar[i - 1];
                ll hi = (b / ar[i - 1]) * ar[i - 1] + ar[i - 1] - 1;
                if (lo > b) {
                    impossible = true;
                    break;
                }
                a = lo;
                b = hi;
            }
        }
    }
    if (impossible)
        puts("-1");
    else {
        printf("%lld %lld\n", a, b);
    }
    return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100005,maxm=400005;
int last[maxn],pre[maxm],other[maxm],t,cal[maxn],vis[maxn],q[maxn],head,tail;
int n,m,x,y;
void add(int x,int y)
{   
    ++t;
    pre[t]=last[x];
    last[x]=t;
    other[t]=y;
}
inline int read(void)
{
	int x=0,f=1;
     char ch=getchar();
     while(ch>'9'||ch<'0'){
       if(ch=='-') f=-1;
       ch=getchar(); }
     while(ch>='0'&&ch<='9'){
       x=x*10+ch-'0';
       ch=getchar();}
     return x*f;
}
int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		ll I=0,P=0,Q=0;
		memset(last,0,sizeof(last));t=0;memset(vis,0,sizeof(vis));
		memset(pre,0,sizeof(pre));memset(other,0,sizeof(other));
		for(int i=1;i<=m;++i){
				x=read(),y=read();add(x,y);add(y,x);
		}
		for(int i=1;i<=n;++i)if(!vis[i])
		{
				head=tail=0;
				q[++tail]=i;
				cal[i]=0;
				vis[i]=1;
				bool flag=1;
				while(head<tail)
				{
    	              int u=q[++head];
    	              for(int j=last[u];j;j=pre[j])
					  {
    	                     int v=other[j];
    	                     if(!vis[v])
							 {
            	                q[++tail]=v;vis[v]=1;cal[v]=cal[u]+1;
           	              	 }
							 else
							 {
								 if((cal[v]-cal[u])%2==0)flag=0;
							 }
                       }
	            }
	  			if(head==1)
				{++I;continue;}
	  			if(flag)++Q;
	  			else ++P;
		}
		printf("%lld\n",2ll*I*n-I*I+P*P+2ll*P*Q+2ll*Q*Q);
    }
	return 0;
}

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

using namespace std;

int main()
{
	int n[3];
	
	cin >> n[0] >> n[1] >> n[2];
	
	sort(n, n + 3);
	
	if (n[2] == n[0] + n[1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return (0);
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int par[10000];//親
int fukasa[10000];//深さ
//初期化
void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        fukasa[i]=0;
    }
}
//木の根を求める
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}
//xとyの集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y){
        return;
    }
    if(fukasa[x]<fukasa[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(fukasa[x]==fukasa[y]){
            fukasa[x]++;
        }
    }
}
int main() {
    int n,m;
    cin>>n>>m;
    int a[100],b[100];
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
    }
    int ans=0;
    for(int i=0;i<m;i++){
        init(n);
        for(int j=0;j<m;j++){
            if(i!=j){
                unite(a[j]-1,b[j]-1);
            }
        }
        int k=0;
        for(int j=0;j<n;j++){
            if(find(j)==j){
                k++;
            }
        }
        if(k==2){
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

	#define rep(i,a,b)                for(ll i=a;i<b;i++)
	#define re(i,b)                for(ll i=0;i<b;i++)
	#define repr(i,n)                for(ll i=n-1;i>=0;i--)
	#define ll long long
	#define ld long double
	#define llu long long unsigned
	#define vll std::vector<ll>
	#define mll std::map<ll, ll>
	#define pll std::pair<ll, ll>
	#define mpll std::map<pair<ll,ll>, ll>
	#define sll std::set<ll>
	#define ff first
	#define ss second
	#define msll std::multiset<ll>
	#define all(c) c.begin(), c.end()
	#define allr(c) c.rbegin(), c.rend()
	#define srt(x) sort(all(x))
	#define rsrt(x) sort(allr(x))
	#define mp make_pair
	#define mt make_tuple
	#define eb emplace_back
	#define pb push_back
	#define s(yy) ll yy;cin>>yy
	#define mod 1e9+7
	#define maxlong 1e18+5


	/*
	###################################################### 
	#                                                    #
	#                     @author                        #
	#                  Parth Lathiya                     #
	#      https://www.cse.iitb.ac.in/~parthiitb/        #
	#                                                    #
	###################################################### 
	*/


	int main()
	{

		ios_base::sync_with_stdio(false);
		cin.tie(NULL);

		#ifdef PARTH_LATHIYA_HOME

			freopen("A_in.txt","r",stdin);
		
			ll ttt,bkkk;
			cin>>ttt;
			bkkk=ttt;
			while(ttt--) {
				cout<<"Testcase - "<<bkkk-ttt<<"\n";
		#endif

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

	// whbrjpjyhsrywlqjxdbrbaomnw
		string s;
		cin>>s;
		ll prev[26];
		ll ma[26];
		re(i,26){
			prev[i]=-1;
			ma[i]=-1;
		}
		re(i,s.length()){
			ma[s[i]-'a']=max(ma[s[i]-'a'],(ll) (i-prev[s[i]-'a']-1));
			prev[s[i]-'a']=i;
		}
		re(i,26)
		{
			ma[s[i]-'a']=max(ma[s[i]-'a'],(ll)(s.length()-prev[s[i]-'a']-1));
		}
		ll ans=101;
		re(i,26)
			if(ma[i]!=-1)ans=min(ans,ma[i]);

			cout<<ans;

	//--------------------------------------------------------------------------------------
		
		#ifdef PARTH_LATHIYA_HOME
			cout<<"\n"; }
		#endif

		return 0;
	}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tiii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

struct unionFind {
    vector<int> data;
    unionFind(int size) : data(size, -1) {}
    
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if(data[y] < data[x]) {
                swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }

    int rank(int x) {
        return -data[root(x)];
    }
};

//cost,from,toの順
vector<tiii> T;
vector<tiii> Krusans;

ll Kruskal(int n) {
    sort(T.begin(), T.end());
    ll ans = 0;
    ll num = 0;
    unionFind u(n);
    int size = T.size();
    for (int i = 0; i < size; i++) {
        int cost = get<0>(T[i]);
        int from = get<1>(T[i]);
        int to = get<2>(T[i]);
        if (u.root(from) != u.root(to)) {
            u.unite(from, to);
            ans += cost;
            num++;
            tiii t = make_tuple(cost, from, to);
            Krusans.push_back(t);
        }
        if (num == n - 1) {
            break;
        }
    }
    return ans;
}

int mat[200][200];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> mat[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (mat[i][j] != -1) {
                tiii e = make_tuple(mat[i][j], i, j);
                T.push_back(e);
            }
        }
    }
    ll ans = Kruskal(N);
    cout << ans << endl;
}



Measured memory_bytes: 3260
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

ans = 0
tmp = 0
for i in range(N):
    if S[i] == "I":
        tmp += 1
    else:
        tmp -= 1
    if (tmp > ans):
        ans = tmp
print(ans)


Measured memory_bytes: 27240
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, W = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(N)]


dp = [[0]*(W+1) for _  in range(N+1)]

for i in range(1, N+1): # watasu=
    v, w = vw[i-1]
    for j in range(W+1):
        if j-w>=0:
            dp[i][j] = max(dp[i-1][j-w]+v, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
print(max(dp[N]))



Measured memory_bytes: 42396
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
  cin>>n;
  long long int a[n];
  long long int dp[n][n];
  long long int sum=0;
  for(int i=0;i<n;i++){
    	cin>>a[i];
    dp[i][i]=a[i];
    sum+=a[i];
    }
     for(int len=2;len<=n;len++){
	for(int i=0;i<n-len+1;i++){
      int j=i+len-1;
      if(i+1==j)
        dp[i][j]=max(a[i],a[j]);
      else
        dp[i][j]=max(a[i]+min(dp[i+2][j],dp[i+1][j-1]),a[j]+min(dp[i+1][j-1],dp[i][j-2]));
    }
    }
  
  cout<<2*dp[0][n-1]-sum<<endl;
}


Measured memory_bytes: 70528
#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;
	string s;
	cin >> s;
	ll l = s.length(), i, t = 0;
	ll ans = 0;
	fr(i,0,l)
	{
		if(i == 0)
			ans++;
		else
		{
			if(s[i] != s[i-1])
			{
				ans++;
				t = 0;
			}
			else
			{
				if(t)
				{
					ans++;
					t = 0;
				}
				else
				{
					if(i + 1 < l)
					{
						ans++;
						i++;
						t = 1;
					}
				}
			}
		}
	}
	cout << ans;
}


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

int main() {
    int n;
    cin >> n;
    ll a[n];
    int mi = 0, ze = 0;
    ll sum = 0, t = 1e18;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) mi++;
        if (a[i] == 0) ze = 1;
        sum += abs(a[i]);
        t = min(t, abs(a[i]));
    }
    if (mi % 2 && ze == 0) {
        cout << sum - 2 * t << endl;
    } else {
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        List<Grid> gridList = new ArrayList<>();

        int n = in.nextInt();
        for(int i = 0; i < n; i++) {
            gridList.add(new Grid(Color.RED, in.nextInt(), in.nextInt()));
        }
        for(int i = 0; i < n; i++) {
            gridList.add(new Grid(Color.BLUE, in.nextInt(), in.nextInt()));
        }
        gridList.sort(Comparator.comparing(Grid::getX).thenComparing(Grid::getColor).thenComparing(Grid::getY));
        List<Grid> tmp = new ArrayList<>();
        int ans = 0;
        for (Grid grid : gridList) {
            if(grid.color == Color.RED) {
                tmp.add(grid);
            } else {
                List<Grid> list = tmp.stream()
                        .filter(g -> g.getY() < grid.getY())
                        .collect(Collectors.toList());
                if(list.size() > 0) {
                    ans++;
                    list.sort(Comparator.comparing(Grid::getY));
                    tmp.remove(list.get(list.size() - 1));
                }
            }
        }
        System.out.println(ans);
    }
}

class Grid {

    Color color;
    int x;
    int y;

    public Grid(Color color, int x, int y) {
        this.color = color;
        this.x = x;
        this.y = y;
    }
    public Color getColor() { return this.color; }
    public int getX() { return this.x; }
    public int getY() { return this.y; }

    public String toString(){
        return String.format(color + " \t" + x + ", " + y);
    }
}

enum Color {
    BLUE,
    RED
}


Measured memory_bytes: 28884
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] map = new char[h][w];
        boolean[][] arrived = new boolean[h][w];
        int sharp = 0;
        for(int i = 0; i < h; i++){
            map[i] = sc.next().toCharArray();
            for(char c : map[i]){
                if(c == '#'){
                    sharp++;
                }
            }
        }
        arrived[0][0] = true;
        Deque<Point> q = new ArrayDeque<Point>();
        q.add(new Point(0,0,1));
        int[] mx = {-1,0,0,1};
        int[] my = {0,-1,1,0};
        while(q.size() > 0){
            Point p = q.poll();
            for(int i = 0; i < 4; i++){
                int nx = p.x + mx[i];
                int ny = p.y + my[i];
                if(nx == w-1 && ny == h-1){
                    System.out.println(h*w-sharp-p.cnt-1);
                    return;
                }
                if(0 <= nx && nx < w && 0 <= ny && ny < h && map[ny][nx] != '#' && !arrived[ny][nx]){
                    q.add(new Point(nx,ny,p.cnt+1));
                    arrived[ny][nx] = true;
                }
            }
        }
        System.out.println(-1);
    }
}

class Point{
    int x, y, cnt;
    public Point(int x, int y, int cnt){
        this.x = x;
        this.y = y;
        this.cnt = cnt;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21332
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		Integer[] arr = new Integer[3];

		for(int i = 0; i < arr.length; i++) {
			arr[i] = sc.nextInt();
		}

		Arrays.sort(arr);


		String buf ="";
		for(int i = 0; i < arr.length; i++){
			buf += arr[i];
			if(i != arr.length-1) buf += " ";
		}

		System.out.println(buf);

	}

}



Measured memory_bytes: 26364
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    int a[55], b[55], c[55], d[55];
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> vec(N + M, 1);
    rep(i, M - 1) {
        vec.at(i) = 0;
    }

    int ans = 0;
    do {
        int cnt = 0;
        int tmp = 0;
        vector<int> A;
        rep(i, N + M) {
            if(vec.at(i) == 0) cnt++;
            else A.push_back(cnt + 1);
        }
        rep(i, Q) {
            if(A.at(b[i]) - A.at(a[i]) == c[i]) tmp += d[i];
        }
        ans = max(ans, tmp);
    } while (next_permutation(all(vec)));

    cout << ans << endl;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int> > s(M);
    for (int i = 0; i < M; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int a; cin >> a; --a;
            s[i].push_back(a);
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; ++i) cin >> p[i];
    
    long long res = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            int con = 0;
            for (auto v : s[i]) {
                if (bit & (1<<v)) ++con;
            }
            if (con % 2 != p[i]) ok = false;
        }
        if (ok) ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
using System;
class pg
 {
  static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());
    string a = Console.ReadLine();
    string[] v = a.Split(' ');
    
    double[] t= new double[n];

    for(int i =0;i< n;i++)
    {
      t[i]= double.Parse(v[i]);
    }
    
    Array.Sort(t);
    double pre = t[0];
    for(int i =1;i< n;i++)
    {
      pre = (t[i]+ pre)/2;
    }
    
    Console.WriteLine(pre);
  }
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


int n;
string s, t;

map<char,set<char>> mp;
set<char> viz;

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

    cin>>s>>t;

    n = s.size();
    map<char,int> into;

    for (int i=0; i<n; i++) {
	mp[s[i]].insert(t[i]);
	if (!into.count(s[i])) {
	    into[s[i]];
	}
	into[t[i]]++;
    }

    for (auto p: mp) {
	int n = p.second.size();
	if (n != 1) out("No");
    }

    for (auto qq: into) {
	char c = qq.first;
	if (viz.count(c)) continue;
	if (qq.second>0) continue;
	bool cycle = true;
	while (!viz.count(c)) {
	    viz.insert(c);
	    if (!mp.count(c)) {
		cycle = false;
		break;
	    }
	    c = *mp[c].begin();
	}
	if (cycle) {
	    if (c != qq.first) {
		out("No");
	    }
	}

    }

    out("Yes");    
    
    return 0;
}


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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    string s;
    cin >> s;
    string a = "";
    FOR(i, 0, s.size()) {
        a += s[i];
        i++;
    }
    cout << a << "\n";
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n,m;
LL fac[N],inv[N];
const LL mod=1e9+7;
LL pm(LL x,LL y){
	LL z=1;
	while(y){
		if(y&1)z=z*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return z;
}
void P(){
	fac[0]=1;
	for(int i=1;i<N;i++)fac[i]=fac[i-1]*i%mod;
	inv[N-1]=pm(fac[N-1],mod-2);
	for(int i=N-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
LL get(int x,int y){
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;P();
  LL ans=0;
  for(int i=0;i<=n;i++){
  	int l=n-i;
  	if(i&1)ans=(ans-get(n,i)*get(m-i,l)%mod*fac[l]%mod+mod)%mod;
  	else ans=(ans+get(n,i)*get(m-i,l)%mod*fac[l]%mod)%mod;
  }
  cout<<ans*get(m,n)%mod*fac[n]%mod<<'\n';
 	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i, n) {
    int b;
    cin >> b;
    a[i] = P(b, i);
  }
  sort(a.begin(), a.end());
  vector<int> ans(n);
  P mx = a[n - 1], sc = a[n - 2];
  ans[mx.second] = sc.first;
  rep(i, n - 1) {
    P p = a[i];
    ans[p.second] = mx.first;
  }
  rep(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 100001

using namespace std;

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

int main() {
    int n;
    int a[MAX_N];
    cin >> n;
    int max_a = 0;
    int max_index = -1;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (max_a < a[i]) {
            max_a = a[i];
            max_index = i;
        }
    }
    
    int min_diff = INF;
    int min_index = -1;
    if (max_a % 2 == 0) {
        for (int i = 0; i < n; ++i) {
            if (i == max_index) continue;
            if (min_diff > abs(max_a/2 - a[i])) {
                min_diff = abs(max_a/2 - a[i]);
                min_index = i;
            }
        }
    } else {
        for (int i = 0; i < n; ++i) {
            if (i == max_index) continue;
            if (min_diff > min(abs((max_a-1)/2 - a[i]), abs((max_a+1)/2 - a[i]))) {
                min_diff = min(abs((max_a-1)/2 - a[i]), abs((max_a+1)/2 - a[i]));
                min_index = i;
            }
        }
    }
    
    printf("%d %d\n", max_a, a[min_index]);
    
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int array[] = new int[3];
        for (int i = 0; i < 3; i++) {
            array[i] = scan.nextInt();
        }
           
        
        for (int i = 0; i < (3 - 1); i++) {
            for (int j = (3 - 1); j > i; j--) {
                if(array[j-1] > array[j]){
                    int tmp = array[j-1];
                    array[j-1] = array[j];
                    array[j] = tmp;
                }
            }
        }
        System.out.println(array[0]+" "+array[1]+" "+array[2]);
        

    }

}
 


Measured memory_bytes: 26156
#include <bits/stdc++.h>
using namespace std;
const int N=200010,Mod=998244353;
const double pi=acos(-1.0);
typedef long long int ll;
typedef pair<int,int> pii;
int a,b,c;
int main()
{
  cin>>a>>b>>c;
  cout<<(max(0,c-a+b))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,x,y;
signed main()
{
	cin>>n>>m>>x>>y;
	double ans=1.0*n*m/2.0;
	if(n%2==0&&m%2==0)
	{
		if(x==n/2&&y==m/2)printf("%.6lf 1",ans);
		else printf("%.6lf 0",ans);
	}
	else printf("%.6lf 0",ans);;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll n, s[334], sum = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> s[i];
		sum += s[i];
	}
	sort(s, s + n);
	if (sum % 10 != 0)cout << sum << endl;
	else for (int i = 0;i < n;i++) {
		if (s[i] % 10 != 0) {
			cout << sum - s[i] << endl;
          	break;
		}
      	if(i==n-1)cout << 0 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll W, H, x, y;
  cin >> W >> H >> x >> y;


  if(W%2==0 && H%2==0 && W/2==x && H/2==y){
    printf("%.12lf %d\n", W*(double)H/2.0, 1);
  }else{
    printf("%.12lf %d\n", W*(double)H/2.0, 0);
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N,K;
  double ans=0;
  double tmp=1.0;
  cin >> N >> K;
  rep(i, N){
    long double cnt=0;
    int j=i+1;
    while(j<K){
      j *= 2;
      cnt += tmp;
    }
    ans += (long double)pow(0.5, cnt)/N;
  }
 cout<< fixed <<setprecision(12)<<ans<<endl;
}


Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [0] * N
    for i in range(N)[::-1]:
        s = sum(B[i :: i + 1]) % 2
        if A[i] == s:
            continue
        else:
            B[i] = 1

    B = [i + 1 for i in range(N) if B[i] == 1]
    print(len(B))
    print(*B, sep=" ")


if __name__ == "__main__":
    main()


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

using namespace std;

int helpercol(int j, int h, int w, int k, int total, vector<vector<char>> &sq, vector<bool> &rows) {
    if (total < 0) {
        return 0;
    }
    int black = 0;
    int solutions = 0;
    for (int i = 0; i < h; i++) {
        if (rows[i] == 0 && sq[i][j] == '#') {
            black += 1;
        }
    }
    if (total - black == k) {
        solutions += 1;
    }
    for (int i = j + 1; i < w; i++) {
        solutions += helpercol(i, h, w, k, total - black, sq, rows);
    }
    return solutions;
}
    
int helper(int i, int h, int w, int k,int total, vector<vector<char>> &sq, vector<bool> &rows){
    if (total < 0) {
        return 0;
    }
    int black = 0;
    int solutions = 0;
    for (int j = 0; j < w; j++) {
        if (sq[i][j] == '#') {
            black += 1;
        }
    }
    if (total - black == k) {
        solutions += 1;
    }
    rows[i] = 1;
    for (int j = 0; j < w; j++) {
        solutions += helpercol(j,h,w,k,total-black,sq,rows);
    }
    for (int j = i + 1; j < h; j++) {
        vector<bool> nrow = rows;
        solutions += helper(j,h,w,k,total-black,sq,nrow);
    }
    return solutions;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> sq;
    char c;
    int total = 0;
    for (int i = 0; i < h; i++) {
        sq.push_back(vector<char> ());
        for (int j = 0; j < w; j++) {
            cin >> c;
            if (c == '#') {
                total += 1;
            }
            sq[i].push_back(c);
        }
    }
    int solutions = 0;
    if (total == k) {
        solutions += 1;
    }
    vector<bool> rows(h,0);
    for (int j = 0; j < w; j++) {
        solutions += helpercol(j,h,w,k,total,sq,rows);
    }   
    for (int i = 0; i < h; i++) {
        vector<bool> rows(h,0);
        solutions += helper(i,h,w,k,total,sq,rows);
    }
    cout << solutions;
}


Measured memory_bytes: 3644
import numpy as np

n, m, c = map(int, input().split())
B = np.array(list(map(int, input().split())))

ans = 0
for i in range(n):
    sum = 0
    A = np.array(list(map(int, input().split())))
    sum += np.dot(A, B)
    if sum > -c: ans += 1
print(ans)


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  string S;

  cin >> N >> S;

  int ans = 0;
  REP(i, N - 2) {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

struct node{int l,r;}seg[300300];
bool operator <(node p,node q) {return p.r-p.l<q.r-q.l;}
int n,m,tr[300300],ans[300300];

void add(int p,int x)
{
	for (int i=p;i<=m;i+=lowbit(i)) tr[i]+=x;
}

int query(int p)
{
	int ans=0;
	for (int i=p;i;i-=lowbit(i)) ans+=tr[i];
	return ans;
}

void modify(int l,int r,int x) {add(l,x);add(r+1,-x);}

int main()
{
	n=read();m=read();
	rep(i,1,n) {seg[i].l=read();seg[i].r=read();}
	sort(seg+1,seg+1+n);
	int l=1;
	rep(d,1,m)
	{
		while ((l<=n) && (seg[l].r-seg[l].l+1<d))
		{
			modify(seg[l].l,seg[l].r,1);
			l++;
		}
		ans[d]+=n-l+1;
		for (int i=d;i<=m;i+=d) ans[d]+=query(i);
	}
	rep(i,1,m) printf("%d\n",ans[i]);
	return 0;
}
		



Measured memory_bytes: 4352
def d_3n_numbers(N, A):
    import heapq
    left = A[:N]
    heapq.heapify(left)
    # heappopはキューの最小値を取り出すが、rightからは最大値を取り出したいので-1を掛ける
    # 後にマイナスが付いているところは、それの帳尻を合わせている
    right = [-i for i in A[2 * N:]]
    heapq.heapify(right)

    # 最初、leftには数列の先頭N個が、rightには末尾N個が格納されている
    # 数列のN番目から2N番目まで順に、leftに格納して最小値を捨てることを繰り返す
    # 数列の2N番目からN番目まで順に、rightに格納して最大値を捨てることを繰り返す
    left_sum = [sum(left)]
    right_sum = [-sum(right)]
    for k in range(N, 2 * N):
        heapq.heappush(left, A[k])
        v = heapq.heappop(left)
        left_sum.append(left_sum[-1] + A[k] - v)
    for k in range(2 * N - 1, N - 1, -1):
        heapq.heappush(right, -A[k])
        v = heapq.heappop(right)
        right_sum.append(right_sum[-1] + A[k] - (-v))

    score = [a - b for a, b in zip(left_sum, right_sum[::-1])]
    return max(score)

N = int(input())
A = [int(i) for i in input().split()]
print(d_3n_numbers(N, A))

Measured memory_bytes: 40724
#include <stdio.h>
    #include <string.h>

    void swap(int *x,int *y);
    int gcd(int a,int b);

    int main(void)
    {
        int a,b,ans;

        scanf("%d %d",&a,&b);
        if(a<b){swap(&a,&b);}
        ans = gcd(a,b);
        
        printf("%d\n",ans);

        return 0;
    }

void swap(int *x,int *y){
    int tmp;

    tmp = *x;
    *x = *y;
    *y = tmp;
}

    int gcd(int a,int b){
        int r;

        r = a % b;
        while(r>0){
            a = b;
            b = r;
            r = a % b;
        }

        return b;
    }



Measured memory_bytes: 2088
# import pandas as pd
# import numpy as np

# d = pd.read_csv("useful.csv", usecols = ["Q133", "Q134", "Q146"])

# #l = d["Q133"]
# l = d["Q146"]
# bad = []
# good = [] 
# for i in range(1, 56):
# 	if int(l[i][0]) >= 4:
# 		good.append(i)
# 	else:
# 		bad.append(i)
# print(bad, good)

import sys
input = sys.stdin.readline

n = int(input())
b = list(map(int, input().split()))
a = [0 for _ in range(n)]
a[0] = b[0]
for i in range(1, n-1):
	a[i] = min(b[i-1], b[i])
a[-1] = b[-1]
print(sum(a))


Measured memory_bytes: 38384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
// use std::cmp::{max, min};

fn main() {
    input! { s: String }
    println!("{}", (0..(s.len() - 2)).map(|i| {
        (s[i..(i + 3)].parse::<i32>().unwrap() - 753).abs()
    }).min().unwrap())
}


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

int main(){
    string S;
    cin >> S;
    int count =0;
    for(int i=0;i<=((S.length()-1)/2);i++){
        if(S.at(i)!=S.at(S.length()-1-i)) count++;
    }
    cout << count <<endl;
}

Measured memory_bytes: 256
N , M = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(M)]

ans = "IMPOSSIBLE"

start_candidate = [X[1] for X in s if X[0]==1 ]
goal_candidate = [X[0] for X in s if X[1]==N]

ans = len(start_candidate)+len(goal_candidate)-len(set(start_candidate+goal_candidate))
if ans != 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 64156
# coding: utf-8
N=int(input())
n=int(str(N)[-1])

if n==2 or n==4 or n==5 or n==7 or n==9:
    print("hon")
elif n==0 or n==1 or n==6 or n==8:
    print("pon")
elif n==3:
    print("bon")


Measured memory_bytes: 9172
N,K = map(int, input().split())
S = input()

change = [0] # 開始地点も連続文字列の始点なので
for i, (a, b) in enumerate(zip(S,S[1:])):
    if a != b: # 01の切り替わりの個数を調べる
        change.append(i+1)

ans = 0
for i in range(len(change)):
    if S[change[i]] == "0":
        if i == 0:
            if 2*K >= len(change):
                print(N)
                exit()
            tmp = change[2*K]
        else:
            if i+2*K >= len(change):
                tmp = N-(change[i-1])
            else:
                tmp = (change[i+2*K] - 1) - (change[i-1] - 1)
        ans = max(ans, tmp)
    else:
        if i+2*K+1 >= len(change):
            tmp = N - change[i]
        else:
            #if i == 1:
            #print("qqqqq",len(change), i+2*K+1 )
            tmp = (change[i+2*K+1]-1) - (change[i]-1)
        ans = max(ans, tmp)
    #print("---",i, ans,  N - change[i])

print(ans)
#print(change)



Measured memory_bytes: 7252
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,tmp=0;
    long long ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        tmp = max(tmp,a[i]);
    }
    for(int i = 0;i < n;i++){
        ans += a[i];
    }
    ans -= (tmp/2);
    cout << ans << endl;
    return 0;
}


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

#define pb push_back
#define ll long long
#define inf 1e18+9

using namespace std;

void merge(vector<vector<float > >& a, int start, int mid, int end){
	// printf("%d %d %d\n", start, mid , end);
	int i = 0, j = 0 , k = start;
	vector<vector<float > > temp1, temp2;
	for (int i = start; i <= mid; ++i)
	{
		temp1.pb(a[i]);
	}
	for (int i = mid+1; i <= end; ++i)
	{
		temp2.pb(a[i]);
	}
	i = 0;
	while(i < temp1.size() && j < temp2.size()){
		if(temp1[i][2] > temp2[j][2]){
			a[k]=temp1[i];
			i++;
		}
		else{
			a[k] = temp2[j];
			j++;
		}
		k++;
	}
	while(i<temp1.size()){
			a[k]=temp1[i];
			i++;
			k++;
	}
	while(j< temp2.size()){
			a[k]=temp2[j];
			j++;
			k++;
	}
	// for (int i = 0; i < a.size(); ++i)
	// {
	// 	for (int j = 0; j < 3; ++j)
	// 	{
	// 		printf("%f ",a[i][j]);
	// 	}
	// 	printf("\n");
	// }
}

void mergeSort(vector<vector<float > >& a, int start, int end){
	if(start < end){
		int mid =( start + end)/2;
		mergeSort(a, start, mid);
		mergeSort(a, mid+1, end);
		merge(a, start, mid, end);
	}
}

int main(int argc, char const *argv[])
{
	int n, wght, profit,weight;

	scanf("%d%d", &n, &wght);
	// vector<vector<float> > p;
	// vector<int> profits, weights;
	vector<ll> dp(wght+1, 0); // 0- whht +1 

	for (int i = 0; i < n; ++i)
	{
		scanf("%d%d", &weight, &profit);
		for(int j= wght ; j>=0 ; j--){
			if(j >= weight){
				// printf("helo\n");
				dp[j] = max(dp[j], dp[j-weight] + profit);
			}
		}
	}
	// for(int i = 0 ; i<=wght; i++){
	// 	printf("%lld\n", dp[i]);
	// }
	printf("%lld\n", dp[wght]);

	
	// int profitfull = 0;
	// for (int i = 0; i < profits.size(); ++i)
	// {
	// 	profitfull += profits[i];
	// }

	// vector<ll> dp(profitfull, inf);
	// dp[0] = 0;
	// for(int item = 0 ; item < n ; item++){
	// 	for(int i = profitfull - profits[item] ; i>=0 ; i++){
	// 		dp[i] = min(dp[i+profits[item]] + weights[item], dp[i]);
	// 	}
	// }

	// printf("%d", profitfull);


	// for (int i = 0; i <= n; ++i)
	// {
	// 	for (int j = 0; j <= w; ++j)
	// 	{
	// 		printf("%lld ", dp[i][j]);
	// 	}
	// 	printf("\n");
	// }

	// printf("s\n");
	// for (int i = 0; i < 7; ++i)
	// {
	// 	for (int j = 0; j < 7; ++j)
	// 	{
	// 		printf("%d ", s[i][j]);
	// 	}
	// 	printf("\n");
	// }
	// printBrac(1,6);
	return 0;
}




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

#define ORZ_lqs2015
#define ORZ_EVERYBODY

#define fi first
#define se second
typedef long long ll;
const size_t MAX_N = (size_t)1e5 + 5;

vector<pair<int, ll> > g[MAX_N];
ll dis[MAX_N];
int n, k;

void dfs(int v, int p, ll d) {
    dis[v] = d;
    for (auto x: g[v])
        if (x.fi != p) dfs(x.fi, v, d + x.se);
}

int main() {
    scanf("%d", &n);
    for (int i = 1, a, b, c; i < n; i++) {
        scanf("%d%d%d", &a, &b, &c);
        g[a].emplace_back(b, (ll)c);
        g[b].emplace_back(a, (ll)c);
    }
    int q;
    scanf("%d%d", &q, &k);
    dfs(k, 0, 0LL);
    ios::sync_with_stdio(false);
    for (int i = 0, x, y; i < q; i++) {
        scanf("%d%d", &x, &y);
        cout << dis[x] + dis[y] << '\n';
    }
}

Measured memory_bytes: 14336