akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

//add this function
struct Node *find(struct Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;
  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  struct Node *t;
  int n,i,x;
  char tmp[1000];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",tmp);
    if(strcmp(tmp,"find")==0){
      scanf("%d",&x);
      t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(tmp,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(tmp,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 20516
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int H, W, K;
	cin >> H >> W >> K;
	int c[7][7] = { 0 };
	int brack = 0;
	rep(i, H) {
		rep(j, W) {
			char car;
			cin >> car;
			if (car == '#') {
				brack++;
				c[i][j] = 1;
			}
		}
	}

	int ans = 0;
	rep(y, 1 << H) {
		rep(x, 1 << W) {
			int cnt = 0;
			rep(i,H) {
				rep(j,W) {

					if (((y >> i) & 1) == 0) {
						if (((x >> j) & 1) == 0) {
							if (c[i][j] == 1) cnt++;
						}
					}
				}
			}
			if (cnt == K)ans++;
		}
	}

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


Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		string s;
		cin>>s;
		if(s=="0") break;
		vector<ll> en(11,0);
		vector<ll> on(11,0);
		ll esum=0;
		ll osum=0;
		en[0]++;
		on[0]++;
		ll ret=0;
		REP(i,(ll)s.size()) {
			if(i%2) {
				esum+=(int)(s[i]-'0');
				osum-=(int)(s[i]-'0');
				esum=((esum%11)+11)%11;
				osum=((osum%11)+11)%11;
				ret+=en[esum];
				if(i!=(ll)s.size()-1&&s[i+1]!='0') {
					en[esum]++;
					on[osum]++;
				}
			} else {
				esum-=(int)(s[i]-'0');
				osum+=(int)(s[i]-'0');
				esum=((esum%11)+11)%11;
				osum=((osum%11)+11)%11;
				ret+=on[osum];
				if(i!=(ll)s.size()-1&&s[i+1]!='0') {
					en[esum]++;
					on[osum]++;
				}
			}
		}
		cout<<ret<<endl;
	}
}

Measured memory_bytes: 3296
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())

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

  int n;
  int f[100][14];
  int p[100][15];

  cin >> n;
  for(int i=0;i<n;i++) {
    for(int j=0;j<10;j++) {
      cin >> f[i][j];
    }
  }
  for(int i=0;i<n;i++) {
    for(int j=0;j<11;j++) {
      cin >> p[i][j];
    }
  }

  int res = -(1<<30);
  for(int b=1;b<(1<<10);b++) {
    int cc = 0;
    for(int i=0;i<n;i++) {
      int c = 0;
      for(int j=0;j<10;j++) {
        if((b>>j & 1) && f[i][j]) {
          c++;
        }
      }
      cc += p[i][c];
    }
    if(res<cc) {
      res = cc;
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int l,r,d;
  cin>>l>>r>>d;
  Int ans=0;
  for(Int i=l;i<=r;i++)
    if(i%d==0) ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3580
h,w=gets.split.map(&:to_i)
ss=h.times.map{gets.chomp}
ans="Yes"
h.times do |i|
  w.times do |j|
    if ss[i][j]=="#"
      check=false
      check=true if j!=0 && ss[i][j-1]=="#"
      check=true if j!=w-1 && ss[i][j+1]=="#"
      check=true if i!=0 && ss[i-1][j]=="#"
      check=true if i!=h-1 && ss[i+1][j]=="#"
      if !check
        ans="No"
      end
    end
  end
end
puts ans


Measured memory_bytes: 1916
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    const int MAX=1000000;
    vector<bool> pri(MAX+1,true);
    pri[0]=pri[1]=false;
    for(int i=2;i<=sqrt(MAX);i++){
        if(pri[i]){
            for(int j=i*i;j<=MAX;j+=i){
                pri[j]=false;
            }
        }
    }
    int N,X;
    for(;;){
        scanf("%d%d",&N,&X);
        if(N==0&&X==0) break;
        vector<bool> has(X+1,false);
        has[0]=true;
        int in;
        for(int i=0;i<N;i++){
            scanf("%d",&in);
            for(int j=0;j<=X;j++){
                if(has[j]&&(j+in<=X)) has[j+in]=true;
            }
        }
        int ret=-1;
        for(int i=X;i>=0;i--){
            if(pri[i]&&has[i]){
                ret=i;
                break;
            }
        }
        if(ret==-1) printf("NA\n");
        else printf("%d\n",ret);
    }
}

Measured memory_bytes: 0
def Fib(n):
    a, b = 1, 1
    if n == 0:
        return a
    elif n == 1:
        return b
    else:
        for _ in range(n-1):
            a, b = b, a + b
        return b

N, M = map(int, input().split())
ai = -1
ans = 1


for _ in range(M):
    af = int(input())
    L = af - ai - 2
    if L == -1:
        ans = 0
        break
    else:
        ans *= Fib(L)
        ai = af
ans *= Fib(N - ai - 1)

ans = ans % 1000000007

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define ad(a,b)  (a%mod+b%mod+mod)%mod
#define nl endl
#define inf 1e9
#define cases ll t;cin>>t;while(t--)
#define BLOCK 500
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
 
using namespace std;



int32_t main()
{
    fast
    ll n,k;
    cin>>n>>k;
    ll h[n];
    f(i,n)
    {
        cin>>h[i];
    }

    ll dp[n];
    f(i,n)
    {
        dp[i]=inf;
    }
    dp[0]=0;

    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<=k;j++)
        {
            if(i-j>=0)
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }

    cout<<dp[n-1];



       
    return 0;
    
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	H := nextInt(sc)
	N := nextInt(sc)
	for i := 0; i < N; i++ {
		v := nextInt(sc)
		H -= v
	}
	if H <= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int> canwthdrw(0);
    int a=1;
    canwthdrw.push_back(a);
    while(a*6<=100000){
        a *= 6;
        canwthdrw.push_back(a);
    }
    a = 1;
    while(a*9<=100000){
        a *= 9;
        canwthdrw.push_back(a);
    }
    int n,ans=0;
    cin >> n;
    int dp[100000]={};
    for(int i=1;i<=n;i++){
        int b = 100000;
        for(int j=0;j<canwthdrw.size();j++){
            if(canwthdrw[j]<=i) b = min(b,dp[i-canwthdrw[j]]+1);
        }
        dp[i] = b;
    }
  cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
	int n;
	
	cin >> n;
	vector<long> a(n*3);

	for (int i = 0; i < n * 3; i++) {
		cin >> a.at(i);
	}

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

	long ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		ans += a.at(n+2*i);
	}
	cout << ans << endl;
	return 0;
}

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

#define task "D" //abc134
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Limit

// Struct

// Variables
int n;
bool a[200004],b[200005];
// Function

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n;
	rep(i,1,n) cin >> a[i];
	Rep(i,n,n/2+1) b[i]=a[i];
	int lim=n/2;
	Rep(i,lim,1)
	{
	    int tem=0;
	    for(int j=2*i;j<=n;j+=i) tem+=b[j];
	    if (!(tem&1)) b[i]=a[i];
	    else b[i]=1-a[i];
	}
	vi ans;
	rep(i,1,n) if (b[i]) ans.pb(i);
	cout << ans.size() << '\n';
	for (int res:ans) cout << res << ' ';
}


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

int main() {
  long long int a,b,c,d;
  cin >> a >> b >> c >> d;
  long long int ansA,ansB,ansC,ansD;
  ansA = a*c;
  ansB = b*c;
  ansC = a*d;
  ansD = b*d;
  if (ansA >= ansB && ansA >= ansC && ansA >= ansD){
    cout << ansA <<endl;
  }else if (ansB >= ansA && ansB >= ansC && ansB >= ansD){
    cout << ansB <<endl;
  }else if (ansC >= ansA && ansC >= ansB && ansC >= ansD){
    cout << ansC <<endl;
  }else if (ansD >= ansA && ansD >= ansC && ansD >= ansC){
    cout << ansD <<endl;
  }
}

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

using int_ = int;
#define int int_least64_t

int_ main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  vector<int> v;
  copy_n(istream_iterator<int>(cin), 3, back_inserter(v));
  if (v[0]==v[1] && v[1] == v[2])
    cout << "Yes\n";
  else
    cout << "No\n";
}



Measured memory_bytes: 256
use std::io;

fn get_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf
}

fn main() {
    let s = get_line();
    println!("{}",
             if "aieou".contains(&(s.trim())) {
                 "vowel"
             } else {
                 "consonant"
             });
}

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,k;
  cin>>a>>b>>k;
  if(a+b<k)cout<<"0 0"<<endl;
  else {
    if(a<k){
      k-=a;
      a=0;
      b-=k;
    }
    else a-=k;
    cout<<a<<" "<<b<<endl;
  }
  return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1; finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  long long n, m, k;
  cin>>n>>m>>k;
  COMinit();
  long long ans = 0;
  for (int i=1; i<=m; i++) {
    long long cnt = n * n % MOD * (i - 1 - (m - i)) % MOD;
    if (cnt < 0) {
      cnt += MOD;
    }
    cnt = cnt * COM(n * m - 2, k - 2) % MOD * i % MOD;
    ans = (ans + cnt) % MOD;
  }
  for (int i=1; i<=n; i++) {
    long long cnt = m * m % MOD * (i - 1 - (n - i)) % MOD;
    if (cnt < 0) {
      cnt += MOD;
    }
    cnt = cnt * COM(n * m - 2, k - 2) % MOD * i % MOD;
    ans = (ans + cnt) % MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

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

int n, l;
vector<int> turara;
vector<int> memo;

int dfs(int now)
{
	if(memo[now] != -1) return memo[now];

	int ret = 0;
	if(turara[now - 1] > turara[now])
	{
		ret = dfs(now - 1);
	}
	if(turara[now + 1] > turara[now])
	{
		ret = max(ret, dfs(now + 1));
	}
	ret += l - turara[now];

	return memo[now] = ret;
}

int main(void)
{
	ios::sync_with_stdio(false);
	while(cin >> n >> l && n)
	{
		turara.resize(n + 2);
		memo = Array(n + 2, -1);
		memo[0] = memo[n + 1] = 0;
		turara[0] = turara[n + 1] = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> turara[i + 1];
		}

		int ans = 0;
		for (int i = 1; i <= n; i++)
		{
			ans = max(ans, dfs(i));
		}

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

Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
#define MOD 1000000007
//scanf("%d", &a) '\n'

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)  scanf("%d", &a[i]);
	ll k=0;
	rep(i, n) k += a[i];
	
	ll l=0;
	ll sign;
	rep(i, n) {
		l += a[i];
		if (l >= k / 2) { 
			sign = i - 1;
			break;
		}

	}
	ll l1 = l-a[sign+1];
	
	cout << min(2*l-k,k-2*l1) << endl;
}
	

Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int fst(int num){
    int buf;
    while(num!=0){
        buf = num;
        num /= 10;
    }
    return buf;
}

int main()
{
    int n,x;
    cin >> n;
    int a,b;
    int ans=0;

    int p[9][9];
    
    for(int i=0; i<9; i++){
        for(int j=0; j<9; j++){
            p[i][j]=0;
        }
    }


    for(int i=1; i<n+1; i++){
        a = fst(i); //fisrt
        b = i % 10; //last
    
        if(b!=0){
            p[a-1][b-1]++;
        }
    }

    
    for(int i=0; i<9; i++){
        for(int j=0; j<9; j++){
            ans += p[i][j]*p[j][i];
        }
    }

    cout << ans ;
/*

    for(int i=0; i<9; i++){
        for(int j=0; j<9; j++){
            cout << p[i][j] << " ";
        }
        cout << endl;
    }
*/

/*
    int n,m;
    cin >> n >> m;

    string ans1;
    string ans2;
    string ans;
    

    for(int i=0; i<m; i++){
        char x = '0' + n;
        ans1.push_back(x);
    }

    for(int i=0; i<n; i++){
        char x = '0' + m;
        ans2.push_back(x);
    }

    if(ans1<ans2)
        ans = ans1;
    else
        ans = ans2;    

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    string sa,sb,sc;
    cin >> sa >> sb >> sc;

    queue<char> qsa,qsb,qsc;
    for(auto itr = sa.begin(); itr != sa.end(); ++itr) qsa.push(*itr);
    for(auto itr = sb.begin(); itr != sb.end(); ++itr) qsb.push(*itr);
    for(auto itr = sc.begin(); itr != sc.end(); ++itr) qsc.push(*itr);

    char c = qsa.front(); qsa.pop();
    while(true)
    {
        if(c == 'a'){
            if(qsa.empty()){
                cout << "A" << endl;
                return 0;
            }
            c = qsa.front(); qsa.pop();
        }else if(c == 'b'){
            if(qsb.empty()){
                cout << "B" << endl;
                return 0;
            }
            c = qsb.front(); qsb.pop();
        }else if(c == 'c'){
            if(qsc.empty()){
                cout << "C" << endl;
                return 0;
            }
            c = qsc.front(); qsc.pop();
        }
    }

    return 0;
}


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

int main(){
  ll n,m,l,g,i;
  string s,t;
  cin >> n >> m >> s >> t;
  g=__gcd(n,m);
  l=n*m/g;
  for(i=0;i<g;i++){
    if(s.at(i*n/g)!=t.at(i*m/g)){
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << l << endl;
}

Measured memory_bytes: 3760
abcd = gets.chomp

A, B, C, D = abcd.split('').map(&:to_i)

['+', '-'].each do |op1|
  ['+', '-'].each do |op2|
    ['+', '-'].each do |op3|
      if op1 == '+'
        res = A + B
      else
        res = A - B
      end

      if op2 == '+'
        res += C
      else
        res -= C
      end

      if op3 == '+'
        res += D
      else
        res -= D
      end

      if res == 7
        puts "#{A}#{op1}#{B}#{op2}#{C}#{op3}#{D}=7"
        exit 0
      end
    end
  end
end


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int
int main(){
  int a,b,c,ans;
  cin >> a >> b >> c;

  if( c <= b ) 
  {
    ans = b + c;  
  } 
  else if ( ( c - b ) <= a ) 
  {
    ans = b + c;  
  }
  else 
  {
    ans = 2 * b + a + 1;  
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 888
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;

int dp[N][3], arr[N][3]; 

int main()
{
   int n;
   scn(n);

   rep(i, 1, n+1) {
      rep(j, 0, 3) {
         scn(arr[i][j]);
      }
   }

   dp[0][0] = dp[0][1] = dp[0][2] = 0;
   dp[1][0] = arr[1][0]; dp[1][1] = arr[1][1]; dp[1][2] = arr[1][2];

   rep(i, 2, n+1) {
      rep(j, 0, 3) { 
         dp[i][j] = max(dp[i][j], arr[i][j] + max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3])); 
      }
   }

   int mx = max({dp[n][0], dp[n][1], dp[n][2]});

   prin(mx);
   return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()

template <typename T, typename E>
ostream &operator<<(std::ostream &os, const std::pair<T, E> &p){
  return os << "(" << p.first << ", " << p.second << ")";
}

typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int n, m;
  while (cin >> n >> m && n + m){
    int score[110][110];
    memset(score, 0, sizeof(score));

    REP(i, m){
      int x, y, f;
      cin >> x >> y >> f; x--, y--;
      score[x][y] = score[y][x] = f;
    }

    int res = 0;
    REP(i, n){
      vector<int> fs;
      REP(j, n) if (score[i][j] > 0){
        fs.push_back(j);
      }
      
      int size = fs.size();
      if (size * (size - 1) / 2 <= m){

        
        REP2(mask, 1, 1 << size){
          
          vector<int> vs(1, i);
          REP(j, size) if (mask & (1 << j)){
            vs.push_back(fs[j]);
          }
          
          int sum = 0;
          REP(j, vs.size()){
            int add = 1e9;
            REP(k, vs.size()) if (j != k) {
              add = min(add, score[vs[j]][vs[k]]);
            }
            sum += add;
          }
          res = max(res, sum);
        }
      }
    }
    cout << res << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1268
//IncubatorMan
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
    int n;
    read(n);
    vi data(n);
    data[0]=0;
    map<int,int> fre;
    for(int i=1;i<n;i++){
            read(data[i]);
            fre[data[i]-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<fre[i]<<endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
        int test=1;
        //read(test);
        while(test--){
            solve();
        }
    return 0;
}

Measured memory_bytes: 13548
#include <iostream>

using namespace std;

int main() {
   int n;
   cin>>n;
   string flag="No";
   for(int i=1;i<=9;i++)
    {
        if(n%i==0)
            {
                if(n/i<=9)
                    flag="Yes";
            }
    }
    cout<<flag<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int const N = 1e5+9;
int p[N];
int rnk[N];
int parent(int x){
    if(p[x] == x)
        return x;
    return p[x] = parent(p[x]);
}
bool isConnected(int x , int y){
    return parent(x) == parent(y);
}
void connect(int x , int y){
    if(isConnected(x,y))
        return;
    int pOfx = parent(x);
    int pOfy = parent(y);
    if(rnk[pOfx] > rnk[pOfy]){
        p[pOfy] = pOfx;
    }else if(rnk[pOfy] > rnk[pOfx]){
        p[pOfx] = pOfy;
    }else{
        p[pOfy] = pOfx;
        rnk[pOfx]++;
    }
}
void preDSU(){
    for(int i = 0;i<N;i++){
        p[i] = i;
    }
}

int main(){
    preDSU();
    int n;
    cin>>n;
    map<pair<int,int> , int> indx;
    set<pair<int,int>> x , y;
    for(int i = 0;i<n;i++){
        int xx , yy;
        cin>>xx>>yy;
        indx[{xx,yy}]++;
        x.insert({xx,yy});
        y.insert({yy,xx});
    }
    int k = 0;
    for(auto &i : indx){
        i.second = k++;
    }
    vector<pair<int,pair<int,int>>>mst;
    pair<int,int> last = {-1,-1};
    for(auto i : x){
        if(last.first != -1){
            mst.push_back({i.first-last.first , {indx[i] , indx[last]} });
        }
        last = i;
    }
    last = {-1,-1};
    for(auto i : y){
        if(last.first != -1){
            mst.push_back({i.first-last.first , {indx[{i.second , i.first}] , indx[{last.second , last.first}]} });
        }
        last = i;
    }
    sort(mst.rbegin(),mst.rend());
    ll ans = 0;
    while(!mst.empty()){
        int cost = abs(mst.back().first);
        int x = mst.back().second.first;
        int y = mst.back().second.second;
        mst.pop_back();
        if(!isConnected(x,y)){
            ans+=cost;
            connect(x,y);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 20976
# -*- coding utf-8 -*-

MOD = 10 ** 9 + 7

n, m = map(int, input().split())
xyz_m = [list(map(int, input().split())) for _ in range(m)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)
for x, y, z in xyz_m:
    uf.union(x - 1, y - 1)

print(uf.group_count())

Measured memory_bytes: 32176
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  // D
  int N;
  int a[60];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int max_idx = -1;
  int min_idx = -1;
  int max = -1000000-1;
  int min = 1000000+1;
  bool is_plus = false; 
  for(int i = 0; i < N; i++) {
    if(max < a[i]) {
      max = a[i];
      max_idx = i;
    }
    if (min > a[i]) {
      min = a[i];
      min_idx = i;
    }
  }

  int sum = 0;
  int sum_idx = -1;
  if (abs(max) >= abs(min) ){
    sum = max;
    sum_idx = max_idx;
  } else {
    sum = min;
    sum_idx = min_idx;
  }

  cout << 2*N-1 << endl;
  for(int i = 0; i < N ; i++) {
    a[i] += sum;
    cout << sum_idx+1 << " " << i+1 << endl;
  }

  if (a[0] >= 0) {
    for(int i = 0 ; i < N-1; i++) {
      a[i+1] += a[i];
      cout << i+1 << " " << i+2 << endl;
    }
  } else {
    for(int i=N-1 ; i > 0; i--) {
      a[i-1] += a[i];
      cout << i+1 << " " << i << endl;
    }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=100000+1;

struct info {
    int st,dr;
};

int len,n;
info v[N];
bool cmp(info a,info b) {
    if(a.st==b.st)
        return a.dr>b.dr;
    return a.st<b.st;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>len>>n;
    for(int i=1;i<=n;i++) {
        cin>>v[i].st>>v[i].dr;
    }
    sort(v+1,v+n+1,cmp);
    int ans=1;
    int st=v[1].st;
    int dr=v[1].dr;
    for(int i=2;i<=n;i++) {
        if(v[i].st>=dr) {
            ans++;
            st=v[i].st;
            dr=v[i].dr;
        }
        st=max(st,v[i].st);
        dr=min(dr,v[i].dr);
    }
    cout<<ans<<"\n";
    return 0;
}
/**

0 0 0 0


**/


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int r,g,b;
	scanf("%d",&r);
	scanf("%d",&g);
	scanf("%d",&b);
	int y = g*10+b;
	if (y%4 == 0){
		printf("YES\n");
	}else {
		printf("NO\n");
	}
}

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

typedef long long ll;

int solve(string remaining, string order, const vector<int>& v) {
	if (remaining == "") {
		int ans = 0;
		for (int i = 0; i < v.size(); ++i) {
			ans += v[order[i]-'0'];
			if (ans%10 != 0 and i+1 != 5)
				ans += 10-v[order[i]-'0']%10;
		}
		return ans;
	} else {
		int ans = 10000000;
		for (int i = 0; i < remaining.size(); ++i) {
			ans = min(ans, solve(remaining.substr(0,i)+remaining.substr(i+1),order+remaining[i],v));
		}
		return ans;
	}
}

int main () {
	vector<int> v(5);
	string rem = "01234", placeholder = "";
	for (int i = 0; i < 5; ++i)
		cin >> v[i];
	cout << solve(rem,placeholder,v) << endl;
	return 0;
}


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

#define MOD 1000000007
#define MAX 2000000

long int fac[MAX],inv[MAX],finv[MAX];

void pre(){
  fac[0]=fac[1]=1;
  inv[1]=1;
  finv[0]=finv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=(fac[i-1]*i)%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

long int com(int n,int k){
  return ((fac[n]*finv[k])%MOD)*finv[n-k]%MOD;
}

int main(){
  pre();
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  
  sort(A.begin(),A.end());
  long int sum=0;
  for(int i=0;i<N-K+1;i++){
    sum+=A.at(i+K-1)*com(i+K-1,K-1)%MOD;
    sum-=(A.at(N-K-i)*com(i+K-1,K-1))%MOD;
    if(sum<0){
      sum+=MOD;
    }
    sum%=MOD;
  }
  cout<<sum<<endl;
}
  
  
  
  

Measured memory_bytes: 47488
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int maxn = 2e5 + 5;
typedef long long ll;
typedef uint64_t HT;
const int mod = 1e9 + 7;
int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1), pre(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pre[i] = (1LL * pre[i - 1] + a[i]) % mod;
    }
    ll ans = 0;
    for (int i = 2; i <= n; i++) {
        ans = (1LL * ans + 1LL * pre[i - 1] * a[i]) % mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	int res=0;
	for(int i=1;i<=n;++i)
		if(a[i]==i)swap(a[i],a[i+1]),res++;
	cout<<res;
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const int MAX_N = 100010;

struct UnionFind
{
  vector<int> data;
  UnionFind(){}
  UnionFind(int sz):data(sz, -1){};
  int size(int x) { return -data[find(x)]; }
  int find(int x) {
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y]; data[y] = x;
    return;
  }
};


int N, M;
vint graph[MAX_N];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  UnionFind uf(N*2);
  rep(i, M) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
    uf.unite(u, v+N);
    uf.unite(u+N, v);
  }
  int one = 0;
  int big = 0;
  int non = 0;
  rep(i, N) {
    if(i != uf.find(i) && i+N != uf.find(i)) continue;
    if(uf.size(i) == 1) one++;
    else if(uf.find(i) == uf.find(i+N)) non++;
    else big++;
  }
  cout << big*big*2+non*non+one*one+non*big*2+one*(N-one)*2 << endl;

  return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <cstring>
using namespace std;
int main(){
	string S;
	cin>>S;
	int s=S.length();
	for (int i=1;i<s;i++){
		for (int k=0;k<i;k++){
			if (S[i]==S[k]){
				cout<<"no"<<endl;
				return 0;
			}
		}
	}
	cout<<"yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
S = input[0]
T = input[1]
// console.log(`S=${S}`)
// console.log(`T=${T}`)

if (T.startsWith(S)) {
    console.log(`Yes`)
} else {
    console.log(`No`)
}

Measured memory_bytes: 29456
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int R,G;
int main() {
	cin>>R>>G;


	cout<<2*G-R<<endl;
	return 0;
}


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

#define int long long

using namespace std;

const int MOD = 1E9 + 7;

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

    int n, res = 0;

    cin >> n;

    vector<int> a(n);

    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < 60; i++)
    {
        vector<int> c(2, 0);

        for (int j = 0; j < n; j++)
            c[(a[j] >> i) & 1]++;

        int p = c[0] * c[1];
        p %= MOD;

        for (int j = 0; j < i; j++)
            p = (p * 2) % MOD;

        res = (res + p) % MOD;
    }

    cout << res << "\n";

    return 0;
}

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

int main(){
  string S;
  cin>>S;
  if(S=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  if(S=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  if(S=="Rainy"){
    cout<<"Sunny"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ACC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};
bool isvowel(char c)
{
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':return true;
        default : return false;
    }
}
bool isValid(ll x,ll y)
{
    //if(x<0||x>h-1||y<0||y>w-1)return false;
    //if(s[x][y]=='#')return false;
    //if(vis[x][y])return false;
    return true;
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    if(x.first==y.first)
        return x.second<y.second;
    return x.first<y.first;
}

int main()
{
    ACC
    int T;
    T=1;
    //cin>>T;
    while(T--)
    {
        ll i,h,w,b;
        cin>>h>>w>>b;
        vector<pair<ll,ll>> v;
        map<ll,ll> r,c;
        map<pair<ll,ll>,ll> m;
        for(i=0;i<b;i++)
        {
            ll x,y;
            cin>>x>>y;
            v.pb({x,y});
            r[x]++;
            c[y]++;
            m[{x,y}]++;
        }
        vector<pair<ll,ll>> vr,vc;
        for(auto j:r)
        {
            vr.pb({j.second,j.first});
        }
        for(auto j:c)
        {
            vc.pb({j.second,j.first});
        }
        ll ans=0;
        sort(vr.begin(),vr.end());
        sort(vc.begin(),vc.end());
        //cout<<vr.size()<<","<<vc.size()<<"\n";
        ll j,x;
        bool f=false;
        for(i=vr.size()-1;i>=0;i--)
        {
            if(vr[vr.size()-1].first-vr[i].first>1)break;
            for(j=vc.size()-1;j>=0;j--)
            {
                if(vc[vc.size()-1].first-vc[j].first>1)break;
                x=vr[i].first+vc[j].first;
                if(m[{vr[i].second,vc[j].second}])
                {
                    x--;
                }
                else
                {
                    f=true;
                    ans=max(ans,x);break;
                }
                ans=max(ans,x);
            }
            if(f)break;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 81180
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    
    private static HashMap<Integer, HashMap<Integer,Integer>> map1;
    private static boolean[] visited;
    private static boolean[] white;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int u,v,w;
        map1 = new HashMap<>();
        for(int i = 0; i < n-1; i++){
            u = Integer.parseInt(sc.next());
            v = Integer.parseInt(sc.next());
            w = Integer.parseInt(sc.next());
            if(map1.containsKey(u)){
                map1.get(u).put(v, w);
            }else{
                HashMap<Integer,Integer> map2 = new HashMap<>();
                map2.put(v, w);
                map1.put(u, map2);
            }
            if(map1.containsKey(v)){
                map1.get(v).put(u, w);
            }else{
                HashMap<Integer,Integer> map2 = new HashMap<>();
                map2.put(u, w);
                map1.put(v, map2);
            }
        }
        
        visited = new boolean[n+1];
        white = new boolean[n+1];
        if(!map1.isEmpty()){
            dfs(1);
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 1; i <= n; i++){
            if(white[i]){
                sb.append("0").append(System.lineSeparator());
            }else{
                sb.append("1").append(System.lineSeparator());
            }
        }
        System.out.print(sb);
    }
    
    private static void dfs(int v){
        
        visited[v] = true;
        
        for(Integer i : map1.get(v).keySet()){
            if(!visited[i]){
                if(map1.get(v).get(i) % 2 == 0){
                    white[i] = white[v];
                }else{
                    white[i] = !white[v];
                }
                dfs(i);
            }
        }
    }
}

Measured memory_bytes: 98152
#include<bits/stdc++.h>
using namespace std;
int main(){
  bool flag=true;
  int N;
  cin>>N;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
    }
  for(int i=N-1;0<i;i--){
    if(H.at(i)>=H.at(i-1))
      continue;
    else if(H.at(i)>=H.at(i-1)-1)
      H.at(i-1)--;
    else{
      flag=false;
      break;
      }
    }
  if(flag==true)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 640
#

import sys
input=sys.stdin.readline

def main():
    N,K=map(int,input().split())
    # gcd=i
    dp=[0]*(K+1)
    MOD=10**9+7
    for i in range(K,0,-1):
        x=(K//i)
        dp[i]=pow(x,N,MOD)
        # (x**N)%MOD、pow(x,N)%MODはTLEE
        for j in range(2,x+1):
            dp[i]-=dp[i*j]
            dp[i]%=MOD
    ans=0
    for i in range(K+1):
        ans+=i*dp[i]
        ans%=MOD
    print(ans)
    
    
    
if __name__=="__main__":
    main()


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

int a[6];

int main()
{
	for (int i=1; i<=5; i++)
		cin >> a[i];
		
	for (int i=1; i<=5; i++)
		if (a[i]!=i)
		{
			cout << i;
			return 0;
		}
	
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
bool a[101]={false};
int main()
{
	int m=0,n=0,x=0,c=0,t0=0,tn=0;
	cin>>n>>m>>x;
	for(int i=1;i<=m;++i)
	{
		cin>>c;
		a[c]=true;
	}
	for(int i=1;i<=x-1;++i)
	if(a[i])++t0;
	for(int i=x+1;i<=n;++i)
	if(a[i])++tn;
	if(t0<tn)cout<<t0;
	else cout<<tn;
}

Measured memory_bytes: 256
/*
ID: torchwr1 
PROG: game1
LANG: C++     
*/
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int a[100005], len;
//int b[100005];
int pd(int k) {
	int tmp = 0;
	for (int i = 1; i <= len; ++i) {
		if (i == k + 1) return 1;
		if ((a[i] + tmp) % 2 == 1) {
			//cout << i;
			if (len - i + 1 < k) return 0;
			else {
				tmp++;
			}
		}
		//cout << i << " " <<tmp << endl;
	}
	return 1;
}
int main(){
	scanf("%s", s + 1);
	len = strlen(s + 1);
	for (int i = 1; i <= len; ++i) {
		a[i] = s[i] - '0';
	}
	int l = 1, r = len, res = 1;
	while (l <= r) {
		int mid = (l + r) >> 1;
		//cout << mid << endl;
		if (pd(mid)) {
			l = mid + 1;
			res = mid;
		} else {
			r = mid - 1;
		}
	}
	//cout << pd(7);
	printf("%d", res);
    return 0;
}

Measured memory_bytes: 768
import sys
from heapq import *
sys.setrecursionlimit(10**8)
 
input = sys.stdin.readline
tree = [[] for _ in range(200001)]
scores = [0 for _ in range(200001)]

def dfs(pre, p):
    for child in tree[p]:
        if child == pre: continue
        scores[child] += scores[p]
        dfs(p, child)

def main():
    N, Q = map(int, input().split())
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)

    for _ in range(Q):
        p, x = map(int, input().split())
        scores[p] += x
    dfs(0, 1)
    print(' '.join(map(str, scores[1:N+1])))

if __name__ == '__main__':
    main()

Measured memory_bytes: 232256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
# define M_PI           3.14159265358979323846
int main()
{
	int r;
	cin >> r;
	float ans = M_PI * 2.0 * r;
	printf("%.2f", ans);
	
	return 0;
}


Measured memory_bytes: 3760
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int d(ll n) {
  int digit = 0;
  while (n > 0) {
    digit++;
    n /= 10;
  }
  return digit;
}

vector<ll> prime_numbers(ll n) {
  vector<ll> primes;
  for (ll i = 2; (ll)i * i <= n; i++) {
    while (n % i == 0) {
      primes.push_back(i);
      n /= i;
    }
  }
  if (n != 1) {
    primes.push_back(n);
  }
  return primes;
}

ll N;

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

  ll ans = inf;
  vector<ll> primes = prime_numbers(N);

  int n = primes.size();
  for (int i = 0; i < ((ll)1 << n); i++) {
    ll A = 1;
    // 223355
    // 000000
    ll ii = i, bit = 0;
    while (ii > 0) {
      if (ii & 1) {
        A *= primes[bit];
      }
      bit++;
      ii >>= 1;
    }
    ll B = N / A;
    ll a = max(d(B), d(A));
    ans = min(ans, a);
  }
  cout << ans << endl;

  return 0;
}


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

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}

int main() {

	ll N, K, cnt[100005];

	for (ll i = 0; i < 100005; i++)cnt[i] = 0;
	cin >> N >> K;
	for (ll i = 0; i < N; i++) {

		ll a, b;
		cin >> a >> b;
		cnt[a] += b;

	}

	for (ll i = 1; i < 100005; i++) {

		if (K <= cnt[i]) {

			cout << i << endl;
			break;

		}
		K -= cnt[i];

	}

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		//整数a,bを読み込んで、大小関係を示す
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a>b){
			System.out.println("a > b");
		}else if(a<b){
			System.out.println("a < b");
		}else{
			System.out.println("a == b");
		}
	}

}



Measured memory_bytes: 26236