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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, M;
    cin >> N >> M;

    vector<ll> cnt(N, 0);
    REP(i, M){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	cnt[a]++;
    	cnt[b]++;
    }
    bool ok = true;
    REP(i, N) if(cnt[i]%2) ok = false;
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 1024
house = [[[0 for col in range(10)]for row in range(3)]for layer in range(4)]
n = int(raw_input())
for i in range(n):
    input_line = raw_input().split()
    house[int(input_line[0])-1][int(input_line[1])-1][int(input_line[2])-1] += int(input_line[3])
for i in range(0,4):
    if i != 0:
        print "#"*20
    for j in range(0,3):
        buf = ""
        for k in range(0,10):
                buf += " " + str(house[i][j][k])
        print buf

Measured memory_bytes: 6392
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    a.sort()
    y = x = 0
    i = n - 1
    while i > 0:
        if a[i] == a[i-1]:
            if not y:
                y = a[i]
                i -= 1
            else:
                x = a[i]
                break
        i -= 1
    print(y * x)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  int i;
  for(i=0;i<n;i++){
    cin >> h.at(i);
  }
  int ans=0,maxi=0;
  for(i=0;i<n-1;i++){
    if(h.at(i)>=h.at(i+1)){
      maxi++;
    }else{
      ans=max(ans,maxi);
      maxi=0;
    }
  }
  ans=max(ans,maxi);
  cout << ans;
}

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

int main(){
  int N;
  cin >> N;
  multiset<int> max;
  for(int i = 1; i <= N;i++){
    int M;
    cin >> M;
    for(int j = 0;j < M; j++){
      int c;
      cin >> c;
      max.insert(c);
      if(i<max.size())max.erase(max.begin());
    }
  }
  long long int ans = 0;
  for(auto x = max.begin(); x != max.end(); x++){
    ans += *x;
  } 
  cout << ans << endl;
}



Measured memory_bytes: 17096
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string s;
  int n=700;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='o'){
      n+=100;
    }
  }
  cout<<n<<endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1234567890123LL
#define MN 1001

using namespace std;

typedef long long ll;
typedef pair<int, ll> arc;

ll dist[MN];
vector<arc> es[MN];

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i=0; i<m; i++)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        es[a].push_back(arc(b, -c));
    }
    dist[1] = 0;
    for(int i=2; i<=n; i++) dist[i] = INF;
    
    for(int t=1; t<=n; t++)
    {
        for(int i=1; i<=n; i++)
        {
            for(vector<arc>::iterator itr=es[i].begin(); itr!=es[i].end(); itr++)
            {
                if(dist[itr->first] > dist[i] + itr->second)
                {
                    dist[itr->first] = dist[i] + itr->second;
                    if(t==n)
                    {
                        dist[itr->first] = -INF;
                    }
                }
            }
        }
    }
    
    if(dist[n]<=-INF)
    {
        cout << "inf" << endl;
    }
    else
    {
        cout << -dist[n] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
#define MAX 10000003
using namespace std;
typedef long long ll;

int prime[MAX]; 
unordered_map<int, int> max_map; 

int power(int a, int n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % MOD; 
    p = (p * p) % MOD; 
    if (n & 1) 
        p = (p * a) % MOD; 
    return p; 
}

void sieve() { 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
}

ll lcmModuloM(const int* ar, int n) 
{ 
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 
        while (num > 1) { 
            int factor = prime[num]; 
            temp[factor]++; 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    ll ans = 1; 
    for (auto it : max_map) { 
        ans = (ans * power(it.first, it.second)) % MOD; 
    } 
  
    return ans; 
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    sieve();
    ll l = lcmModuloM(A, N);
    
    ll ans = 0;
    REP(i, 0, N) {
        ans = (ans + (l * modinv(A[i], MOD)) % MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int judge = 1;
  for(int i=0;i<S.size();i++){
    if(i%2 == 0){
      if(S[i] == 'R' || S[i] == 'U' || S[i] == 'D'){

        }else{
          judge = 0;
        }
      }else{
        if(S[i] == 'L' || S[i] == 'U' || S[i] == 'D'){

        }else{
          judge = 0;
        }
      }
  }
  if(judge == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define mod 1000000007
#define inf 1e18
#define PI 3.14159265358979323846264338327950L
#define w(x) int x; cin>>x; while(x--)
using namespace std;
bool sieve[100007];
void sieve_make() 
{
	memset(sieve,true,sizeof(sieve));
	sieve[0]=sieve[1]=false;
	for(int i=2;i*i<=100006;i++)
	{
		if(sieve[i])
		{
			for(int j=2*i;j<=100006;j+=i)
				sieve[j]=false;
		}
	}
}

int max(int a,int b)
{
	if(a>b)
		return a;
	return b;
}
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int modexp(int a,int b,int c)
{
	if(a==0) return 0;
	if(b==0) return 1;

	int ans;
	if(b%2==0)
	{
		int small=modexp(a,b/2,c);
		ans=(small*small)%c;
	}
	else
	{
		int small=modexp(a,b-1,c);
		ans=(a%c);
		ans=(small*ans)%c;
	}
	return (ans+c)%c;
}

string rev(string s)
{
	reverse(s.begin(), s.end());
	return s;
}
bool sign(int x)
{
	if(x>0)
		return true;
	return false;
}

int base3(string b)
{
	int ans=0,c=0;
	for(int i=b.length()-1;i>=0;i--)
	{
		ans+=(b[i]-'0')*pow(3,c++);
	}
	return ans;
}


int32_t main()
{
	ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
	
	
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double v=(m*30)/60;
	
	h*=30;
	m*=6;
	h+=v;
	double angle=abs(h-m);
	angle = angle*(PI/180);
	double ans=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(angle));
	printf("%.20lf",ans);
}

Measured memory_bytes: 4240
/*
        Author: Prokash
                CSE48, JU

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    string str1,str2;
    cin>>str1>>str2;
    vector<int>v1,v2;
    map<char,int>mp1,mp2;
    map<char,int>::iterator it;
    for(int i=0;i<str1.size();i++)
    {
        mp1[str1[i]]++;
        mp2[str2[i]]++;
    }
    for(it=mp1.begin();it!=mp1.end();it++)
    {
        v1.push_back(it->second);
    }
    sort(v1.begin(),v1.end());
    for(it=mp2.begin();it!=mp2.end();it++)
    {
        v2.push_back(it->second);
    }
    sort(v2.begin(),v2.end());
    if(v1==v2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 916
s = input()
t = input()
st = list(s)
ts = list(t)
j = 0
for i in range(len(st)):
    if(st[i] == ts[i]):
        j = j
    elif(st[i] != ts[i]):
        ts[i] = st[i]
        j = j + 1

# print(st)
# print(ts)
print(j)

Measured memory_bytes: 12352
s=input()
l=len(s)

dp=[4*[0]for _ in range(l+1)]
dp[0][0]=1

for i in range(1,l+1):
  si = s[i-1]
  if si == "?":
    dp[i][0] = dp[i-1][0] * 3
    dp[i][1] = dp[i-1][1] * 3
    dp[i][2] = dp[i-1][2] * 3
    dp[i][3] = dp[i-1][3] * 3
  else:
    dp[i][0] = dp[i-1][0]
    dp[i][1] = dp[i-1][1]
    dp[i][2] = dp[i-1][2]
    dp[i][3] = dp[i-1][3]
    
  if si == "A":
    dp[i][1] = dp[i-1][0] + dp[i][1]
  elif si == "B":
    dp[i][2] = dp[i-1][1] + dp[i][2]
  elif si == "C":
    dp[i][3] = dp[i-1][2] + dp[i][3]
  else:
    dp[i][1] = dp[i-1][0] + dp[i][1]
    dp[i][2] = dp[i-1][1] + dp[i][2]
    dp[i][3] = dp[i-1][2] + dp[i][3]
  
  for j in range(4):
    dp[i][j] = dp[i][j] % 1000000007
  
print(int(dp[-1][-1]))

Measured memory_bytes: 27536
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());



signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  vector<int> a(5);
  rep(i, 5) cin >> a[i];

  int pos = -1;
  int mi = 10;
  rep(i, 5) {
    int r = a[i]%10;
    if (r>0) {
      if (r < mi) {
        mi = r;
        pos = i;
      }
    }
  }

  if (pos == -1) {
    int sum = 0;
    rep(i, 5) {
      sum += a[i];
    }
    cout << sum << endl;
    return 0;
  }

  int ans = 0;
  rep(i, 5) {
    if (i!=pos) {
      ans += a[i]/10*10;
      if (a[i]%10) ans += 10;
    } else {
      ans += a[i];
    }
  }
  cout << ans << endl;
}


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

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;


 


int main() {
	
   
	ll n,k;cin>>n>>k;
	ll arr[n];
	for(ll i=0;i<n;i++)cin>>arr[i];
	ll dp[n+1];dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	
	for(ll i=2;i<n;i++){
		dp[i] = LONG_MAX;
		for(int j=max(i-k,0*1ll);j<i;j++){
			dp[i] = min(dp[j]+abs(arr[i]-arr[j]),dp[i]);
		}
		
	}
	
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int count_substr(const string& word,const string& q) {
	int count = 0;
	for (string::size_type pos = 0; (pos = word.find(q, pos)) != string::npos; pos += q.size()) {
		++count;
	}
	return count;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in();
	vector<string> S=vecin<string>(N);

	int startB=0,endA=0,both=0,AB=0;
	REP(i,N){
		if(S[i].front()=='B' && S[i].back()=='A') both++;
		else if(S[i].front()=='B') startB++;
		else if(S[i].back()=='A') endA++;

		AB += count_substr(S[i],"AB");
	}

	if(!startB && !endA){
		AB += max(both-1,0);
	}
	else{
		int minAB = min(startB,endA);
		startB -= minAB;
		endA -= minAB;
		AB += minAB;
		if(!startB){
			int rest = min(endA,both);
			both -= rest;
			AB += rest;
			AB += both;
		}
		else{
			int rest = min(startB,both);
			both -= rest;
			AB += rest;
			AB += both;
		}
	}
	out(AB);
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
    #include<numeric>
    #include<array>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define Vl vector<ll>
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
   ll a, b, c, d;
   cin >> a >> b >> c >> d;
   ll r1 = a * c, r2 = a * d, r3 = b * c, r4 = b * d;
   ll res = max({r1, r2, r3, r4});
   cout << res << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    ll t,n;
    cin>>t>>n;
   ll nn;
   nn=(t/n);
    ll sum=nn*n;
    ll sum1=t-sum;
    if(sum1>0)
        cout<<nn+1<<endl;
    else
        cout<<nn<<endl;

}


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

using namespace std;

int main() {
    string yohou, genjitu;
    cin >> yohou >> genjitu;
    
    int count=0;
    for(int i=0; i<3; i++) {
        if(yohou[i]==genjitu[i]) count++;
    }
    
    cout << count << endl;

    return 0;
    
}

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

int main(){
    int a,b,N=20000;
    
    for(int i =0;i<N;i++){
        cin >> a >> b;
        if(a==0&&b==0) break;
        if(a<b) cout << a << " " << b << endl;
        else cout << b << " " << a << endl;
    }




}


Measured memory_bytes: 3056
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            String s = cin.Read;
            String t = cin.Read;

            Dictionary<String, String> map = new Dictionary<string, string>();

            String result = "Yes";
            for (int i = 0; i < s.Length; i++)
            {
                String a = s.Substring(i, 1);
                String b = t.Substring(i, 1);

                if (map.ContainsKey(a))
                {
                    if(map[a] != b)
                    {
                        result = "No";
                        break;
                    }
                }
                else if (map.ContainsValue(b))
                {
                    result = "No";
                    break;
                }
                else
                {
                    map.Add(a, b);
                }
            }

            Console.WriteLine(result);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 20572
// AOJ 1532 Yu-kun Likes Building Block
// 2018.3.18 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 高速数値入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()  // 非負整数のみ
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}


// 2部グラフの最大マッチング
#define BMAX 105
int  hi[BMAX], to[BMAX][BMAX];
static char seen[BMAX];    // 内部作業用
static int  matchL[BMAX];  // 内部作業用
static int  matchR[BMAX];  // 内部作業用

int bpm(int u)
{
	int i, v;

	for (i = 0; i < hi[u]; i++) {
		v = to[u][i];
		if (seen[v]) continue;
		seen[v] = 1;
		if (matchR[v] < 0 || bpm(matchR[v])) {
			matchL[u] = v, matchR[v] = u;
			return 1;
		}
	}
	return 0;
}

int bipartiteMatching(int m, int n)
{
	int u, max;

	memset(matchL, -1, m * sizeof(int));
	memset(matchR, -1, n * sizeof(int));
	max = 0;
	for (u = 0; u < m; u++) {
		memset(seen, 0, n * sizeof(char));
		if (bpm(u)) max++;
	}
	return max;
}


// 本問題関連
#define MAX(a, b)  ((a)>=(b)? (a): (b))
#define MIN(a, b)  ((a)<=(b)? (a): (b))
typedef struct { int w, h; } T;
T t[105]; int N;

int main()
{
	int i, j;

	N = in();
	for (i = 0; i < N; i++)	t[i].w = in(), t[i].h = in();
	for (i = 0; i < N; i++) for (j = 0; j < N; j++) if (i != j) {
		if (MAX(t[i].w, t[i].h) < MAX(t[j].w, t[j].h) &&
			MIN(t[i].w, t[i].h) < MIN(t[j].w, t[j].h))
			to[i][hi[i]++] = j;
	}
#if 0
	for (i = 0; i < N; i++) {
		printf("[%d] hi=%d:", i, hi[i]);
		for (j = 0; j < hi[i]; j++) printf(" %d", to[i][j]);
		printf("\n");
	}
#endif
	printf("%d\n", N - bipartiteMatching(N, N));
	return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n, m, x;
    cin >> n >> m >> x;
    vi c(n);
    vvi a(n, vi(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    ll ans = INFL;
    rep(bit,1<<n){
        ll cur = 0;
        vi level(m);
        rep(i,n){
            if(bit & (1<<i)){
                cur += c[i];
                rep(j,m){
                    level[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        rep(j,m) if(level[j] < x) ok = false;
        if(ok) ans = min(ans, cur);
    }
    if(ans == INFL) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
using namespace std;

int main() {
	int M1, D1, M2, D2; cin >> M1 >> D1 >> M2 >> D2;
	if ((M1 = M2 - 1 || (M1 == 12 && M2 == 1))&& D2 == 1) cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#![allow(unused_variables, dead_code, clippy::many_single_char_names, non_upper_case_globals, unused_imports, unused_macros)]
use std::{
    collections::{BTreeMap, HashSet, HashMap, VecDeque},
    io::{stdin, stdout, StdinLock, StdoutLock, BufReader, BufWriter, prelude::*},
    mem::swap,
    str::FromStr,
};

struct Reader<'a> {
    stdin: BufReader<StdinLock<'a>>
}

impl<'a> Reader<'a> {
    fn new(stdin: BufReader<StdinLock<'a/*'*/>>) -> Self {
        Self {stdin}
    }
    fn read_str(&mut self) -> String {
        let mut s = String::with_capacity(100);
        self.stdin.read_line(&mut s).unwrap();

        if s.ends_with('\n') { s.pop(); if s.ends_with('\r') { s.pop(); } }
        s
    }
    fn read_int<T: FromStr>(&mut self) -> T {
        match self.read_str().parse::<T>() {
            Ok(n) => n,
            _ => panic!()
        }
    }
}

macro_rules! pipe_read {
    ($r: expr, str, $($x: ident),+) => {
        let t = $r.read_str();
        let mut it = t.split(' ');
        $($x = it.next().unwrap();)+
    };
    ($r: expr, $t: ty, $($x: ident),+) => {
        let t = $r.read_str();
        let mut it = t.split(' ').map(|x| x.parse::<$t>().unwrap());
        $($x = it.next().unwrap();)+
    }
}

macro_rules! pipe {
    ($r: expr, str, $($x: ident),+) => {
        pipe_read!($r, str, $($x),+);
    };
    (declare $r: expr, str, $($x: ident),+) => {
        $(let $x: $t;)+
        pipe_read!($r, str, $($x),+);
    };
    ($r: expr, $t: ty, $($x: ident),+) => {
        pipe_read!($r, $t, $($x),+);
    };
    (declare $r: expr, $t: ty, $($x: ident),+) => {
        $(let $x: $t;)+
        pipe_read!($r, $t, $($x),+);
    };
}

const M: usize = 1_000_000;

fn main() {
    let stdin = stdin();
    let stdout = stdout();
    unsafe {
    solve(&mut Reader::new(BufReader::with_capacity(M, stdin.lock())), &mut BufWriter::with_capacity(M, stdout.lock()));
    }
}

const ROWS: usize = 1;
const COLS: usize = 100001;
// static mut dp: [[usize; COLS]; ROWS] = [[0; COLS]; ROWS];
static mut dp: [usize; COLS] = [0; COLS];

unsafe fn solve(r: &mut Reader, w: &mut BufWriter<StdoutLock>) {
    pipe!(declare r, usize, n, w_cap);
    let mut w = Vec::with_capacity(n);
    let mut v = Vec::with_capacity(n);

    for _ in 0..n {
        let t = r.read_str();
        let mut t = t.split(' ').map(|x| x.parse::<usize>().unwrap());
        w.push(t.next().unwrap());
        v.push(t.next().unwrap());
    }

    for (wi, vi) in w.into_iter().zip(v.into_iter()) {
        for ii in (wi..=w_cap).rev() {
            dp[ii] = dp[ii].max(dp[ii-wi]+vi);
        }
    }
    print!("{}", dp[w_cap]);
}


Measured memory_bytes: 2916
def main():
    H,W,K = map(int,input().split())
    S = [input()for _ in range(H)]
    ans = 10**9
    for i in range(2**(H-1)):
        aa = 0
        for j in range(H-1):
            if (i>>j)&1 == 1:
                aa+=1
        c = aa
        b = [0]*(c+1)
        OK = True
        for j in range(W):
            k = 0
            for h in range(H):
                if S[h][j] == "1":b[k] += 1
                if (i>>h)&1==1:k+=1
            
            ok = True
            for p in b:
                if p > K:ok = False
            if not ok:
                aa += 1
                b = [0]*(c+1)
                
                k = 0
                for h in range(H):
                    if S[h][j]=="1":b[k] += 1
                    if (i>>h)&1==1:k+=1
                ok = True
                for p in b:
                    if p > K:ok = False
                if not ok:OK = False;break                
        if OK:ans = min(ans,aa)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
// Problem : D - Chat in a Circle
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n];
		for(int i=0;i<n;++i)
		cin>>arr[i];
		sort(arr,arr+n);
		int sum = arr[n-1];
		int xxx = n-2;
		int ct = 0;
	    if(xxx&1)
	    ++ct;
	    xxx/=2;
	    int i = n-2;
	    while(xxx--)
	    {
	    	sum+=2*arr[i];
	    	--i;
	    }
	    if(ct)
	    sum+=arr[i];
	    cout<<sum<<"\n";
	    	
    }
    return 0;
}


Measured memory_bytes: 5236
# cook your dish here
n=int(input())
a=list(map(int,input().split()))
st=[]
ans=0
for i in range(n):
    if i==0:
        st.append(a[i])
        ans+=1
    else:
        if st[-1]>=a[i]:
            ans+=1
            st.append(a[i])
print(ans)

Measured memory_bytes: 24744
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
using namespace std;
typedef long long int ll;
const int MOD = 1000000007;

int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    if(n < m){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    string ans(n+1, 'z');
    string arr[n-m+1];

    int ng[n-m+1] = {0};
    for(int i = 0; i < n - m + 1; i++){
        for(int j = 0; j < n; j++){
            //比較する
            if(i <= j && j < i+m){
                if(s[j] != '?' && s[j] != t[j-i]){
                    ng[i] = 1;
                    arr[i] = arr[i] + '?';
                }
                else{
                    arr[i] = arr[i] + t[j-i];
                }
            }
            //比較しない
            else{
                if(s[j] == '?'){
                    arr[i] = arr[i] + 'a';
                }
                else{
                    arr[i] = arr[i] + s[j];
                }
            }
        }   
    }

    // for(int i = 0; i < n-m+1; i++){
    //     cout << arr[i] << endl;
    //     cout << ng[i] << endl;
    // }
    
    bool flag = false;
    for(int i = 0; i < n - m + 1; i++){
        if(ng[i] == 0){
            if(ans > arr[i]){
                ans = arr[i];
                flag = true;
            }
        }
    }
    if(flag){
        cout << ans << endl;
    }
    else{
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
map<int,int> dy;
int n,ans,a[100001],b[100001];
int main()
{
	re(n);
	for(int i=1;i<=n;++i)re(a[i]);
	memcpy(b,a,sizeof a);
	sort(b+1,b+n+1);
	for(int i=1;i<=n;++i)
		dy[b[i]]=i;
	for(int i=1;i<=n;++i)
		ans+=(i^dy[a[i]])&1;
	printf("%d\n",ans/2);
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define N 222
using namespace std;
int n,m;
char se[N],ss[N];
int tl[N];
char s[N<<2][N];
int len[N<<2];
inline int getval(int id,int len){
	putchar('?');putchar(' ');
	for(int i=1;i<=len;++i)putchar(s[id][i]);puts("");
	fflush(stdout);
	int x;scanf("%d",&x);return x;
}
inline void solve(int g,int l,int r){
	if(l==r){for(int i=1;i<=tl[l];++i)s[g][i]=se[l];len[g]=tl[l];return;}
	int lc=g<<1,rc=g<<1|1,mid=l+r>>1;
	solve(lc,l,mid);solve(rc,mid+1,r);
	if(!len[lc]&&!len[rc])return;
	len[g]=len[lc]+len[rc];
	for(int i=1,j=1,k=1;i<=len[g];++i){
		if(j>len[lc]){s[g][i]=s[rc][k];++k;}
		else if(k>len[rc]){s[g][i]=s[lc][j];++j;}
		else{
			s[g][i]=s[rc][k];
			for(int o=j,p=i+1;o<=len[lc];++o,++p)s[g][p]=s[lc][o];
			if(n-getval(g,i+len[lc]-j+1)!=i+len[lc]-j+1)s[g][i]=s[lc][j],++j;
			else ++k;
		}
	}
}
int main(){
	int cnt=0;
	for(char a='a';a<='z';++a){
		se[++cnt]=a;
		for(int i=1;i<=128;++i)s[1][i]=a;
		tl[cnt]=128-getval(1,128);n+=tl[cnt];
		if(!tl[cnt])--cnt;
	}
	for(char a='A';a<='Z';++a){
		se[++cnt]=a;
		for(int i=1;i<=128;++i)s[1][i]=a;
		tl[cnt]=128-getval(1,128);n+=tl[cnt];
		if(!tl[cnt])--cnt;
		
	}
	for(char a='0';a<='9';++a){
		se[++cnt]=a;
		for(int i=1;i<=128;++i)s[1][i]=a;
		tl[cnt]=128-getval(1,128);n+=tl[cnt];
		if(!tl[cnt])--cnt;
	}
	solve(1,1,cnt);
	printf("! ");for(int i=1;i<=len[1];++i)putchar(s[1][i]);puts("");fflush(stdout);
	return 0;
}

Measured memory_bytes: 3828
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> arr = new ArrayList<>();

        int n = sc.nextInt();
        int min = 0;
        int max = 0;
        long sum = 0;

        for (int i=0; i<n; ++i) {
            arr.add(sc.nextInt());
        }
        
        for (int i=0; i<arr.size(); ++i) {
            sum += arr.get(i);
            
            if (arr.get(i) > max || i == 0) max = arr.get(i);
            if (arr.get(i) < min || i == 0) min = arr.get(i);
        }

        System.out.println(min + " " + max + " " + sum);
    }
}


Measured memory_bytes: 42948
N = int(input())
As = list(map(int, input().split()))
smallest = min(As)

while True:
    l = []
    for i in range(len(As)):
        if As[i] > smallest and As[i]%smallest > 0:
            l.append(As[i]%smallest)
        elif As[i]== smallest :
            l.append(As[i])
        
    if l == As:
        smallest = min(As)
        break
    else:
        As = l
        smallest = min(As)

print(smallest)




Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << x << '\n'
const int N = 1003;
int n, m, dis[N], par[N];
vector<int> adj[N], ans;
int main(int argc, char const *argv[])
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}
	for (int s = 1; s <= n; ++s)
	{
		queue<int> q;
		memset(dis, -1, sizeof(dis));
		memset(par, -1, sizeof(par));
		q.push(s);
		dis[s] = 0;
		while (!q.empty())
		{
			int u = q.front();
			q.pop();
			for (int v: adj[u])
			{
				if (dis[v] == -1)
				{
					par[v] = u;
					dis[v] = 1 + dis[u];
					q.push(v);
				}
				else if (v == s)
				{
					int cur = u;
					vector<int> temp;
					while (cur != -1)
					{
						temp.push_back(cur);
						cur = par[cur];
					}
					if (temp.size() < ans.size() || ans.empty())
					{
						ans.clear();
						for (int node: temp)
							ans.push_back(node);
					}
				}
			}
		}
	}
	if (ans.empty())
		cout << -1 << '\n';
	else
	{
		cout << ans.size() << '\n';
		for (int nodes: ans)
			cout << nodes << '\n';
	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  vector<vector<int>> A(3,vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> A.at(i).at(j);
  int N; cin >> N;
  vector<int> b(N); rep(i, N) cin >> b.at(i);
  vector<vector<bool>> bingo(3,vector<bool>(3));
  rep(i, N){
    rep(j, 3){
      rep(k, 3){
        if(b.at(i) == A.at(j).at(k)) bingo.at(j).at(k) = true;
      }
    }
  }
  bool ok = false;
  rep(i, 3){
    if(bingo.at(i).at(0) == bingo.at(i).at(1) && bingo.at(i).at(1) == bingo.at(i).at(2) && bingo.at(i).at(1) == true) ok = true;
  }
  rep(i, 3){
    if(bingo.at(0).at(i) == bingo.at(1).at(i) && bingo.at(1).at(i) == bingo.at(2).at(i) && bingo.at(1).at(i) == true) ok = true;
  }
  if(bingo.at(0).at(0) == bingo.at(1).at(1) && bingo.at(1).at(1) == bingo.at(2).at(2) && bingo.at(1).at(1) == true) ok = true;
  if(bingo.at(0).at(2) == bingo.at(1).at(1) && bingo.at(1).at(1) == bingo.at(2).at(0) && bingo.at(1).at(1) == true) ok = true;
  if(ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	string kata;
	int i,j;
	cin>>kata;
	int pjg = kata.length();
	if(pjg==1){printf("YES\n"); return 0;}

	set<char> s;
	set<char>::iterator it;
	int counter[256];
	memset(counter,0,sizeof counter);
	for(i=0;i<pjg;i++){
		s.insert(kata[i]);
		counter[kata[i]]++;
	}
	int ukuran = (int)s.size();
	if(pjg==2){
		if(ukuran==1){
			printf("NO\n");	
		}else{
			printf("YES\n");
		}
		return 0;
	}
	if(pjg>=3 && ukuran<=2){printf("NO\n"); return 0;}
	int batas;
	if(pjg%ukuran==0){batas = pjg/ukuran;}
	else{batas = pjg/ukuran + 1;}

	bool valid = true;
	for(it=s.begin();it!=s.end();it++){
		char kar = *it;
		if(counter[kar]>batas){valid = false; break;}
	}
	if(valid){printf("YES\n");}
	else{printf("NO\n");}
	return 0;
};

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

using namespace std;

int main() {
	int h, n;
	cin >> h >> n;
	while (n--) {
		int a;
		cin >> a;
		h -= a;
	}

	if (h > 0) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())

    if sum((m, f, r)) == -3: break
    if m == -1 or f == -1: print("F")
    elif m + f >= 80: print("A") 
    elif m + f >= 65: print("B") 
    elif m + f >= 50: print("C") 
    elif m + f >= 30: 
        if r >= 50: print("C")
        else: print("D")
    else: print("F")


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second

ll D,G;
ll p[15],c[15];
ll dp[15][1005];
ll ans=mod;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>D>>G;

rep(i,D) cin>>p[i]>>c[i];

rep(x,p[0]+1){
	dp[0][x]=100*x;
	if(x==p[0]) dp[0][x]+=c[0];
}

rep1(i,D){
	rep(x,1002){
		ll mx=0;
		rep(k,p[i]+1){
			ll cmp;
			if(x-k>=0){
				cmp=dp[i-1][x-k]+100*(i+1)*k;
				if(k==p[i]) cmp+=c[i];
			}
			else{
				cmp=0;
			}
			mx=max(mx,cmp);
		}
		dp[i][x]=max(dp[i][x],mx);
	}
}

rep(x,1002){
	if(dp[D-1][x]>=G){
		ans=min(ans,x);
	}
}

cout<<ans<<endl;

}
	


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a, b, c[1000], d; 
cin >> a >> b;
for(int i = 0; i < a; i++)
cin >> c[i];

sort(c,c+a,greater<int>() );
for(int j = 0; j < b; j++ )
d += c[j];
cout << d << endl;
return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define Spa putchar(32)
const int maxn=121111;
int A[maxn];
int read()
{
	int s=0,c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
} 
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
int main()
{
	int N=read(),M=read(),C=read(),lll=0;
	for(int i=1;i<=M;++i) A[i]=read();
	for(int i=1;i<=N;++i)
	{
		int ans=C;
		for(int j=1;j<=M;++j) ans+=(read()*A[j]);
		if(ans>0) ++lll;
	}
	write(lll);
	return 0;
}

Measured memory_bytes: 256
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        long l = 0, r = 0;
        PriorityQueue<int[]> lq = new PriorityQueue<>(Comparator.comparing(x -> x[1]));
        PriorityQueue<int[]> rq = new PriorityQueue<>(Comparator.comparing(x -> x[0]));
        for (int i = 0; i < N; i++) {
            String s = in.next();
            int left = 0, right = 0, tmp = 0;
            for (int j = 0; j < s.length(); j++) {
                if (s.charAt(j) == ')') {
                    if (tmp == 0) {
                        right++;
                    } else {
                        tmp--;
                    }
                } else {
                    tmp++;
                }
            }
            tmp = 0;
            for (int j = s.length() - 1; j >= 0; j--) {
                if (s.charAt(j) == '(') {
                    if (tmp == 0) {
                        left++;
                    } else {
                        tmp--;
                    }
                } else {
                    tmp++;
                }
            }
            if (left == 0) r += right;
            else if (right == 0) l += left;
            else if (left > right) lq.add(new int[]{left, right});
            else rq.add(new int[]{left, right});
        }

        while (!lq.isEmpty()) {
            int[] poll = lq.poll();
            if (l < poll[1]) {
                System.out.println("No");
                return;
            } else {
                l = l - poll[1] + poll[0];
            }
        }

        while (!rq.isEmpty()) {
            int[] poll = rq.poll();
            if (r < poll[0]) {
                System.out.println("No");
                return;
            } else {
                r = r + poll[1] - poll[0];
            }
        }

        System.out.println(l == r ? "Yes" : "No");
    }
}


Measured memory_bytes: 64192
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        mut n: i64,
    }

    if n == 0 {
        println!("0");
        return;
    }

    let mut bottom = vec![];
    let mut vat = vec![];
    let mut up = vec![];
    let mut minv = 0;
    let mut maxv = 0;
    let mut v = 0;
    for i in 0..40 {
        if v == 0 {
            v = 1;
        } else {
            v *= -2;
        }
        if v < 0 {
            minv += v;
        } else {
            maxv += v;
        }
        vat.push(v);
        bottom.push(minv);
        up.push(maxv);
    }

    let mut ans = vec![];

    while n != 0 {
        for i in 0..40 {
            if bottom[i] <= n && n <= up[i] {
                ans.push(i);
                n -= vat[i];
                break;
            }
        }
    }
    let mut ans2 = vec!['0'; ans[0] + 1];
    for &v in &ans {
        ans2[v] = '1';
    }
    println!("{}", ans2.into_iter().rev().collect::<String>());
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
  int a[100][100]={0},b[100]={0},c[100]={0},m,n,i,j;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);
  }
  for(i=0;i<m;i++)
    scanf("%d",&b[i]);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++)
      c[i]+=a[i][j]*b[j];
  }
  for(i=0;i<n;i++)
    printf("%d\n",c[i]);
  return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int res = 0;
    int i_cur=0;
    int n_array = 0;
    for(int i=1;i<N;i++){
        if(S[i]==S[i-1]) continue;
        res += i-i_cur-1;
        i_cur = i;
        n_array++;
    }
    if(S[N-1]==S[N-2]){
        res += N-i_cur-1;
        n_array++;
    }else{
        n_array++;
    }
    res += min(2*K, n_array-1);
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{ // Main
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long a = scanner.nextLong();
		long b = scanner.nextLong();
		long[] health = new long[n];
		for(int i = 0; i < n; i ++) {
			health[i] = scanner.nextInt();
		}
		long min = 1;
		long max = (long) Math.pow(10, 9);
		long ans = 0;
		while(min < max) {
			long med = (min + max) / 2;
			long count = 0;
			for(int i = 0; i < n; i ++) {
				long k = (health[i] - med * b + a - b - 1) / (a - b);
				k = Math.max(0, k);
				count += k;
			}
			if(count <= med) {
				ans = med;
				max = med;
			} else {
				min = med + 1;
			}
		}
		System.out.println(ans);
				
		scanner.close();
	}
}

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

bool solve(long long N, const vector<long long> &a) {
    long long S = 0;
    for (int i = 0; i < N; ++i) S += a[i];
    if (S % (N * (N+1)/2) != 0) return false;
    long long num = S / (N * (N+1)/2);
    for (int i = 0; i < N; ++i) {
        long long b = a[(i+1)%N] - a[i] - num;
        if (b % N != 0 || b > 0) return false;
    }
    return true;
}

int main() {
    long long N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    if (solve(N, a)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main() {
  string s1, s2; cin >> s1 >> s2;
  for (int i = 0; i < 3; i++) {
    if (s1[i] != s2[2-i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
double a,b,x;
double PI=acos(-1.0);
int main()
{
	scanf("%lf%lf%lf",&a,&b,&x);
	double S=x/a;
	if (2*S<=a*b)
	{
		double now=2*S/(b*b);
		double k=atan(now);
		printf("%.10lf",90-k*180/PI); 
	}
	else
	{
		double SS=a*b-S;
		b=SS*2/a;
		double now=a/b;
		double k=atan(now);
		printf("%.10lf",90-k*180/PI); 
	}
	return 0;
}

Measured memory_bytes: 256