akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

struct Pt{
	double x,y;
	Pt(){}
	Pt(double x,double y):x(x),y(y){}
	Pt operator+(const Pt&a)const{return Pt(x+a.x,y+a.y);}
	Pt operator-(const Pt&a)const{return Pt(x-a.x,y-a.y);}
	Pt operator*(const Pt&a)const{return Pt(x*a.x-y*a.y,x*a.y+y*a.x);}
	Pt operator*(const double&k)const{return Pt(x*k,y*k);}
	Pt operator/(const double&k)const{return Pt(x/k,y/k);}
	double abs2()const{return x*x+y*y;}
	double arg()const{return atan2(y,x);}
	double dot(const Pt&a)const{return x*a.x+y*a.y;}
	double det(const Pt&a)const{return x*a.y-y*a.x;}
};

Pt proj(Pt a,Pt b){return a*a.dot(b)/a.abs2();}
Pt prep(Pt a,Pt b,Pt c){return a+proj(b-a,c-a);}
Pt refl(Pt a,Pt b,Pt c){return prep(a,b,c)*2-c;}

double area(Pt a,Pt b,Pt c){
	return fabs((b-a).det(c-a))/2;
}

int main() {
	Pt a,b,c;
	double res=0;
	scanf("%lf,%lf",&(a.x),&(a.y));
	scanf("%lf,%lf",&(b.x),&(b.y));
	for(;~scanf("%lf,%lf",&(c.x),&(c.y));){
		res+=area(a,b,c);
		b=c;
	}
	printf("%.10f\n",res);
	return 0;
}

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

namespace _1_11_A_2
{
    class Program
    {
        static void Main(string[] args)
        {
            Dice dice1 = new Dice();
            string[] dice = Console.ReadLine().Split(' ');
            string secondLine = Console.ReadLine();
            List<string> orderList = new List<string>();
            for (int i = 0; i < secondLine.Length; i++)
            {
                orderList.Add(secondLine.Substring(i, 1));
            }
            for (int i = 0; i < orderList.Count; i++)
            {
                dice1.Order(orderList[i], dice);
            }
            Console.WriteLine(dice[0]);
        }
    }

    class Dice
    {
        internal void Order(string order, string[] dice)
        {
            Order_E(order, dice);
            Order_N(order, dice);
            Order_S(order, dice);
            Order_W(order, dice);
        }
        internal void Order_E(string order, string[] dice)
        {
            if (order == "E")
            {
                string str = dice[0];
                dice[0] = dice[3];
                dice[3] = dice[5];
                dice[5] = dice[2];
                dice[2] = str;
            }
        }
        internal void Order_W(string order, string[] dice)
        {
            if (order == "W")
            {
                string str = dice[0];
                dice[0] = dice[2];
                dice[2] = dice[5];
                dice[5] = dice[3];
                dice[3] = str;
            }
        }
        internal void Order_S(string order, string[] dice)
        {
            if (order == "S")
            {
                string str = dice[0];
                dice[0] = dice[4];
                dice[4] = dice[5];
                dice[5] = dice[1];
                dice[1] = str;
            }
        }
        internal void Order_N(string order, string[] dice)
        {
            if (order == "N")
            {
                string str = dice[0];
                dice[0] = dice[1];
                dice[1] = dice[5];
                dice[5] = dice[4];
                dice[4] = str;
            }
        }
    }
}



Measured memory_bytes: 15876
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  
  ll n;cin>>n;
  string s;cin>>s;
  ll one=0;
  rep(i,n){
    if(s[i]=='1')one++;
  }
  vl pows_minus(n);
  vl pows_plus(n);
  pows_minus[0]=1,pows_plus[0]=1;
  for(ll i=1;i<n;i++){
    if(one>1)pows_minus[i]=pows_minus[i-1]*2%(one-1);
    pows_plus[i]=pows_plus[i-1]*2%(one+1);
  }
  vl x(n);
  ll x_plus=0,x_minus=0;
  for(ll i=0;i<n;i++){
    x_plus+=((s[n-1-i]-'0')*pows_plus[i])%(one+1);
    x_plus%=one+1;
    if(one>1)x_minus+=((s[n-1-i]-'0')*pows_minus[i])%(one-1);
    if(one>1)x_minus%=(one-1);
  }
  rep(i,n){
    if(s[i]=='1'){
      if(one==1){
        cout<<0<<endl;
        continue;
      }
      ll nx=(x_minus+(one-1-pows_minus[n-1-i]))%(one-1);
      ll ans=1;
      while(nx>0){
        nx=(nx%__builtin_popcount(nx));
        ans++;
      }
      cout<<ans<<endl;
    }
    if(s[i]=='0'){
      //cout<<x_plus<<" "<<pows_minus[n-1-i]<<" "<<one+1<<endl;
      ll nx=(x_plus+pows_plus[n-1-i])%(one+1);
      ll ans=1;
      while(nx>0){
        nx=(nx%__builtin_popcount(nx));
        ans++;
      }
      cout<<ans<<endl;
    }
  }
  //cout<<x_plus<<endl;
}

  

Measured memory_bytes: 8324
n,m=map(int,input().split())
# n = int(input())
# b = list(map(int,input().split()))
l = [list(map(int,input().split())) for _ in range(m)]

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

ans=0
for i in range(1<<n):
    lcnt=0
    for j in range(m):
        # k = l[j][0]

        s = l[j][1:]
        scnt=0
        for x in s:
            x -= 1
            if(i>>x)&1 == 1:
                scnt+=1

        if scnt%2 == p[j]:
            lcnt+=1
            continue
        elif scnt%2 >0 and p[j] ==1:
            lcnt+=1
            continue

    if lcnt== m:
        ans+=1
        
print(ans)




Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long double r;
    cin >> r;
    cout << fixed << setprecision(10) << 2 * r * 2*acos(0);

    return 0;

}




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

int main()
{
  int x,y,z;
  cin >> x >> y >> z;
  int ret = 0;
  int sum = 0;
  while(sum <= x - z){
    sum += z + y;
	++ret;
  }
  if(0 < sum ){
    --ret;
  }
  cout << ret << endl;
  return 0;
}

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

using namespace std;

int main()
{
  	vector<int>v;
  	int n,m,sum=0;
  	cin>>n>>m;
  	for(int i=0;i<n;i++){
      int a;
      cin>>a;
      sum+=a;
      v.push_back(a);
    }
  	double ll = ((1.00/((double)m*4.00))*sum);
	int nt=0;
    for(int i=0;i<n;i++){
      if(v[i]>=ll)
        nt++;
    }
	if(nt>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
                 
    return 0;
}
    


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define ITERATOR map<int,int>::iterator
using namespace std;
class point {
public:
	int x;
	int y;
	void in() {
		cin >> x >> y;
	}
};
bool compare(point&a, point&b) {
	return a.x < b.x;
}

void add(map<int, int>&, int);
int gmax(map<int, int>&);
void del(map<int, int>&, int);

int main() {
	int a, N;
	cin >> a >> a >> N;
	vector<point> line(N);
	for (int i = 0; i < N; ++i) {
		line[i].in();
	}
	sort(line.begin(), line.end(), compare);
	map<int, int> ma;
	for (int i = 0; i < N; ++i) {
		add(ma, line[i].y);
	}
	int ans = gmax(ma);
	for (int i = 0; i < N; ++i) {
		del(ma, line[i].y);
		ans = min(ans, line[i].x + gmax(ma));
	}
	cout << ans << endl;
	return false;
}

void del(map<int, int>&ma, int y) {
	if (ma[y] == 1) {
		ma.erase(y);
	}
	else {
		--ma[y];
	}
	return;
}
int gmax(map<int, int>&ma) {
	if (ma.empty()) {
		return 0;
	}
	ITERATOR pt = ma.end();
	--pt;
	return pt->first;
}
void add(map<int, int>&ma, int y) {
	ITERATOR pt = ma.find(y);
	if (pt == ma.end()) {
		ma[y] = 1;
	}
	else {
		++ma[y];
	}
}

Measured memory_bytes: 8292
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	char s[100001];
	int start0, start1;
	start0 = start1 = 0;
	cin >> s;
	for(int i = 0;s[i] != '\0';i++){
		if(i % 2 == 0){
			if(s[i] == '0') start1++;
			if(s[i] == '1') start0++;
		}else{
			if(s[i] == '1') start1++;
			if(s[i] == '0') start0++;
		}

	}
	cout << min(start0, start1) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

vector<bool> visited(105);
vector<vector<int>> edge(105);
bool dfs(int cur, int par) {
    // if a cycle doesn't exist, return true
    visited[cur] = true;
    bool ic = false;
    if (edge[cur].size() == 0) {
        return true;
    } else {
        for (int i = 0; i < edge[cur].size(); i++) {
            if (edge[cur][i] == par) {
                continue;
            }
            if (visited[edge[cur][i]]) {
                ic = true;
                break;
            } else {
                visited[edge[cur][i]] = true;
            }
            if (!dfs(edge[cur][i], cur)) {
                ic = true;
            }
        }
        if (ic) {
            return false;
        } else {
            return true;
        }
    }
}
int main() {
    long long n, ans = 0;
    cin >> n;
    vector<string> as(n);
    map<string, int> cnt;
    REP(i, n) {
        cin >> as[i];
        if (cnt[as[i]] == 0) {
            ans++;
        }
        cnt[as[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 25016
#include <iostream>
using namespace std;
int main(){
  int a, b, i, tmp;
  for (i=0; ; i++) {
    cin >> a >> b;
    if (a+b==0) {break;}
    else {
      if (a > b) {
        tmp=a;
        a=b;
        b=tmp;
      }
      cout << min(a, b) << " " << max(a, b) << endl;
    }
  }
}


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

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  vector<int>p(A),q(B),r(C);
  for(int i=0;i<A;i++){cin>>p[i];}
  for(int i=0;i<B;i++){cin>>q[i];}
  for(int i=0;i<C;i++){cin>>r[i];}
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  vector<int>d;
  for(int i=0;i<X;i++){d.push_back(p[i]);}
  for(int i=0;i<Y;i++){d.push_back(q[i]);}
  for(int i=0;i<C;i++){d.push_back(r[i]);}
  sort(d.rbegin(),d.rend());
  int64_t ans=0;
  for(int i=0;i<X+Y;i++){ans+=d[i];}
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6532
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N;
	int pa,pb,pc,pd,ta,tb,tc,td;
	cin>>N>>pa>>pb>>pc>>pd>>ta>>tb>>tc>>td;
	int mi = INF;
	REP(i,101)REP(j,101)REP(k,101){
		int buyD = max(0ll,(N - (ta*i+tb*j+tc*k) + td - 1)/td);
		CHMIN(mi,pa*i+pb*j+pc*k+pd*buyD);
	}
	cout<<mi<<endl;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
    char r[1000];
    while(scanf("%s",r)==1)
    {
        a=strlen(r);
        cout<<r[0]<<a-2<<r[a-1]<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static double pie= 3.14159265358979323846264338327950;
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b =sc.nextInt();
        int h =sc.nextInt();
        int m =sc.nextInt();
        double  rad=pie*2*((double ) h / 12.0 + ((double ) m / 60.0) / 12.0 - (double) m / 60.0);
        double  rsq =  ((double) (a * a + b * b) - (double ) (2 * a * b) * Math.cos(rad));
        System.out.println(Math.sqrt(rsq));






    }
}





Measured memory_bytes: 36008
a =  list(map(int, input().split()))
W = a[0]
H = a[1]
x = a[2]
y = a[3]
r = a[4]

if (x-r)>=0 and (x+r)<=W:
    if (y-r)>=0 and (y+r)<=H:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 5592
#include<iostream>
using namespace std;
struct sushi {
    long long pos, _pos;
    int v;
}a[100005];
long long L_qzh[1000005], L_B_qzh[100005], L_M_qzh[100005];
long long R_qzh[1000005], R_B_qzh[100005], R_M_qzh[100005];
int main () {
    int n;
    long long C;
    long long ans = 0;
    cin >> n >> C;
    for(int i = 1; i <= n; i++)
        cin >> a[i].pos >> a[i].v, a[i]._pos = C - a[i].pos;
    for(int i = 1; i <= n; i++)
        L_qzh[i] = L_qzh[i - 1] + a[i].v, ans = max(ans, L_qzh[i] - a[i].pos), L_B_qzh[i] = L_qzh[i] - 2 * a[i].pos, L_M_qzh[i] = max(L_B_qzh[i], L_M_qzh[i - 1]);
    for(int i = n; i >= 1; i--)
        R_qzh[n - i + 1] = R_qzh[n - i] + a[i].v, ans = max(ans, R_qzh[n - i + 1] - a[i]._pos), R_B_qzh[n - i + 1] = R_qzh[n - i + 1] - 2 * a[i]._pos, R_M_qzh[n - i + 1] = max(R_B_qzh[n - i + 1], R_M_qzh[n - i]);
    for(int i = 1; i <= n; i++)
        ans = max(ans, L_qzh[i] - a[i].pos + R_M_qzh[n - i]);
    for(int i = 1; i <= n; i++)
        ans = max(ans, R_qzh[i] - a[n - i + 1]._pos + L_M_qzh[n - i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
int main(){
    int X;
    int i,j;
    scanf("%d",&X);
    for(i = X ; ; i++){
        int flag = 0;
        for(j = 2 ; j < i ; j++){
            if(i%j == 0){
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
n, m = gets.chomp.split(" ").map(&:to_i)

p = Array.new(m) { |i| gets.chomp.split(" ").map(&:to_i) + [i] }
p.sort! do |a, b|
  if a.first != b.first
    a.first <=> b.first
  else
    a[1] <=> b[1]
  end
end

l = 0
r = 0
p.each do |e|
  if e[0] != l
    l = e[0]
    r = 0
  end

  r += 1
  e.push(r)
end

p.sort! {|a, b| a[2] <=> b[2] }
p.each do |e|
  puts "%06d%06d" % [e.first, e.last]
end


Measured memory_bytes: 29036
#include<bits/stdc++.h>
#define T 100000
using namespace std;
int main()
{	
	int n,c;
	cin>>n>>c;
	int ct[c+1][T+1];
	for(int i=0;i<=c;i++)
	{
		for(int j=0;j<=T;j++)
		{
			ct[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++)
	{
		int s,t,c;
		cin>>s>>t>>c;
		for(int ss=s-1;ss<t;ss++)
		{
			ct[c][ss]=1;
		}
	}
	int res=0;
	for(int i=0;i<=T;i++)
	{
		int cres=0;
		for(int j=0;j<=c;j++)
		{
			cres+=ct[j][i];
		}
		res=max(cres,res);
	}

	cout<<res<<endl;

	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, k; cin >> n >> k;
    vector<int> a(n);
    int sum = 0;
    for (int &x : a) {
        cin >> x;
        sum += x;
    }
    auto check = [&](int val) {
        vector<int> rems;
        int tot = 0;
        for (int &x : a) {
            rems.push_back(x % val);
            tot += val - (x % val);
        }
        sort(rems.begin(), rems.end());
        int cur = 0;
        for (int &rem : rems) {
            cur += rem;
            tot -= val - rem;
            if (cur == tot && cur <= k) {
                return true;
            }
        }
        return false;
    };
    int res = 0;
    for (int i = 1; i * i <= sum; i++) {
        for (int x : {i, sum / i}) {
            if (sum % x == 0 && check(x)) {
                res = max(res, x);
            }
        }
    }
    cout << res << "\n";
}

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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    char S[H][W];
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> S[i][j];
        }
    }

    int Tate[H][W], Yoko[H][W];

    for (int i = 0; i < H; i++){
        int count = 0;
        int start = 0, end = 0;

        for (int j = 0; j < W; j++){
            if (S[i][j] == '.'){
                count ++;

                if (j == W - 1){
                    for (int k = start; k < W; k++){
                        Yoko[i][k] = count;
                    }
                }
            }else{
                end = j - 1;
                for (int k = start; k <= end; k++){
                    Yoko[i][k] = count;
                }
                Yoko[i][j] = 0;
                count = 0;
                start = j + 1;
            }
        }
    }

    for (int i = 0; i < W; i++){
        int count = 0;
        int start = 0, end = 0;

        for (int j = 0; j < H; j++){
            if (S[j][i] == '.'){
                count ++;

                if (j == H - 1){
                    for (int k = start; k < H; k++){
                        Tate[k][i] = count;
                    }
                }
            }else{
                end = j - 1;
                for (int k = start; k <= end; k++){
                    Tate[k][i] = count;
                }
                Tate[j][i] = 0;
                count = 0;
                start = j + 1;
            }
        }
    }


    int ans = 0;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (Tate[i][j] + Yoko[i][j] - 1 > ans){
                ans = Tate[i][j] + Yoko[i][j] - 1;
            }
        }
    }
    cout << ans << endl;
    
    

    

    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
using namespace std;
int a,b,n;
int ketasum(int num){
    int sum=0;
    while(num!=0){
        sum+=num%10;
        num/=10;
    }
    return sum;
}
int main() {
    int sum=0;
    int tmp;
   cin>>n>>a>>b;
   for(int i=1;i<n+1;i++){
       tmp=ketasum(i);
       if(a<=tmp&&tmp<=b){
           sum+=i;
       }
   }
    cout<<sum<<endl;
}



Measured memory_bytes: 256
import static java.lang.Character.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while ((str = br.readLine()) != null) {
			for (int i = 0; i < str.length(); i++) {
				char c = str.charAt(i);
				if (isLetter(c)) {
					if (isUpperCase(c)) {
						System.out.print(toLowerCase(c));
					} else {
						System.out.print(toUpperCase(c));
					}
				} else {
					System.out.print(c);
				}
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 16980
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			HashMap<Integer, HashSet<Integer>> map = new HashMap<Integer, HashSet<Integer>>(n);

			for (int i = 0; i < m; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (map.keySet().contains(a)) {
					map.get(a).add(b);
				} else {
					HashSet<Integer> tmp = new HashSet<Integer>();
					tmp.add(b);
					map.put(a, tmp);
				}
				if (map.keySet().contains(b)) {
					map.get(b).add(a);
				} else {
					HashSet<Integer> tmp = new HashSet<Integer>();
					tmp.add(a);
					map.put(b, tmp);
				}
			}

			for (int i : map.get(1)) {
				// 1から移動可能な島を探索
				for (int j : map.get(i)) {
					if (j == n) {
						System.out.println("POSSIBLE");
						return;
					}
				}
			}
			System.out.println("IMPOSSIBLE");
		}
	}
}

Measured memory_bytes: 233448
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<cctype>
using namespace std;

typedef long long ll;
const int Maxn=610000;

char s[Maxn];

int main() {
	scanf("%s",s);
	int lens=strlen(s);
	ll temp=0,ans=0;
	for(int i=0;i<lens;i++)
		if(s[i]=='B') temp++;
		else ans+=temp;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
 
using namespace std;
 
int main(){
  int W, H, x, y, r;
 
  cin >> W >> H >> x >> y >> r;
  if(x-r < 0 || x+r > W || y-r < 0 || y+r > H){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3084
import numpy as np

n = input()
a = np.array([int(num) for num in input().split(' ')])

min = 100000000000
sunuke = 0
araiguma = a.sum()
for i in range(0, len(a) - 1):
    sunuke += a[i]
    araiguma -= a[i]
    dif = abs(sunuke - araiguma)
    if dif < min: min = dif
print(min)


Measured memory_bytes: 32944
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

	int N, a[200001];
	long long result = 0;

	cin >> N;

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

	sort(a, a + N);

	int median;
	median = a[N / 2];

	for (int i = 0; i < N; i++){
		result += abs(a[i] - median);
	}


	cout << result << endl;

	return 0;
}


Measured memory_bytes: 1024
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
b = LIST()
ans = deque()

while b:
    m = len(b)
    chk = False
    for i in range(m-1, -1, -1):
        if b[i] == i + 1:
            ans.appendleft(b.pop(i))
            chk = True
            break
    if chk == False:
        print(-1)
        exit()
for x in ans:
    print(x)

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

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

  for(int i=0;i<k;i++) {
    if(i % 2 == 0) {
      b += a / 2;
      a /= 2;
    } else {
      a += b / 2;
      b /= 2;
    }
  }

  cout << a << " " << b << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  char tmp = S[0];
  int ans = 1;
  rep(i, 1, N) {
    if (tmp != S[i]) {
      ans++;
      tmp = S[i];
    }
  }

  cout << ans << endl;
};


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

int main()
{
  int N,arr[101];
  long long mn=2001001001;
  cin>>N;
  for (int i=0;i<N;i++)
    cin>>arr[i];
  for (int i=-100;i<=100;i++){
    long long temp=0;
    for (int j=0;j<N;j++)
      temp+=(i-arr[j])*(i-arr[j]);
    mn=min(mn,temp);
  }
  cout<<mn<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const int gmax_n = 100005;

int par[gmax_n]; //親
int depth[gmax_n];//木の深さ

void init(int n){
	rep(i,n){
		par[i] = i;
		depth[i] = 0;
	}
}

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

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

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

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

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

	vector<long long> a(n);
	rep(i,n){
		cin >> a[i];
	}

	init(n);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		unite(a,b);
	}

	vector< priority_queue<int, vector<int>, greater<int>>  > v(n);
	map<int,int> t;
	rep(i,n){
		t[find(i)] = 1;
		v[ find(i) ].emplace(a[i]);
	}

	int cnt = (t.size() - 1) * 2;
	long long sum = 0;
	rep(i,n){
		if(cnt == 0) break;
		if(v[i].empty()) continue;
		sum += v[i].top();
		v[i].pop();
		cnt--;
	}

	priority_queue<int, vector<int>, greater<int>> al;
	rep(i,n){
		while(not v[i].empty()){
			al.emplace(v[i].top());
			v[i].pop();
		}
	}

	rep(i,cnt){
		if(al.empty()){
			cout << "Impossible" << endl;
			return 0;
		}
		sum += al.top();
		al.pop();
	}
	cout << sum << endl;

	/*
	set<int> s;
	rep(i,n){
		s.emplace(find(i));
	}

	vector<priority_queue<long long>> q(s.size());
	rep(i,n){
		int t = distance(s.begin(), s.lower_bound(find(i)));
		q[t].push(a[i]);
	}

	if(s.size() == 1){
		cout << 0 << endl;
		return 0;
	}

	int need = (s.size() - 1) * 2;
	if(need > n){
		cout << "Impossible" << endl;
		return 0;
	}

	vector<long long> v;
	for(auto& i : q){
		while(i.size() > 1){
			v.emplace_back(i.top());
			i.pop();
		}
	}
	sort(all(v), greater<long long>());
	cout << accumulate(all(a),0LL) - accumulate(v.begin(), next(v.begin(), n - need), 0LL) << endl;
	*/
}


Measured memory_bytes: 12800
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238


#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        ll n, k;
        cin >> n >> k;
        vector<ll> v(n);
        for(i =0 ; i <n ;i++){
            cin >> v[i];
        }
        while(k--){
            vector<ll> v2(n + 1);
            for(i =0 ; i <n ;i++){
                ll lo, hi;
                lo = max(0LL, i - v[i]);
                hi = min(i + v[i], n - 1);
                v2[lo]++;
                v2[hi + 1]--;
            }
            for(i = 1 ;i < n; i++){
                v2[i] += v2[i - 1] ;
            }
            for(i =0 ;i < n; i++){
                v[i] = v2[i];
            }
            bool flag = true;
            for(i =0 ;i < n; i++){
                if(v[i] != n){
                    flag = false;
                    break;
                }
            }
            if(flag){
                break;
            }
        }
        for(i =0 ;i < n; i++){
            cout << v[i] <<" ";
        }
    }

    return 0;
}


Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define FOR(i, a, b) for(long long i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
using namespace std;

signed main(void)
{
	long long n, ans;
	cin >> n;
	map<long long, long long> m;

	rep(i, n)
	{
		long long a;
		cin >> a;
		m[a]++;
	}
	ans = 0;
	for(auto p : m)
	{
		auto k = p.first;
		auto v = p.second;
		if (k < v)
			ans += v - k;
		else if (k > v)
			ans += v;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6272
#
# abc165 c
#
import sys
from io import StringIO
import unittest
sys.setrecursionlimit(100000)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 4 3
1 3 3 100
1 2 2 10
2 3 2 10"""
        output = """110"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 6 10
2 4 1 86568
1 4 0 90629
2 3 0 90310
3 4 1 29211
3 4 3 78537
3 4 2 8580
1 2 1 96263
1 4 2 2156
1 2 0 94325
1 4 3 94328"""
        output = """357500"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 10 1
1 10 9 1"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    global N, M
    N, M, Q = map(int, input().split())
    ABCD = [list(map(int, input().split())) for _ in range(Q)]

    T = []
    func([1], T)

    ans = 0
    for t in T:
        score = 0
        for abcd in ABCD:
            a, b, c, d = abcd
            if t[b-1] - t[a-1] == c:
                score += d
        ans = max(ans, score)
    print(ans)


def func(L, T):
    if len(L) == N:
        T.append(L)
        return

    for i in range(L[-1], M+1):
        NL = L + [i]
        func(NL, T)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 23536
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int p[3000001];
int sum[3000001];
bool judge(int x,int k)
{
	int l=0,r=n+1;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(p[mid]<=x)
			r=mid;
		else
			l=mid;
	}
	int tot=n-(sum[l]-l*x);
	return tot>=k*x;
}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%lld",&x);
		p[x]++;
	}
	sort(p+1,p+n+1);
	reverse(p+1,p+n+1);
	for(int i=1;i<=n;i++)
		sum[i]+=sum[i-1]+p[i];
	for(int k=1;k<=n;k++)
	{
		int l=0,r=n+1;
		while(l+1<r)
		{
			int mid=(l+r)/2;
			if(judge(mid,k))
				l=mid;
			else
				r=mid;
		}
		printf("%lld\n",l);
	}
	return 0;
} 


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

using ll = long long;

ll n, m;
std::vector<ll> vec;
std::map<ll, ll> ma;
ll ans = 0;


int main() {
    std::cin >> n >> m;
    vec.resize(n+1);
    for (int i = 1; i <= n; i++) {
        std::cin >> vec[i];
    }
    ma[0]++;
    for (int i = 1; i <= n; i++) {
        vec[i] = vec[i] + vec[i-1];
        ma[vec[i]%m]++;
    }
    for (auto e: ma) {
        ans += (e.second * (e.second-1) / 2);
    }
    std::cout << ans << std::endl;


}


Measured memory_bytes: 4992
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,i;
    cin>>n;
    ll a[n],b[n];
    ll p=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        if(a[i]!=b[i])
        {
            p++;
        }
    }
    if(p==0||p==2)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }

}


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

const int N = 1e7 + 5;
typedef long long LL;

int n, cnt[N];
LL ans;

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++)
		for(int j = 1; i*j <= n; j++) 
			cnt[i*j]++;
	for(int i = 1; i <= n; i++)
		ans += (LL) i*cnt[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 42624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

struct CountUnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;
    vector<int> cnt;

    CountUnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        cnt.assign(sz, 1);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

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

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

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y]){
            par[x] = y;
            cnt[y] += cnt[x];
        }
        else{
            par[y] = x;
            cnt[x] += cnt[y];
            if(rank[x] == rank[y])  ++rank[x];
        }
    }

    int get_cnt(int x){
        return cnt[find(x)];
    }
};

vector<int> friends[100005];
vector<int> block[100005];

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

    int n, m, k;
    cin >> n >> m >> k;
    CountUnionFind uf(n);
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        friends[--a].push_back(--b);
        friends[b].push_back(a);
        uf.unite(a, b);
    }
    for(int i = 0; i < k; ++i){
        int c, d;
        cin >> c >> d;
        block[--c].push_back(--d);
        block[d].push_back(c);
    }
    for(int i = 0; i < n; ++i){
        int block_cnt = 0;
        for(int v : block[i]){
            if(uf.same(i, v))   ++block_cnt;
        }
        cout << uf.get_cnt(i) - friends[i].size() - block_cnt - 1;
        cout << ((i == n - 1) ? "\n" : " ");
    }
}

Measured memory_bytes: 13048
#include <stdio.h>
int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    int sum = a + b;
    if (sum < 24) {
        printf("%d\n", sum);
    } else {
        printf("%d\n", sum - 24);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	ll sum = 0 ;
	for(int i=0;i<n;i++) sum += a.at(i) ;
	for(int i=1;i<n;i+=2) sum -= 2*a.at(i) ;
	vll ans(n) ;
	ans.at(0) = sum ;
	for(int i=0;i<n-1;i++){
		ans.at(i+1) = 2*a.at(i)-ans.at(i) ;
	}
	for(int i=0;i<n;i++){
		cout << ans.at(i) ;
		if(i==n-1) cout << endl ;
		else cout << " " ;
	}
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    int N; cin >> N;
    bool can=true;
    rep(i,N){
        int a; cin >> a;
        if(a%2==0){
            if(a%3 != 0 && a%5!=0){
                can=false;
            }
        }
    }
    if(can) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string s;
    cin >> s;
    if(s == "MON") print(6);
    if(s == "TUE") print(5);
    if(s == "WED") print(4);
    if(s == "THU") print(3);
    if(s == "FRI") print(2);
    if(s == "SAT") print(1);
    if(s == "SUN") print(7);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=15,INF=1<<30;
int S[MAX][MAX];

int main(){

    int V,E;cin>>V>>E;
    for(int i=0;i<V;i++){
        for(int j=0;j<V;j++){
            S[i][j]=INF;
        }
    }
    
    for(int i=0;i<E;i++){
        int a,b,c;cin>>a>>b>>c;
        S[a][b]=min(S[a][b],c);
    }
    
    int ans=INF;
    
    for(int k=0;k<V;k++){
        vector<vector<int>> dp((1<<V),vector<int>(V,INF));
        dp[0][k]=0;
        for(int x=0;x<=V;x++){
            for(int bit=0;bit<(1<<V);bit++){
                int cnt=0;
                for(int i=0;i<V;i++){
                    if(bit&(1<<i)) cnt++;
                }
                if(cnt!=x) continue;
                for(int i=0;i<V;i++){
                    if(dp[bit][i]==INF) continue;
                    if(x&&!(bit&(1<<i))) continue;
                    for(int j=0;j<V;j++){
                        if(bit&(1<<j)) continue;
                        if(S[i][j]==INF) continue;
                        dp[bit|(1<<j)][j]=min(dp[bit|(1<<j)][j],dp[bit][i]+S[i][j]);
                    }
                }
                //if(k==0) cout<<bit<<" "<<endl;
            }
        }
        ans=min(ans,dp[(1<<V)-1][k]);
    }
    
    if(ans==INF) cout<<-1<<endl;
    else cout<<ans<<endl;
    
}




Measured memory_bytes: 6208
#import sys
import numpy as np
#input = sys.stdin.readline

def main():
    n, k=map(int, input().split())
    a=np.array(list(map(int, input().split())), dtype=np.int64)
    f=np.array(list(map(int, input().split())), dtype=np.int64)
    a=np.sort(a)
    f=np.sort(f)[::-1]
    l,r=0,10**12
    while l<=r:
        m=(l+r)//2
        tr=np.clip(a-m//f,0,None).sum()
        if tr>k:
            l=m+1
        else:
            r=m-1
    print(l)

if __name__ == '__main__':
    main()

Measured memory_bytes: 37196
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  set<ll>s;
  ll temp,tc,q,x;
  cin>>tc;
  while(tc--)
  {
    cin>>q;
    if(q==0)
    {
      cin>>temp;
      s.insert(temp);
      cout<<s.size()<<endl;
    }
    else
    {
      cin>>x;
      cout<<s.count(x)<<endl;
    }
  }
}



Measured memory_bytes: 12388
#include<cstdio>
int a[1000001],b[1000001];
int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        int st,ed;
        scanf("%d%d",&st,&ed);
        if(st==1)a[ed]=1;//记录第一次坐船的终点 
        if(ed==n)b[st]=1;//记录第二次坐船的起点 
    }
    for(i=1;i<=m;i++)
        if(a[i]&&b[i])//等价于a[i]==1&&b[1]==1 
        {
            printf("POSSIBLE\n");return 0;//若有，直接退出 
        }
    printf("IMPOSSIBLE\n");
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

int main(void)	
{
	ll n, m;
	cin >> n >> m;
	vector<set<ll>> ss(n);
	rep(i, m) {
		ll s, c;
		cin >> s >> c;
		ss[s - 1].insert(c);
	}
	rep(i, n) {
		if (ss[i].size()>=2) {
			cout << -1 << endl;
			return 0;
		}
	}
	vector<ll> r;
	if (n == 1) {
		int i = 0;
		if (ss[i].size() == 0) {
			r.push_back(0);
		}
		else {
			ll t = *ss[i].begin();
			r.push_back(t);
		}
		cout << r[0] << endl;
		return 0;
	}
	if (n == 1 && *ss[0].begin() == 0) {
		cout << 0 << endl;
		return 0;
	}

	rep(i, n) {
		if (ss[i].size() == 0) {
			if (i == 0) r.push_back(1);
			else r.push_back(0);
		}
		else {
			ll t = *ss[i].begin();
			if (i == 0 && t == 0) {
				cout << -1 << endl;
				return 0;
			}
			r.push_back(t);
		}
	}
	rep(i, n) cout << r[i];
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
for _ in range(int(input())):
    N=int(input())
    A=list(map(int,input().split()))
    S=input()
    base=[]
    for i in range(N-1,-1,-1):
        a=A[i]
        for b in base:
            test=a^b
            if a>test:
                a=test
        if a!=0:
            if S[i]=="1":
                print("1")
                break
            else:
                base.append(a)
    else:
        print("0")

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

const int kSize = 100000;

struct Node {
    int parent = -1;
    int depth;
    vector<int> children;
};

Node tree[kSize];

void GetDepth(int node) {
    int ans = 0;
    int var = node;
    while (tree[var].parent != -1) {
        var = tree[var].parent;
        ans++;
    }

    tree[node].depth = ans;
}

void Print(int node) {
    printf("node %d: parent = %d, depth = %d, ", node, tree[node].parent, tree[node].depth);
    if (tree[node].parent == -1) {
        cout << "root, ";
    } else if (tree[node].children.empty()) {
        cout << "leaf, ";
    } else {
        cout << "internal node, ";
    }

    if (tree[node].children.empty()) {
        cout << "[]";
    } else {
        cout << "[";
        vector<int> v = tree[node].children;
        for (int i = 0; i < v.size(); ++i) {
            if (i != v.size() - 1) {
                cout << v[i] << ", ";
            } else {
                cout << v[i];
            }
        }
        cout << "]";
    }

    cout << endl;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int id, k;
        cin >> id >> k;
        for (int i = 0; i < k; ++i) {
            int c;
            cin >> c;
            tree[c].parent = id;
            tree[id].children.push_back(c);
        }
    }

    for (int i = 0; i < n; ++i) {
        GetDepth(i);
    }

    for (int i = 0; i < n; ++i) {
        Print(i);
    }
    return 0;
}



Measured memory_bytes: 7084
def f(x,y):
	m=x*(x%3>0)
	for i in range(2):
		d=x//3+i;e=x-d;l=sorted([d*y,e*(y//2),e*(-~y//2)]);m=min(m,l[2]-l[0])
	return m
h,w=map(int,input().split())
print(min(f(h,w),f(w,h)))

Measured memory_bytes: 3060
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,A = int(input()),lint()
S = dict()
for a in A:
    S.setdefault(a,0)
    S[a] += 1
ans = 0
for k in S:
    ans += S[k]*(S[k]-1)//2
for a in A:
    print(ans-(S[a]-1))

Measured memory_bytes: 109556