akhauriyash/Code-Regression huggingface dataset:
#include <vector>
using namespace std;


const int Interval = 512;
struct SqrtDecomp{
  typedef long long Type;
  const int n;
  vector<Type> arr,buc;
  const Type ide;

SqrtDecomp(const vector<Type>& init,const Type& ide_) : n(init.size()),ide(ide_),arr(init),buc((int)init.size() / Interval + 10,ide_){ for(int i = 0;i < n;i++){
    }
  }

  void update_inter(int l,int r,Type x){
    while(l < r){
      if(l % Interval == 0 && l + Interval <= r){
        buc[l / Interval] += x;
        l += Interval;
      }
      else{
        arr[l] += x;
        l++;
      }
    }
  }

  Type get(int idx){
    return arr[idx] + buc[idx / Interval];
  }
};
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
int main(){
  int n,q;
  cin >> n >> q;
  SqrtDecomp srd(vector<i64>(n,0),0);
  vector<i64> ans;
  for(int i = 0;i < q;i++){
    i64 com;
    cin >> com;
    if(com == 0){
      int s,t;
      i64 x;
      cin >> s >> t >> x;
      srd.update_inter(s - 1,t,x);
    }
    else{
      int s;
      cin >> s;
      ans.push_back(srd.get(s - 1));
    }
  }

  for(int i = 0;i < ans.size();i++){
    cout << ans[i] << endl;
  }
}



Measured memory_bytes: 5300
loop do
  n, k = gets.split.map(&:to_i)
  break if k == 0
  d = 1
  while n >= (d == 1 ? 10 : 9 * d * 10 ** (d - 1))
    n -= d == 1 ? 10 : 9 * d * 10 ** (d - 1)
    d += 1
  end
  x = (d == 1 ? 0 : 10 ** (d - 1)) + n / d
  a = []
  i = n % d
  until k == 0
    a << x.to_s[i]
    k -= 1
    i += 1
    x, i = x + 1, 0 if i >= x.to_s.size
  end
  puts a * ""
end


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

int cnt[2020];

int main() {
    string s;
    cin >> s;
    int now = 0;
    reverse(s.begin(), s.end());
    int base = 1;
    long long ans = 0;
    cnt[0]++;
    for (auto &c : s) {
        now = (now + (c - '0') * base) % 2019;
        ans += cnt[now]++;
        base = base * 10 % 2019;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

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

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

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

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

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

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


int main() {

    int N; scanf("%d", &N);

    map<int, int> mp;

    int data;
    REP(i, N){
        scanf("%d", &data);
        mp[data]++;
    }
    int sum = 0;
    for(auto it = mp.begin();it!=mp.end();it++){
        if(it->second%2){
            sum++;
        }
    }
    printf("%d",sum);
    return 0;
    
}











































Measured memory_bytes: 4992
#include <iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
	int N, T, A, H[1000];
	cin >> N >> T >> A;
	double ans = 1e18;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
		ans = min(ans, abs(A - (T - H[i] * 0.006)));
	}
	for (int i = 0; i < N; i++) {
		if (ans == abs(A - (T - H[i] * 0.006))) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
N = gets.to_i
a = gets.split(" ").map(&:to_i)
s = [0]
0.upto(a.size-1) do |i|
  s.push(s[i] + a[i])
end
cnt = 0
s.sort!
i = 0; j = 1; c = 1
while j < s.size
  if s[i] == s[j]
    c += 1
    j += 1
  else
    i = j
    j += 1
    cnt += c*(c-1)/2
    c = 1
  end
end
cnt += c*(c-1)/2

puts cnt

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

typedef long long ll;
const int INF = 1e9 + 5;
int main() {
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> h(n), dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 0; i < n - 1; i++) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	cout << dp[n - 1] << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long N, long long K) {
    cout << min(N%K, K-(N%K)) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  cin >> N;
  long long K;
  cin >> K;
  solve(N, K);
  return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
int main(void){
  int n;
  int a[10000];
  int ans = 0;
  int count;
  scanf("%d",&n );
  for (int i = 0; i < n; i++) {
    scanf("%d",&a[i] );
  }
  for (int i = 0; i < n-1; i++) {
    if (a[i] == a[i+1]) {
      count = 2;
      for (int j = i+2; j < n && a[i] == a[j]; j++) {
        count++;
      }
      i += count-1;
      ans += count / 2;
    }
  }
  printf("%d\n",ans );
  return 0;
}

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

using namespace std;

int main(){
	int n, x;
	cin >> n>> x;
	
	int arr[n];
	
	for(int i = 0; i < n; i ++)
		cin >> arr[i];
		
	sort(arr, arr+n);
	
	int h = 0;
	while(x > 0 && h < n){
		x -= arr[h];
		if(x < 0)
			break;
		else if(h == n-1 && x > 0)
			break;
		h ++;
	}
	cout << h << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a[100005], s[100005];

int main()
{
	ll ans = 0, cur = 0, ret = 0;
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		s[i] = s[i-1] + a[i];
	}
	for(ll i=1;i<=n;i++) {
		if((1-i%2*2)*(s[i]+cur) <= 0) {
			ll C = 1/(1-i%2*2)-s[i];
			ret += abs(C - cur);
			cur = C;
		}
	}
	ans = ret;
	ret = 0; cur = 0;
	for(ll i=1;i<=n;i++) {
		if((i%2*2-1)*(s[i]+cur) <= 0) {
			ll C = 1/(i%2*2-1)-s[i];
			ret += abs(C - cur);
			cur = C;
		}
	}
	ans = min(ans, ret);
	printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, B, C, res;
  rd(A);
  rd(B);
  rd(C);
  res = (A^B^C);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int A, B, C, res;
//   rd(A,B,C);
//   res = (A^B^C);
//   wt(res);
// }


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define SIZE 505

using namespace std;

char mp[SIZE][SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",&mp[i]);
	bool up=false,A=true;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(mp[i][j]=='#') up=true;
			else A=false;
		}
	}
	if(!up)
	{
		puts("-1");
		return 0;
	}
	if(A)
	{
		puts("0");
		return 0;
	}
	int ret=SIZE*SIZE;
	for(int i=0;i<n;i++)
	{
		int cnt=0;
		for(int j=0;j<n;j++)
		{
			if(mp[i][j]=='.') cnt++;
		}
		bool now=false;
		for(int j=0;j<n;j++)
		{
			if(mp[j][i]=='#') now=true;
		}
		if(!now) cnt++;
		ret=min(ret,cnt);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(mp[j][i]=='.')
			{
				ret++;
				break;
			}
		}
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
z=x;
while(x>0){
  y+=x%10;
  x/=10;
}

std::cout << ((z%y==0)? "Yes":"No" ) << '\n';
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)
	a, _ := strconv.Atoi(string(n[0]))
	b, _ := strconv.Atoi(string(n[1]))
	c, _ := strconv.Atoi(string(n[2]))
	d, _ := strconv.Atoi(string(n[3]))
	options := [][]bool{
		{true, false, false},
		{true, true, false},
		{true, true, true},
		{true, false, true},
		{false, true, true},
		{false, false, true},
		{false, true, false},
		{false, false, false},
	}
	for _, op := range options {
		total := a
		var op1, op2, op3 string
		if op[0] {
			total += b
			op1 = "+"
		} else {
			total -= b
			op1 = "-"
		}
		if op[1] {
			op2 = "+"
			total += c
		} else {
			op2 = "-"
			total -= c
		}
		if op[2] {
			op3 = "+"
			total += d
		} else {
			op3 = "-"
			total -= d
		}
		if total == 7 {
			fmt.Println(fmt.Sprintf("%d%s%d%s%d%s%d=7", a, op1, b, op2, c, op3, d))
			return
		}
	}
}


Measured memory_bytes: 512
n,C=map(int,input().split())
d=[]
c=[]
for i in range(C):
    d.append([int(j) for j in input().split()])
for i in range(n):
    c.append([int(j) for j in input().split()])
l1=[0 for i in range(C+1)]
l2=[0 for i in range(C+1)]
l3=[0 for i in range(C+1)]

for i in range(n):
    for j in  range(n):
        if (i+j+2)%3==0:
            for k in range(1,C+1):
                l1[k]+=d[c[i][j]-1][k-1]
        if (i+j+2)%3==1:
            for k in range(1,C+1):
                l2[k]+=d[c[i][j]-1][k-1]
        if (i+j+2)%3==2:
            for k in range(1,C+1):
                l3[k]+=d[c[i][j]-1][k-1]
ans=10**100
for i in range(1,C+1):
    for j in range(1,C+1):
        for k in range(1,C+1):
            if i!=j and i!=k and j!=k:
                ans=min(ans,l1[i]+l2[j]+l3[k])
print(ans)

Measured memory_bytes: 45404
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

typedef struct{
  int x,y;
  int o,st;
  int cost;
}state;

int vis[10][10][1<<10][50];
int in[10][10];

const int qmax=(1<<13)-1;
state Q[qmax+1];

main(){
  int w,h;
  while(cin>>w>>h,w|h){
    memset(vis,0,sizeof(vis));
    rep(i,10)rep(j,10)rep(k,1<<10)rep(l,50)vis[i][j][k][l]=1<<28;
    
    int f,m,o;
    cin>>f>>m>>o;

    rep(i,h)rep(j,w)cin>>in[i][j];


    int qs=0,qnum=0;
    state st;
    st.x=0;
    rep(i,w){
      st.y=i;
      st.o=o-1;
      if(st.o<1)continue;
      if(in[0][i]<0){
	st.cost=-in[0][i];
      }else{
	st.o+=in[0][i];
	st.cost=0;
      }
      if(st.o>m)st.o=m;
      st.st=1<<i;
      if(st.cost>f || st.o<1)continue;
      Q[qs+qnum++&qmax]=st;
    }
    

    while(qnum){
      st=Q[qs++&qmax];--qnum;
      int cx=st.x,cy=st.y,cvis=st.st,cc=st.cost,co=st.o;
      if(vis[cx][cy][cvis][co]<=cc)continue;
      vis[cx][cy][cvis][co]=cc;

      rep(i,3){
	int nx=cx+dx[i],ny=cy+dy[i];
	int nc=cc;
	int no=co-1;
	int nvis=cvis;
	if(no<1)continue;
	if(nx<0 || h<=nx || ny<0 || w<=ny)continue;
	if((dx[i]==0 && (nvis>>ny&1)==0) || dx[i]){
	  if(in[nx][ny]<0)nc-=in[nx][ny];
	  else no+=in[nx][ny];
	  if(no>m)no=m;
	}
	if(dx[i]==0)nvis=cvis|1<<ny;
	else nvis=1<<ny;
	if(nc>f)continue;
	if(vis[nx][ny][nvis][no]<=nc)continue;
	st.x=nx,st.y=ny,st.st=nvis,st.cost=nc,st.o=no;
	Q[qs+qnum++&qmax]=st;
      }
    }
    int ans=f+1;

    rep(i,w)rep(j,1<<w)rep(k,m)ans=min(ans,vis[h-1][i][j][k+1]);

    if(ans==f+1)cout<<"NA"<<endl;
    else cout<<ans<<endl;
  }
}
	   

Measured memory_bytes: 20000
use std::io::*;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    for c in b'a'..(b'z' + 1) {
        let mut cnt: u32 = 0;

        for &x in s.as_bytes() {
            if c == x || c == (x ^ 32) {
                cnt += 1;
            }
        }

        println!("{} : {}", c as char, cnt);
    }
}


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

int f(int x) {
    if (x % 2 == 1) return 0;
    return f(x / 2) + 1;
}

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

    int ans = 1;
    for (int i = 1; i <= n; i++) {
        if (f(i) > f(ans)) {
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  string S; cin >> S;
  string T = "";
  REP(i, S.size()) {
    if (S[i] == 'A') T += 'X';
    else if (i+1 < S.size() && S[i] == 'B' && S[i+1] == 'C') {
      i++;
      T += 'Y';
    } else T += S[i];
  }
  vector<pair<int, int>> itv;
  int state = 0;
  int l;
  T += '#';
  REP(i, T.size()) {
    if (state == 0 && (T[i] == 'X' || T[i] == 'Y')) {
      state = 1;
      l = i;
    } else if (state == 1 && (T[i] != 'X' && T[i] != 'Y')) {
      state = 0;
      itv.PB(MP(l, i));
    }
  }

  ll ans = 0;
  for (auto e : itv) {
    ll psum = 0;
    for (ll i = e.FI; i < e.SE; i++) {
      if (T[i] == 'X') psum++;
      else ans += psum;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1284
num = input()
ssa = [int(x) for x in num]
if ssa[0]+ssa[1]+ssa[2]+ssa[3] == 7:print('{}+{}+{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]+ssa[3] == 7:print('{}-{}+{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]+ssa[3] == 7:print('{}-{}-{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]-ssa[3] == 7:print('{}-{}-{}-{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]+ssa[3] == 7:print('{}+{}-{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]-ssa[3] == 7:print('{}+{}-{}-{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]-ssa[3] == 7:print('{}-{}+{}-{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]+ssa[2]-ssa[3] == 7:print('{}+{}+{}-{}=7'.format(num[0],num[1],num[2],num[3]))

Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {
    var A = input[0].split(" ")[0]-0;
    var B = input[0].split(" ")[1]-0;

    var ans = -1;
    for(var i=0;i<=1000;i++){
        var a = Math.floor(i*0.08);
        var b = Math.floor(i*0.1);
        if(a==A && b==B){
            ans = i;
            break;
        }
    }
    console.log(ans);
}



Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

signed main() {
    int n;
    cin >> n;
    vector<int> hs(n);
    rep(i, n) cin >> hs[i];
    int ans = 1;
    for(int i = 1; i < n; ++i) {
        auto e = hs[i];
        auto result = find_if(&hs[0], &hs[i+1], [&e](int a){ return a > e; });
        if(result == &hs[i+1]) ++ans;
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int N;
int A[100000];
vector<int> edge[100000];
bool used[100000];

LL DFS(int v){
    used[v]=true;
    if(edge[v].size()==1)return A[v];

    vector<LL> lift;
    REP(i,edge[v].size())if(!used[edge[v][i]])lift.push_back(DFS(edge[v][i]));
    REP(i,lift.size())if(lift[i]==-1)return -1;

    LL sum = 0;
    REP(i,lift.size())sum+=lift[i];
    LL maxl = *max_element(ALL(lift));
    LL lower = (maxl*2 > sum ? maxl : (sum+1)/2);
    if(A[v]<lower||A[v]>sum)return -1;

    return 2*A[v]-sum;
}


int main(){
    cin>>N;
    REP(i,N)cin>>A[i];

    REP(i,N-1){
        int a,b;cin>>a>>b;
        edge[--a].push_back(--b);
        edge[b].push_back(a);
    }
    fill_n(used,N,false);

    REP(i,N){
        if(edge[i].size()>1){
            if(DFS(i)==0)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
            return 0;
        }
    }
    if(A[0]==A[1])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;


    return 0;
}

Measured memory_bytes: 14208
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input = input.split("\n");
var N = parseInt(input[0]);
var A = input[1].split(" ").map(function(e){ return parseInt(e,10)});

var count = 0;
for(var i = 0; i < N-1; i++){
  for(var j = N-1 ; j > i; j--){
    if(A[j-1] > A[j]){
      var tmp = A[j];
      A[j] = A[j-1];
      A[j-1] = tmp;
    count += 1;
    }
  }
};
console.log(A.join(" "));
console.log(count);


Measured memory_bytes: 15416
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using M = map<string,ll>;

const int MAX = 100000;
const int MOD = 1000000007;

long long F[MAX];

// テーブルを作る前処理
void T() {
    F[0]=1;F[1]=1;
    for(int i=2;i<MAX+1;i++){F[i]=(F[i-1]+F[i-2])%MOD
    ;}
}




int main(){
    T();
    ll N;
    cin >> N;
    ll M;
    cin >> M; ll ans=1;
    vector<ll> a(M+2,-1);
    for(int i=1;i<M+1;i++){
        cin>>a[i];if(a[i-1]==a[i]-1){ans=0;goto SKIP;}
    ;}
   
   
    for(int i=1;i<M+1;i++){
        ans=(ans*F[a[i]-a[i-1]-2])%MOD
    ;}
    if(a[M]==N-1){;}
    else ans=(ans*F[N-a[M]-1])%MOD;
    SKIP:
    cout<<ans<<endl;



return 0;


}  



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n;
  long long int k;
	cin >> n>>k;
	long long int nu[100010] = {};
	int a[100010];
	int b[100010];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		nu[a[i]] += b[i];
	}
	long long int x = 0;
	int ans = 0;
	for (int i = 1; i <= 100000; i++) {
		x += nu[i];
		if (x >= k) {
			ans = i;
			break;
        }
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    std::vector<int> nums(3);
    std::cin >> nums[0] >> nums[1] >> nums[2];
    std::sort(nums.begin(), nums.end());
    std::cout << nums[0] << " " << nums[1] << " " << nums[2] << std::endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> c(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> c[i][j];
    }
  }
  ll ans = 0LL;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += min(c[i][j], c[j][i]);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3204
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a;
	string b;
	cin>>a>>b;
	int c=0;
	int n = b.length();
	FOR(i,0,n-1){
		if (b[i] == '.') continue;
		int dig = (int) b[i] - '0';
		c *= 10;
		c += dig;
	}
	cout << a*c/100;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <numeric>
#include <list>
using namespace std;

// それぞれの行と列において、全て白（"."）だったら表示しないで詰める
// （AtCoder公式の答えより）黒が含まれている列と行は出力される
int main() {
    int height, width;
    cin >> height >> width;
    
    vector<vector<char> > table(height, vector<char>(width));

    for (int i = 0; i < table.size(); i++)
    {
        for (int j = 0; j < table.at(0).size(); j++)
        {
            cin >> table.at(i).at(j);
        }
    }

    vector<bool> containsBlackCellInTheRow(height, false), containsBlackCellInTheColumn(width, false);

    for (int i = 0; i < table.size(); i++)
    {
        for (int j = 0; j < table.at(0).size(); j++)
        {
            if(table.at(i).at(j) == '#')
            {
                containsBlackCellInTheRow.at(i) = true;
                containsBlackCellInTheColumn.at(j) = true;
            }
        }
    }

    for (int i = 0; i < table.size() ; i++)
    {
        if(containsBlackCellInTheRow.at(i))
        {
            for (int j = 0; j < table.at(0).size(); j++)
            {
                if(containsBlackCellInTheColumn.at(j))
                    cout << table.at(i).at(j);
            }
            cout << endl;
        }
    }
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if ((a == b && b == c) || (a != b && b != c && c != a)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

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

using namespace std;

typedef long long ll;

struct ppp{ll l,r,v,tag;}tree[4000005];

struct ttt{ll s,t,x;}b[200005];

bool cmp(ttt l,ttt r){return l.x>r.x;}

ll p[200005];

set<ll> k;

vector<ll> a;

void push(ll i){

    tree[i*2].tag=tree[i].tag;

	tree[i*2+1].tag=tree[i].tag;

	tree[i*2].v=(tree[i*2].r-tree[i*2].l+1)*tree[i*2].tag;

	tree[i*2+1].v=(tree[i*2+1].r-tree[i*2+1].l+1)*tree[i*2+1].tag;

	tree[i].tag=0;

}

void buildtree(ll i,ll l,ll r){

	tree[i].l=l;tree[i].r=r;

	if(l==r){

		tree[i].v=-1;

		return;

	}

	buildtree(i*2,l,(l+r)/2);

	buildtree(i*2+1,(r+l)/2+1,r);

	tree[i].v=tree[i*2].v+tree[i*2+1].v;

}

void update(ll i,ll l,ll r,ll k){

    if(tree[i].l>=l&&tree[i].r<=r){

        tree[i].tag=k;

		tree[i].v=(tree[i].r-tree[i].l+1)*k;

        return ;

    }

    if(tree[i].tag) push(i);

    ll m=(tree[i].l+tree[i].r)/2;

    if(l<=m) update(i*2,l,r,k);

    if(r>m) update(i*2+1,l,r,k);

    tree[i].v=tree[i*2].v+tree[i*2+1].v;

}

ll query(ll i,ll l,ll r){

    if(tree[i].l>=l&&tree[i].r<=r){

        return tree[i].v;

    }

    if(tree[i].tag) push(i);

    ll m=(tree[i].r+tree[i].l)/2,ans=0;

    if(l<=m) ans+=query(i*2,l,r);

    if(r>m) ans+=query(i*2+1,l,r);

    return ans;

}

int main(){

	ll n,q;

	cin>>n>>q;

	a.push_back(-1e9);

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

		cin>>b[i].s>>b[i].t>>b[i].x;

		k.insert(max(b[i].s-b[i].x,(ll)0));

		k.insert(max(b[i].t-1-b[i].x,(ll)0));

	}

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

		cin>>p[i];k.insert(p[i]);

	}

	for(auto x:k){

		a.push_back(x);

	}

	buildtree(1,1,a.size());

	sort(b+1,b+1+n,cmp);

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

		ll l=lower_bound(a.begin(),a.end(),max((ll)0,b[i].s-b[i].x))-a.begin();

		ll r=lower_bound(a.begin(),a.end(),max((ll)0,b[i].t-b[i].x-1))-a.begin();

		update(1,l,r,b[i].x);

	}

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

		ll l=lower_bound(a.begin(),a.end(),p[i])-a.begin();

		cout<<query(1,l,l)<<endl;

	}

}

Measured memory_bytes: 108136
/*
Author : N_o_o_B
Created : March 22 2020 17:39:22 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    vi a(n);
    fori(i,n) cin >> a[i];

    vl cnt(n+1);
    fori(i,n){
        cnt[a[i]]++;
    }
    ll ans = 0;
    fori(i,n+1){
        ans += cnt[i]*(cnt[i]-1)/2;
    }
    fori(i,n){
        ans -= (cnt[a[i]]-1);
        cout << ans << endl;
        ans += (cnt[a[i]]-1);
    }




    time_taken();
    return 0;
}

Measured memory_bytes: 4992
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    long long count=0;
    cin>>n;
    cout<<(n%2==0 ? n/2-1 : n/2)<<'\n';
    return 0;
}
  
  

Measured memory_bytes: 256
N, X = map(int, input().split())
A = [1] * 55
memo = {}


def func(n, x):
    if x <= 0:
        return 0
    if n == 0:
        return 1
    if (n, x) in memo:
        return memo[(n, x)]

    if x == 1:
        return 0
    if 1 < x <= 1 + A[n-1]:
        memo[(n, x)] = func(n-1, x-1)
        return memo[(n, x)]
    if x == 2 + A[n-1]:
        memo[(n, x)] = func(n-1, x-1) + 1
        return memo[(n, x)]
    if 2 + A[n-1] < x < A[n]:
        memo[(n, x)] = func(n-1, A[n-1]) + func(n-1, x-A[n-1]-2) + 1
        return memo[(n, x)]
    else:
        memo[(n, x)] = 2 * func(n-1, A[n-1]) + 1
        return memo[(n, x)]


def main():
    for i in range(1, N+1):
        A[i] = 2 * A[i-1] + 3

    print(func(N, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);

int main(){
	double l;
	cin>>l;
	double tmp=(double)l/3;
	double ans=(double)tmp*tmp*tmp;
	cout<<setprecision(10)<<fixed;
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut rem = N;
    let mut div = HashMap::new();
    for i in (2..).take_while(|i| i * i <= N) {
        while rem % i == 0 {
            *div.entry(i).or_insert(0usize) += 1;
            rem /= i;
        }
    }
    if rem != 1 {
        div.insert(rem, 1);
    }
    let mut ans = 0usize;
    for (&_, &v) in &div {
        let mut cnt = 1usize;
        let mut exp = v;
        while exp >= cnt {
            ans += 1;
            exp -= cnt;
            cnt += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2192
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int[] p = new int[5];
			p[0] = scan.nextInt();
			if(p[0] == 0){
				break;
			}
			int[] t = new int[3];
			t[p[0]-1]++;
			for(int i = 1;i < 5;i++){
				p[i] = scan.nextInt();
				t[p[i]-1]++;
			}
			if(t[0] != 0 && t[1] != 0 && t[2] != 0){
				t[0] = t[1] = t[2] = 3;
			}else if(t[0] != 0 && t[1] != 0){
				t[0] = 1;
				t[1] = 2;
			}else if(t[0] != 0 && t[2] != 0){
				t[0] = 2;
				t[2] = 1;
			}else if(t[1] != 0 && t[2] != 0){
				t[1] = 1;
				t[2] = 2;
			}else if(t[0] != 0 || t[1] != 0 || t[2] != 0){
				t[0] = t[1] = t[2] =3;
			}
			for(int i = 0;i < 5;i++){
				System.out.println(t[p[i]-1]);
			}
		}
	}
}

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


int main(void) {
    using namespace std;

    constexpr long MOD = 1e9 + 7;

    long n;
    cin >> n;
    vector<long> a(n);
    for(auto &x: a) cin >> x;

    vector<int> v(1000000);
    long r = 1;
    for(int i=0; i<n; i++) {
        if(a[i] == 0) {
            r *= 3 - v[0]++, r %= MOD;
        } else {
            r *= v[a[i]-1] - v[a[i]]++, r %= MOD;
        }
    }

    cout << r << endl;
}


Measured memory_bytes: 4992
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let r: usize = sc.next();
    if r < 1200 {
        println!("ABC");
    } else  if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#include<climits>
#include<sstream>
using namespace std;
#define maxn 105
const long long inf=200000000000;
int n,m;
long long g[maxn][maxn],g_[maxn][maxn];

int main(){

    int i,j,k,x,y,val;
    cin>>n>>m;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            if(i==j)
                g[i][j]=0;
            else g[i][j]=inf;
    for(i=0;i<m;i++){
        cin>>x>>y>>val;
        g[x][y]=val;
    }
    for(k=0;k<n;k++)
        for(i=0;i<n;i++)
            for(j=0;j<n;j++)
                if(g[i][k]!=inf &&g[k][j]!=inf &&g[i][k]+g[k][j]<g[i][j])
                    g[i][j]=g[i][k]+g[k][j];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            g_[i][j]=g[i][j];
    for(k=0;k<n;k++)
        for(i=0;i<n;i++)
            for(j=0;j<n;j++)
                 if(g[i][k]!=inf &&g[k][j]!=inf &&g[i][k]+g[k][j]<g[i][j])
                    g[i][j]=g[i][k]+g[k][j];
    bool negative=false;
     for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            if(g[i][j]!=g_[i][j])
                negative=true;
    if(negative)
        cout<<"NEGATIVE CYCLE"<<endl;
    else{
        for(i=0;i<n;i++){
            for(j=0;j<n-1;j++)
                if(g[i][j]==inf)
                    cout<<"INF ";
                else
                    cout<<g[i][j]<<" ";
            if(g[i][n-1]==inf)
                    cout<<"INF"<<endl;
                else
                    cout<<g[i][n-1]<<endl;
        }
    }
    return 0;
}



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

int main(){
    int x=0,y=0;
    cin >> x >> y;
    bool ans=false;
    for(int i=0;i<=x;i++){
        if(i*2+(x-i)*4==y)ans=true;
    }
    if(ans){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 3644
p = int(input())
mod = p


def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%mod
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], mod -2, mod)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % mod
    return frac, fraci

frac, fraci = frac(p)



A = list(map(int, input().split()))

C = [0]*p
for i in range(p):
    a = A[i]
    for j in range(i):
        a = (a-C[j]*frac[i]*fraci[i-j])
    C[i] = fraci[i]*a%p
B = [0]*p
t = [0]*p
t[0] = 1
for i in range(p):
    for j in range(p):
        B[j] += t[j]*C[i]
    t2 = ([0] + t)[:-1]
    t2 = [(a-b*i)%p for a, b in zip(t2, t)]
    t = t2[:]

B = [b%p for b in B]
print(*B)

Measured memory_bytes: 52588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll a[n];
    ll mat[n][n];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
mat[i][j]=0;
    for(int i=0;i<n;i++){

    cin>>a[i];
    mat[i][i]=a[i];}
    for(int l=2;l<=n;l++){
    for(int i=0;(i+l)<=n;i++){
mat[i][i+l-1]=max(a[i]-mat[i+1][i+l-1],a[i+l-1]-mat[i][i+l-2]);
    }
    }

    cout<<mat[0][n-1];






    return 0;}


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


int main() {
    int k,s;
    cin >> k >> s;

    int cnt=0;
    rep(i,k) rep(j,k) {
        int x,y,z;
        x=i;
        y=j;
        z=s-x-y;
        if (z >= 0 and z <= k) cnt++;
    }

    cout << cnt << endl;



    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    
    int sum = 0;
    for(int i=1; i<=N; i++){
      int n = i;
      int digitSum =0;
      while(n>0){
        digitSum += n%10;
        n /= 10;
      }
      
      if(digitSum>=A && digitSum<=B){
        sum+=i;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 23252
/*
    Author: isaf27 (Ivan Safonov)
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll bt = 31;
const ld eps = 1e-8;
const ll INF = 1e18 + 239;
const int BIG = 2e9 + 239;
const int MOD = 1e9 + 7;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937_64 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

//constants
const int M = 2e5 + 239;
const int N = 2e3 + 239;
const int L = 19;
const int T = (1 << 18);
const int B = trunc(sqrt(M)) + 1;
const int X = 1e4 + 239;
const int A = 26;

int n, kol[A];
string s;

int32_t main()
{
    #ifdef ONPC
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> s;
    for (int i = 0; i < n; i++)
        kol[s[i] - 'a']++;
    int ans = 1;
    for (int i = 0; i < A; i++)
        ans = 1LL * ans * (kol[i] + 1) % MOD;
    ans--;
    cout << ans;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
#define chmax(a,b) a=max(a,b);
typedef long long ll;

using namespace std;
#define N 3010
ll d[N],n;
vector<ll> g[N];

ll t[N];
bool dfs(ll x){
    for(auto y:g[x]){
	if(t[y]<t[x]){
	    t[x]--;
	    if(dfs(y)==0)return 1;
	    t[x]++;
	}
    }
    return 0;
}
bool Solve(ll x){
    lol(i,n)t[i]=d[i];
    return dfs(x);
}

int main(){
    cin>>n;
    lol(i,n)cin>>d[i];
    lol(i,n-1){
	ll a,b;cin>>a>>b;a--,b--;
	g[a].push_back(b);
	g[b].push_back(a);
    }
    bool fi=0;
    lol(i,n){
	if(Solve(i)){
	    if(fi)cout<<" ";
	    cout<<i+1;
	    fi=1;
	}
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 512
fn main() {
    let mut ab = String::new();
    std::io::stdin().read_line(& mut ab).unwrap();
    let ab: Vec<f32> = ab.trim().split_whitespace()
            .map(|x| x.parse().unwrap()).collect();
    
    let mean = (ab[0] + ab[1]) / 2.0;
    let ans = mean.ceil();
    println!("{}",ans);
}

Measured memory_bytes: 4352
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

v1, v2 = b1 - a1, b2 - a2
x1, x2 = t1 * v1, t2 * v2
if x1 + x2 == 0:
  print('infinity')
else:
  if x1 < 0:
    x1, x2 = [x1 * -1, x2 * -1]

  if x1 + x2 > 0:
    print(0)
  else:
    dx = abs(x1 + x2)
    c = (x1 // dx) * 2 + 1
    if x1 % dx == 0:
      c -= 1
    
    print(c)

Measured memory_bytes: 3316
#include <stdio.h>

int main(){
	// N Genap
	// M Ganjil
	int N,M,C,D;
	scanf("%d %d", &N, &M);
	C=(N-1)*N/2;
	D=(M-1)*M/2;
	printf("%d", C+D);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,ans,tot,h[maxn],dep[maxn],fa[maxn];
struct node
{
    int to,nxt;
}a[maxn];
void add(int x,int y)
{
    tot++;
    a[tot].to=y;
    a[tot].nxt=h[x];
    h[x]=tot;
}
void dfs(int now)
{
    for(int i=h[now];i;i=a[i].nxt)
    {
        int x=a[i].to;
        fa[x]=now;
        dfs(x);
        dep[now]=max(dep[now],dep[x]+1);
    }
    if(now!=1&&dep[now]==m-1&&fa[now]!=1)ans++,dep[now]=-1;
}
int main()
{
    int i,j;
    scanf("%d%d",&n,&m);
    rep(i,1,n){scanf("%d",&j);if(i==1&&j!=1)ans++;if(i!=1)add(j,i);}
    dfs(1);
    printf("%d\n",ans);
    //system("Pause");
    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;

int main(){
  cin >> N;
  cout << N*(N-1)/2 - N/2 << endl;
  int u = (N%2==0?1:0);
  rep(i,1,N) rep(j,i+1,N+1) {
    if(i+j != N+u) cout << i << " " << j << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = [0]*n
y = [0]*n
h = [0]*n
for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())

H = max(h)
while 1:
  for i in range(101):
    for j in range(101):
      flg =True
      for k in range(n):
        dx,dy = abs(x[k]-i),abs(y[k]-j)
        if max(H-dx-dy,0)!=h[k]:
          flg = False
      if flg:
        print(i,j,H)
        exit()
  H +=1
    


Measured memory_bytes: 50752