akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

#define MAX_N 200005

class UnionFind
{
public:
  int par[MAX_N];
  int depth[MAX_N];
  int nGroup[MAX_N];

  UnionFind(int n) {
    init(n);
  }

  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }

  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

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

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;

    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<int> A(m), B(m);
  rep(i, m) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
  }
  UnionFind uf(n);
  ll tmp = 1LL*n*(n-1)/2;
  vector<ll> ans(m);
  rrep(i, m) {
    ans[i] = tmp;
    if(!uf.same(A[i], B[i])) {
      int cntA = uf.nGroup[uf.root(A[i])];
      int cntB = uf.nGroup[uf.root(B[i])];
      tmp -= 1LL * cntA * cntB;
    }
    uf.unite(A[i], B[i]);
  }
  rep(i, m) cout << ans[i] << endk;
  return 0;
}


Measured memory_bytes: 6068
#include <stdio.h>  //itp1_6_d

int main(void) {
	int n, m, i, j, arr[111][111], re[111], sum[111]={}, ans[111];
	
	scanf("%d %d", &n, &m);
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d", &arr[i][j]);
		}
	}
	
	for(i=0;i<m;i++){
		scanf("%d", &re[i]);
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			ans[i]=arr[i][j]*re[j];
			sum[i]+=ans[i];
		}
	}
	
	for(i=0;i<n;i++){
		printf("%d\n", sum[i]);
	}
	return 0;
}

Measured memory_bytes: 648
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms=grep!$ls[$_-1]&&$ls[$_],1..$n-1;
	my@lms_map=(-1)x($n+1);
	my$m=@lms;
	for(0..$m-1){
		$lms_map[$lms[$_]]=$_;
	}
	@sa=$induce->(@lms);
	if($m){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms[$lms_map[$l]+1]//$n;
			my$end_r=$lms[$lms_map[$r]+1]//$n;
			my$different;
			if($end_l-$l!=$end_r-$r){
				$different=1;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$different=$l==$n||$s[$l]!=$s[$r];
			}
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper+=$different;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


Measured memory_bytes: 251864
N = int(input())
a6 = []
a2 = []
a3 = []
for i in range(2, 30001):
    if i % 6 == 0:
        a6 += [i]
    elif i % 2 == 0:
        a2 += [i]
    elif i % 3 == 0:
        a3 += [i]
if N == 3:
    print(2, 5, 63)
    exit()
N -= 4
n2 = 2 * min(4999, N // 2)
N -= n2
n3 = 2 * min(2499, N // 2)
n6 = N - n3
n2 += 2
n3 += 2
print(*(a2[:n2] + a3[:n3] + a6[:n6]))


Measured memory_bytes: 4644
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2 << endl;
	}
	else {
		cout << min((a+(b-a-1)/2),(n-b+1+(b-a-1)/2)) << endl;
	}
}

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

const int N=2e5+20;

int n,k,a[N],ans;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);

	int lo=1,hi=*max_element(a,a+n);
	while(lo<=hi)
	{
		int mid=(lo+hi)>>1;

		long long cuts=0;
		for(int i=0;i<n;i++)
		{
			cuts+=(a[i]-1)/mid;
		}

		if(cuts<=k) ans=mid,hi=mid-1;
		else lo=mid+1;
	}
	printf("%d",ans);
}

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

void insert_sort(int* a, int* b){
    int l = b - a,y;
    for(y = 0; y < l-1; y++){
        cout << *(a+y) << ' ';
    }
    cout << *(a+l-1) << '\n';
    for(int x = 1; x < l; x++){
        y = x;
        int i = *(a+x);
        while( y > 0 && *(a+y-1) > i ){
            *(a+y) = *(a+y-1);
            y--;
        }
        *(a+y) = i;
        for(y = 0; y < l-1; y++){
            cout << *(a+y) << ' ';
        }
        cout << *(a+l-1) << '\n';
    }
}

int main(){
    int arr[100], N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> arr[i];
    }
    insert_sort(arr, arr+N);
    return 0;
}

Measured memory_bytes: 1160
#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 x,n;

    cin>>x>>n;
    vector<int> p(n);
    rep(i,n)cin>>p[i];
    sort(p.begin(),p.end());
    rep(i,200){
        int pcount=0;
        int mcount=0;
        if(n==0){
            cout<<x<<endl;
            return 0;
        }
        rep(j,n){
            
            if((x-i)!=p[j])pcount++;
            if(pcount==n){
                cout<<x-i;
                return 0;
            }
            if((x+i)!=p[j])mcount++;
            if(mcount==n){
                cout<<x+i;
                return 0;
            }
        }
    
    
    }

}

Measured memory_bytes: 3584
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                  1000000007
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() 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 pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={-2,-2,1,-1,-1,-1,1,1};
int dy[8]={1,-1,-2,-2,-1,1,-1,1};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    ll cnt=0;
    int n;
    cin>>n;
    vector<ll> a(n+1),b(n);
    f(i,n+1)
    {
        cin>>a[i];
    }
    f(i,n)
    {
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        if(b[i]>=a[i])
        {
            cnt=cnt+a[i];
            b[i]=b[i]-a[i];
            a[i]=0;
            if(a[i+1]>=b[i])
            {
                cnt=cnt+b[i];
                a[i+1]=a[i+1]-b[i];
            }
            else
            {
                cnt=cnt+a[i+1];
                a[i+1]=0;
            }
        }
        else
        {
            cnt=cnt+b[i];
            a[i]=a[i]-b[i];
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2000+10;
struct node{int k,p;}a[N];
int n,f[N][N],ans;
bool cmp(node x,node y){return x.k>y.k;}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i].k);
		a[i].p=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=n-i;j++)
		{
			f[i+1][j]=max(f[i+1][j],f[i][j]+abs(a[i+j+1].p-(i+1))*a[i+j+1].k);
			f[i][j+1]=max(f[i][j+1],f[i][j]+abs(a[i+j+1].p-(n-(j+1)+1))*a[i+j+1].k);
		}
	}
	for(int i=0;i<=n;i++)ans=max(ans,f[i][n-i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 26524
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
v_ll A,B,C;
int main(){
  cin >> N;
  A.assign(N+10,0);
  B.assign(N+10,0);
  C.assign(N+10,0);
  for (ll i=1;i<=N;i++){
    cin >> A[i];
  }
  A[N+1]=A[1];
  ll sum=0;
  for (ll i=1;i<=N;i++){
    sum += A[i];
  }
  B[0]=0;B[1]=0;
  for (ll i=2;i<=N+1;i++){
    B[i]=B[i-2]+A[i-1]*2;
  }
  for (ll i=1;i<=N;i+=2){
    C[i]=sum-(B[N]-B[i]+B[i-1]);
  }
  for (ll i=2;i<=N;i+=2){
    C[i]=sum-(B[N+1]-B[i]+B[i-1]);
  }
  for (ll i=1;i<=N;i++){
    if (i!=1) cout << " ";
    cout << C[i];
  }
  cout << endl;
}


Measured memory_bytes: 3712
while True: 
   a,b = map(int,raw_input().split())
  
   if a+b == 0:
      break

   print b *"#"
   for i in range(1,a-1):   
      print "#" + ('.'*(b-2)) + "#"
   
   print b*"#"
   print ""
   


 

  
   
   

Measured memory_bytes: 6428
#include <iostream>
using namespace std;
int main(void){
 int a,b,c;
 cin >> a >> b >> c;
  if(a == 1 && b == 1 && c == 0){
   cout << "Open" << endl;
  }
  else if(a == 0 && b == 0 && c == 1){
   cout << "Open" << endl;
  }
  else {
   cout << "Close" << endl;
  }
} 


Measured memory_bytes: 3084
import java.util.concurrent.LinkedBlockingDeque

fun main() {
    data class Pos(val toRoom: Int, val room: Int)
    val (n, m) = readLine()?.split(" ")?.map(String::toInt) ?: return

    val routes = Array(n) { mutableListOf<Int>() }
    repeat(m) {
        val (a, b) = readLine()?.split(" ")?.map(String::toInt)!!
        routes[a - 1].add(b - 1)
        routes[b - 1].add(a - 1)
    }
    val signpost = Array(n) { -1 }
    val already = Array(n) { false }
    already[0] = true
    var remain = n
    val queue = LinkedBlockingDeque<Int>()
    routes.first().forEach {
        already[it] = true
        signpost[it] = 0
        remain--
        queue.offer(it)
    }
    while (queue.isNotEmpty()) {
        val p = queue.poll()
        val aisles = routes[p]
        aisles.forEach {
            if (signpost[it] == -1) {
                signpost[it] = p
                remain--
            }
            if (!already[it]) {
                already[it] = true
                queue.offer(it)
            }
        }
    }
    if (signpost.any { remain > 0 }) {
        println("No")
        return
    }
    buildString {
        appendln("Yes")
        1.until(n).forEach {
            appendln(signpost[it] + 1)
        }
    }.let {
        println(it)
    }
}

Measured memory_bytes: 84984
# 2019-11-23 01:28:44(JST)
import sys

def main():
    n, s, k = sys.stdin.read().split()
    n, k = map(int, [n, k])

    c = s[k-1]
    letters = set(s) - set(c)
    for l in letters:
        s = s.replace(l, '*')
    
    print(s)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
function Main(input) {
    input = input.split("\n");
    var aMax = parseInt(input[0], 10);
    var bMax = parseInt(input[1], 10);
    var cMax = parseInt(input[2], 10);
    var total = parseInt(input[3], 10);
    var A_Amount = 500;
    var B_Amount = 100;
    var C_Amount = 50;
    var matchCount = 0;
    for(var aCount = 0; aCount <= aMax; aCount++) {
        if((A_Amount * aCount) > total) continue;
        for(var bCount = 0; bCount <= bMax; bCount++) {
            if(((A_Amount * aCount) + (B_Amount * bCount)) > total) continue;
            for(var cCount = 0; cCount <= cMax; cCount++) {
                var tmpTotal = (A_Amount * aCount) + (B_Amount * bCount) + (C_Amount * cCount);
                if(tmpTotal === total) {
                    matchCount++
                }
            }
        }
    }
    console.log(matchCount);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21320
#include <stdio.h>

int main()
{
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  W -= r;
  H -= r;
  if( x >= r && y >= r && x <= W && y <= H )
    printf("Yes\n");
  else
    printf("No\n");
}



Measured memory_bytes: 2104
#include <iostream>

using namespace std;

static const int MAX = 200000;

int main () {
        int i, n, max, min, R[MAX], temp;

        cin >> n;
        for (i = 0; i < n; i++) {
                cin >> R[i];
        }

        max = R[1] - R[0];
        min = R[0];
        for (i = 1; i < n; i++) {
                temp = R[i] - min;
                if (max < temp)
                        max = temp;
                if (min > R[i])
                        min = R[i];
        }

        cout << max << endl;

        return 0;
}

Measured memory_bytes: 3848
k, s = [int(x) for x in input().split()]
count = 0
for x in range(k+1):
    if x <= s:       
        for y in range(k+1):
            if x + y <= s:
                z = s - (x + y)
                if  z <= k:
                    count += 1
            
print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string v;
  cin >> v;
  REP(a, 0, 2) {
    REP(b, 0, 2) {
      REP(c, 0, 2) {
	string ret = v.substr(0, 1) + (a == 0 ? "+" : "-")
	  + v.substr(1, 1) + (b == 0 ? "+" : "-")
	  + v.substr(2, 1) + (c == 0 ? "+" : "-")
	  + v.substr(3, 1) + "=7";
	int k = v[0] - '0';
	k += (a == 0 ? 1 : -1) * (v[1] - '0');
	k += (b == 0 ? 1 : -1) * (v[2] - '0');
	k += (c == 0 ? 1 : -1) * (v[3] - '0');
	if (k == 7) {
	  cout << ret << endl;
	  return 0;
	}
      }
    }
  }
}


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

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int n = s.length();
            int[] f = new int[26];
            long ans = 1;
            for (int i = 0; i < n; i++) {
                int c = s.charAt(i) - 'a';
                ans += i - f[c];
                f[c]++;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 26764
using System;
using System.Linq;
using System.Collections.Generic;

namespace abc081a{
    class Program{
        static void Main (string[] args){
            string s;
            s=Console.ReadLine();
            int cnt=0;
            if(s[0]=='1')cnt++;
            if(s[1]=='1')cnt++;
            if(s[2]=='1')cnt++;
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

struct dice {
    mt19937 mt;
    dice() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}
    ll operator()(ll x) { return this->operator()(0, x - 1); }
    ll operator()(ll x, ll y) {
        uniform_int_distribution<ll> dist(x, y);
        return dist(mt);
    }
} rnd;

class rollingHash {
private:
    static constexpr ll mod = (1LL<<61) - 1;
    static ll base;
    vector<ll> hash, p;

    ll mul(ll a, ll b) {
        ll au = a>>31, ad = a & ((1LL<<31)-1);
        ll bu = b>>31, bd = b & ((1LL<<31)-1);
        ll mid = ad*bu+au*bd, midu = mid>>30, midd = mid & ((1LL<<30)-1);
        return au*bu*2 + midu + (midd<<31) + ad*bd;
    }
    ll calcmod(ll x) {
        ll ret = (x>>61) + (x & mod);
        if(ret >= mod) ret -= mod;
        return ret;
    }

public:
    rollingHash(const string &s) : hash(s.size()+1), p(s.size()+1, 1) {
        if(base == -1) base = rnd(2, 100000);
        REP(i, s.size()) {
            hash[i+1] = calcmod(mul(hash[i], base)+s[i]);
            p[i+1] = calcmod(mul(p[i], base));
        }
    }
    // [l,r)
    ll get(int l,int r) {
        return calcmod(hash[r] + 3*mod - mul(hash[l], p[r-l]));
    }
    ll concat(ll h1, ll h2, ll h2len) {
        return calcmod(mul(h1, p[h2len]) + h2);
    }
};
ll rollingHash::base = -1;

int main(void) {
    ll n;
    string s;
    cin >> n >> s;

    map<PII,ll> mp;
    REP(i, 1LL<<n) {
        string strr = "", strb = "";
        REP(j, n) {
            if(i&1LL<<j) strr += s[j];
            else strb += s[j];
        }
        reverse(ALL(strr));
        reverse(ALL(strb));
        rollingHash hash_r(strr), hash_b(strb);
        mp[{hash_b.get(0, strb.size()), hash_r.get(0, strr.size())}]++;
    }

    ll ans = 0;
    REP(i, 1LL<<n) {
        string strr = "", strb = "";
        REP(j, n) {
            if(i&1LL<<j) strr += s[n+j];
            else strb += s[n+j];
        }
        rollingHash hash_r(strr), hash_b(strb);
        PII p({hash_r.get(0, strr.size()), hash_b.get(0, strb.size())});
        ans += mp[p];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 33152
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

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

    bool sleep = false;
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(sleep){
            ans += t[i];
        }
        else{
            if(s[i] == X){
                sleep = true;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	ll n1 = n / k;
	ans = n1*n1*n1;
	if (k % 2 == 0) {
		ll n2 = n / (k / 2) - n1;
		ans += n2*n2*n2;
	}
	cout << ans << endl;
	return 0;
}

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


int main(){
    int n; cin >> n;
    vector<ll> a(n+1);
    map<ll, ll> mp;
    mp[0]++;
    for(int i  = 0; i < n; i++){
        ll mid; cin >> mid;
        a[i+1] = mid + a[i];
        mp[a[i+1]]++;
    }
    ll ans = 0;
    for(auto x:mp){ans+= x.second*(x.second-1)/2;};
    cout << ans << endl;
}

Measured memory_bytes: 14336
import sys
import  math
import fractions
from collections import defaultdict
import copy
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


H,W,K=nm()
mass=[[0 for i in range(W)] for i in range(H)]
for i in range(H):
    c=list(ns())
    for j in range(W):
        mass[i][j]=(0 if c[j]=='.' else 1)

ans=0
c=0
for i in range(2**W):
            for j in range(2**H):
                mass2=copy.deepcopy(mass)
                c=0
                for k in range(W):
                        if((i>>k) & 1):
                            for l in range(H):
                                mass2[l][k]=-1

                for k in range(H):
                        if((j>>k) & 1):
                            for l2 in range(W):
                                mass2[k][l2]=-1
                for k in range(W):
                    for l in range(H):
                        if(mass2[l][k]==1):
                            c+=1
                if(c==K):
                    ans+=1
print(ans)


                    





Measured memory_bytes: 10396
#include <iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int a_1=0,a_2=0,a_3=0,a_4=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(s=="AC") a_1++;
    if(s=="WA") a_2++;
    if(s=="TLE") a_3++;
    if(s=="RE") a_4++;
  }
  cout<<"AC x "<<a_1<<endl;
  cout<<"WA x "<<a_2<<endl;
  cout<<"TLE x "<<a_3<<endl;
  cout<<"RE x "<<a_4<<endl;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[100005], finv[100005], inv[100005];

vector<int>v[10005];
int main() {
	int n;
	cin >> n;

	int mon = n, dec = -1, monn = 0;

	for (int i = 1; i < 1005; ++i) {
		if (i*(i - 1) / 2 == n) {
			dec = i;
			break;
		}
	}

	if (dec == -1) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl << dec << endl;
	for (int i = 0; i < dec; ++i) {
		for (int j = i + 1; j < dec; ++j) {
			++monn;
			v[i].push_back(monn);
			v[j].push_back(monn);
		}
	}

	for (int i = 0; i < dec; ++i) {
		cout << v[i].size() << " ";
		for (int j = 0; j < v[i].size(); ++j) {
			cout << v[i][j];
			if (j != v[i].size() - 1) { cout << " "; }
		}
		cout << endl;
	}
}

Measured memory_bytes: 2560
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').trim()

const output = (x: string | number | boolean): void => console.log(x)
const splitLine = (string: string): string[] => string.split('\n')
const splitBlank = (string: string): string[] => string.split(' ')
const toNumbers = (array: string[]): number[] => array.map(v => Number(v))
const range = (end: number, start :number = 0): number[] => [...Array(end - start)].map((v, i) => i + start)

// debug(input)

/* ここから */
const [str1, str2] = splitBlank(input)
const A = BigInt(str1)
const B = BigInt(Math.round(Number(str2) * 100))

// console.log(A, B)

// @ts-ignore
const ans = (A * B) / 100n

console.log(ans.toString())

Measured memory_bytes: 29620
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();
        sc.close();
        if(a < b)
        {
            System.out.println( "a < b" );
        }
        else
        {
            if(a == b) System.out.println("a == b" );
            else System.out.println("a > b");
        }
    }
}


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

typedef struct{
	int x, y;
	vector<pair<int, int>> e;
}Node;

int main(void){
	int N;
	cin >> N;
	Node n[N];
	for(int i = 0; i < N; ++i){
		cin >> n[i].x >> n[i].y;
	}
	for(int i = 0; i < N; ++i){
		for(int j = 0; j < N; ++j){
			if(i==j) continue;
			n[i].e.push_back(make_pair(n[j].x-n[i].x, n[j].y-n[i].y));
			n[j].e.push_back(make_pair(n[i].x-n[j].x, n[i].y-n[j].y));
		}
	}
	map<pair<int, int>, int> mp;
	for(int i = 0; i < N; ++i){
		for(auto a : n[i].e){
			mp[a]++;
			//cout << a.first << " " << a.second << endl;
		}
	}
	int ans = 0;
	for(auto a : mp){
		ans = max(a.second,ans);
		//cout << a.first.first << " " << a.first.second << " " << a.second << ", ";
	}
	cout << N-ans/2 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
#define cpy(a,b) tront[a-1] = temp[b-1]

class dice {
public:
	int tront[6];
	int flag;

	dice() {
		flag = 0;
	}
	void ini() {
		for (int i = 0; i < 6; i++) {
			cin >> tront[i];
		}
	}

	void rotation(char c) {
		int temp[6], i;
		for (i = 0; i < 6; i++)
			temp[i] = tront[i];
		switch (c) {
		case 'E':
			cpy(1, 4);
			cpy(4, 6);
			cpy(6, 3);
			cpy(3, 1);
			break;
		case 'N':
			cpy(5, 1);
			cpy(1, 2);
			cpy(2, 6);
			cpy(6, 5);
			break;
		case 'S':
			cpy(2, 1);
			cpy(1, 5);
			cpy(5, 6);
			cpy(6, 2);
			break;
		case 'W':
			cpy(1, 3);
			cpy(3, 6);
			cpy(6, 4);
			cpy(4, 1);
			break;
		}
	}

	void check(dice d1) {
		for (int j = 0; j < 6; j++) {
			if (d1.tront[j] != tront[j])
				return;
		}
		flag = 1;
	}
};

int main() {
	int i, j, k, q, l, m;
	cin >> q;
	vector<dice> d(q);
	for (i = 0; i < q; i++) {
		d[i].ini();
		for (j = 0; j < 2; j++) {
			d[i].rotation('N');
			d[i].rotation('E');
			d[i].rotation('S');
			for (k = 0; k < 4; k++) {
				d[i].rotation('N');
				for (l = 0; l < 4; l++) {
					d[i].rotation('E');
					for (m = 0; m < q; m++) {
						if (i != m)
							d[i].check(d[m]);
					}
				}
			}
		}
	}
	for (i = 0; i < q && !d[i].flag; i++);
	if (i == q)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

const int N = 2e5 + 7;
int n,cnt,hd[N],v[N],nxt[N],w[N];
long long d[N];

void adde ( int x , int y , int z )
{
	v[++cnt] = y;
	nxt[cnt] = hd[x];
	w[cnt] = z;
	hd[x] = cnt;
}

void dfs ( int u , int fa )
{
    for ( int i = hd[u] ; i ; i = nxt[i] )
    {
    	if ( v[i] != fa )
    	{
    	    d[v[i]] = d[u] + w[i];
    	    dfs ( v[i] , u );
    	}
    }
    
}

int main ()
{
	cin >> n;
    for ( int i = 1 , x , y , z ; i < n ; ++ i )
    {
    	cin >> x >> y >> z;
    	adde ( x , y , z );
    	adde ( y , x , z );
    }
    
	dfs ( 1 , 0 );
	
    for ( int i = 1 ; i <= n ; ++ i )
    {
        int op = d[i] & 1;
        cout << op << endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 6144
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    res = 0
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            if a == b:
                continue
            c = x - a - b
            if c!=a and c!= b and b<c<=n:
                res += 1
    print(res)



Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int main(){
  int a,b,c,cnt=0,count=0;
  cin>>a>>b>>c;
  if(a==5)cnt++;
  if(a==7)count++;
  if(b==5)cnt++;
  if(b==7)count++;
  if(c==5)cnt++;
  if(c==7)count++;
  
  if(cnt==2&&count==1)cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i,n,a,min,max;
	long long int sum;
	scanf("%d",&n);
	min = 1000000;
	max =-1000000;
	sum=0;

	for(i=0;i<n;i++){
		scanf("%d",&a);
		sum = sum + a ;
		if(min>a){min=a;}
		if(max<a){max=a;}
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
k,n = list(map(int,input().split()))
a = list(map(int,input().split()))
res = 0
max_num = 0
num = 0

for i in range(n):
    if i != (n - 1):
        num = a[i+1] - a[i]
    else:
        num = (k - a[i]) + a[0]
    
    res += num
    if max_num < num:
        max_num = num

print(res - max_num)


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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int a, b, c, d;
    cin >> a >> b >> c >> d;
    print(max({a * c, a * d, b * c, b * d}));
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
#define int long long
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1){
    int a,b[11400],c[11400],d,e,f,g,h;
    cin >>a;
    if(a==0) break;
    for(int n=0;n<=a;n++){
      cin >>b[n];
      if(n!=0){
        c[n]=b[n]-b[n-1];
      }
    }
    d=c[1];
    e=0;
    g=0;
    h=0;
    for(int n=1;n<=a;n++){
      if(h>0){
	if(d+b[n-2]!=b[n]){
	  e=n;
	  g++;
	}
	h--;
      }
      else{
	if(d+b[n-1]!=b[n]){
	  e=n;
	  g++;
	  h++;
	}
      }
    }
    if(g==1) cout <<b[e]<<'\n';
    if(g>1){
      if(c[a]==b[2]-b[0]) cout <<b[1]<<'\n';
      else cout <<b[0]<<'\n';
    }
  }
  return(0);
}



Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  string w[n+1];
  for(int i=0;i<n;i++) cin>>w[i];
  bool flag=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(w[i]==w[j]){
        flag=1;
      }
    }
  }
  if(flag){
    cout<<"No"<<endl;
    return 0;
  }

  for(int i=1;i<n;i++){
    if(w[i-1][w[i-1].size()-1]!=w[i][0]){
      flag=1;
    }
  }
  if(flag)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int a[100001];
long long l[100002];
long long r[100002];

int main() {
    int n, i;
    long long x = 1, ans = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i <= n; i++) scanf("%d", &a[i]);
    
    l[n] = r[n] = a[n];
    
    for (i = n - 1; i >= 0; i--) {
        l[i] = a[i] + (l[i + 1] + 1) / 2;
        r[i] = a[i] + r[i + 1];
    }
    
    for (i = 0; i <= n; i++) {
        if (l[i] > x) {
            puts("-1");
            
            return 0;
        }
        
        if (x > r[i]) x = r[i];
        
        ans += x;
        
        x = min((x - a[i]) * 2, r[i + 1]);
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  cout << ((N % K == 0) ? 0 : 1) << endl;
  return 0;
}


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

int main()
{
	int n, l;
	int sum;
	cin >> n >> l;
	sum = (n - 1) * n / 2;
	sum += n * l;

	if (0 < l) {
		printf("%d", sum - l);
	} else if (l + n - 1 < 0) {
		printf("%d", sum - l - n + 1);
	} else {
		printf("%d", sum);
	}
	

	return 0;
}

Measured memory_bytes: 256
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

int n, k;
int arr[100010];
int dp[100010];

void solve(){
    dp[1] = abs(arr[1] - arr[0]);

    for(int i=2; i<n; i++){
        dp[i] = INT_MAX;
        for(int j=i-1; j>=i-k && j>=0; j--){
            dp[i] = min(dp[i], abs(arr[i] - arr[j]) + dp[j]);
        }
    }
    cout<<dp[n-1]<<endl;
}

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    cin>>n>>k;
    for(int i=0; i<n; i++){
        cin>>arr[i];
    }
    solve();

    return 0;
}


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

int main() {
  int n;
  string s;
  int cnt=0, ans=0;

  cin >> n >> s;

  for(int i=0;i<n;i++) {
    if(cnt==2) {
      if(s[i]=='C') {ans++;cnt=0;}
      else if(s[i]=='A') {cnt=1;}
      else{cnt=0;}
    }
    else if(cnt==1) {
      if(s[i]=='B') {cnt++;}
      else if(s[i]=='A') {cnt=1;}
      else {cnt=0;}
    }
    else if(s[i]=='A') {cnt=1;}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
P = [0] + list(map(float, input().split()))
A = [[0 for _ in range(N + 1)] for __ in range(N + 1)]
A[1][0] = 1 - P[1]
A[1][1] = P[1]

for i in range(2, N + 1):
    for j in range(i + 1):
        A[i][j] = A[i-1][j] * (1 - P[i]) + A[i-1][j-1] * P[i]

prob = 0

for i in range(N // 2 + 1):
    prob += A[N][i]

print(1 - prob)

Measured memory_bytes: 261640
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int A,B,C,K;
   cin>>A>>B>>C>>K;

   if(A>=K)
   {
       cout<<K;
   }
   else if(A+B>=K)
   {
       cout<<A;
   }
   else
   {
       cout<<A-(K-(A+B));
   }
  
}

Measured memory_bytes: 3624
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 50
#define MX 150000
#define ll long long
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,d,p[MN+5],rk[MN+5],ans,can[MN+5],v[MN+5];
ll f[MX+5],w[MN+5];
struct My_Queue
{
	int q[MX+5],top,tail;ll g[MX+5];
	void init(){top=0;tail=1;}
	void Ins(int x,ll v)
	{
		while(top>=tail&&v<=g[top]) --top;
		q[++top]=x;g[top]=v;	
	}
	ll Query(int pos,int d)
	{
		while(pos-q[tail]>d) ++tail;
		return g[tail];
	}
}q[MN+5];
bool cmp(int x,int y){return 1LL*v[x]*w[y]>1LL*v[y]*w[x];}
int main()
{
	n=read();m=read();d=read();w[1]=read();
	for(int i=2;i<=n;++i) w[i]=read(),p[i]=read();
	for(int i=n;i;--i) ++v[i],v[p[i]]+=v[i],w[p[i]]+=w[i],rk[i]=i;
	sort(rk+1,rk+n+1,cmp);
	memset(f,40,sizeof(f));f[0]=0;
	for(int i=0;i<=n;++i)
	{
		int mn=rk[i]==1?50:min(50,d);
		for(int j=0;j<v[rk[i]];++j) q[j].init();
		for(int j=0;j<=MX;++j)
		{
			int r=j%v[rk[i]];
			q[r].Ins(j/v[rk[i]],f[j]-(j/v[rk[i]]*w[rk[i]]));
			f[j]=q[r].Query(j/v[rk[i]],mn)+j/v[rk[i]]*w[rk[i]];
		}
	}
	for(int j=MX;~j;--j) if(f[j]<=m)
	{
		int left=m-f[j],res=j;
		for(int i=1;i<=n;++i)
		{
			int num=min(max(0,(rk[i]==1?int(2e9):d)-50),int(left/w[rk[i]]));
			res+=num*v[rk[i]];left-=num*w[rk[i]];
		}
		ans=max(ans,res);
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 87424
import java.util.Scanner;
import java.util.Arrays;
 
public class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int count = stdIn.nextInt();
        
        for(int i = 0; i < count; i++){
            int side[] = {stdIn.nextInt(), stdIn.nextInt(), stdIn.nextInt()};

            Arrays.sort(side);
            
            if(side[0] * side[0] + side[1] * side[1] == side[2] * side[2]){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }

        stdIn.close();
    }
}


Measured memory_bytes: 33116
package main

import (
        "fmt"
)

func solution(w string) string {
        var memo [26]int

        for _, r := range w {
                memo[r-'a']++
        }

        for i := range memo {
                if memo[i]&1 == 1 {
                        return "No"
                }
        }
        return "Yes"
}

func main() {
        var w string
        fmt.Scan(&w)
        fmt.Println(solution(w))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A,B,C,D,E,F,G;
    cin >> A >> B >> C >> D;
  E =A * B;
  F = C * D;
  
   if(E<F){//F
    G = F;
     
   }   
   else if (F<E){//E
     G = E;
     
   }
    cout << G << endl;
}

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

int main(void){
  int N, M, C;
  cin >> N >> M >> C;
  int B[M];
  for(int i = 0; i < M; i++) cin >> B[i];
  int ans = 0;
  int temp;
  for(int i = 0; i < N; i++){
    int sum = C;
    for(int j = 0; j < M; j++){
      cin >> temp;
      sum += B[j] * temp;
    }
    if(sum > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

/*
a_n a_{n-1} ... a_2 a_1
+
d_n d_{n-1} ... d_2 d_1
=
a_1 a_2 ... a_{n-1} a_n
*/

/*
dp :
                (t)
... a[n-i] ... a[i+1] a[i] ...
... d[n-i] ... d[i+1] d[i] ...
   j      J   K      k
... a[i+1] ... a[n-i]
*/

const int N = 19;
int f[2][2][N], d[N];

int work(int n) {
	for(int i=0;i<=n;++i)
		f[0][0][i] = f[0][1][i] = f[1][0][i] = f[1][1][i] = 0;
	f[0][0][0] = 1;
	
	int ani, K, J;
	for(int i=0;i<(n>>1);++i)
	for(int j=0;j<2;++j)
	for(int k=0;k<2;++k) if(f[j][k][i])
		for(int t = 0; t < 10; ++ t) {
			ani = (t + d[i+1] + k)%10; // ani : a[n-i]
			K = (t + d[i+1] + k) >= 10;
			J = (j*10+t) - (d[n-i]+ani);
			if(J and J != 1) continue;
			if(!i and (!t or !ani)) continue;
			f[J][K][i+1] += f[j][k][i];
		}
	
	if(~n&1) return f[0][0][n>>1] + f[1][1][n>>1];
	int p = n + 1 >> 1, res = 0;
	for(int k = 0; k < 2; ++ k)
		for(int t = 0; t < 10; ++ t)
			if((t + d[p] + k)%10 == t)
				res += f[(t+d[p]+k)>=10][k][n>>1];
	return res;
}

int main() {
	int x, t = 0;
	for(scanf("%d",&x); x; x /= 10) d[++t] = x%10;
	int Ans = 0;
	for(int n = t; n <= (t<<1); ++ n)
		Ans += work(n);
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    int x[5];
    int ans;
    for (int i = 0; i < 5; i++)
    {
        cin >> x[i];
        if (x[i] == 0)
        {
            ans = i + 1;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int fastpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

class Combination
{
public:

    vec fact, invfact;
    int MAX_N, mod;

    Combination(int MAX_N, int mod): MAX_N(MAX_N), mod(mod) {
        fact = vec(MAX_N + 1);
        invfact = vec(MAX_N + 1);
        fact[0] = 1;
        FOR(i, 1, MAX_N + 1){
            fact[i] = (fact[i - 1] * i) % mod;
        }
        invfact[MAX_N] = fastpow(fact[MAX_N], mod - 2, mod);
        IREP(i, MAX_N){
            invfact[i] = (invfact[i + 1] * (i + 1)) % mod;
        }
    }

    int comb(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        int a = fact[n];
        a = (a * invfact[r]) % mod;
        a = (a * invfact[n - r]) % mod;
        return a;
    }
};

int mod = 1000000007;

signed main(){

    int N, M; cin >> N >> M;
    
    int n = 2;
    map<int, int> m;
    while(M > 1){
        while(M % n == 0){
            m[n] += 1;
            M /= n;
        }
        n++;
    }
    vec l;
    for(auto p: m) l.push_back(p.second);

    Combination C(N + 100000, mod);
    int ans = 1;
    REP(i, l.size()){
        ans *= C.comb(N - 1 + l[i], l[i]);
        ans %= mod;
    }
    cout << ans;


    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 3328
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct edge
{
	int r,c,v;
}e[200001];
bool cmp(edge a,edge b){return a.v>b.v;}
int fa[200001];
int siz[200001];
int find(int x){return (fa[x]==x)?x:fa[x]=find(fa[x]);}
signed main() 
{
	int n,h,w;
	scanf("%lld%lld%lld",&n,&h,&w);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld%lld",&e[i].r,&e[i].c,&e[i].v);
		e[i].c+=h;
	}
	sort(e+1,e+n+1,cmp);
	int ans=0;
	for(int i=1;i<=w+h;i++)
		fa[i]=i,siz[i]=1;
	for(int i=1;i<=n;i++)
	{
		int f1=find(e[i].r),f2=find(e[i].c);
		if(f1==f2)
		{
			if(siz[f1]>=1)
			{
				siz[f1]--;
				ans+=e[i].v;
			}
		}
		else if(siz[f1]+siz[f2]>=1)
		{
			fa[f1]=f2;
			siz[f2]+=siz[f1]-1;
			ans+=e[i].v;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6528
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int n;
    set<int> s;
    cin >> n;
    forn(i, n) {
        int x;
        cin >> x;
        s.insert(x);
    }

    cout << (s.size() == n ? "YES\n" : "NO\n");

    return 0;
}

Measured memory_bytes: 9600