akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main(){
	int x,a; cin >> x >> a;
	if(x < a) cout << 0 << endl;
	else cout << 10 << endl;
}

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

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int)(0);
}

segtree<int, op, e> seg(900900);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int ans = 0;
    const int geta = 300300;
    for (int i = 0; i < n; ++i) {
        int l = a[i] - k, r = a[i] + k + 1;
        auto cur = seg.prod(geta + l, geta + r);
        cur++;
        ans = max(ans, cur);
        seg.set(geta + a[i], cur);
    }
    cout << ans << endl;
}




Measured memory_bytes: 14716
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

ll dp[100002];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	rep(i,n+2)dp[i]=LINF;
	dp[0]=0;
	vl h(n);
	rep(i,n)cin>>h[i];
	range(i,1,n){
		range(j,1,k+1){
		if(i-j>=0)dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }


int main() {
    init();

    int d, g;
    cin >> d >> g;
    g /= 100;
    VI p(d), c(d);
    FOR(i, 0, d) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }

    int ans = INF;
    FOR(bit, 0, 1 << d) {
        int point = 0, cnt = 0;
        FOR(i, 0, d)if (bit & (1 << i)) {
            point += p[i] * (i + 1) + c[i];
            cnt += p[i];
        }
        if (point < g)rFOR(i, 0, d)if (!(bit & (1 << i))) {
            int add = (g - point) / (i + 1) + bool((g - point) % (i + 1));
            if (add <= p[i]) {
                point += add * (i + 1);
                cnt += add;
            }
            break;
        }
        if (g <= point)chmin(ans, cnt);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
M=[]
F=[]
R=[]
while True:
    m,f,r=map(int,raw_input().split())
    if (m,f,r)==(-1,-1,-1):
        break
    else:
        M.append(m)
        F.append(f)
        R.append(r)
for i in range(len(M)):
    sum=M[i]+F[i]
    if M[i]==-1 or F[i]==-1:
        print('F')
    elif sum>=80:
        print('A')
    elif sum>=65:
        print('B')
    elif sum>=50:
        print('C')
    elif sum>=30:
        if R[i]>=50:
            print('C')
        else:
            print('D')
    else:
        print('F')

Measured memory_bytes: 6424
import sys

def gcd(a,b):
    r= b % a
    while r != 0:
        a,b = r,a
        r = b % a
    return a

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

for line in sys.stdin:
    a,b = sorted(map(int, line.rstrip().split(' ')))
    print("{} {}".format(gcd(a,b),lcm(a,b)))

Measured memory_bytes: 7572
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    ans = n * 800
    print(ans-(n//15)*200)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  int n,m; cin >> n >> m;
  map<int,int> mp;
  mp[0] = 1;
  vector<int> v(n); cin >> v;
  ll sum = 0;
  for(auto e:v){
    sum += e;
    mp[sum % m]++;
  }
  ll ans = 0;
  for(auto e:mp){
    ans += (ll)e.second*(e.second-1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
int f,p;
string s;
map<char,int>m;
int bns1();
int g_A(){
  int r=0;
  if(s[p]=='('){
    p++;
    r=bns1();
    p++;
  }
  else{
    while(isdigit(s[p])){
      r=r*10+(s[p]-'0');
      p++;
    }
  }
  return r;
}
int bns3(){
  int res=g_A();
  while(m[s[p]]==3){
    int t=p++;
    if(s[t]=='+')res+=g_A();
    if(s[t]=='-')res-=g_A();
    if(s[t]=='*')res*=g_A();
  }
  return res;
}
int bns2(){
  int res=bns3();
  while(m[s[p]]==2){
    int t=p++;
    if(s[t]=='+')res+=bns3();
    if(s[t]=='-')res-=bns3();
    if(s[t]=='*')res*=bns3();
  }
  return res;
}
int bns1(){
  int res=bns2();
  while(m[s[p]]==1){
    int t=p++;
    if(s[t]=='+')res+=bns2();
    if(s[t]=='-')res-=bns2();
    if(s[t]=='*')res*=bns2();
  }
  return res;
}
int dfs(){
  int res=LLONG_MIN;
  r(i,3)r(j,3)r(k,3){
    m['+']=i+1;
    m['-']=j+1;
    m['*']=k+1;
    p=0;
    res=max(res,bns1());
  }
  return res;
}
main(){
  cin>>s;s+='(';
  cout<<dfs()<<endl;
}

Measured memory_bytes: 3180
n,num=gets.chomp.split(" ").map(&:to_i)
if num == 1
 puts 1
 exit
elsif n == 1
 puts num
 exit
end
require 'prime'
ary = Prime.prime_division(num)
c = 1

ary.each do |a|
  if a[1] >= n
    ii = a[1] / n
    c = c * a[0] ** ii 
   end
end
puts c

Measured memory_bytes: 2172
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back             
#define se second                
#define fi first  
#define be begin()
#define en end()
#define all(v) v.be, v.en
// template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
// template<typename... T> void po(T... args) { ((cout << args << " "), ...); cout<<""; }

 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
     int test=1;
     //cin>>test;
     for(int tt=1; tt<=test; tt++){
       ll n,m,k;
       cin>>n>>m>>k;
       int a[n][m],tot=0;
       char ch;
       int row[n]={0},col[m]={0};
       for(ll i=0; i<n ;i++){
           for(ll j=0; j<m ;j++){
               cin>>ch;
               if(ch=='.')a[i][j]=0;
               else a[i][j]=1; 
               if(a[i][j]==1)tot++; 
               row[i]+=a[i][j];
               col[j]+=a[i][j];             
           }           
       }
       int ans=0;
       //cout<<k<<endl;
       int bn = pow(2,n),bm=pow(2,m);
       for(ll i=0; i<bn ;i++){
           for(ll j=0; j<bm ;j++){
               ll sum = 0;
               ll r=i,c=j,w=0;
               vector<ll> v;
               while(r>0){
                   if(r%2==1){
                       sum+=row[w];
                       v.pb(w);
                   }
                   r/=2;w++;
               }
               w=0;
               while(c>0){
                   if(c%2==1){
                       sum+=col[w];
                       for(auto q:v){
                           sum-=a[q][w];
                       }
                   }
                   c/=2;w++;
               }
               if(tot-sum==k)ans++;
           }

       }
       
       cout<<ans<<endl;
       
     //cout<<"Case #"<<tt<<": ";  
     }
 
    return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    int ans=0;
    for(int i=1; i<=N; i++){
        int a;
        cin >> a;
        if(i%2 && a%2){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
N,K = [int(i) for i in input().split()]
P = 0
def nPossibility(n):
    c = 0
    while K > n:
        n = n*2
        c += 1
    return 1/(2**c)
for i in range(1,N+1):
    P += (1/N)*nPossibility(i)
print(P)

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

int main() {
    int N; cin >> N;
    vector<long long> vx(N), vy(N), vh(N);
    int si = -1;
    for (int i = 0; i < N; ++i) {
        cin >> vx[i] >> vy[i] >> vh[i];
        if (vh[i] > 0) si = i;
    }
    
    long long resx = -1, resy = -1, resh = -1;
    for (long long x = 0; x <= 100; ++x) {
        for (long long y = 0; y <= 100; ++y) {
            long long h = vh[si] + abs(x - vx[si]) + abs(y - vy[si]);
            bool ok = true;
            for (int i = 0; i < N; ++i) {
                if (vh[i] > 0 && h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]))
                    ok = false;
                if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i]))
                    ok = false;
            }
            if (ok) resx = x, resy = y, resh = h;
        }
    }
    cout << resx << " " << resy << " " << resh << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

typedef long long ll;

vector<vector<int>> dp(3010, vector<int>(3010, 0));
vector<vector<string>> lcs(3010, vector<string>(3010));
int main()
{
    string s, t;
    cin >> s;
    cin >> t;

    dp.at(0).at(0) = 0;
    lcs.at(0).at(0) = "";

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            if (s.at(i) == t.at(j)) {
                dp.at(i + 1).at(j + 1) = dp.at(i).at(j) + 1;
            } else {
                dp.at(i + 1).at(j + 1) = max(dp.at(i).at(j + 1), dp.at(i + 1).at(j));
            }
        }
    }

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();

    while (i > 0 && j > 0) {
        // (i-1, j) -> (i, j)と更新されていた場合
        if (dp.at(i).at(j) == dp.at(i - 1).at(j))
            --i; // dpの遷移をたどる
        // (i, j-1) -> (i, j)と更新されていた場合
        else if (dp.at(i).at(j) == dp.at(i).at(j - 1))
            --j; // dpの遷移をたどる
        // (i-1,j-1) -> (i,j)と更新されていた場合
        else {
            res = s[i - 1] + res; // s[i-1] == t[j-1]なのでどっちでもよい
            --i, --j; // dpの遷移をたどる
        }
    }

    cout << res << endl;
}


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

using namespace std;

inline void update(int &x,int y) {
  x=max(x,y);
}

char str[205][205];

int row[205][205],col[205][205];
int f[205][205][205],g[205][205][205];

void pre(int n,int m) {
  for(int i=1;i<=n;i++)
  	for(int j=m;j>0;j--) row[i][j]=((str[i][j]==str[i][j+1])?row[i][j+1]:0)+1;
  for(int i=1;i<=m;i++)
    for(int j=n;j>0;j--) col[j][i]=((str[j+1][i]==str[j][i])?col[j+1][i]:0)+1;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++) {
    	f[i][j][j]=col[i][j];
    	for(int k=j+1;k<=m;k++)
    	  f[i][j][k]=min(f[i][j][k-1],(str[i][k]==str[i][k-1])?col[i][k]:0);
	}
  for(int i=1;i<=m;i++)
    for(int j=1;j<=n;j++) {
    	g[i][j][j]=row[j][i];
    	for(int k=j+1;k<=n;k++)
    	  g[i][j][k]=min(g[i][j][k-1],(str[k][i]==str[k-1][i])?row[k][i]:0);
	}
}

int cur1[205][205][205],cur2[205][205][205];

void dp(int n,int m) {
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
      for(int k=j;k<=m;k++) {
	    f[i][j][k]+=f[i+f[i][j][k]][j][k];
	    if (f[i][j][k]) update(cur1[j][i][i+f[i][j][k]-1],k-j+1);
	  }
  for(int i=1;i<=m;i++)
    for(int j=1;j<=n;j++)
      for(int k=j;k<=n;k++) {
	    g[i][j][k]+=g[i+g[i][j][k]][j][k];
	    if (g[i][j][k]) update(cur2[j][i][i+g[i][j][k]-1],k-j+1);
	  }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
      for(int k=m;k>=j;k--) update(f[i][j][k],max(f[i][j][k+1],cur2[i][j][k]));
  for(int i=1;i<=m;i++)
    for(int j=1;j<=n;j++)
      for(int k=n;k>=j;k--) update(g[i][j][k],max(g[i][j][k+1],cur1[i][j][k]));
}

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++) scanf("%s",str[i]+1);
  pre(n,m);
  int ans=0;
  while (f[1][1][m]<n) {
  	ans++;
  	dp(n,m);
  }
  printf("%d\n",ans);
  return 0;
}

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


int main() {
	int a,b; cin >> a >> b ;
  	vector<int> vec(a) ;
    for ( int i = 0 ; i < a ; i++ )
      cin >> vec.at(i);
  
  int duration = 0 ; int max = 0 ;
  
  
  
  for ( int i= 0 ; i < a ; i++ ){
  	
    if ( vec.at(i) <= max && max <= vec.at(i)+b) {
    	
    	duration += vec.at(i) + b - max ; 
        max = vec.at(i) + b;
        
    }
    else if ( max < vec.at(i) ) {
    	duration += b;
        max = vec.at(i) + b;
        
        
    }
  
  
  }
  
  cout << duration << endl ;


}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);
    int[] n = new int[3];
    n[0] = sc.nextInt();
    n[1] = sc.nextInt();
    n[2] = sc.nextInt();
    int min = min(n[0],n[1],n[2]);
    int max = min(-n[0],-n[1],-n[2]);
    int i;
    for(i = 0;i < n.length;i++){
      if(i != min && i != max)break;
    }
    System.out.println(n[min] + " " + n[i] + " " + n[max]);
}
public static int min (int a, int b, int c){
  int m  = -1;
  if (a <= b && a <= c){
    return 0;
  }else if (b <= a && b <= c){
    return 1;
  }else{
    return 2;
  }
}
}


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

int main(){
  int n[3];
  rep(i, 3) cin >> n[i];
  sort(n, n+3);
  int ans = n[2] - n[1];
  n[1] = n[2]; n[0] += ans;
  if((n[2] - n[0]) % 2) ans += (n[2] - n[0] + 1)/2 + 1;
  else ans += (n[2] - n[0])/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int partition(int *,int,int);

int main()
{
  int i,a[MAX],n,x,k;

  scanf("%d",&n);
  for(i=1 ; i<=n ; i++)
  {
    scanf("%d",&a[i]);
  }

  k = partition(a,1,n);

  for(i=1 ; i<=n ; i++)
  {
    if(i!=k && i!=n)printf("%d ",a[i]);
    else if (i==k)printf("[%d] ",a[i]);
    else if(i== n) printf("%d",a[i]);
  }
  printf("\n");

  return 0;
}

int partition(int *A,int p,int r)
{
  int j,n,m,x,i;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++)
  {
    if(A[j]<=x)
    {
      i=i+1;
      n=A[i];
      A[i]=A[j];
      A[j]=n;
    }
  }
  m=A[i+1];
  A[i+1]=A[r];
  A[r]=m;
  return i+1;
}



Measured memory_bytes: 2108
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        String key1 = scanner.next();
        String key2 = scanner.next();
        int val1 = Integer.parseInt(scanner.next());
        int val2 = Integer.parseInt(scanner.next());
        String key3 = scanner.next();

        if (key1.equals(key3)) {
            val1--;
        } else {
            val2--;
        }

        System.out.printf("%d %d\n", val1, val2);
    }
}



Measured memory_bytes: 23636
import java.util.Scanner;

public class Main implements Runnable {

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();

        long prev = x;
        int count = 1;
        while (prev * 2 <= y) {
            count++;
            prev *= 2;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 24020
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=5e3+10;
const int M=220;
ll a[N],b[N][M],cnt[N][N];
int n,m,S[N],top,L[N][M],R[N][M];
inline int rd(){
	int x=0;int f=1;char s=getchar();
	while(!isdigit(s)){if(s=='-')f=-1;s=getchar();}
	while(isdigit(s)) x=(x<<1)+(x<<3)+s-'0',s=getchar();
	return x*f;
}
int main(){
	n=rd();m=rd();a[0]=a[1]=0;
	for(int i=2;i<=n;i++) a[i]=a[i-1]+1ll*rd();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) b[i][j]=1ll*rd();
	for(int j=1;j<=m;j++){
		top=0;
		for(int i=1;i<=n;i++){
			while(top && b[S[top]][j] <b[i][j] ) top--;
			L[i][j]=top?S[top]+1:1;
			S[++top]=i;
		}
		top=0;
		for(int i=n;i>=1;i--){
			while(top && b[S[top]][j]<b[i][j] ) top--;
			R[i][j]=top?S[top]-1:n;
			S[++top]=i;
		}
		for(int i=1;i<=n;i++){
			cnt[L[i][j]][i]+=b[i][j];
			cnt[L[i][j]][R[i][j]+1]-=b[i][j];
			cnt[i+1][i]-=b[i][j];
			cnt[i+1][R[i][j]+1]+=b[i][j];
		}
	}	
	ll ans=0;
	for(int i=1;i<=n;i++){
		
		for (int j = 1; j <= n; ++j)
			cnt[i][j] += cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1];
		for(int j=i;j<=n;j++) ans=max(ans,cnt[i][j]-a[j]+a[i]); 
	} 
	printf("%lld\n",ans); 
	return 0;
}

Measured memory_bytes: 213632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    vector<long long> X(N);
    rep(i, N) cin >> X[i];
    ll sum = 0;
    rep(i, N)
    {
        sum += X[i];
    }
    int P = (ld)sum / (ld)N + 0.5;
    int ans = 0;
    rep(i, N)
    {
        ans += (X[i] - P) * (X[i] - P);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int A, P;
  cin >> A >> P;
  P += A * 3;
  cout << P / 2 << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>

int main(void) {

    double r;
    double s;
    double l;

    scanf("%lf", &r);
    
    s = r * r * M_PI;
    l = 2 * r * M_PI;

    printf("%lf %lf", s, l);

    return 0;
}

Measured memory_bytes: 1076
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
struct FlowEdge {
    ll v, u;
    ll cap, flow = 0;
    FlowEdge(ll v, ll u, ll cap) : v(v), u(u), cap(cap) {}
};

struct Dinic {
    const ll flow_inf = 1e18;
    vector<FlowEdge> edges;
    vector<vector<ll>> adj;
    ll n, m = 0;
    ll s, t;
    vector<ll> level, ptr;
    queue<ll> q;

    Dinic(ll n, ll s, ll t) : n(n), s(s), t(t) {
        adj.resize(n);
        level.resize(n);
        ptr.resize(n);
    }

    void add_edge(ll v, ll u, ll cap) {
        edges.emplace_back(v, u, cap);
        edges.emplace_back(u, v, 0);
        adj[v].push_back(m);
        adj[u].push_back(m + 1);
        m += 2;
    }

    bool bfs() {
        while (!q.empty()) {
            ll v = q.front();
            q.pop();
            for (ll id : adj[v]) {
                if (edges[id].cap - edges[id].flow < 1)
                    continue;
                if (level[edges[id].u] != -1)
                    continue;
                level[edges[id].u] = level[v] + 1;
                q.push(edges[id].u);
            }
        }
        return level[t] != -1;
    }

    ll dfs(ll v, ll pushed) {
        if (pushed == 0)
            return 0;
        if (v == t)
            return pushed;
        for (ll& cid = ptr[v]; cid < (ll)adj[v].size(); cid++) {
            ll id = adj[v][cid];
            ll u = edges[id].u;
            if (level[v] + 1 != level[u] || edges[id].cap - edges[id].flow < 1)
                continue;
            ll tr = dfs(u, min(pushed, edges[id].cap - edges[id].flow));
            if (tr == 0)
                continue;
            edges[id].flow += tr;
            edges[id ^ 1].flow -= tr;
            return tr;
        }
        return 0;
    }

    ll flow() {
        ll f = 0;
        while (true) {
            fill(level.begin(), level.end(), -1);
            level[s] = 0;
            q.push(s);
            if (!bfs())
                break;
            fill(ptr.begin(), ptr.end(), 0);
            while (ll pushed = dfs(s, flow_inf)) {
                f += pushed;
            }
        }
        return f;
    }
};

int main() {
    cin >> n;
    vl A;

    Dinic D(n+2,0,n+1);
    
    rep(i,n){
        cin >>f;
        A.push_back(f);
    }

    for(ll i=1;i<=n;i++){
        for(ll j=2;i*j<=n;j++){
            D.add_edge(i,i*j,INF);
        }
    }

    rep(i,n){
        if(A[i]<0)D.add_edge(0,i+1,-A[i]);
        else{
            a+=A[i];
            D.add_edge(i+1,n+1,A[i]);
        }
    }


    cout<<a-D.flow()<<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String S = in.next();
            String T = in.next();
            int cnt = 0;
            for (int i = 0; i < S.length(); i++)
            {
                if (S.charAt(i) != T.charAt(i)) cnt++;
            }
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 32068
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = help(s)?"YES":"NO";
        System.out.println(ans);
    }
    static boolean help(String s){
        char[] S = s.toCharArray();
        int n = S.length;
        Integer[] rec = new Integer[3];
        Arrays.fill(rec,0);
        for(char w:S) rec[w-'a']++;
        Arrays.sort(rec,Collections.reverseOrder());
        for(int i=0;i<n;i++){
            if(rec[i%3]--<=0) return false;
        }
        return true;
    }
}


Measured memory_bytes: 27844
import sys
C = [0] * 3
for i in range(3):
    C[i] = list(map(int, input().split()))

for j in range(2):
    diff = [0] * 3
    for i in range(3):
        diff[i] = C[i][j] - C[i][j+1]
    if diff[0] != diff[1] or diff[1] != diff[2]:
        print("No")
        sys.exit()
for j in range(2):
    diff = [0] * 3
    for i in range(3):
        diff[i] = C[j][i] - C[j+1][i]
    if diff[0] != diff[1] or diff[1] != diff[2]:
        print("No")
        sys.exit()
print("Yes")


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

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int n  = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n];
		int  count = 0;
		long sum = 0;
		
		for(int i = 0; i < n ; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}
		if(sum == x) {
			System.out.println(a.length);
		}
		if(x > sum) {
			System.out.println(a.length-1);
		}
		if(x < sum) {
			Arrays.sort(a);
			for(int i = 0; i<n;i++) {
				if(x>=a[i]) {
					x-=a[i];
					count++;
				}
				else {
					break;
				}
			}
			System.out.println(count);
		}

 
 
	}
 
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const LL INF = 0x3f3f3f3f3f3fLL;

int n, a[200005];
LL ans = INF;
LL rs[200005];

pair<LL, LL> getmd(int l, int r, LL s)
{
	LL ret = 0;
	int pos = upper_bound(rs + l, rs + r, s / 2) - rs;
	if(pos < r) ret = max(ret, s - rs[pos]);
	if(pos > l) ret = max(ret, rs[pos - 1]);
	return MP(s - ret, ret);
}

int main()
{
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	rep(i, n) rs[i + 1] = rs[i] + a[i];
	for(int i = 2; i <= n - 2; i ++) {
		pair<LL, LL> u = getmd(1, i, rs[i]);
		pair<LL, LL> v = getmd(i + 1, n, rs[i] + rs[n]);
		v.first -= rs[i]; v.second -= rs[i];
		ans = min(ans, max(u.first, v.first) - min(u.second, v.second));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<double> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    for(int i=1; i<N; i++)
    {
        A.at(i)+=A.at(i-1);
        A.at(i)/=2;
    }
    cout << setprecision(10) << fixed << A.at(N-1) << endl;
    
}


Measured memory_bytes: 384
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)      for(int(i)=0;(i)<=(n);(i)++)

// code
// ------------------------------------------------
int main() {

  int n,y;
  int a,b,c;

  cin >> n >> y;

  int p,q,r;
  p = -1;
  q = -1;
  r = -1;
  repe(i,n)
  {
    for(int j = 0; i + j <= n; j++)
    {
      a = n - i - j;
      if(( 10000 * i + 5000 * j + 1000 * a) == y)
      {
        p = i;
        q = j;
        r = a;
        break;
      }
    }

  }

  cout << p << " " << q << " " << r;















  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <time.h>

#define all(dat)       dat.begin(), dat.end()
#define rep(num)       for (int _ = 0; _ < num; _++)
#define loop(i, num)   for (int i = 0; i < num; i++)
#define count(i, num)  for (int i = 1; i <= num; i++)

typedef long long      num;

using namespace std;

int n, rt;

vector<int> dp;

vector<vector<int>> nei;

void dfs(int cur, int rt){

    int res = 0, has = 0;
    
    for (int i = 0; i < nei[cur].size(); i++) {
    
        if (nei[cur][i] != rt) {
        
            dfs(nei[cur][i], cur);
            
            res += dp[nei[cur][i]];
            
            has += (dp[nei[cur][i]] != 0);
            
        }
        
    }
    
    res += max((int) (nei[cur].size()) - 1 - has - 1, 0);
    
    res += rt == -1;
    
    dp[cur] = res;
    
}


int main() {

    cin >> n;
    
    dp.resize(n + 1);
    
    nei.resize(n + 1);
    
    loop (i, n - 1) {
    
        int a, b;
        
        cin >> a >> b;
        
        nei[a].push_back(b);
        
        nei[b].push_back(a);
        
    }
    
    loop (i, nei.size()) {
        
        if (nei[rt].size() < nei[i].size()) {
            
            rt = i;
            
        }
        
    }
    
    dfs(rt, -1);
    
    cout << dp[rt] << endl;;
    
    return 0;
}


Measured memory_bytes: 13824
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

int N,a,b;

vector<int> bfs(vector<vector<int>> &G, int s) {
	vector<bool> used(N);
	vector<int> d(N);
	queue<pi> q;

	d[s] = 0;
	used[s] = true;
	q.push({s,0});

	while (!q.empty()) {
		int cx = q.front().first;
		int ct = q.front().second;
		q.pop();
		used[cx] = true;
		d[cx] = ct;

		for (int i = 0; i < G[cx].size(); i++) {
			int nx = G[cx][i];
			if (!used[nx])
				q.push({nx,ct+1});
		}
	}
	return d;
}

int main()
{
	cin >> N;
	vector<vector<int>> G(N);

	for (int i = 0; i < N-1; i++) {
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	int s = 0;
	int g = N - 1;

	vector<int> d1 = bfs(G,s);
	vector<int> d2 = bfs(G,g);

	int l = 0, r = 0;

	for (int i = 0; i < N; i++) {
		if (d1[i] <= d2[i])l++;
		else r++;
	}

	if (l > r)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;

	return 0;
}

Measured memory_bytes: 6584
#include <iostream>
using namespace std;
int main(void){
        int x,y;
        while (1){
            cin >> x>>y;
            if(x==0 && y==0) break;
            else if(x>y) swap(x,y);
            
            cout << x <<" "<<y<<endl;
        }
   
    
}


Measured memory_bytes: 3080
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cctype>
#include <string>
#include <vector>
#include <algorithm>

bool next_operation(std::string &s) {
  for (size_t i=s.length(); i--;) {
    if (s[i] == 'A') {
      s[i] = 'O';
      return true;
    } else if (s[i] == 'O') {
      s[i] = 'X';
      return true;
    } else if (s[i] == 'X') {
      s[i] = 'A';
    }
  }
  return false;
}

int parse(const std::string &s, size_t &i, size_t preced=0) {
  const std::vector<std::string> ops={"AOX"};

  if (preced == ops.size()) {
    if (s[i] == '(') {
      int res=parse(s, ++i, 0);
      assert(s[i] == ')');
      ++i;
      return res;
    }
    if ('0' <= s[i] && s[i] < '0'+16) {
      return s[i++]-'0';
    }
    assert(false);
  }

  int lhs=parse(s, i, preced+1);
  while (i < s.length()) {
    char op=s[i];
    if (!isupper(op)) break;
    int rhs=parse(s, ++i, preced+1);
    if (op == 'A') lhs &= rhs;
    if (op == 'O') lhs |= rhs;
    if (op == 'X') lhs ^= rhs;
  }
  return lhs;
}

int testcase_ends() {
  char buf[1024];
  scanf(" %[^\n]", buf);
  std::string s=buf;
  if (s == "END") return 1;

  size_t n;
  scanf("%zu", &n);
  std::vector<int> item(n);
  for (size_t i=0; i<n; ++i) {
    for (int j=0; j<4; ++j) {
      int x;
      scanf("%d", &x);
      item[i] |= x<<j;
    }
  }

  {
    for (size_t i=0; i<s.length(); ++i) {
      if (isdigit(s[i])) {
        s[i] = item[s[i]-'1']+'0';
      } else if (s[i] == ' ') {
        s[i] = 'A';
      }
    }
  }

  int res=0;
  do {
    size_t i=0;
    if (parse(s, i) == 15) ++res;
  } while (next_operation(s));
  printf("%d\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    multiset<LL> A;
    REP(i,N){
        LL a; cin >> a;
        A.insert(a);
    }
    LL ans = 0;
    while(A.size() >= 2){
        LL x = *prev(A.end());
        A.erase(prev(A.end()));
        LL base = 1;
        while(base <= x){
            base *= 2;
        }
        LL rem = base - x;
        if(A.find(rem) != A.end()){
            ans++;
            A.erase(A.find(rem));
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 9600
N, T = [int(nt) for nt in input().split()]
mn_c = 1001
for n in range(N):
  c, t = [int(ct) for ct in input().split()]
  if t <= T:
    if c < mn_c:
      mn_c = c
if mn_c < 1001:
  print(mn_c)
else:
  print("TLE")

Measured memory_bytes: 3060
s = input()
a = int(s[:2])
b = int(s[2:])

if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")

elif 1 <= b <= 12:
    print("YYMM")

elif 1 <= a <= 12:
    print("MMYY")

else:
    print("NA")

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

#define N_MAX 1000000
#define N_MAX_SQRT 1000

ll fact[N_MAX];

void init_fact() {
  std::vector<ll> prime_vec;

  fact[1 - 1] = 1;
  for (size_t i = 2; i <= N_MAX; i++) {
    bool is_prime = true;
    for (auto &&p : prime_vec) {
      if (i % p == 0) {
        fact[i - 1] = p;
        is_prime = false;
        break;
      }
      if (p * p > i) {
        break;
      }
    }

    if (is_prime) {
      fact[i - 1] = i;
      prime_vec.push_back(i);
    }
  }
}

unordered_map<ll, ll> factorize(ll n) {
  //
  unordered_map<ll, ll> retv;
  while (n > 1) {
    ll f = fact[n - 1];
    retv[f]++;
    n /= f;
  }

  return retv;
}

ll count_divider(ll n) {
  unordered_map<ll, ll> factor_dict = factorize(n);
  ll retv = 1;
  for (auto &&p : factor_dict) {
    retv *= p.second + 1;
  }
  return retv;
}

ll solve(ll N) {
  init_fact();
  ll ans = 1;
  for (ll i = 2; i < N; i++) {
    ans += count_divider(i);
  }

  return ans;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  // main procedure
  ll ans = solve(N);

  // output
  cout << ans << endl;

  return 0;
}

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

const int N = 2e5+10;
vector<int> edge[N], a(N,0), ans(N,0);

int dfs(int no, int sum, int par){
  sum += a[no];
  for(int to: edge[no]){
    if(to==par) continue;
    dfs(to,sum,no);
  }
  ans[no] = sum;
}

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

  int n,q;
  cin >> n >> q;

  REP(_,n-1){
    int x,y;
    cin >> x >> y;
    x--; y--;
    edge[x].emplace_back(y);
    edge[y].emplace_back(x);
  }

  REP(_,q){
    int x,p;
    cin >> x >> p;
    a[x-1] += p;
  }
  
  dfs(0,0,-1);

  REP(i,n) cout << ans[i] << " ";
  cout << endl;

  return 0;
}

Measured memory_bytes: 25856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    int n,m,i,j;
    multiset <ll> ms;
    vector < pair < ll , int > > v;
    cin>>n>>m;
    for(i=0;i<n;i++){
        ll k;
        cin>>k;
        ms.insert(k);
    } 
    for(i=0;i<m;i++){
        int b;
        ll c;
        cin>>b>>c;
        v.pb(mkp(c,b));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    bool dn = false;
    for(i=0;i<m;i++){
        ll c = v[i].fi;
        int b= v[i].se;
        for(j=0;j<b;j++){
            ll foo = *(ms.begin());
            if(foo>=c){
                dn=true;
                break;
            }
            ms.erase(ms.begin());
            ms.insert(c);
        }
        if(dn) break;
    }
    ll ans = 0;
    for(auto it:ms) ans += it;
    cout << ans << endl;

 
    return 0;
}

Measured memory_bytes: 7160
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

bool dfs(int i, int x, vector<int> &a)
{
	if (i == a.size())
	{
		return x == 0;
	}

	return (dfs(i + 1, x, a) || dfs(i + 1, x - a.at(i), a));
}

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

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

	int m;
	for (cin >> m; m--; )
	{
		int x;
		cin >> x;
		cout << (dfs(0, x, a) ? "yes" : "no") << endl;
	}
}


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

vector<vector<int>> adj;
vector<int> dp;

int dfs(int p) {
  if (dp[p] != -1) return dp[p];
  dp[p] = 0;
  for (auto to: adj[p]) {
    dp[p] = max(dp[p], dfs(to) + 1);
  }
  return dp[p];
}

int main() {

  int n, m;
  cin >> n >> m;
  adj.resize(n + 1);
  int u, v;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
  }

  dp = vector<int>(n + 1, -1);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (dp[i] == -1) {
      ans = max(ans, dfs(i));
    }
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 11056
#include <algorithm>
#include <array>
#include <deque>
#include <functional>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int c = 0;
    REP(i, s.length()) {
        if (s[i] == t[i])
            continue;
        c++;
    }
    cout << c << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int l[n] = {};
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    for(int t = n-1; t >= 0; t--){
        cout << l[t];
        if(t>0){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include<stdio.h>

int main(void){
        while(1){
                int n, x, ans = 0;
                scanf("%d %d", &n, &x);
                if(n+x==0) break;
                for(int i=1; i<=n; i++)for(int j=i+1; j<=n; j++)for(int k=j+1; k<=n; k++){
                        if(i+j+k==x) ans++;
                }
                printf("%d\n", ans);
        }
        return 0;
}



Measured memory_bytes: 2120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; ++i)
            a[i] = in.nextInt();

        int l = 0, sum = 0, xorSum = 0;
        long ans = 0;
        for(int r = 0; r < n; ++r) {
            sum += a[r];
            xorSum ^= a[r];
            while (xorSum != sum) {
                sum -= a[l];
                xorSum ^= a[l];
                ++l;
            }
            ans += r-l+1;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 72864