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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

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

  int a, b; cin >> a >> b;

  cout << max({a + b, a * b, a - b}) << endl;
  
  return (0);
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,i;
string s;
int main()
{
	cin>>a>>b;
	cin>>s;
	for(i=0;i<a;i++)
		if(s[i]<'0'||s[i]>'9')
		{
			cout<<"No\n";
			return 0;
		}
	if(s[a]!='-')
	{
		cout<<"No\n";
		return 0;
	}
	for(i=a+1;i<s.length();i++)
		if(s[i]<'0'||s[i]>'9')
		{
			cout<<"No\n";
			return 0;
		}
	cout<<"Yes\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int A,B,C,X,Y; cin >> A >> B >> C >>X >> Y;

    if(A+B <= 2*C) {cout << A*X+B*Y << endl; return 0;}
    else{
        if(X>=Y) {cout << min(X*2*C, Y*2*C+(X-Y)*A) << endl; return 0;}
        else {cout << min(Y*2*C, X*2*C+(Y-X)*B) << endl; return 0;}
    }
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> A(3000,0);
    A[0]=1;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        for(ll t=3000-a-1;t>=0;t--){
            if(A[t]){A[t+a]=1;}
        }
    }
    ll q;
    cin>>q;
    while(q--){
        ll Q;
        cin>>Q;
        cout<<(A[Q]?"yes":"no")<<endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<tuple>
#include<utility>
#include<math.h>
using namespace std;
typedef long long ll;

int main(){
    ll n,a,b; cin>>n>>a>>b;

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

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

int main(void){
	int w,n;
	int a,b;
	int line[30];
	int i;
	char comma;

	for(i=0;i<30;i++){
		line[i]=i+1;
	}
	cin >> w;
	if(w<=30&&w>0){
		cin >> n;
		for(i=0;i<n;i++){
			cin >> a >> comma >> b;
			if(a>0&&b>0&&a<=w&&b<=w) swap(line[a-1],line[b-1]);
		}
		for(i=0;i<w;i++){
			cout << line[i] << endl;
		}
	}
	return 0;
}

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

int main(){
    long long N;cin>>N;
    vector<long long>A(5);
    long long mi=1LL<<60;
    for(int i=0;i<5;i++) cin>>A[i],mi=min(mi,A[i]);
    cout<<(N+mi-1)/mi+4<<endl;
}

Measured memory_bytes: 256
def kaibun(s):
    N = len(s)

    flag = True
    for i in range(N // 2):
        if s[i] != s[N - i - 1]:
            flag = False
    return flag

string = input()
N = len(string)
if kaibun(string) and kaibun(string[:(N - 1) // 2]) and kaibun(string[(N + 1) // 2:N]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
H,W,*a = $<.take(3).join.split.map &:to_i
S = (1..H).map{ s=gets; s[W]='||'; s }.fill(0,H,2)
a.map!{_1-1}
B = (1<<10) - 1
D = a[3]
L = S[a[2]]
h = [*-2..2].repeated_permutation(2).group_by{_1.abs+_2.abs}
N = h[1]
P = h[2]+h[3]+h[4]
Q = [(a[0]<<10)+a[1]]
R = []
p (0..).each {|n|
  R.pop(H*W).each {
    h,w = _1>>10, _1&B
    P.each {|r,c| (S[r][c]=?*; Q << (r<<10)+c) if S[r+=h][c+=w]==?. }
  }
  while Q[0]
    Q.pop(H*W).each {|q|
      h,w,j = q>>10, q&B
      N.each {|r,c|
        s = S[r+=h][c+=w]
        if s == ?#
          j = 1
        elsif s == ?.
          S[r][c] = ?+
          Q << (r<<10)+c
        end
      }
      R << q  if j
    }
  end
  break n if L[D] != ?.
  break -1 if !R[0]
}

Measured memory_bytes: 20040
import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        int p, x;
        long sum = 0;
        int n = sc.nextInt();
        int array[] = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            sum += array[i];
        }
        int test = sc.nextInt();
        for (int i = 0; i < test; i++) {
            p = sc.nextInt();
            x = sc.nextInt();
            System.out.println(sum - array[p - 1] + x);
        }
        bw.flush();
    }
}


Measured memory_bytes: 36144
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>

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

using namespace std;

int n,m,q;
vector<int> a,b,c,d;
int ans =0;
void dfs(vector<int> A){//深さ優先探索
	if(A.size() == n+1)
	{
		//rep(i,n+1)cout << A[i]<< " ";
		//cout << endl;
		int tmp =0;
		rep(i,q){
			if(A[b[i]]-A[a[i]]==c[i]){
				tmp+=d[i];
			}
		}
		ans = max(ans,tmp);

		return;
	}

	A.push_back(A.back());
	while(A.back() <= m){
		dfs(A);
		A.back()++;
	}

}

int main() {

	cin >>n>>m>>q;

	a=b=c=d = vector<int>(q);

	vector<int> A(1,1);


	rep(i,q){
		cin >> a[i]>>b[i]>>c[i]>>d[i];

	}

	dfs(A);
	cout << ans;

	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int n,a[200010];
bool used[200010];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	int ans=0;
	for (int i=30;i;i--)
	{
		for (int j=1,k=n;j<=n;j++)
		{
			if (used[j])
			{
				continue;
			}
			while (k && (used[k] || a[j]+a[k]>(1<<i)))
			{
				k--;
			}
			if (j>=k)
			{
				break;
			}
			if (a[j]+a[k]==(1<<i))
			{
				used[j]=used[k]=true;
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

int N, M, A[500100], B[500100], X[500100];

int imos[5009][5009];

int main() {
    // 入力
    cin >> N >> M;
    REP(i, M) cin >> A[i] >> B[i] >> X[i];

    // imos を初期化する
    REP(i, 5009) {
        REP(j, 5009) {
            imos[i][j] = 0;
        }
    }

    // 左 -> 右, 右上 -> 左下, 右下 -> 左上
    REP(i, M) {
        imos[A[i]        - 1][B[i]        - 1]--;
        imos[A[i]        - 1][B[i]           ]++;
        imos[A[i] + X[i]    ][B[i] + X[i] + 1]--;
        imos[A[i] + X[i] + 1][B[i] + X[i] + 1]++;
        imos[A[i] + X[i] + 1][B[i]           ]--;
        imos[A[i] + X[i]    ][B[i]        - 1]++;
    }

    // 左 -> 右
    FOR(i, 0, N+1) {
        FOR(j, 1, i+1) {
            imos[i][j] += imos[i][j-1]; 
        }
    }
    // 右上 -> 左下
    FOR(i, 1, N+1) {
        FOR(j, 0, i+1) {
            imos[i][j] += imos[i-1][j];
        }
    }
    // 右下 -> 左上
    FORD(i, N, 0) {
        FORD(j, i, 0) {
            imos[i][j] += imos[i+1][j+1];
        }
    }

    int ans = 0;
    FOR(i, 1, N) {
        FOR(j, 1, i) {
            if (imos[i][j] > 0) ans++;
            // printf("%d ", imos[i][j]);
        }
        // printf("\n");
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
   // freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);

    string s;
    cin >> s;
    stack<char> st;

    for (int i = 0; i < s.length(); ++i) {
        if (st.size() > 0 && st.top() == 'S' && s[i] == 'T')
            st.pop();
        else
            st.push(s[i]);
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 644
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

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

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll k;cin>>k;
  vector<ll>dp(n,1e18),h(n);
  rep(i,n)cin>>h[i];
  dp[0]=0;

  repi(i,1,n){
    repi(j,1,min((ll)i+1,k+1)){
      chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }

  cout<<dp[n-1]<<endl;



  return 0;

}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long double a, b, c;
  cin >> a >> b >> c;
  
  if (c - a - b > 2 * sqrt(a * b)) cout << "Yes\n";
  else cout << "No\n";
}

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

#define rep(i,start,n) for(int i=start;i<(int)(n);i++)
#define rrep(i,n,end) for(int i=n-1;i>=end;i--)
#define each(it,v) for(auto it : v)
#define all(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using vpii = vector<Pii>;
using vpll = vector<Pll>;

const ll mod=1e9+7;
const int intINF=INT_MAX;
const ll  longINF=LONG_LONG_MAX;

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

        vector<pair<double,string>> v(n);
        double ans=0;
        rep(i,0,n)
        {
                cin>>v[i].first>>v[i].second;
                if(v[i].second=="BTC")ans+=v[i].first*380000;
                else ans+=v[i].first;
        }

        printf("%.12lf\n",ans);


}

Measured memory_bytes: 256
def divide(n):
    m = 0
    count = -1
    while m ==0:
        n, m = divmod(n, 2)
        count += 1
    return count

def foo(xs):
    possible = 31
    # 2 ^ 30 = 2 ^ (10 * 3) =  (2^10) ^ 3 ~ (10^3) ^ 3 = 10^ 9
    for x in xs:
        possible = min(possible, divide(x))
        if possible == 0:
            return 0
    return possible

if __name__ == "__main__":
    n = int(input())
    xs = list(map(int, input().split()))
    print(foo(xs))

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

typedef long long ll;

main()
{
    int n, sum = 0;
    cin >> n;
    int arr1[n], arr2[n], arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr1[i];
    }
    for(int i = 0; i < n; i++){
        cin >> arr2[i];
    }
    for(int i = 0; i < n; i++){
        arr[i] = arr1[i] - arr2[i];
        if(arr[i] > 0){
            sum = sum + arr[i];
        }
    }
    cout << sum;

}





///promy_pompom
//hello world


Measured memory_bytes: 3596
#pragma GCC optimize(2)
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e7+5+5e6;
using namespace std;
const ll INF=1e15+7;
const ll mod=1e9+7;
ll n,m,p;
int main()
{
    scanf("%lld%lld%lld",&n,&m,&p);
    ll temp=n+m+p;
    if(temp>=22) printf("bust\n");
    else printf("win\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
const ll MOD = 1e9;

int main(){
  ll n;
  cin>>n;
  ll a[111111];
  for(int i=0;i<n;i++){
	cin>>a[i];
  }
  ll ans=0;
  sort(a,a+n);
  if(n%2){
	ll sum1=0,sum2=0;
	for(int i=0;i<n;i++){
	  if(i<n/2)sum1+=a[i];
	  if(i>n/2)sum2+=a[i];
	}
	ans=max(ans,sum2*2-((sum1+a[n/2])*2-(a[n/2]+a[n/2-1])));
	ans=max(ans,abs(sum1*2-((sum2+a[n/2])*2-(a[n/2]+a[n/2+1]))));
  }else{
	
	ll sum1=0,sum2=0;
	for(int i=0;i<n;i++){
	  if(i<n/2)sum1+=a[i];
	  else sum2+=a[i];
	}
	ans=(sum2*2-a[n/2])-(sum1*2-a[n/2-1]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

#define MAX_N 500000
#define INF 2000000000

int dp[2][MAX_N][2];//dp[????????????][???????????§??§A?????????????????????][??´???]
int n, a[MAX_N];

int main() {
	cin >> n;
	for (int i = 1; i < n; i++) { cin >> a[i]; }
	memset(dp, 127, sizeof(dp));
	dp[0][0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (dp[0][j][0] < INF) {
				dp[1][j + 1][0] = min(dp[1][j + 1][0], dp[0][j][0]);
				dp[1][j + 1][1] = min(dp[1][j + 1][1], dp[0][j][0] + a[i + 1]);
			}
			if (dp[0][j][1] < INF) {
				dp[1][j][1] = min(dp[1][j][1], dp[0][j][1]);
				dp[1][j][0] = min(dp[1][j][0], dp[0][j][1] + a[i + 1]);
			}
		}
		for (int j = 0; j <= n; j++) {
			dp[0][j][0] = dp[1][j][0];
			dp[0][j][1] = dp[1][j][1];
			dp[1][j][0] = INF;
			dp[1][j][1] = INF;
		}
	}
	cout << min(dp[0][n / 2][0], dp[0][n / 2][1]) << endl;
	return 0;
}

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;

typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if (a+b+c>21)cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}




Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class BaseballSimulation
    {
        public static void Main()
        {
            int data_cnt = int.Parse(Console.ReadLine());
            for (int i = 0; i < data_cnt; i++)
            {
                int point = 0;
                int out_cnt = 0;
                var runners = new bool[3] { false, false, false };

                while (true)
                {
                    string input = Console.ReadLine();
                    if (input == "OUT") { out_cnt++; }
                    else if (input == "HIT")
                    {
                        if (runners[2] == true) { point++; }

                        if (runners[1] == true) { runners[2] = true; }
                        else { runners[2] = false; }

                        if (runners[0] == true) { runners[1] = true; }
                        else { runners[1] = false; }

                        runners[0] = true;
                    }
                    else if (input == "HOMERUN")
                    {
                        point++;
                        if (runners[0] == true) { point++; }
                        if (runners[1] == true) { point++; }
                        if (runners[2] == true) { point++; }

                        runners = new bool[3] { false, false, false };
                    }

                    if (out_cnt >= 3) { break; }
                }

                Console.WriteLine(point);
            }
        }
    }
}

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

class Dice {
public:
    int face[6];

    Dice() {
    }

    Dice(int face1, int face2, int face3, int face4, int  face5, int face6) {
        face[0] = face1;
        face[1] = face2;
        face[2] = face3;
        face[3] = face4;
        face[4] = face5;
        face[5] = face6;
    }

    void move(char c) {
        if (c == 'N') {
            moveFace(1, 2, 6, 5);
        } else if (c == 'S') {
            moveFace(1, 5, 6, 2);
        } else if (c == 'W') {
            moveFace(1, 3, 6, 4);
        } else if (c == 'E') {
            moveFace(1, 4, 6, 3);
        }
    }

    void moveFace(int i1, int i2, int i3, int i4) {
        int tmp = face[i1 - 1];
        face[i1 - 1] = face[i2 - 1];
        face[i2 - 1] = face[i3 - 1];
        face[i3 - 1] = face[i4 - 1];
        face[i4 - 1] = tmp;
    }

    bool isSameDice(Dice d) {
        for (int i = 0; i < 4; i++) {
            move('N');
            for (int j = 0; j < 4; j++) {
                move('W');
                for (int k = 0; k < 4; k++) {
                    move('N');
                    bool isSame = true;
                    for (int l = 0; l < 6; l++) {
                        if (face[l] != d.face[l]) isSame = false;
                    }

                    if (isSame) return true;
                }
            }
        }

        return false;
    }
};

int main() {
    int face1, face2, face3, face4, face5, face6;
    int count;
    cin >> count;
    Dice d[100] = {};

    for (int i = 0; i < count; i++) {
        cin >> face1 >> face2 >> face3 >> face4 >> face5 >> face6;
        d[i] = Dice(face1, face2, face3, face4, face5, face6);
    }

    bool isSameDice = false;
    for (int i = 0; i < count; i++) {
        for (int j = i + 1; j < count; j++) {
            if (d[i].isSameDice(d[j])) isSameDice = true;
        }
    }

    cout << (isSameDice ? "No" : "Yes") << endl;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define Inf 100000000000ll
#define MAXN 100000
#define MAXX 5
#define ll long long
using namespace std;


int A[MAXN+2];
int main() {
    int N;
    cin>>N;
    map<int,int> init_pos;
    //srand(time(NULL));
    for(int i=0;i<N;i++) {
        cin>>A[i];
        //A[i]=rand()%1000000000;
        init_pos[A[i]]=i;
    }
    
    map<int,int> final_pos;
    sort(A,A+N);
    for(int i=0;i<N;i++) {
        final_pos[A[i]]=i;
    }
    
    int ct = 0;
    for(int i=0;i<N;i++) {
        int d = abs(final_pos[A[i]] - init_pos[A[i]]);
        d = d % 2;
        if (d != 0)
            ct++;
    }
    
    cout << ct / 2 << endl;
    
    
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	if (n%2==0)
	{
		long long ans=0LL;
		for (int i = 0; i < n/2; ++i)
		{
			ans-=2LL*a[i];
		}
		for (int i = n/2; i < n; ++i)
		{
			ans+=2LL*a[i];
		}
		ans+=a[n/2-1];
		ans-=a[n/2];
		cout<<ans<<endl;
	}
	else
	{
		long long ans1=0LL,ans2=0LL;
		for (int i = 0; i < n/2; ++i)
		{
			ans1-=2LL*a[i];
		}
		for (int i = n/2; i < n; ++i)
		{
			ans1+=2LL*a[i];
		}
		ans1-=a[n/2];
		ans1-=a[n/2+1];
		for (int i = 0; i < n/2+1; ++i)
		{
			ans2-=2LL*a[i];
		}
		for (int i = n/2+1; i < n; ++i)
		{
			ans2+=2LL*a[i];
		}
		ans2+=a[n/2-1];
		ans2+=a[n/2];
		cout<<max(ans1,ans2)<<endl;
	}
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <set>
using namespace std;
 
int getKey(const string &s){
  int res=0;
 
  for(int i=0;i<s.size();i++){
    res*=10;
 
    switch(s[i]){
    case 'A': res+=1; break;
    case 'C': res+=2; break;
    case 'G': res+=3; break;
    case 'T': res+=4; break;
    }
  }
 
  return res;
}

int main(){
  set<int> s;
  int n;
  cin>>n;
 
  for(int i=0;i<n;i++){
    string op;
    string str;
    cin>>op>>str;
 
    if(op=="insert"){
      s.insert(getKey(str));
    }
    else if(s.find(getKey(str))!=s.end()){
      cout<<"yes"<<endl;
    }
    else{
      cout<<"no"<<endl;
    }
  }
}


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

int main() {
  ll n, d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> v(n);
  for (auto& e : v) cin >> e.first >> e.second;
  sort(v.begin(), v.end());
  vector<ll> x(n), h(n);
  for (int i = 0; i < n; i++) x[i] = v[i].first, h[i] = (v[i].second - 1) / a + 1;

  vector<int> w(n);
  for (int i = 0; i < n; i++) {
    w[i] = upper_bound(x.begin(), x.end(), x[i] + 2 * d) - x.begin();
  }

  ll m = 0, s = 0;
  vector<ll> t(n + 1);
  for (int i = 0; i < n; i++) {
    s += t[i];
    if (s < h[i]) {
      m += h[i] - s;
      t[i] += h[i] - s;
      t[w[i]] -= h[i] - s;
      s = h[i];
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 8832
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

template<typename T>
class BIT {
    int n;
    vector<T> val;
public:
    BIT(int n):n(n),val(n+1,0) {}
    void add(int i,T x=1) {
        i++;
        while(i <= n) {
            val[i] += x;
            i += i&-i;
        }
    }
    T sum(int i) {
        T ret = 0;
        i++;
        while(i > 0) {
            ret += val[i];
            i -= i&-i;
        }
        return ret;
    }
    // [l,r)
    T sum(int l,int r) { return sum(r-1)-sum(l-1); }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    // first/second
    vector<LP> a(n);
    vector<BIT<int>> cnt(41,BIT<int>(101));
    ll ans = 0;
    rep(_,n) {
        string s;
        cin >> s;
        ll u = 0,l = 1;
        bool flag = false;
        for(char c : s) {
            if(c == '.') {
                flag = true;
            } else {
                if(flag) l *= 10;
                u *= 10;
                u += (c-'0');
            }
        }
        int x = 0,y = 0;
        while(u%2 == 0) {
            u /= 2;
            x++;
        }
        while(u%5 == 0) {
            u /= 5;
            y++;
        }
        int z = 0,w = 0;
        while(l%2 == 0) {
            l /= 2;
            z++;
        }
        while(l%5 == 0) {
            l /= 5;
            w++;
        }
        int d2 = x-z+50,d5 = y-w+20;
        rep(i,d5+1) {
            ans += cnt[i].sum(0,d2+1);
        }
        cnt[w-y+20].add(z-x+50);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6268
import sys,queue,math,copy,itertools,bisect,collections,heapq


def wf(d,n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

def main():
    INF = 10**18
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,M,L = LI()
    road = [[INF] * N for _ in range(N)]
    for _ in range(M):
        a,b,c = LI()
        if c <= L:
            road[a-1][b-1] = c
            road[b-1][a-1] = c

    road = wf(road,N)


    gas = [[INF] * N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if road[i][j] <= L:
                gas[i][j] = 1

    gas = wf(gas,N)

    Q = NI()
    for _ in range(Q):
        s,t = LI()
        if gas[s-1][t-1] == INF:
            print(-1)
        else:
            print(gas[s-1][t-1]-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 81184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];

    vector cnt(h, vector(w, INT_MAX));
    cnt[ch][cw] = 0;
    deque<pair<int, int>> que;
    que.emplace_back(ch, cw);

    vector vy = {-1, 1, 0, 0};
    vector vx = { 0, 0,-1, 1};
    while (!que.empty()) {
        auto [y, x] = que.front();
        que.pop_front();

        
        for (int i=0; i<4; i++) {
            int yy = y + vy[i];
            int xx = x + vx[i];
            if (yy<0 || h<=yy || xx<0 || w<=xx) continue;
            if (s[yy][xx] == '#') continue;
            if (cnt[yy][xx] <= cnt[y][x]) continue;

            cnt[yy][xx] = cnt[y][x];
            que.emplace_front(yy, xx);
        }

        for (int i=-2; i<=2; i++) {
            for (int j=-2; j<=2; j++) {
                int yy = y + i;
                int xx = x + j;
                if (yy<0 || h<=yy || xx<0 || w<=xx) continue;
                if (s[yy][xx] == '#') continue;
                if (cnt[yy][xx] <= cnt[y][x]+1) continue;

                cnt[yy][xx] = cnt[y][x]+1;
                que.emplace_back(yy, xx);
            }
        }
    }

    if (cnt[dh][dw] == INT_MAX)
        cout << -1 << endl;
    else
        cout << cnt[dh][dw] << endl;
}


Measured memory_bytes: 8572
#include <stdio.h>
int n,x,i,j,p,q,a[100][100],ans=-99999;
int main(void){
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&x);
			a[i][j]=x;
			if(x>ans)ans=x;
			if(j>0)a[i][j]+=a[i][j-1];
		}
		if(i>0){
			for(j=0;j<n;j++){
				a[i][j]+=a[i-1][j];
			}
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<n;j++){

			for(p=i;p<n;p++){
				for(q=j;q<n;q++){
					if(i>0 && j>0)x=a[i-1][j-1]; else x=0;
					if(i>0)x-=a[i-1][q];
					if(j>0)x-=a[p][j-1];
					x+=a[p][q];
					if(x>ans)ans=x;
				}
			}

		}
	}

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

Measured memory_bytes: 636
s = list(input())
t = list(input())
tr = []
a_ar =[chr(ord('a') + i) for i in range(26)]
a_edge = []
for i in range(26):
    a_edge.append(set())
for i in range(len(s)):
    a_edge[a_ar.index(s[i])].add(a_ar.index(t[i]))

ans = []
for i in range(26):
    if len(a_edge[i]) >= 2:
        print("No")
        exit()
    elif len(a_edge[i]) != 0:
        l = list(a_edge[i])
        ans.append(l[0])
p = len(ans)
q = len(set(ans))
if p == q:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 70476
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		boolean[] dp = new boolean[K + 1];
		for (int i = A[0]; i <= K; i++) {
			for (int j = 0; j < N && i - A[j] >= 0; j++) {
				if (!dp[i - A[j]]) {
					dp[i] = true;
					break;
				}
			}
		}
		System.out.println(dp[K] ? "First" : "Second");
	}
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 100010

vector<int> G[MAX_N];
int n,m;
int num[MAX_N],par[MAX_N],low[MAX_N];
int cnt;
vector<pair<int,int> > res;

void bridge(int v,int prev){
	num[v]=low[v]=++cnt;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(num[nv]==-1){
			par[nv]=v;
			bridge(nv,v);
			low[v]=min(low[v],low[nv]);
			if(num[v]<low[nv]){
				res.push_back(make_pair(min(v,nv),max(v,nv)));
			}
		}else if(nv!=prev){
			low[v]=min(low[v],num[nv]);
		}
	}
}

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		G[a].pb(b); G[b].pb(a);
	}
	memset(num,-1,sizeof(num));
	cnt=0;
	bridge(0,-1);
	sort(all(res));
	rep(i,res.size()){
		cout<<res[i].fi<<" "<<res[i].se<<endl;
	}
	return 0;
}

Measured memory_bytes: 7516
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=1e9+7,N=2e6+5;
int n,a,b,c,p,q,ans,fac[N],ifac[N],inv,pw1[N],pw2[N],pw3[N];

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod;
	return res;
}

int C(int n,int m){
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

signed main(){
	read(n,a,b,c);
	a=1ll*a*fpow(a+b,mod-2)%mod;
	b=(mod+1-a)%mod;
	c=100ll*fpow(100-c,mod-2)%mod;
	fac[0]=ifac[0]=1;for(int i=1;i<=n*2;i++) fac[i]=1ll*fac[i-1]*i%mod,ifac[i]=fpow(fac[i],mod-2);
	for(int i=0;i<n;i++){
		int x=1ll*C(n+i-1,n-1)*(n+i)%mod*c%mod;
		ans=(1ll*ans+1ll*x*fpow(a,n)%mod*fpow(b,i)%mod)%mod;
		ans=(1ll*ans+1ll*x*fpow(b,n)%mod*fpow(a,i)%mod)%mod;
	}
	write(ans);
}

Measured memory_bytes: 6776
import java.util.Scanner;

public class Main {

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

		int n = in.nextInt();
		int a[] = new int[n];
		int xor_sum = 0;
		for ( int i = 0; i < n; i++ ) {
			a[i] = in.nextInt();
			xor_sum = xor_sum ^ a[i];
		}
		
		if(xor_sum == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		

		in.close();
	}
}

Measured memory_bytes: 50356
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[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 (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int memol[514514];
int memor[514514];
int ans[514514];
signed main() {
	string s;
	cin >> s;
	int n = s.size();
	int cnta = 0, cntb = 0;
	rep(i, n) {
		if (s[i] == '<') {
			cnta++;
			memol[i + 1] = cnta;
		}
		else {
			cnta = 0;
			memol[i + 1] = cnta;
		}
	}
	memol[0] = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '>') {
			cntb++;
			memor[i] = cntb;
		}
		else {
			cntb = 0;
			memor[i] = cntb;
		}
	}
	memor[n] = 0;
	int ta = 0;
	rep(i, n + 1) {
		ans[i] = max(memol[i], memor[i]); ta += ans[i];
	}
	cout << ta << endl;
	ggr
}



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

int main(){
  int N;
  string S,T;
  cin>>N>>S>>T;
  for(int i=0; i<N; i++){
    cout<<S.at(i)<<T.at(i);
    if(i==N-1){
      cout<<endl;
    }
  }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  int M = 1 << N;
  vector<int> S(M); rep(i, M) cin >> S[i];
  sort(range(S));
  reverse(range(S));
  int i = 0;
  priority_queue<int> q;
  q.push(N);
  while (i < M) {
    int j = i;
    while (i < M && S[i] == S[j]) i++;
    int c = i - j;
    if (q.size() < c) {
      cout << "No" << endl;
      return 0;
    }
    vector<int> used;
    while (c > 0) {
      used.push_back(q.top()); q.pop();
      c--;
    }
    for (int x : used) {
      for (int k = 0; k <= x - 1; k++) q.push(k);
    }
  }
  cout << "Yes" << endl;
}

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

int divide(int count, bool odd, vector<int> &A){
  
  if(odd == true){
    return count;
  }
  
  for(int i = 0; i < A.size(); i++){
    if( (A.at(i) % 2) != 0 ){
      odd = true;
      break;
    } else {
      odd = false;
    }
  }
  
  if(odd == false){
    for(int i = 0; i < A.size(); i++){
      A.at(i) = A.at(i)/2;
    }
    count += 1;
  }

  return divide(count, odd, A);
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);

  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  bool odd = false; // 奇数があればtrueにする(フラグは1にすることで「立てる」イメージ）
  int count = 0;
 
  count = divide(count, odd, A);
  cout << count << endl;
  
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

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

struct ICE{
	ICE(bool a, int b, int c):mark(a), exist(b), count(c){};
	bool mark;
	int exist;
	int count;
};

int maxcount = 0;
void dfs(int x, int y, vector<vector<ICE> > &map){
	map[y][x].mark = true;
	map[y][x].count++;
	for(int i = 0; i < 4; i++){
		if( (x+dx[i]<0 || x+dx[i]>=map[y].size()) || (y+dy[i]<0 || y+dy[i]>=map.size()) || map[y+dy[i]][x+dx[i]].exist==0 || map[y+dy[i]][x+dx[i]].mark) continue;
		map[y+dy[i]][x+dx[i]].count = map[y][x].count;
		dfs(x + dx[i], y + dy[i], map);
	}
	maxcount = maxcount < map[y][x].count ? map[y][x].count : maxcount;
	map[y][x].mark = false;
	map[y][x].count -= map[y][x].count;
}


int main(){
	int w = 0, h = 0;
	while(cin >> w >> h && (w != 0 || h != 0)){
		maxcount = 0;
		vector<vector<ICE> > map(h, vector<ICE>(w, ICE(false, 0, 0)));
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> map[i][j].exist;
			}
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(!map[i][j].exist) continue;
				dfs(j, i, map); 
			}
		}
		cout << maxcount << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
ll dsum(ll x){
  ll res = 0;
  while(x>0){
    res += x%10;
    x /= 10;
  }
  return res;
}

int main() {
  ll n; cin >> n;
  ll ans = INF;
  FOR(i, 1, n){
    ll j = n-i;
    ll t = dsum(i) + dsum(j);
    ans = min(ans, t);
  }
  cout << ans << endl;
}

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

signed main(void)
{
	string s;
	int n, ans;
	cin >> s;
	n = s.size();
	ans = 0;
	rep(i, n)
	{
		// g
		if (i % 2 == 0)
		{
			if (s[i] == 'p')
				ans--;	
		}
		// p
		else
		{
			if (s[i] == 'g')
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
 
#define ll long long
 
#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));
 
int main(){
	struct UnionFind{
	vector<int> par; //親の番号

	UnionFind(int N) : par(N){ //初期化で最初はすべてが根であるとする
		for(int i = 0;i < N;i++) par[i] = i;
	}

	int root(int x){ //データxが属する木の根を再帰的に求める
		if(par[x] == x) return x; //根を返す
		return par[x] = root(par[x]); //データxの親の番号でroot()を再帰する
	}

	void unite(int x,int y){ //xとyの木を併合
		int rx = root(x); //xの根
		int ry = root(y); //yの根
		if(rx == ry) return; //同じ木にある時はそのまま
		par[rx] = ry; //別々の木にある時は根を同じにしてくっつける
	}
	
	bool same(int x,int y){ //xとyが同じ木に属するか判別する
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
  
  int N,M;
  cin >> N >> M;
  UnionFind u(N);
  froop1(0,M){
   int a,b;
    cin >> a >> b;
    a--;b--;
    u.unite(a,b);
  }
	int count = 0;
  set<int> m;
  froop1(0,N){
    int p = u.root(i);
        m.insert(p);
  }
  count = m.size() - 1;
  
    cout << count << endl;
}

Measured memory_bytes: 7712
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
typedef long long ll;
typedef double db;
#define lp1(i, n)  for(int i=0; i<(int)(n); ++i)
#define lp2(i, n)  for(int i=1; i<=(int)(n); ++i)
#define lp3(j, m)  for(int j=0; j<(int)(m); ++j)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];
int main(){

   string s;
   int n,m;
   cin>>n;
   m=n;
   cin>>s;
   for(int i=0 ; i<s.size() ; i++)
   {
       m=n;
          while(m--)
       {
           if(s[i]=='Z')
            s[i]='A';
           else
           s[i]+=1;
       }
       cout<<s[i];
   }
go;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
template<typename T>
void swap(T &a, T &b) {
    T tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
  ll N;
  vector<ll> nb(64,0);
  cin>>N;
  FOR(i,N){
    ll tmp;
    cin>>tmp;
    bitset<64> b(tmp);
    for(int j=0;j<64;++j){
      nb[j]+=b[j];
    }
  }
  lll a=1;
  lll num=0;
  for(int i=0;i<64;++i){
    num+=(a*nb[i]*(N-nb[i]))%1000000007;
    num%=1000000007;
    a*=2;
  }
  cout<<num<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
AB = N.times.map { gets.split.map(&:to_i) }
AB.sort!{|i, j| i[0] <=> j[0]}

res = 0
AB.each do |ab|
  if ab[1] < M
    res += ab[0] * ab[1]
    M -= ab[1]
  else
    puts res + ab[0] * M
    break
  end  
end



Measured memory_bytes: 16880
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

const int di[]={-1, 0, 1, 0}, dj[]={0, -1, 0, 1};

bool is_valid(const vector<size_t> &q, size_t r) {
    for (size_t j=0; j<8; ++j)
        if (j!=r && q[j]==q[r])
            return false;

    for (size_t i=0; i<r; ++i) {
        if (q[i]-i == q[r]-r) return false;
        if (q[i]+i == q[r]+r) return false;
    }

    return true;
}

bool solve_equeen(vector<size_t> &q, size_t r=0) {
    if (r == 8) return true;

    if (!~q[r]) {
        for (size_t c=0; c<8; ++c) {
            q[r] = c;
            if (is_valid(q, r))
                if (solve_equeen(q, r+1))
                    return true;
        }
        q[r] = -1;
    } else {
        if (is_valid(q, r))
            if (solve_equeen(q, r+1))
                return true;
    }

    return false;
}

int main() {
    size_t k;
    scanf("%zu", &k);

    vector<size_t> q(8, -1);
    for (size_t i=0; i<k; ++i) {
        size_t r, c;
        scanf("%zu %zu", &r, &c);

        if (~q[r]) return 1;
        q[r] = c;
    }

    solve_equeen(q);

    for (size_t i=0; i<8; ++i)
        for (size_t j=0; j<8; ++j)
            printf("%c%s", q[i]==j? 'Q':'.', j<7? "":"\n");

    return 0;
}

Measured memory_bytes: 2752
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);


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

    ll n;
    cin>>n;
    ll ans = n + n*n + n*n*n ;
    cout << ans << endl;

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string A;

int num2[1010101];
int S2[1010101];

int hoge(string A) {
	int i;
	for(i=1;i<=N;i++) {
		int x=i;
		while(x%2==0) x/=2, num2[i]++;
		S2[i]=S2[i-1]+num2[i];
	}
	
	int sum=0;
	int N=A.size();
	FOR(i,N) {
		int a=S2[N-1]-S2[i]-S2[N-1-i];
		if(a==0) sum+=A[i];
	}
	return sum%2;
	
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A;
	int C[3]={};
	FORR(c,A) {
		c-='1';
		C[c]++;
	}
	
	if(C[0]==0) {
		string B;
		C[0]=C[1]=C[2]=0;
		FOR(i,N-1) B.push_back(abs(A[i]-A[i+1]));
		N--;
		A=B;
		FORR(c,A) C[c]++;
	}
	
	if(C[1]==0) {
		FORR(c,A) c/=2;
		cout<<hoge(A)*2<<endl;
		return;
	}
	cout<<hoge(A)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 10140
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>
//#pragma warning(disable : 4996)
#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back
using namespace std;
typedef long long ll;

const int maxn = (int)1e6 + 13;
const ll INFL = 9223372036854775807;
const int INF = 2147483647;
const ll MOD = (int)1e9 + 7;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101;
const long double pi = 3.1415926535897932;


int main() {
	drobucs;
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			cout << "Yes\n";
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No\n";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
  long long mod=1000000007;
  long long n,m,i;
  cin >> n >> m;
  if(abs(n-m)>1){
    cout << 0 << endl;
    return 0;
  }
  long long ans=1;
  for(i=1;i<=n;i++){
    ans=ans*i%mod;
  }
  for(i=1;i<=m;i++){
    ans=ans*i%mod;
  }
  if(abs(n-m)==0){
    ans=ans*2%mod;
  }
  cout << ans%mod << endl;
}

Measured memory_bytes: 3636