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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

const int INF = 1e9+7;

using ipair = pair<int, int>;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

const double PI=3.14159265358979323846;

double a, b, x;
bool over_half;

double calc_triangle(double alpha){
    if(over_half){
        return 0.5 * a*a * tan(PI/2 - alpha);
    }else{
        return 0.5 * b*b * tan(alpha);
    }
}

double calc_target(double x){
    if(over_half){
        double V = (a*a * b - x);
        double S = V / a;
        return S;
    }else{
        double V = x;
        double S = V / a;
        return S;
    }
}

double get_arc(double radian){
    return (radian / PI) * 180;
}

int main(){
    cin >> a >> b >> x;

    if(a*a*b < 2*x){
        over_half = true;
    }else{
        over_half = false;
    }

    double target = calc_target(x);

    double l=0, r=PI/2;
    rep(i, 1000){
        double m = (l+r)/2;
        if(over_half){
            if(calc_triangle(m) > target){
                l = m;
            }else{
                r = m;
            }
        }else{
            if(calc_triangle(m) > target){
                r = m;
            }else{
                l = m;
            }
        }
    }

    double ans = get_arc(PI/2 - l);

    printf("%.13f\n", ans);
    
    return 0;
}

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

using ll = long long;

ll n;
vector<ll> dep(52), p(52);

ll f(ll a, ll b) {
  if(b == 1 && a == 0) return 1;
  if(b == 1 && a != 0) return 0;
  if(b <= dep.at(a) / 2) return f(a - 1, b - 1);
  if(b == dep.at(a) / 2 + 1) return p.at(a - 1) + 1;
  if(b <= dep.at(a) - 1) return p.at(a - 1) + 1 + f(a - 1, b - dep.at(a - 1) - 2);
  return 2 * p.at(a - 1) + 1;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll x;
  cin >> n >> x;
  
  dep.at(0) = 1;
  p.at(0) = 1;
  for(int i = 1; i < n + 1; i++){
    dep.at(i) = 2 * dep.at(i - 1) + 3;
    p.at(i) = 2 * p.at(i - 1) + 1;
  }
  
  cout << f(n, x) << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
using namespace std;
using ll = long long;
const int mod = 1000000007;

ll memo[3000];

int main() {
	ll n, m,memo;
	string s, t;
	cin >> n >> m;
	cin >> s >> t;
	for (int i = max(n, m); i >= 1; i--) {
		if (n%i == 0 && m%i == 0) {
			memo = i;
			break;
		}
	}
	for (int i = 0; i < memo; i++) {
		if (s[n / memo * i] != t[m / memo * i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << n * m / memo << endl;
	return 0;
}





Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  const int n=100000;
  int *a=(int *)malloc(sizeof(int)*(n+1));
  int i,j;
  for(i=0;i<=n;i++) a[i]=1;
  a[0]=a[1]=0;
  for(i=2;i*i<=n;i++){
    if(a[i]){
      for(j=i*i;j<=n;j+=i){
	a[j]=0;
      }
    }
  }
  int *b=(int *)malloc(sizeof(int)*(n+1));
  for(i=0;i<=n;i++) b[i]=0;
  for(i=3;i<=n;i+=2){
    if(a[i] && a[(i+1)/2]){
      b[i]=1;
    }
  }
  for(i=1;i<=n;i++){
    b[i]+=b[i-1];
  }
  int q;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    int l,r;
    scanf("%d%d",&l,&r);
    printf("%d\n",b[r]-b[l-1]);
  }
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    char S;
    cin >> N;
    for (int a=0;a<N;a++){
    cin >> S;
    if (S=='Y'){
    cout << "Four" << endl;
    return 0;
    }
    }
    cout << "Three" << endl;
}


Measured memory_bytes: 3640
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a;
		int n = sc.nextInt();
		int basePrice = sc.nextInt();
		int topPrice = sc.nextInt();
		int baseCal = sc.nextInt();
		int[] topCal = new int[n];
		for(int i=0;i<n;i++){
			topCal[i]=sc.nextInt();
		}
		Arrays.sort(topCal);
		for(int i=n;i>0;i--){
			if((baseCal+topCal[i-1])/(basePrice+topPrice)>=(baseCal/basePrice)){
				baseCal += topCal[i-1];
				basePrice += topPrice;
			}
		}
		System.out.println(baseCal/basePrice);
	}
}	

Measured memory_bytes: 18260
N,L = map(int,input().split())

ringo = []
abs_list = []

for i in range(1,N+1):
    ringo.append(L + i - 1)

minus = True

minabs = 100000

for i in ringo:
    if abs(i) < minabs :
        minabs = abs(i)
        if i > 0 :
            minus = False

ans = sum(ringo)

if minus == True :
    print(ans + minabs)
else:
    print(ans - minabs)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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++)
using namespace std;
const long long INF=1e9+5;
typedef long long ll;

int main() {
  ll K,S;
  cin>>K>>S;
  ll ans=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      int z=S-i-j;
      if(z>=0&&z<=K){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

template<class D>
struct Hungarian {
    V<D> le, ri;
    V<int> perm;

    Hungarian(const VV<D> &c) {
        int n = int(c.size()), m = int(c[0].size());
        assert(n <= m);
        le = V<D>(n, D(0)); ri = V<D>(m, D(0));
        perm = V<int>(n);
        V<int> to_r(n, -1), to_l(m, -1);

        for (int s = 0; s < n; s++) {
            V<char> l_u(n), r_u(m); l_u[s] = true;
            V<int> tr(m, -1), min_l(m, s);
            V<D> min_cost(m);
            for (int j = 0; j < m; j++) min_cost[j] = c[s][j] + le[s] + ri[j];
            while (true) {
                int r = -1;
                D d = numeric_limits<D>::max();
                for (int j = 0; j < m; j++) {
                    if (!r_u[j] && min_cost[j] < d) {
                        r = j;
                        d = min_cost[j];
                    }
                }
                for (int i = 0; i < n; i++) if (l_u[i]) le[i] -= d;
                for (int j = 0; j < m; j++) {
                    if (r_u[j]) ri[j] += d;
                    else min_cost[j] -= d;
                }
                tr[r] = min_l[r];
                int l = to_l[r];
                if (l == -1) {
                    while (r != -1) {
                        int nl = tr[r], nr = to_r[nl];
                        to_l[r] = nl; to_r[nl] = r;
                        r = nr;
                    }
                    break;
                }
                l_u[l] = r_u[r] = true;
                for (int j = 0; j < m; j++) {
                    D cost = c[l][j] + le[l] + ri[j];
                    if (cost < min_cost[j]) {
                        min_l[j] = l;
                        min_cost[j] = cost;
                    }
                }
            }
        }
        perm = to_r;
    }
};

 
using D = double;
const D PI = acos(D(-1)), EPS = 1e-10;
using P = complex<D>;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
 
    D ans = 0;
 
    int n;
    cin >> n;
    V<P> up(n), dw(n);
    D x, y;
    cin >> x >> y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y; up[i] = P(x, y);
        cin >> x >> y; dw[i] = P(x, y);
        ans += abs(up[i]-dw[i]);
    }
 
    int l = int(up.size()), r = int(dw.size());
    VV<D> cost(l, V<D>(r));
    for (int i = 0; i < l; i++) {
        for (int j = 0; j < r; j++) {
            cost[i][j] = abs(up[i] - dw[j]);
        }
    }
    auto perm = Hungarian<D>(cost).perm;
    for (int i = 0; i < l; i++) {
        ans += cost[i][perm[i]];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3896
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		ArrayDeque<String> deque = new ArrayDeque<String>();
		String s = sc.next();
 
		int q = sc.nextInt();
		int top = 1;
		deque.add(s);
 
		for (int i = 0; i < q; i++) {
			int t = sc.nextInt();
			if (t == 1) {
				top *= -1; // 反転情報を更新
			} else {
				int f = sc.nextInt();
				String c = sc.next();
				if (f == 1) { // 先頭にcを追加
					if (top > 0) {
						deque.addFirst(c);
					} else {
						deque.addLast(c);
					}
				} else { // 末尾にcを追加
					if (top > 0) {
						deque.addLast(c);
					} else {
						deque.addFirst(c);
					}
				}
			}
		}
		// 出力
		StringBuffer sb = new StringBuffer();
		int m = deque.size();
		for (int i = 0; i < m; i++) {
			sb.append(deque.pollFirst());
		}
		if (top < 0) {
			sb.reverse();
		}
 
		System.out.println(sb.toString());
		sc.close();
	}
}

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

int main(){
    string S;
    cin>>S;
    vector<pair<int,int>> D;
    vector<char> OP;
    for(int i=0;i<S.size();i++){
        if(isdigit(S[i])) D.emplace_back(i,S[i]-'0');
        if(S[i]=='+'||S[i]=='-') OP.push_back(S[i]);

    }
    int N = D.size();
    bool R[N],L[N];
    fill(R,R+N,true);
    fill(L,L+N,true);
    R[0]=L[N-1]=false;
    for(int i=0;i<N;i++){
        if(D[i].first>0&&S[D[i].first-1]=='(') R[i]=false;
        if(D[i].first+1<S.size()&&S[D[i].first+1]==')') L[i]=false;
    }
    int DP_MIN[N][N+1],DP_MAX[N][N+1];//[l,r)
    fill(DP_MIN[0],DP_MIN[N],1000000);
    fill(DP_MAX[0],DP_MAX[N],-1000000);
    for(int i=0;i<N;i++){
        DP_MAX[i][i+1]=DP_MIN[i][i+1]=D[i].second;
    }
    for(int len=2;len<=N;len++){
        for(int l=0;l+len<=N;l++){
            if(L[l]&&R[l+len-1]){
                for(int r=l+1;r<l+len;r++){
                    if(DP_MAX[l][r]!=-1000000&&DP_MAX[r][l+len]!=-1000000){
                        DP_MAX[l][l+len]=max(DP_MAX[l][l+len],DP_MAX[l][r]+(OP[r-1]=='+'?DP_MAX[r][l+len]:-DP_MIN[r][l+len]));
                        DP_MIN[l][l+len]=min(DP_MIN[l][l+len],DP_MIN[l][r]+(OP[r-1]=='+'?DP_MIN[r][l+len]:-DP_MAX[r][l+len]));
                    }
                }
            }
            // cout<<"l: "<<l<<" r: "<<l+len<<' '<<DP_MIN[l][l+len]<<' '<<DP_MAX[l][l+len]<<endl;
        }
    }
    cout<<DP_MAX[0][N]<<endl;
    return 0;
}

Measured memory_bytes: 3264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class307
    {
        static void Main()
        {
            var abn = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long a = abn[0];
            long b = abn[1];
            long n = abn[2];

            long lb = 0, ub = Math.Min(n,(n/b)+b-1);
            long ans = 0;
            for(int i = 0; i < 100; i++)
            {
                long mid = Math.Min(((lb + ub) / 2) / b + (b - 1),n);
                long num = (a * mid) / b - a * (mid / b);
                if (ans <= num) { lb = mid; ans = num; }
                else ub = mid;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27568
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var abcd = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = abcd[0];
        var b = abcd[1];
        var c = abcd[2];
        var d = abcd[3];
        while (true)
        {
            c -= b;
            if (c <= 0)
            {
                Console.WriteLine("Yes");
                return;
            }
            a -= d;
            if (a <= 0)
            {
                Console.WriteLine("No");
                return;
            }
        }
    }
}

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

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

    int minimum = min(a,b);
    //int alist[110] = {0};
    vector<int> num;
    for (int i=1; i<=minimum; ++i) {
        if (a%i == 0 && b%i == 0) {
            //++alist[i];
            num.push_back(i);
            //cout << i << endl;
        }
    }
    sort(num.begin(), num.end(), greater<int>());
    num.erase(unique(num.begin(), num.end() ), num.end());
    //sort(alist, alist+minimum, greater<int>());
    //for (int i=0; i<minimum; ++i) cout << alist[i] << endl;

    cout << num[k-1] << endl;

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll C[100007];

map<pair<ll,ll>,pair<ll,ll>> M;

int main(){
  ll N,ma=0;
  vector<vector<ll>> Edge(100007);
  cin >> N;
  rep(i,N-1){
    ll a,b;
    cin >> a >> b;
    M[mp(a,b)]=mp(i,0);
    Edge[a].pb(b);
    Edge[b].pb(a);
  }
  queue<pair<ll,ll>> Q;
  Q.push(mp(1,0));
  C[1]=1;
  while(!Q.empty()){
    ll T=1;
    auto X = Q.front();
    Q.pop();
    rep(j,Edge[X.fr].size()){
      if(C[Edge[X.fr][j]]==0){
        if(T==X.sc){
          T++;
        }
        M[mp(X.fr,Edge[X.fr][j])].sc=T;
        C[Edge[X.fr][j]]=1;
        Q.push(mp(Edge[X.fr][j],T));
        ma = max(ma,T);
        T++;
      }
    }
  }
  cout << ma << endl;
  for(auto P : M){
    C[P.sc.fr]=P.sc.sc;
  }
  rep(i,N-1){
    cout << C[i] << endl;
  }
}

Measured memory_bytes: 15360
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};

ll dp[101][100001],a[101],b[101],n,target;


ll F(ll pos,ll now){
    if( pos > n ){
        if( now>= target ) return 0;
        else return INF;
    }
    ll &ret = dp[pos][now];
    if ( ~ret ) return ret;
    ret = a[pos]+F(pos+1,now+b[pos]);
    ret = min(ret,F(pos+1,now));
    return dp[pos][now] = ret;
}


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll w;
    sfl(n),sfl(w);
    for(ll i=1;i<=n;i++){
        sfl(a[i]),sfl(b[i]);
    }
    ll lw = 0,hi = 1e5,mid,ans=0,val;
    while(lw<=hi){
        mid = (lw+hi)/2;
        target = mid;
        memset(dp,-1,sizeof dp);
        val = F(1,0);
        if( val<=w ){
            ans = mid;
            lw = mid+1;
        }
        else{
            hi = mid-1;
        }
    }
    pfl(ans);
    return 0;
}


Measured memory_bytes: 82724
n = gets.to_i
a = gets.split.map(&:to_i)
sum = a.inject(:+)
psum = a[0]
ans = 10**18
(1...n).each do |i|
    b = (sum-psum*2).abs
    ans = b if ans > b
    psum += a[i]
end
puts ans

Measured memory_bytes: 16772
#include <stdio.h>


int main (void){
      
   char s[64];
   int sum = 700;
   scanf("%s", s);

   if(s[0] == 'o')
     sum += 100;
   if(s[1] == 'o')
     sum += 100;
   if(s[2] == 'o')
     sum += 100;

   printf("%d", sum); 
    
    return 0;
    
}


Measured memory_bytes: 128
# include <cstdio>

int main ( )  {
	int c, x ;
	
	while ( ( c = getchar ( ) ) < '0' || c > '9' ) ;
	for ( x = -48 + c ; ( c = getchar ( ) ) >= '0' && c <= '9' ; ( x *= 10 ) += c - 48 ) ;

	return ! printf ( "%d\n", 48 - x ) ;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main() {
	int n;
	cin>>n;
	int d[n];
	rep(i,n) cin>>d[i];
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=(d[i]*d[j]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

int main() {
	int n, t, x, ans = 0, r[200010] = {0};
	char a[200010] = {0};
	scanf("%s", &a);
	for (int i = 0; i < 200010; i++) {
		if (a[i] == '1')r[i] = 1;
		else if (a[i] == '1')r[i] = 1;
		else if (a[i] == '2')r[i] = 2;
		else if (a[i] == '3')r[i] = 3;
		else if (a[i] == '4')r[i] = 4;
		else if (a[i] == '5')r[i] = 5;
		else if (a[i] == '6')r[i] = 6;
		else if (a[i] == '7')r[i] = 7;
		else if (a[i] == '8')r[i] = 8;
		else if (a[i] == '9')r[i] = 9;
	}
	for (int i = 0; i < 200010; i++) ans += r[i];
	if (ans % 9 == 0)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 2704
#include <iostream>
using namespace std;
#define MAX 100000

int parent(int i)
{
  return i / 2;
}
int left(int i)
{
  return 2 * i;
}
int right(int i)
{
  return 2 * i + 1;
}

int main()
{
  int H, i, A[MAX + 1];

  cin >> H;
  for (i = 1; i <= H; i++)
    cin >> A[i];

  for (i = 1; i <= H; i++)
  {
    cout << "node " << i << ": key = " << A[i] << ", ";
    if (parent(i) >= 1)
      cout << "parent key = " << A[parent(i)] << ", ";
    if (left(i) <= H)
      cout << "left key = " << A[left(i)] << ", ";
    if (right(i) <= H)
      cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }
  return 0;
}


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

ll dp[100010];

int main(){
  int n,m;
  cin >> n >> m;
  int a[m+2]={};
  a[0]=-1;
  a[m+1]=n+1;
  rep(i,m)cin >> a[i+1];
  ll ans=1;
  dp[0]=0;
  dp[1]=1;
  for(int i=2;i<=n+100;i++){
    dp[i]=dp[i-1]+dp[i-2];
    dp[i]%=mod;
  }
  rep(i,m+1){
    ans*=dp[a[i+1]-a[i]-1];
    ans%=mod;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1408
// Problem : H - Grid 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_h
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ull 		unsigned long long
#define ll 			long long
#define MM			1000000007
#define N			100005
#define pb 			push_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define Endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for(int i=begin;i<end;i++)
#define repr(i,begin,end) for(int i=end-1;i>=begin;i--)
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)		__builtin_popcountll(a)
#define hell 		(ull)1e9
#define re 			resize
 
 
 
signed main(void)
{ios
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
	{
		int r,c;
		cin>>r>>c;
		char mat[r+1][c+1];
		rep(i,1,r+1) rep(j,1,c+1) cin>>mat[i][j];
		int dp[r+1][c+1];
		memset(dp,0,sizeof(dp));
		rep(i,1,r+1)
		{
		    rep(j,1,c+1)
		    {
		        if(i==1 and j==1)
		        {
		            dp[i][j]=1;
		            continue;
		        }
		        if(mat[i][j]=='#') continue;
		        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MM;
		    }
		}
		cout<<dp[r][c];
	}
}

Measured memory_bytes: 12368
import java.util.Scanner;

public class Main {

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

        int k = Integer.parseInt(sc.next());
        String s = sc.next();

        if(s.length() <= k){
            System.out.println(s);
        }else{
            System.out.println(s.substring(0, k) + "...");
        }
    }
}

Measured memory_bytes: 38492
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

vector<pair<ll, ll>> prime_factor(ll n) {
	vector<pair<ll, ll>> vp; // {素数、個数}

	// iがsqrt(n)となるまで繰り返す
	for (ll i = 2; i*i <= n; i++) {
		if (n%i == 0) {  // iが素因数
			vp.emplace_back(i, 0);

			// 素因数の数を求める
			do {
				vp[vp.size() - 1].second++;
				n /= i;
			} while (n%i == 0);
		}
	}

	if (n != 1) vp.emplace_back(n, 1);
	return vp;
}

int main(){
    int N;
    cin >> N;
    if(N==1){
        P(1);
        return 0;
    }
    map<int, int> mp;

    vector< pair<ll, ll>> vp;
    ll sum=1;
    REP(i,2,N+1){
        vp = prime_factor(i);
        for(auto v: vp){
            mp[v.first]+=v.second;
        }
    }
    for(auto m :mp){
            sum*=m.second+1;
            sum%=MOD;
    }
    P(sum);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main (void) {
char even[3]="RUD";
char odd[3]="LUD";
char S[101]={'\0'};
scanf("%s",S);
int i=0;
while (i<strlen(S)){
        if (i%2==0) {if(S[i]!=even[0] &&  S[i]!=even[1] && S[i]!=even[2])
        {printf("No");
          return 0;
        }
        }
        if (i%2==1) {if(S[i]!=odd[0] &&  S[i]!=odd[1] && S[i]!=odd[2])
        {printf("No");
          return 0;}
        }
        i++;

}
printf("Yes");

return EXIT_SUCCESS;
}


Measured memory_bytes: 128
s=int(input())
A=[0 for i in range(10**6+1)]
A[1]=s
def func(a):
    if a%2==0:
        return(a//2)
    else:
        return(3*a+1)
for j in range(1,10**6+1):
    A[j+1]=func(A[j])
    if A[j+1] in A[0:j]:
        print(j+1)
        break

Measured memory_bytes: 10904
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str;
    cin>>str;
    map<char,ll> m1;
    for(ll i=0;i<str.length();i++)
        m1[str[i]]+=1;
    if(m1['A']>0 && m1['B']>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long long N, A, B; cin >> N >> A >> B;
	cout << N / (A + B) * A + min(N % (A + B), A) << '\n';

	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right

N = int(input())
S = input()

pos = [[] for _ in range(10)]
for i, s in enumerate(S) :
    pos[int(s)].append(i)

ret = 0
for i in range(10) :
    if len(pos[i]) == 0 :
        continue
    a = pos[i][0]
    for j in range(10) :
        b = bisect_right(pos[j], a)
        if b == len(pos[j]) : continue
        b = pos[j][b]
        for k in range(10) :
            c = bisect_right(pos[k], b)
            if c == len(pos[k]) : continue
            c = pos[k][c]
            ret += 1
            
print(ret)

Measured memory_bytes: 40048
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
S = [i[1] for i in Counter(rs()).most_common()]
if len(S) < 3:
    if S[0] == 1:
        print('YES')
    else:
        print('NO')
else:
    if max(S) - min(S) <= 1:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 64428
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt2()

	e := make([]int, n)
	for i := 0; i < m; i++ {
		a, b := nextInt2()
		e[a-1]++
		e[b-1]++
	}

	for i := 0; i < n; i++ {
		if e[i]%2 == 1 {
			puts("NO")
			return
		}
	}

	puts("YES")
}

Measured memory_bytes: 2688
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		char c[] = s.toCharArray();
		int ans = 0;

		for (int i = 0; i < 3; i++)
			if (c[i] == '1')
				ans=ans+1;

		System.out.println(ans);

	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
pair<int,int> b[100005],c[100005];
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(i%2==0)b[a[i]].first++,b[a[i]].second=a[i];
		else c[a[i]].first++,c[a[i]].second=a[i];
	}
	sort(b,b+100005,greater<pair<int,int> >());
	sort(c,c+100005,greater<pair<int,int> >());
	if(b[0].second!=c[0].second)cout << n-b[0].first-c[0].first;
	else cout << min(n-b[0].first-c[1].first,n-b[1].first-c[0].first);
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;
const int INF=1e5;

int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  long long ans=0;
  ans += min(c, a);
  c -= min(c, a);
  ans += min(b, c);
  c -= min(b, c);
  ans += b;
  ans += min(c, 1LL);
  cout << ans << endl;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

int n, x;
int a[maxn];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	scanf("%d", &x);

	forn (i, n)
		scanf("%d", a + i);

	return true;
}

void solve()
{
	llong ans = 0;

	forn (i, n)
	{
		ans += max(0, a[i] - x);
		a[i] -= max(0, a[i] - x);
	}

	forn (i, n - 1)
		if (a[i] + a[i + 1] > x)
		{
			ans += a[i] + a[i + 1] - x;
			int t = a[i] + a[i + 1] - x;
			a[i + 1] -= min(t, a[i + 1]);
		}

	printf("%lld\n", ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
const int oo = 1000000000;
#define pb push_back
string s;
int k;

int main(){
	cin>>s>>k;
	string t=s;
	sort(t.begin(), t.end());
	if(s.size()==1)
		return cout<<k/2<<endl,0;
	if(t[0]==t.back())
		return cout<<1ll*(k+1)/2*(t.size()/2) + 1ll*k/2*((t.size()+1)/2),0;
	int lf=1,rg=1;
	while(s[lf]==s[lf-1])++lf;
	while(s[s.size()-1-rg]==s[s.size()-rg])++rg;
	ll an=0;
	if(s[0]-s.back())lf=rg=0;
	for(int i=lf+1; i<s.size()-rg; ++i)
		if(s[i]==s[i-1])
			an+=k,++i;
	if(s[0]-s.back())return cout<<an<<endl,0;
	if((lf&1) && (rg&1)){
		an += (k-1ll)*((lf+rg)/2) + lf/2 + rg/2;
	}else{
		an+=rg/2ll*k;
		an+=lf/2ll*k;
	}
	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()
T = input()

ans = 0
for i in range(len(S)):
    if S[i] != T[i]:
        ans += 1
print(ans)


Measured memory_bytes: 9412
n = int(input())
p = []
for i in range(n):
  x, l = map(int, input().split())
  p.append((x-l, x+l))


p.sort()
mr = -10**10
for l, r in p:
  if l >= mr:
    mr = r
    continue
  n -= 1
  mr = min(mr, r)

print(n)

Measured memory_bytes: 16996
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <math.h>

#define MOD 1000000007
#define REP(i,n) for ((i)=0;i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define LL long long
#define ULL unsigned long long



int main(void) {

	long N,M,x,y,ans,i;
	int a[100001] = {0, 1};
	int b[100001] = {0};
	ans = 0;
	scanf("%ld %ld", &N, &M);
	N++;
	for(i=0;i<M;i++){
		scanf("%ld %ld", &x, &y);
		if(a[x]==1){
			a[y]=1;
		}
		b[x]--;
		b[y]++;
		if(b[x]==-1){
			a[x] = 0;
		}
	}

	for(i=0;i<N;i++){
		if(a[i]==1){
			ans++;
		}
	}

	printf("%ld\n", ans);

	return 0;
}

/* 最後の改行忘れるな！！ */


Measured memory_bytes: 896
#include<stdio.h>
#define N 100000
int binarySearch(int,int);

  int A[N];
int main(){

  int B[N],num1,num2,i,j,k,cnt=0,x;
  scanf("%d",&num1);

  for(i=0;i<num1;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&num2);

  for(i=0;i<num2;i++){
    scanf("%d",&B[i]);
  }

 for(i=0;i<num2;i++){
    x= binarySearch(num1,B[i]);

   if(x!=0)cnt++;
  }



  printf("%d\n",cnt);
  return 0;

}
binarySearch(int n,int key){
   int left = 0;
   int right = n;
   int mid;
     while (left < right){
       mid = (left + right) / 2;
       if (A[mid] == key){
	 //	 printf("%d ",A[mid]);

	   return 1;
       }
	  else if (key < A[mid])
	    right = mid;
	     else
	       left = mid + 1;
		 }
return 0;
}

Measured memory_bytes: 1192
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
    print(res)


Measured memory_bytes: 12800
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

int change(int n){
	int res = 0;
	res += n / 500;
	n %= 500;
	res += n / 100;
	n %= 100;
	res += n / 50;
	n %= 50;
	res += n / 10;
	n %= 10;
	res += n / 5;
	n %= 5;
	res += n;
	return res;
}

int main(){
	int P;
	int N1,N5,N10,N50,N100,N500;
	while(~scanf("%d %d %d %d %d %d %d",&P,&N1,&N5,&N10,&N50,&N100,&N500)){
		if(P==0) break;
		int res = numeric_limits<int>::max();
		for(int i=P;i<=P+500;i++){
			int rem = i;
			int c=0;
			for(int j=1;j<=N500;j++){
				if(rem-500 >= 0){
					rem -= 500;
					c++;
				}
				else break;
			}
			for(int j=1;j<=N100;j++){
				if(rem-100 >= 0){
					rem -= 100;
					c++;
				}
				else break;
			}
			for(int j=1;j<=N50;j++){
				if(rem-50 >= 0){
					rem -= 50;
					c++;
				}
				else break;
			}
			for(int j=1;j<=N10;j++){
				if(rem-10 >= 0){
					rem -= 10;
					c++;
				}
				else break;
			}
			for(int j=1;j<=N5;j++){
				if(rem-5 >= 0){
					rem -= 5;
					c++;
				}
				else break;
			}
			for(int j=1;j<=N1;j++){
				if(rem-1 >= 0){
					rem -= 1;
					c++;
				}
				else break;
			}

			if(rem != 0) continue;
			res = min(c+change(i-P),res);
		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 876
#include<bits/stdc++.h>
    #define sz(a) (int)(a).size()
     
    using namespace std;
     
    template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
    template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
    const int INF = 2e5+2;
    const long long hell = 998244353ll;
    
    void solve(){
          int n,m,k;
          cin>>n>>m>>k;
          uin(k,n*m);
          cout<<k<<endl;
    }

    int main(){
    	
    	ios_base::sync_with_stdio(0);cin.tie(0);
    	
    	int q=1;
    #ifdef LOCAL
      	cin>>q;
#endif
	while(q--){
	 solve();
	}

    #ifdef LOCAL
        cout << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
    #endif	
    	return 0;
    }

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

using namespace std;

void rotate(vector<int>& from, vector<int>& to) {
    to[0] = from[0];
    to[2] = from[2];
}

int main() {
    vector<int> vertical = { 1, 2, 6, 5 };
    vector<int> horizontal = { 1, 4, 6, 3 };

    vector<int> faces(6);
    string commands;

    for (int i=0; i<6; ++i) {
        int face;
        cin>>face;
        faces[i] = face;
    }
    cin>>commands;

    for (int i=0; i<commands.size(); ++i) {
        if (commands[i] == 'N') {
            int tmp = vertical.front();
            vertical.erase(vertical.begin());
            vertical.push_back(tmp);
            rotate(vertical, horizontal);

        } else if (commands[i] == 'S') {
            int tmp = vertical.back();
            vertical.erase(vertical.begin()+3);
            vertical.insert(vertical.begin(), tmp);
            rotate(vertical, horizontal);

        } else if (commands[i] == 'E') {
            int tmp = horizontal.front();
            horizontal.erase(horizontal.begin());
            horizontal.push_back(tmp);
            rotate(horizontal, vertical);

        } else if (commands[i] == 'W') {
            int tmp = horizontal.back();
            horizontal.erase(horizontal.begin()+3);
            horizontal.insert(horizontal.begin(), tmp);
            rotate(horizontal, vertical);

        }
    }

    int index = vertical[0] - 1;
    cout<<faces[index]<<endl;

    return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[]) {
  int N, L;
  cin >> N >> L;

  vector<string> s(N);
  for (int i = 0; i < N; ++i)
    cin >> s[i];

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

  string ret = "";
  for (int i = 0; i < N; ++i)
    ret += s[i];

  cout << ret << endl;

  return 0;
}

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

using namespace std;

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

int h, w;
char a[22][22];
int b[22][22];

int bfs(int sh, int sw) {
  int d[5] = {0, -1, 0, 1, 0};
  rep(i,h) rep(j,w) b[i+1][j+1] = - (a[i+1][j+1] == '.');
  b[sh][sw] = 0;
  
  queue<pair<int, int> > q;
  q.push(make_pair(sh, sw));
  while(!q.empty()) {
    pair<int, int> p = q.front(); q.pop();
    int ph = p.first, pw = p.second;
    rep(i,4) {
      int nh = ph + d[i], nw = pw + d[i+1];
      if(b[nh][nw] == -1) {
        b[nh][nw] = b[ph][pw] + 1;
        q.push(make_pair(nh, nw));
      }
    }
  }
  
  int m = 0;
  rep(i,h) rep(j,w) m = max(m, b[i+1][j+1]);
  return m;
}

int main() {
  cin >> h >> w;
  rep(i,h) rep(j,w) cin >> a[i+1][j+1];
  
  int m = 0;
  rep(i,h) rep(j,w) if(a[i+1][j+1] == '.') m = max(m, bfs(i+1,j+1));
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long x, y;

int main() {
    cin >> x >> y;
    long long now = x;
    long long cnt = 0;
    while(now <= y) {
        cnt++;
        now *= 2;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int a,b,c,x;
    
    while(1){
        scanf("%d %d %d",&a,&b,&c);
        x = a + b;
        if(a == -1 && b == -1 && c == -1) break;
        else if(a == -1 || b == -1 ) printf("F\n");
        else if(x >= 80) printf("A\n");
        else if(65 <= x && x < 80) printf("B\n");
        else if(50 <= x && x < 65 ) printf("C\n");
        else if(30 <= x && x < 50){
            if(c >= 50) printf("C\n");
            else printf("D\n");
        }
        else if(x < 30) printf("F\n");
    }
    
}

Measured memory_bytes: 1752
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	w := scanString(sc)
	bug := make([]int, 'z'-'a'+1)
	for _, c := range w {
		bug[c-'a']++
	}
	for _, cnt := range bug {
		if cnt%2 == 1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
	return
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

const int mod = (int) (1e9)+7;
using ll = long long;

vector<int> v(1000005);

int cnt[1000005];

int main()
{
    vector<int> primes;
    for(int i = 2; i <= 1005; i++) {
        int sq = sqrt(i);
        int f = 0;
        for(int j = 2; j <= sq; j++) {
            if(i % j == 0) f = 1;
        }
        if(!f) primes.push_back(i);
    }
    
    memset(cnt, 0, sizeof(cnt));

    int n;
    scanf("%d", &n);
    bool pairwise = true;
    for(int i = 0; i < n; i++) {
        scanf("%d", &v[i]);
        int sq = sqrt(v[i]);
        int t = v[i];
        for(int j = 0; j < primes.size(); j++) {
            if(v[i] % primes[j] == 0) {
                if(cnt[primes[j]]) pairwise = false;
                cnt[primes[j]]++;
                while(t % primes[j] == 0) t /= primes[j];
            }
        }
        if(cnt[t]) pairwise = false;
        if(t > 1) cnt[t]++;
    }
    if(pairwise) {
        puts("pairwise coprime");
        return 0;
    }

    int g = v[0];
    for(int i = 1; i < n; i++) {
        g = __gcd(g, v[i]);
    }
    if(g == 1) {
        puts("setwise coprime");
        return 0;
    }
    puts("not coprime");
}


Measured memory_bytes: 10988
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    c = insr()
    if "A" <= c <= "Z":
        print("A")
    else:
        print("a")
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * (max(a) + 1)
    for i in range(len(a)):
        q[a[i]] = q[a[i]] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
    
main()

Measured memory_bytes: 62512
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;


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

	cout << N / 3 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
typedef long long int ll;
 
using namespace std;
 
#define MOD (ll)1000000007
 
ll arr[1000000];
 
int main(){
 
    ll n;
    cin >> n;
    for(ll i = 0; i < n; i++){
        cin >> arr[i];
    }
    ll sum = 0;
    for(ll i = 0; i < 60; i++){
        ll oc = 0, zc = 0;
        for(ll j = 0; j < n; j++){
            if(arr[j] % 2 == 0){
                zc++;
            }
            else{
                oc++;
            }
            arr[j] /= 2;
        }
        sum = (sum + ((zc * oc) % MOD * ((1ll << i) % MOD)) % MOD) % MOD;
    }
    cout << sum;
}

Measured memory_bytes: 4352
nums = [int(e) for e in input().split()]

count=0
for i in range(nums[0]+1):
    for j in range(0, nums[0]+1-i):
        if 10000*i+5000*j+1000*(nums[0]-i-j)==nums[1]:
            print('{} {} {}'.format(i, j, nums[0]-i-j))
            count=1
            break
    if count==1:
        break

if count==0:
    print('-1 -1 -1')


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> S(N + 1), T(N + 1);
    rep(a, N) {
        int b;
        cin >> b;
        S[a + 1] = S[a] ^ b;
        T[a + 1] = T[a] + b;
    }
    ll re = 0;
    rep(l, N) {
        int ok = l + 1, ng = N + 1;
        while (ng - ok > 1) {
            int r = (ok + ng) / 2;
            ll s = S[r] ^ S[l];
            ll t = T[r] - T[l];
            (s == t ? ok : ng) = r;
        }
        re += ok - l;
    }
    cout << re << endl;
}

Measured memory_bytes: 3456