akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;};

signed main(){
  Int T;
  cin>>T;

  cout<<fixed<<setprecision(12);
  while(T--){
    double width;
    Int n;
    cin>>width>>n;
    vector<double> w(n);
    for(Int i=0;i<n;i++) cin>>w[i];

    using P = pair<double, double>;
    Int s=1<<n;
    vector<double> sum(s,0);
    for(Int b=0;b<s;b++)
      for(Int i=0;i<n;i++)
	if((b>>i)&1) sum[b]+=w[i];

    function<vector<P>(Int, double)> dfs=[&](Int b,double pos){
      vector<P> res;      
      if(__builtin_popcount(b)==1){
	res.emplace_back(pos,pos);
	return res;
      }
      for(Int nb=b;nb;nb=(nb-1)&b){
	if(nb==b) continue;
	assert(nb&&(nb^b));
	double x=sum[nb],y=sum[nb^b];
	double aa=1.0/(1.0+x/y);
	double bb=1.0-aa;
	auto l=dfs(nb,pos-aa);
	auto r=dfs(nb^b,pos+bb);
	for(auto p:l) 
	  for(auto q:r)
	    res.emplace_back(min({p.first,q.first,p.second,q.second}),
			     max({p.first,q.first,p.second,q.second}));
      }
      return res;
    };
    
    double ans=-1; 
    auto v=dfs(s-1,0);
    for(auto p:v) if(p.second-p.first<width) chmax(ans,p.second-p.first);
    
    if(ans<0) cout<<"-1"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 3988
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())
    S=str(input())
    val=0
    valmax=0

    for i in range(N):
        if S[i]=='I':
            val+=1
            valmax = max(valmax, val)

        else:
            val-=1

    print(valmax)




resolve()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define dd(x) cout<<#x<<" = "<<x<<" "
#define mes(p) memset(p,0,sizeof(p))
#define per(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) x.begin(),x.end()
#define rson mid+1,r,rt<<1|1
#define sz(x) (int)x.size()
#define lson l,mid,rt<<1
#define pb push_back
#define mp make_pair
//#define ls (rt<<1)
#define se second
//#define rs (ls|1)
#define fi first
typedef pair <int ,int > pi;
typedef vector <int > vi;
typedef long long ll;
const int maxn  = 1e6+5;
int n, a[maxn], b[maxn];
ll s;
int main(){	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	cin >> n;
	n++;
	rep(i,1,n+1) cin >> a[i], s+= a[i];
	rep(i,1,n) cin>> b[i];
	rep(i,1,n+1){
		if(b[i-1]&&a[i]>=b[i-1]) a[i]-=b[i-1],b[i-1]=0;
		else if(a[i]<b[i-1])  a[i] = 0;
		if(b[i]&&a[i]>=b[i]) a[i]-=b[i], b[i]=0;
		else if(a[i]<b[i])  b[i]-=a[i], a[i] = 0;
	}
	rep(i,1,n+1) s-= a[i];
	cout << s;
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	int n, k;
	cin >> n >> k;
	if(n%k) cout << 1 << endl;   
	else cout << 0 << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
lim, pol = map(int,input().split())

count = 0
num = 0
if pol == 0:
    count = lim * lim
else:
    for kk in range(pol, lim + 1):
        num = (lim - lim % kk) / kk
        count += (kk - pol) * num
        if lim % kk >= pol:
            count += lim % kk - pol + 1

print(int(count))

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<stdio.h>
#include<string>
#include<cmath>
using namespace std;
typedef long long LL;
#define maxn (50002)
int a,b;
int main()
{
    cin>>a>>b;
    if(a<=b) cout<<a<<endl;
    else cout<<a-1<<endl;

    return 0;
}

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

#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a, b, c) min(a, min(b, c))
#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	    if(floor((float)i*1.08)==n)
	    {cout<<i;return 0;}
	}
	cout<<":(";
	
}

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


signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int n,x;
    cin>>n;
    int a[n+1]={0};
    for (int i = 0; i < n-1; ++i)
    {
        cin>>x;
        a[x]++;
    }
    for (int i = 1; i <= n; ++i)
    {
        cout<<a[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 5212
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#include <queue>
#include <stack>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;

int main(){
    string s; cin >>s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int A[200001];
int n;
int a;

int main(){
  cin >> n;
  for (int i=2;i<=n;i++){
    cin >> a;
    A[a]++;
  }
  for (int i=1;i<=n;i++){
    cout << A[i] << endl;
  }
}


Measured memory_bytes: 3972
#include <iostream>

using namespace std;
int a, b, x;
int main()
{
    cin >> a >> b;
    if((a + b)%2 >= 1 ){
        cout << (a + b) / 2 + 1;
        }else {
        cout << (a + b) / 2;
        }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cout(48-n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 5010
#define maxk 33
using namespace std;
int p[maxn];
int pp[maxk][maxn]; 
long long c[maxn];
long long val[maxk][maxn];
long long Max[maxk][maxn];
long long Min = numeric_limits<long long>().min();
int main() {
	int n, k;
	long long ans = Min;
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) scanf("%d", p + i);
	for(int i = 1; i <= n; ++i) scanf("%lld", c + i);
	for(int i = 1; i <= n; ++i) Max[0][i] = val[0][i] = c[p[i]], pp[0][i] = p[i];
	for(int kk = 1; kk < 32; ++kk) {
		for(int i = 1; i <= n; ++i) {
			pp[kk][i] = pp[kk - 1][pp[kk - 1][i]];
			val[kk][i] = val[kk - 1][i] + val[kk - 1][pp[kk - 1][i]];
			Max[kk][i] = max(Max[kk - 1][i], val[kk - 1][i] + Max[kk - 1][pp[kk - 1][i]]);
		}
	}
	for(int i = 1; i <= n; ++i) {
		long long K = k, P = i, V = 0, A = Min;
		for(int kk = 30; kk >= 0; --kk) {
			if(K & (1 << kk)) {
				A = max(A, V + Max[kk][P]);
				V += val[kk][P];
				P = pp[kk][P];
			}
		}
		ans = max(ans, A);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 7028
n = int(input())
minus = 0
m = float("inf")
s = 0
for i in map(int,input().split()):
    if i < 0:
        minus += 1
        m = min(m,-i)
        s -= i
    else:
        m = min(m,i)
        s += i
if minus % 2 == 0:
    print(s)
else:
    print(s-2*m)

Measured memory_bytes: 11516
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define pb push_back
#define itr(it, a) for(auto i:a)
int main()
{
string s="ACL";
int a;
cin>>a;
string result="";
for(int i=0;i<a;i++)
  result+=s;
  cout<<result<<endl;

return 0;
}

Measured memory_bytes: 3552
N = int(input())

S = input()
A = list(map(int, S.split(' ')))
S = input()
B = list(map(int, S.split(' ')))
S = input()
C = list(map(int, S.split(' ')))

score = sum(B)

for i in range(N-1):
    if A[i]+1 == A[i+1]:
        score += C[A[i]-1]
    

print(score)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int R = Integer.parseInt(br.readLine());
		
		if(R<1200){
			System.out.println("ABC");
		}else if(R<2800){
			System.out.println("ARC");
		}else{
			System.out.println("AGC");
		}
	}

}


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

int main(){
	int n;
	cin >> n;
	queue<string> que;
	que.push("a");
	
	while(true){
		auto s = que.front();
		if(s.size() == n) break;
		que.pop();
		char m = 'a';
		rep(i,s.size()){
			m = max(m,s[i]);
		}
		for (char j = 'a'; j <= m+1 ; ++j) {
			que.push(s + j);
		}
	}
	
	while(!que.empty()){
		auto t = que.front();
		que.pop();
		cout << t << endl;
	}
    return 0;
}



Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
ll N,M;
vector<ll> a(1005);
//vector<vector<bool>> c2(1005,vector<bool>(12)); 
vector<ll> c(1005);
//vector<vector<ll>> dp(1005,vector<ll>(5000,-1));

vector<ll> dp(5000,-1);

ll ans = -1;
ll rec(ll bit,ll v){
    //cout<<bitset<12>(bit)<<endl;
    if(dp[bit] != -1){
        return dp[bit];
    }

    if(bit == (ll(1)<<N)-1){
        //cout << "OK"<< endl;
        return dp[bit] = 0;
    }

    ll res = INF;
    rep(i,M){
        if(bit != (bit|c[i])){
            chmin(res,rec(bit | c[i],i)+a[i]);
        }
    }
    return dp[bit] = res;
}
int main() {
    
    cin >>N>>M;
    

    rep(i,M){
        ll b;
        cin>>a[i]>>b;
        rep(j,b){
            ll C;
            cin>>C;
            //c2[i][C-1]=1;
            c[i] |= ll(1)<<(C-1);

        }
    }
    
    rec(0,-1);
    ans = dp[0];
    if(ans == INF){
        ans=-1;
    }
    cout << ans << endl;
    
    


    return 0;
    

}

Measured memory_bytes: 3688
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
        A[i] -= B[i]
    else:
        ans += A[i]
        B[i] -= A[i]
        A[i] = 0
        if A[i+1] >= B[i]:
            ans += B[i]
            A[i+1] -= B[i]
            B[i] = 0
        else:
            ans += A[i+1]
            A[i+1] = 0
print(ans)


Measured memory_bytes: 18752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _001_FindingMissingCards
{
    /*
     */

    class Program
    {
        static void Main()
        {
            Boolean cont = true;

            while (cont)
            {
                string line = Console.ReadLine();
                string[] line_split = line.Split(' ');
                int m = Convert.ToInt32(line_split[0]);
                int f = Convert.ToInt32(line_split[1]);
                int r = Convert.ToInt32(line_split[2]);
                if (m == -1 && f == -1 && r == -1)
                {
                    cont = false;
                }
                else
                {
                    if (m == -1 || f == -1)
                    {
                        Console.WriteLine("F");
                    }
                    else if (m + f >= 80)
                    {
                        Console.WriteLine("A");
                    }
                    else if (m + f >= 65)
                    {
                        Console.WriteLine("B");
                    }
                    else if (m + f >= 50)
                    {
                        Console.WriteLine("C");
                    }
                    else if (m + f >= 30 && r >= 50)
                    {
                        Console.WriteLine("C");
                    }
                    else if (m + f >= 30 && r < 50)
                    {
                        Console.WriteLine("D");
                    }
                    else if (m + f < 30)
                    {
                        Console.WriteLine("F");
                    }
                }
            }

            
        }
    }
}

Measured memory_bytes: 8884
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

pair<int,int> bfs(auto &E,auto &color,int start){
	pair<int,int> ret(0,0);
	queue<int> Q;
	Q.push(start);
	color[start] = 0;
	ret.first++;
	while(Q.size()!=0){
		int from = Q.front();
		Q.pop();
		for(int i=0;i<E[from].size();i++){
			if(E[from][i]){
				if(color[i]==-1){
					if(color[from]==0){
						color[i]=1;
						ret.second++;
					}
					else{
						color[i]=0;
						ret.first++;
					}
					Q.push(i);
				}
				else{
					if(color[from]==color[i]){
						return make_pair(-1,-1);
					}
				}
			}
		}
	}
	return ret;
}

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<bool>> E(N,vector<bool>(N,true));
	
	for(int i=0;i<M;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;b--;
		E[a][b]=false;
		E[b][a]=false;
	}
	
	for(int i=0;i<N;i++)E[i][i]=false;
	
	vector<int> color(N,-1);
	vector<pair<int,int>> P;
	
	for(int i=0;i<N;i++){
		if(color[i]!=-1)continue;
		P.push_back(bfs(E,color,i));
		if(P.back().first==-1){
			cout<<-1<<endl;
			return 0;
		}
	}
	
	vector<vector<bool>> dp(P.size()+1,vector<bool>(N+1,false));
	dp[0][0] = true;
	
	for(int i=0;i<P.size();i++){
		for(int j=0;j<=N;j++){
			if(dp[i][j]){
				dp[i+1][j+P[i].first]=true;
				dp[i+1][j+P[i].second]=true;
			}
		}
	}
	
	int ans = Inf;
	
	for(int i=0;i<=N;i++){
		if(dp.back()[i]){
			ans = min(ans,i*(i-1)/2 + (N-i)*(N-i-1)/2);
		}
	}
	
	cout<<ans<<endl;

	return 0;
}

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

namespace ConsoleApp11
{
    class Class12
    {
        static void Main()
        {
            var V = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (500 * V[0] >= V[1])
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13268
N, M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))

dp = [[0 for i in range(M+1)] for j in range(N+1)]
SUM = [[0 for i in range(M+1)] for j in range(N+1)]
mod = 10 ** 9 + 7

for i in range(N):
    for j in range(M):
        if S[i] == T[j]:
            dp[i+1][j+1] = SUM[i][j] + 1
        else:
            dp[i+1][j+1] = 0
        SUM[i+1][j+1] = SUM[i][j+1] + SUM[i+1][j] - SUM[i][j] + dp[i+1][j+1]
        dp[i+1][j+1] %= mod
        SUM[i+1][j+1] %= mod

print((SUM[N][M] + 1) % mod)

Measured memory_bytes: 108252
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline void rd(int&x)
{
	x=0;char k=getchar();
	while(k>'9'||k<'0')k=getchar();
	while(k>='0'&&k<='9')x=x*10+k-48,k=getchar();
}
const int N=(1<<21),mod=1e9+7;
int s[N],dp[N],n,a[N],b[N],la[N+N],ans,cnt1[N],cnt2[N];
int gao()
{
	int ret=1;
	for(int i=1;i<n;i++)if(!b[i])ret=(ret*2)%mod;return ret;
}
main()
{
	rd(n);
	for(int i=1;i<=n;i++)rd(a[i]),b[i]=a[i]^b[i-1],s[i]=s[i-1]+(b[i]==0);
	for(int i=1;i<=n;i++)
    {
		if(!la[b[i]])
		{
			la[b[i]]=i;cnt1[b[i]]++,cnt2[b[i]]=(cnt2[b[i]]+s[i])%mod;
			dp[i]=1;if(b[i])ans++;continue;
		}
		int j=la[b[i]],sum=s[i]-s[j];
		dp[i]=(cnt1[b[i]]*s[i]-cnt2[b[i]]+1)%mod,dp[i]=(dp[i]+mod)%mod;la[b[i]]=i;
		if(b[i])ans=(ans+dp[i])%mod;
		cnt1[b[i]]+=dp[i],cnt1[b[i]]%=mod,cnt2[b[i]]+=dp[i]*s[i],cnt2[b[i]]%=mod;
	}
	if(b[n])printf("%lld\n",dp[n]);
	else printf("%lld\n",(ans+gao())%mod);
	return 0;
}


Measured memory_bytes: 47360
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
vector<int>a(10);
vector<int>b(10);
double ans(int p,int q){
  double xx=a[p]-a[q];
  double yy=b[p]-b[q];
  return pow(xx*xx+yy*yy,0.5);
}
int main(){
  int n;
  double sum=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    cin>>b[i];
  }
  vector<int>v(n);
  for(int i=0;i<n;i++)
    v[i]=i+1;
  do{
    for(int j=0;j<n-1;j++){
      sum+=ans(v[j],v[j+1]);
    }
  }while(next_permutation(v.begin(),v.end()));
  int fact=1;
  for(int i=2;i<=n;i++){
    fact=fact*i;
  }
  cout<<fixed<<setprecision(10)<<sum/fact;
  return 0;      
}

Measured memory_bytes: 512
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
import math
import itertools
import numpy as np
from collections import OrderedDict, deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
sys.setrecursionlimit(10000)


class EndLoop(Exception):
    pass


def debug_print(L):
    for col in L:
        print(col)


def debug_print_joined(L):
    for col in L:
        print("".join(col))


def transpose_matrix(L):
    transposed = list(map(list, zip(*L)))
    return transposed


def solve():
    N, M = list(map(int, input().split(" ")))
    graph = [[0] * N for _ in range(N)]
    for _ in range(M):
        a, b = list(map(int, input().split(" ")))
        graph[a - 1][b - 1], graph[b - 1][a - 1] = 1, 1

    visited = [False for _ in range(N)]
    cnt = 0
    def dfs(v, G):
        visited[v] = True
        for v2 in range(N):
            if G[v][v2] == False:
                continue
            if visited[v2] == True:
                continue
            dfs(v2, G)

    check = [[False] * N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if check[i][j] == True:
                pass
            elif graph[i][j] == 1 and check[i][j] == False:
                graph[i][j], graph[j][i] = 0, 0
                dfs(0, graph)
                if visited.count(False) == 0:
                    pass
                else:
                    cnt += 1
                graph[i][j], graph[j][i] = 1, 1
                visited = [False for _ in range(N)]
                check[i][j], check[j][i] = True, True

    print(cnt)

    
solve()

Measured memory_bytes: 12088
#include<iostream>

using namespace std;

int main()
{
 int A,B,C;
 cin >>A>>B>>C;

 if(A==B)
 {
  cout << C<< endl;
 }
 else if(A==C)
 {
  cout<<B<<endl;
 }
 else
 {
  cout<<A<<endl;
 }
}

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

typedef long long ll;
const int maxn = 200005, maxm = 200005;

inline int gi()
{
    char c = getchar();
    while (c < '0' || c > '9') c = getchar();
    int sum = 0;
    while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
    return sum;
}

#define pb push_back

int n, m, d[maxn];

struct edge
{
    int to, next,vis;
} e[maxm * 2];
int h[maxn], tot = 1;
int w[maxm], col[maxn], fa[maxn], fe[maxn];
vector<int> vec[maxn];

inline void add(int u, int v)
{
    e[++tot] = (edge) {v, h[u]}; h[u] = tot;
    e[++tot] = (edge) {u, h[v]}; h[v] = tot;
}

void dfs(int u)
{
    for (int i=h[u];i;i=e[i].next) {
	if(!e[i].vis)continue;
	int v=e[i].to;
	if (col[v] == -1) col[v] = 1-col[u] , dfs(v);
    }
}

int main()
{
    n = gi(); m = gi();
    for (int i = 1; i <= n; ++i) d[i] = gi();
    for (int i = 1; i <= m; ++i) add(gi(), gi());
    fill(w + 1, w + m + 1, 1e9);

    d[0] = 2e9;
    for (int u = 1; u <= n; ++u) {
	if(!h[u])return puts("-1"), 0;;
	int p=h[u];
	for(int i=e[p].next;i;i=e[i].next){
	    if(d[e[i].to]<d[e[p].to])p=i;
	    else if(d[e[i].to]==d[e[p].to]&&e[i].to<e[p].to)p=i;
	}
	if (d[e[p].to] > d[u]) return puts("-1"), 0;
	w[p>>1]=d[u];fa[u] = e[p].to;e[p^1].vis=1;
    }
	
    fill(col + 1, col + n + 1, -1);
    for (int i = 1; i <= n; ++i) if (fa[fa[i]] == i && col[i] == -1) col[i] = 0, dfs(i); 
    for (int i = 1; i <= n; ++i) putchar(col[i] == 0 ? 'B' : 'W');
    puts("");
    for (int i = 1; i <= m; ++i) printf("%d\n", w[i]);
	
    return 0;
}


Measured memory_bytes: 16128
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順

using namespace std;
using ll = long long int;

int main(){
    int N,K;cin>>N>>K;
    vector<int> d(K);
    vector<bool> A(N);
    for(int i=0;i<K;i++){
        int d;cin>>d;
        for(int j=0;j<d;j++){
            int a;cin>>a;
            A[a-1] = true;
        }
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        if(A[i]==false){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#A
def A(s):
    def pri(n, x):
        if n == 0:
            return [0, 0]
        if n == 1:
            return [1, 1]
        if n == 2:
            return [2, 1]
        for i in range(2, int(math.sqrt(n))):
            if n % i == 0 and n // i <= x:
                return [i, n // i]
        return [1, n]
    x = int(math.sqrt(s))
    if s < 10 ** 9:
        print(0, 0, 0, s, 1, 0)
        return
    while 1:
        X = x ** 2
        if X - s < 0:
            x += 1
            continue
        b = pri(X - s, x)
        if b:
            print(0, 0, x, int(b[0]), int(b[1]), x)
            if x > 10 ** 9 or b[0] > 10 ** 9 or b[1] > 10 ** 9:
                print(s)
                quit()
            return
        x += 1
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return



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


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

int main() {

    int a, b, c;
    cin >> a >> b >> c;
	if((a==b && b!=c) || (a==c && b!=c) || (b==c && a!=c)){
		cout << "Yes" << endl;;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define NDEBUG
NDEBUG


#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <random>

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


#define all(c) c.begin(), c.end()


using namespace std;

/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    /// caide keep
    template<int N>
    struct bytetype {
        
    };

    /// caide keep
    template<>
    struct bytetype<4> {
        
    };

    /// caide keep
    template<>
    struct bytetype<3> {
        
    };

    /// caide keep
    template<>
    struct bytetype<2> {
        
    };

    /// caide keep
    template<>
    struct bytetype<1> {
        
    };

    /// caide keep
    template<>
    struct bytetype<0> {
        
    };

    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vector(istream& in, size_t n) {
    vector<T> ret(n);
    for (size_t i = 0; i < n; ++i) {
        ret[i] = next<T>(in);
    }
    return ret;
}


void solve(istream& in, ostream& out) {
    int n = next<int>(in);
    vector<int> a = next_vector<int>(in, n);
    map<int, int> original_position;
    FOR(i, a.size()) {
        original_position[a[i]] = i % 2;
    }
    sort(all(a));
    vector<int> sw(2);
    FOR(i, a.size()) {
        if (original_position[a[i]] != i % 2) {
            sw[i % 2]++;
        }
    }
    out << max(sw[0], sw[1]) << endl;
}


int main() {
    solve(cin, cout);
    return 0;
}



Measured memory_bytes: 5376
#include <iostream>
using namespace std;
#include <stack>
#include <string>

const int Max = 100;
const int white = 0;
const int gray = 1;
const int black = 2;

int n, M[Max][Max];
int color[Max], d[Max], f[Max], tt;
int nt[Max];

int next(int u){
    for(int v = nt[u]; v<n; v++){
        nt[u] = v+1;
        if(M[u][v]) return v;
    }
    return -1;
}
void dfs_visit(int r){
    for(int i=0; i<n; i++) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = gray;
    d[r] = ++tt;

    while( !S.empty() ){
        int u = S.top();
        int v = next(u);
        if( v != -1){
            if(color[v] == white){
                color[v] = gray;
                d[v] = ++tt;
                S.push(v);
            }
        } else {
            S.pop();
            color[u] = black;
            f[u] = ++tt;
        }
    }
}
void dfs(){
    for(int i=0; i<n; i++){
        color[i] = white;
        nt[i] = 0;
    }
    tt = 0;

    for(int u=00; u<n; u++){
        if( color[u] == white) dfs_visit(u);
    }
    for(int i=0; i<n; i++){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main(){
    int u, k, v;

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

    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;

}


Measured memory_bytes: 3132
#include<iostream>

using namespace std;

int main()
{
  int in1, in2;

  cin >> in1 >> in2;

  while((in1 != 0)||(in2 != 0)){
    if(in1 < in2)
      cout << in1 << ' ' << in2 << endl;
    else
      cout << in2 << ' ' << in1 << endl;
    cin >> in1 >> in2;
  }
  return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    int n;
    cin >> n;
    vector<int> ans(10000);

    for (int x=1;x<100;x++) {
        for (int y=1;y<100; y++) {
            for (int z=1;z<100; z++) {
                int tmp = x*x + y*y + z*z + x*y + y*z + z*x;
                if (tmp > 10000) break;
                ans[tmp]++;
            }
        }
    }

    for (int i=1; i<=n; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3592
while 1:
    n=int(input())
    if n==0:break
    a={};c=[]
    for _ in range(n):
        b=list(map(int,input().split()))
        if b[0] in a:a[b[0]]+=b[1]*b[2]
        else:a[b[0]]=b[1]*b[2];c.append(b[0])
    if max(a.values())<=999999:print('NA' )
    for i in c:
        if a[i]>999999:print(i)


Measured memory_bytes: 5828
// AOJ Volume2 0228

#include <stdio.h>

char pattern[] = 
    {0x3f,           // 011 1111   0
     0x06,           // 000 0110   1
     0x5b,           // 101 1011   2
     0x4f,           // 100 1111   3 
     0x66,           // 110 0110   4
     0x6d,           // 110 1101   5
     0x7d,           // 111 1101   6
     0x27,           // 010 0111   7
     0x7f,           // 111 1111   8
     0x6f            // 110 1111   9
};

int main(void)
{
    int n;
    int m;
    int p;
    int i, j;
    
    while (1){
        scanf("%d", &n);
        if (n == -1){
            break;
        }
        p = 0;
        for (i = 0; i < n; i++){
            scanf("%d", &m);
            p = p ^ pattern[m];
            
            for (j = 0; j < 7; j++){
                if ((p & (0x40 >> j)) == 0){
                    printf("0");
                }
                else {
                    printf("1");
                }
            }
            printf("\n");
            p = pattern[m];
        }
    }
    return (0);
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(W<x+r||0>x-r||H<y+r||0>y-r){cout << "No" << endl;}
	else{cout << "Yes" << endl;}
}



Measured memory_bytes: 3116
N,*as=$<.read.split.map(&:to_i)
MOD=10**9+7

ret = 0

60.times do |i|
    n = as.count {|a| a[i] == 1 } * as.count {|a| a[i] == 0 }
    ret = (ret + n * 2**i) % MOD
end

puts ret



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

int main() {
  ll n; cin >> n;
  ll m = 1000000007;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll c = 0, ans = 0;
  rep(i,n-1) {
    c = (c + a[i]) % m;
    ans = (ans + (c * a[i+1] % m)) % m;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4828
#include<stdio.h>
int main(){
    int A,B,C,ans;
    scanf("%d %d %d",&A,&B,&C);
    if(A==B){
        ans=C;
    }else if(B==C){
        ans=A;
    }else{
        ans=B;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<27;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Matrix &g, Matrix &dist) {
  int n = g.size();
  dist = g;
  REP(k, n) REP(i, n) REP(j, n)
    dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
}

int main() {
  int n,m;
  while(cin>>n>>m,n) {
    Matrix gl(n,Array(n,INF));
    Matrix gs(n,Array(n,INF));
    set<int> ses;
    REP(i,n) {
      gl[i][i] = 0;
    }
    REP(i,m) {
      int a,b,c;
      cin >> a>>b>>c;
      a--;b--;
      char ch;
      cin >> ch;
      if (ch=='L') {
        gl[a][b] = c;
        gl[b][a] = c;
      }else {
        gs[a][b] = c;
        gs[b][a] = c;
        ses.insert(a);
        ses.insert(b);
      }
    }
    FOR(it,ses)
      gs[*it][*it] = 0;
    int t;
    cin >> t;
    int z[t];
    REP(i,t) {
      cin >> z[i];
      z[i]--;
    }
    Matrix distl, dists;
    shortestPath(gl, distl);
    shortestPath(gs, dists);
    vector<int> ikerul[n], ikerus[n];
    REP(i,n) {
      FOR(jt,ses) {
        int j =*jt;
        if (dists[i][j]!=INF)
          ikerus[i].push_back(j);
        if (distl[i][j]!=INF)
          ikerul[i].push_back(j);
      }
    }

    int dp[t][n];
    REP(i,t)REP(j,n)dp[i][j] = INF;
    dp[0][z[0]] = 0;
    int cnt = 0;
    REP(i,t-1) {
      REP(j, n) {
        REP(k, n) {
          int tmp;
          if (j==k) tmp = distl[z[i]][z[i+1]];
          else tmp = distl[z[i]][j] + dists[j][k] + distl[k][z[i+1]];
          dp[i+1][k] = min(dp[i+1][k], dp[i][j] + tmp);
        }
      }
    }
    cout << *min_element(dp[t-1], dp[t-1]+n) << endl;
  }
}

Measured memory_bytes: 2756
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.* ;
 
class Main{
  public static void main(String[] args)throws IOException{
      
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\?????????
    String str = br.readLine();
  
    String[] strAry = str.split(" ");
    int a = Integer.parseInt(strAry[0]);
  	int b = Integer.parseInt(strAry[1]);
  	int c = Integer.parseInt(strAry[2]);
  	int i, j ;
  	for ( i= a, j = 0 ; i <= b ; i++) {if ( c % i == 0) {j++;}
  	}
  		 
  System.out.println( j );
  		
  		
  
  	}
  	}	
  		
  

Measured memory_bytes: 24408
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    if(n%2==0)
    {
        cout<<n/2;
    }
    else 
    {
        cout<<n/2+1;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
# all sum
res = (1 + n) * n/2
# Fizz sum
n3 = n // 3
fizzSum = 3 * (1 + n3) * n3 / 2
# Buzz sum
n5 = n // 5
buzzSum = 5 * (1 + n5) * n5 / 2
# FizzBuzz sum
n15 = n // 15
fizzbuzzSum = 15 * (1 + n15) * n15 / 2

print(int(res- fizzSum - buzzSum + fizzbuzzSum))

Measured memory_bytes: 9124
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007
#define moda 1000003


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W, X;
long long A[200005] = {};
long long B[200005] = {};
long long C[200005] = {};
bool f, ff,fff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <pl>vpl[2];
vector <string> vs;
set<ll> llset;

struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;

bitset<5000> bits;

int main() {

	cin >> a>>b;
	if (a * b <= 0) {
		cout << "Zero" << endl;

		
	}
	else if(a>0){
		cout << "Positive" << endl;
	}
	else if((b-a+1)%2==0){
		cout << "Positive" << endl;
	}
	else {
		cout << "Negative" << endl;
	}
	

	return 0;

}


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

int main() {
    char b;
    cin >> b;
    if(b == 'A'){
        cout << 'T' << endl;
        return 0;
    }else if(b == 'T'){
        cout << 'A' << endl;
        return 0;
    }else if(b == 'C'){
        cout << 'G' << endl;
        return 0;
    }else{
        cout << 'C' << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		boolean [][]g = new boolean [8][8];
		
		for(int i = 0; i < m ;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			g[a - 1][b - 1] = true;
			g[b - 1][a - 1] = true;
		}
		boolean []visit = new boolean [n];
		visit[0] = true;
		int count = dfc(n,0,g,visit);
		System.out.println(count);
		
	}
	
	private static int dfc(int n ,int v, boolean[][]g , boolean[]visit) {
		
		boolean allvisit = true;
		for(int i = 0 ; i < n  ;i++) {
			if(!visit[i]) {
			allvisit = false;
			break;
			}
		}
		if(allvisit) {
			return 1;
		}
		
		int sum = 0;
		
		for(int i = 0; i < n ; i++) {
			if(!visit[i] && g[v][i]) {
				visit[i] = true;
				sum += dfc(n,i,g,visit);
				visit[i] = false;
			}
		}
		return sum;
		
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main(){
  
    int a, b, c;
    cin >> a >> b >> c;
	
  	int m = max({a, b, c});
  	if(m == a)
    	cout << a*10 + b + c << endl;
  	else if(m == b)
    	cout << b*10 + a + c << endl;
  	else if(m == c)
    	cout << c*10 + b + a << endl;
  
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
from collections import defaultdict

def f(x, i):
    if i == 10:
        return check(x)
    ret = 0
    for y in range(x[-1], M+1):
        ret = max(ret, f(x+[y], i+1))
    return ret

def check(x):
    ret = 0
    for a, b, c, d in abcd:
        if x[b-1] - x[a-1] == c:
            ret += d
    return ret

N, M, Q = map(int, input().split())
abcd = [None]*Q
for i in range(Q):
    abcd[i] = list(map(int, input().split()))
print(f([1], 1))

Measured memory_bytes: 71632
import Data.List

main = do
  getLine
  a <- getLine >>= return . reverse . f . sort . (map read) . words
  
  print $ g $ filter (\(x,c) -> c>=2) a

  where
    f :: [Int] -> [(Int, Int)]
    f [] = []
    f xs@(x:rest) = (x, len) : (f (drop len xs))
      where
        l = takeWhile (==x) xs
        len = length l

    g :: [(Int,Int)] -> Integer
    g ((a,c):(b,_):_) = if c>=4 then (fi a)^2 else (fi a)*(fi b)
    g ((a,c):[]) = if c>=4 then (fi c)^2 else 0
    g [] = 0

    fi = fromIntegral
           


Measured memory_bytes: 51580
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string str = Console.ReadLine();
		int Q = int.Parse(Console.ReadLine());
		string[] str2 = Console.ReadLine().Split();
		var list = new List<int>();
		var list2 = new List<int>();
		for(var i=0;i<N;i++){
			string s = str.Substring(i,1);
			switch(s){
				case "D":
					list.Add(i);
					list2.Add(0);
					break;
				case "M":
					list.Add(i);
					list2.Add(1);
					break;
				case "C":
					list.Add(i);
					list2.Add(2);
					break;
			}
		}
		int listct = list.Count;
		for(var i=0;i<Q;i++){
			int A = int.Parse(str2[i]);
			int Dt = 0;
			int Mt = 0;
			long DM = 0;
			long ans = 0;
			int ai = 0;
			int ai2 = 0;
			while(ai < listct){
				while(list[ai2]+A <= list[ai]){
					switch(list2[ai2]){
						case 0:
							Dt -= 1;
							DM -= Mt;
							break;
						case 1:
							Mt -= 1;
							break;
					}
					ai2 += 1;
				}
				switch(list2[ai]){
					case 0:
						Dt += 1;
						break;
					case 1:
						Mt += 1;
						DM += Dt;
						break;
					default:
						ans += DM;
						break;
				}
				ai += 1;
			}
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 30292
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Bounding
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, x;
  scanf("%d%d", &n, &x);

  int d = 0, i = 0;
  for (; i < n; i++) {
    int li;
    scanf("%d", &li);

    d += li;
    if (d > x) break;
  }

  printf("%d\n", i + 1);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;

int main(){
    string S;
    cin >> S;
    ll odd = 0,even = 0;
    for(int i=0;i<S.length();i++){
        if((i % 2 == 0) && (S[i] == '1') ){
            even++;
        }
        if((i % 2 == 1) && (S[i] == '1') ){
            odd++;
        }
    }
    ll odd_size = S.length()/2;
    ll even_size = S.length()/2;
    if(S.length() %2 == 1){
        even_size++;
    }
    ll ans = min(even_size - even + odd,odd_size -odd + even);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	string a, b; cin >> a >> b;
	int N = stoi(a + b);
	double x = sqrt(N);
	int y = x;
	if ((double)x == y)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
	//freopen("in.txt","r",stdin);
	ll n,k;
	scanf("%lld%lld",&n,&k);
	if(k&1){//ji
		if(k>n)printf("0\n");
		else{
			ll cnt1=(n-k)/k;
			cnt1++;
			printf("%lld",cnt1*cnt1*cnt1);
		}
	}else{
		if(k/2>n)printf("0\n");
		else{
			ll cnt1=0;
			if(k<=n){
		cnt1=(n-k)/k;
			cnt1++;
			}
		ll cnt2=(n-(k/2))/k;
		cnt2++;
		printf("%lld",cnt1*cnt1*cnt1+cnt2*cnt2*cnt2);
		}
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
const int MAX = 100010;

int main() {
	int N;
	int cnt = 0;
	int prev = -1;

	cin >> N;
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		
		if (p == i + 1) {
			if (prev == i) {
				prev = -1;
				continue;
			}
			cnt++;
		}
		prev = p;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define piii pair<int,pair<int,int> >
#define pii pair<int,int>
#define ll long long
//10:50
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y,cur,ans=0;
    cin>>x>>y;
    cur=x;
    while(cur<=y){
        cur*=2;
        ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
j = []
for i in range(n):
  a, b = map(int, input().split())
  j.append((b,a))
j.sort()

ct = 0
for i in j:
  ct += i[1]
  if ct > i[0]:
    print("No")
    break
else:
  print("Yes")


Measured memory_bytes: 29444
N = [int(i) for i in input().split()]
N.sort()

if N[0]%2 == N[2]%2:
    if N[1]%2 == N[2]%2:
        print((N[2]-N[0])//2 + (N[2]-N[1])//2)
    else:
        print((N[2]-N[0])//2 + (N[2]+1-N[1])//2 + 1)
else:
    if N[1]%2 == N[2]%2:
        print((N[2]+1-N[0])//2 + (N[2]-N[1])//2 + 1)
    else:
        print((N[2]-N[0])//2 + (N[2]-N[1])//2 + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string H[10465270];
int getchar(char key){
    if(key == 'A'){
        return 1;
    }
    else if(key == 'C'){
        return 2;
    }
    else if(key == 'G'){
        return 3;
    }
    else if(key == 'T'){
        return 4;
    }
}
  
long long getkey(string key){
    long long p = 1,sum = 0;
    for(int i = 0;i<key.size();i++){
        sum += getchar(key.at(i))*p;
        p*= 4;
    }
    return sum;
}
void insert(string dic){
    int key;
    key = getkey(dic);
    H[key] = dic;
}
int find(string dic){
    if(H[getkey(dic)] == dic){
        return 1;
    }
    else{
        return 0;
    }
}
int main(){
    int n;
    string str,dic;
    cin>>n;
    for(int i = 0;i<n;i++){
        cin>>str>>dic;
        if(str.at(0) == 'i'){
            insert(dic);
        }
        else{
            if(find(dic)){
                cout<<"yes"<<endl;
            }
            else{
                cout<<"no"<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 101284
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int H, W, K;
	int[][] c;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		H = Integer.parseInt(tokens[0]);
		W = Integer.parseInt(tokens[1]);
		K = Integer.parseInt(tokens[2]);
		c = new int[H][W];
		for (int i = 0; i < H; ++i) {
			String line = in.readLine();
			for (int j = 0; j < W; ++j) {
				if (line.charAt(j) == '.') {
					c[i][j] = 0;
				} else {
					c[i][j] = 1;
				}
			}
		}
	}

	void drawRow(int[][] cells, int row) {
		for (int i = 0; i < W; ++i) {
			cells[row][i] = 2;
		}
	}

	void drawCol(int[][] cells, int col) {
		for (int i = 0; i < H; ++i) {
			cells[i][col] = 2;
		}
	}

	int[][] getCells(int rowPattern, int colPattern) {
		int[][] target = new int[H][];
		for (int i = 0; i < H; ++i) {
			target[i] = Arrays.copyOf(c[i], W);
		}
		int row = rowPattern;
		for (int i = 0; i < H; ++i) {
			if ((row & 1) > 0) {
				// 塗りつぶし
				drawRow(target, i);
			}
			row >>= 1;
			int col = colPattern;
			for (int j = 0; j < W; ++j) {
				if ((col & 1) > 0) {
					drawCol(target, j);
				}
				col >>= 1;
			}
		}
		return target;
	}

	int count(int[][] cells) {
		int count = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (cells[i][j] == 1) {
					++count;
				}
			}
		}
		return count;
	}

	void calc() {
		int result = 0;
		for (int rowPattern = 0; rowPattern < Math.pow(2, H); ++rowPattern) {
			for (int colPattern = 0; colPattern < Math.pow(2, W); ++colPattern) {
				int[][] cells = getCells(rowPattern, colPattern);
				int count = count(cells);
				if (count == K) {
					++result;
				}
			}
		}
		System.out.println(result);
	}

	void showResult() {
	}
}

Measured memory_bytes: 27752
#include <iostream>
#include <set>

using namespace std;

int main(){
    int s;
    cin >> s;
    int i = 1;
    int now = s;
    set<int> se;

    while(1){
        if(se.count(now)){
            break;
        }
        se.insert(now);
        if(now % 2 == 0){
            now /= 2;
        }
        else{
            now = 3 * now + 1;
        }
        i++;
    }
    cout << i << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int K = s.nextInt();
		int S = s.nextInt();

		int answer = 0;
		for (int x = 0; x <= K; x++) {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		}

		System.out.println(answer);

	}

}


Measured memory_bytes: 23380