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

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define INFL 2000000000000000000LL
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;

bool rev = false;
vc s;
int l, r;

void move(vc &s) {
	if (s[l] == (rev ? 'B' : 'A')) {
		s[l] = (rev ? 'A' : 'B');
		return;
	}
	l++;
	r++;
	rev = !rev;
	s[r] = (rev ? 'B' : 'A');
}

int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;
	s = vc(3*N+100);
	l = 0;
	r = N - 1;
	rep(i, N)s[i] = S[i];
	rep(i, K) {
		if (i == 2 * N) {
			// あとK-2N回
			if (s[0] == (rev ? 'B' : 'A')) {
				// 周期2
				if ((K - 2 * N) % 2 == 1)move(s);
			}
			break;
		}
		move(s);
	}
	if (rev) {
		repl(i, l, r + 1) {
			printf("%c", s[i] == 'A' ? 'B' : 'A');
		}
	}
	else {
		repl(i, l, r + 1) {
			printf("%c", s[i]);
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>

int main(void)
{
    int input[10], output[3], i, j, k;

    for(i = 0; i < 10; ++i)
    {
        scanf("%d", &input[i]);
    }

    for(i = 0; i < 3; ++i)
    {
        output[i] = -1;

        for(j = 0; j < 10; ++j)
        {
            if(output[i] < input[j])
            {
                output[i] = input[j];
                k = j;
            }
        }

        input[k] = -2;
    }

    for(i = 0; i < 3; ++i)
    {
        printf("%d\n", output[i]);
    }

    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    loop(i,1,10)loop(j,1,10){
        if(i*j == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    sort(A.begin(),A.end());
    vector<bool> num(1e6+1,true);
    int ans = 0;
    for(int i=0;i<N;i++){
        if (!num[A[i]]) continue;
        for (int j=A[i];j<1e6+1;j+=A[i]){
            num[j] = false;
        }
        if (i<N-1){
            if (A[i+1] == A[i]){
                continue;
            }
        }
        ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4340
import numpy as np
n,k=map(int, input().split())
p=list(map(int,input().split()))


s=[]
p=np.array(p)
sum=0
for i in range(n):
  sum+=(1+p[i])/2
  s.append(sum)
#print(s)
if k==n:
  print(s[-1])
  exit()
max=s[k-1]-s[0]
for j in range(1,n-k):
  #print(j)
  if max<= s[j+k]-s[j]:
    max=s[j+k]-s[j]
  
print(max)

Measured memory_bytes: 50424
#include<stdio.h>
int main(void){
	int i,j,n,u,k,tmp,adj[100][100]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d",&tmp);
			adj[u-1][tmp-1]=1;
		}
	}
	for(i=0;i<n;i++){
		printf("%d",adj[i][0]);
		for(j=1;j<n;j++){
			printf(" %d",adj[i][j]);
		}
		printf("\n");
	}
	return 0;
}		

Measured memory_bytes: 652
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  
  int n; 
  cin>>n ;
  int a[n] ;

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

int ans = 1 ;
int next = a[0] ;
while (next!=2)
{
  next = a[next-1] ;
  ans++ ;
  if(ans>=100000) break ;
}

if(ans==100000)
cout << -1 << endl ;
else 
cout << ans << endl ;

return 0 ;

}

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

int main()
{
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  vector<int> AC;
  
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if( S[i-1] == 'A' && S[i] == 'C' && i > 0 ){ cnt++; }
    AC.push_back(cnt);
  }
  
  int l, r;
  for(int q = 0; q < Q; q++){
    cin >> l >> r;
    cout << AC[r-1] - AC[l-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N, H;
    cin >> N >> H;
    vector<pair<ll,ll>> ba(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> ba.at(i).second >> ba.at(i).first;
    }
    
    sort(ba.begin(), ba.end(), greater<pair<ll,ll>> ());

    ll maxa = zero;
    for (ll i = 0; i < N; i++)
    {
        maxa = max(ba.at(i).second , maxa);
    }
    
    ll tmp, cnt;
    cnt = zero;
    for (ll i = 0; i < N; i++)
    {
        tmp = ba.at(i).first;
        if(tmp >= maxa){
            H -= tmp; cnt++;
        }
        else{
            break;
        }
        if(H<=0) break;
    }
    if(H > 0) cnt += 1 + (H-1)/maxa;
    printf("%lld\n", cnt);
    


}


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

int main() {
    int a,b;
    cin >> a >> b;
    int count = 0;
    for(int i = a;i<=b;i++) {
        string tmp;
        stringstream ss;
        ss << i;
        ss >> tmp;
        if(tmp[0] == tmp[4] && tmp[1] == tmp[3]) {
            count++;
        }
    }
    cout << count << endl;
}

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

int main(){
    
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if (s<t){
         cout << "Yes" << endl;
     }else{
         cout << "No" << endl;
     }

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
int F[105][5][2];
int P[105][11];

int ans = -INF;

/*==================================================*/
/*function*/
/*==================================================*/

int main() {

    cin>>N;
    REP(i,0,N){
        REP(j,0,5){
            cin>>F[i][j][0]>>F[i][j][1];
        }
    }

    REP(i,0,N)REP(j,0,11){
        cin>>P[i][j];
    }

    REP(state, 1, (1<<10)){
        int ttt = 0;

        REP(i,0,N){
            int d = 0;
            REP(j,0,5){
                REP(k,0,2){
                    //組み合わせのみが重要であるため順番は逆順でもよい
                    //if( ((state & (1<<((4-j)*2+(1-k)))) != 0) & (F[i][j][k] == 1) ) d++;
                    if( (((state>>(j*2+k))&1) == 1) & (F[i][j][k] == 1) ) d++;
                }
            }
            ttt += P[i][d];

        }

        ans = max(ans, ttt);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    multiset<int>st;
    multiset<int>::iterator itr;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int now=a[i];
        itr=st.upper_bound(-now);
       // cout<<"paise "<<*itr<<endl;
        if(itr!=st.end())
        {
            //cout<<"1st "<<endl;
            int ase=*itr;
            st.erase(itr);
            st.insert(-now);
        }
        else
        {
           // cout<<"2nd "<<endl;
            ans++;
            st.insert(-now);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5376
#include<stdio.h>
#define N 200000
 
int main(){
 
  int i,n,maxv,minv;
  int arr[N];
   
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }
   
  maxv = arr[1] - arr[0];
  minv = arr[0];
   
  for(i=1;i<n;i++){
    if(maxv<arr[i]-minv){  
    maxv = arr[i]-minv;
    }
    if(minv>arr[i]){
      minv = arr[i];
    }
  }
     
  printf("%d\n",maxv);
 
  return 0;
}

Measured memory_bytes: 1376
#include <iostream>

using namespace std;
int main(){
  int n,a,b,c,d;
  std::cin >>n>>a>>b>>c>>d;
  int min;
  int set_x,set_y;
  if(n%a==0){
    set_x=n/a;
  }else{
    set_x=n/a+1;
  }
  if(n%c==0){
    set_y=n/c;
  }else{
    set_y=n/c+1;
  }

  if(b*set_x<d*set_y){
    min=b*set_x;
  }else{
    min=d*set_y;
  }

  std::cout << min << '\n';

}


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

using namespace std;


int q_sort(int d[],int left,int right){
	if(left >= right) return 0;
	int pipot = d[(left+right)/2], l = left, r = right, tmp;
	while(l<r){
		while(d[l] < pipot) l++;
		while(d[r] > pipot) r--;
		if( l <=  r){
			tmp = d[l];
			d[l] = d[r];
			d[r] = tmp;
			l++;
			r--;
		}
	}
	q_sort(d,left,r);
	q_sort(d,l,right);
}

int main(void)
{
	int n,k;
	cin>>n>>k;
	int p[n];
	int w[n-k+1];
	w[0] = 0;
	int i;
	for(i=0; i < n; i++) cin>>p[i];
	for(i=0;i<k;i++)w[0]+=p[i];
	for(i = 0; i <= n-k;i++){
		w[i+1] = w[i] - p[i] + p[i+k];
	}
	q_sort(w,0,n-k);
	double ans;
	ans = (double)w[n-k] + (double) k;
	ans = ans / 2.0;
	printf("%lf\n",ans);
	return 0;
}



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

int main() {
int n, w;
scanf("%d %d", &n, &w);
vector<int > wt(n), val(n);
long long valm =0, ans=0;
for(int i=0; i<n; ++i){
	scanf("%d %d",&wt[i] , &val[i]);
	valm+=val[i];
}


vector< vector< long long> > dp(n+1, vector<long long> (valm+1));
dp[0][0]=0;
for(int i=1; i<=valm; ++i) dp[0][i]=1e18;


for(int i=1; i<=n; ++i){
	for(long long j=1; j<=valm; ++j){
		dp[i][j] = dp[i-1][j];
		if(val[i-1]<=j){
			dp[i][j] = min(dp[i][j], dp[i-1][j-val[i-1]] + wt[i-1]);
		}
		
		if(dp[i][j]<=w) ans = max(ans,j);
	}
}

printf("%ld\n", ans);
	
	

	return 0;
}


Measured memory_bytes: 83132
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	int n; cin >> n;
  	string s, t; cin >> s >> t;
  	for (int i = 0; i < n; ++i) {
    	cout << s[i] << t[i];
    }
  	cout << endl;
}

Measured memory_bytes: 256
import sys
import collections
import itertools

sys.setrecursionlimit(10 ** 8)
inm = lambda: map(int, sys.stdin.readline().split())
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

N, A, B = inm()


def solve():
    if A + B > N + 1:
        return None
    a, b = N, 1
    b += B - 1
    a -= B - 1
    # a=N-B+1, b=B

    s = []
    s.append(range(B, 0, -1))
    la = 1
    p = B + 1  # 1-indexed
    ra = N - p + 1
    # debug(f"{p=} {la=} {ra=} {la+ra=}")
    while la + ra > A:
        p2 = p + min(B, la + ra - A + 1)
        s.append(range(p2 - 1, p - 1, -1))
        p = p2
        la += 1
        ra = N + 1 - p
        # debug(f"{p=} {la=} {ra=} {la+ra=}")
        if la == A and ra > 0:
            return None
    assert la + ra == A
    s.append(range(p, N + 1))
    return list(itertools.chain.from_iterable(s))


ans = solve()
if ans is None:
    print(-1)
else:
    print(*ans)


Measured memory_bytes: 22076
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll n,a,ans=0;
    cin>>n;
    map<ll,ll> lmp,smp;
    rep(i,n){
        cin>>a;
        if(i<n-1) smp[i+a]++;
        if(i>0) lmp[i-a]++;
    }
    for(auto x:smp) ans+=x.second*lmp[x.first];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 37924
package main
import "fmt"
func main() {
  var a,b,m int
  fmt.Scan(&a,&b)
  m = 0
  if a < b {
    m += b
    b--
  } else {
    m += a
    a--
  }
  if a < b {
    m += b
    b--
  } else {
    m += a
    a--
  }
  fmt.Println(m)
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m = MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
void solve(){
   int n;
   cin >> n;
   map<int,int> m;
   if ( n == 1){
	      cout << 1 << endl;
	      return; 
	  }
   for(int i = 1; i <= n; i++){
	      int ret = i,cnt=0;
	      if ( ret % 2 == 0){
			  while ( ret % 2 == 0){
				   ret /= 2;
				   cnt++; 
				 } 
			 }
		m[i] = cnt;
	  }
  int ret, mx = 0;
  for(auto it : m) {
	  if( it.s > mx){
		    mx = it.s;
		    ret = it.f; 
		 }
  }
  cout << ret << endl; 	
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


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

int a[110];

int main(){
    int N,c=0,f=1;
    cin>>N;
    for(int i=0;i<N;i++) cin>>a[i];
    while(f){
        f=0;
        for(int i=N-1;i>=1;i--){
            if(a[i]<a[i-1]){
                swap(a[i],a[i-1]);
                c++;
                f=1;
            }
        }
    }
    for(int i=0;i<N;i++){
        if(i==N-1) cout<<a[i]<<endl;
        else cout<<a[i]<<" ";
    }
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 3080
#import numpy as np
n=int(input())
strl=[list(input()) for i in range(n)]

count=0
pt={}
#il=np.arange(n)
for i in range(n) :
  sal=strl[i]
  sal.sort()
  temp="".join(sal)
  if temp in pt.keys() :
    #ptがある
    tempc=pt[temp]
    count+=tempc
    pt[temp]=tempc+1
  else :
    pt[temp]=1
print(count)
#print(count)



Measured memory_bytes: 39040
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

bool connected[10][10];
bool visited[10];
int cnt=0;
int N,M,a,b;

bool isAllVisited(int N){
    Rep(i,N){
        if (visited[i]==false) return false;
    }
    return true;
}


void dfs(int now){
    if (isAllVisited(N)==true){
        cnt ++;
        return;
    }
    Rep(i,N){
        if(!connected[now][i]) continue;
        if (visited[i]) continue;
        visited[i] = true;
        dfs(i);
        visited[i] = false;
    }
    return;
}

int main(){
    cin >> N >> M;

    rep(i,10){
        rep(j,10){
            connected[i][j] = false;
        }
    }

    rep(i,M){
        cin >> a >> b;
        connected[a][b] = connected[b][a] = true;
    }

    visited[1] = true;
    dfs(1);
    cout << cnt << endl;

    return 0;
}


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

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

    int n;
    string s;
    cin >> n >> s;

    int maxi = 0;
    for(int i = 1; i < n; i++){
        map<char, int> mp1, mp2;
        for(int j = 0; j < i; j++){
            mp1[s[j]]++;
        }
        for(int j = i; j < n; j++){
            mp2[s[j]]++;
        }
        int cnt = 0;
        for(auto x : mp1){
            for(auto y : mp2){
                if(x.first == y.first){
                    cnt++;
                }
            }
        }
        maxi = max(maxi, cnt);
    }
    cout << maxi << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

//////////////////////////////////////////////////
//nCr Calculation/////////////////////////////////
//////////////////////////////////////////////////
static const ll FACT_SIZE = 1000000;
ll fact[FACT_SIZE] = {};

ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	else return t * t % MOD;
}
void factorial(ll f) {
	fact[0] = fact[1] = 1;
	rep(i, 1, FACT_SIZE) fact[i] = fact[i - 1] * i % MOD;
}

ll nCr(ll n, ll r) {
	if (fact[0] == 0)	factorial(1000000);
	return ((fact[n] * (Pow(fact[r], MOD - 2) % MOD)) % MOD * Pow(fact[n - r], MOD - 2)) % MOD;
}

ll a[100001] = {};
int main() {
	ll n; cin >> n;
	ll maxV = 0;
	rep(i, 0, n) {
		cin >> a[i];
		maxV = max(maxV, a[i]);
	}

	sort(a, a + n);

	ll d = (double)MAX_L;
	ll middle = (double)(maxV / 2);
	ll ans = 0;

	rep(i, 0, n) {
		if (a[i] != maxV) {
			ll diff = abs(maxV - a[i] * 2);
			if (d >= diff) {
				d = diff;
				ans = a[i];
			}
		}
	}

	cout << maxV << " " << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C;
  cin>>N>>M>>C;
  vector<vector<int>> S(N+1,(vector<int>(M)));
  int sum=0;
  for(int i=0;i<N+1;i++){
    for(int j=0;j<M;j++){
      cin>>S.at(i).at(j);
    }
    if(i>0){
      int ans=0;
      for(int k=0;k<M;k++){
        ans+=S.at(0).at(k)*S.at(i).at(k);
      }
      if(ans+C>0){
        sum++;
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
  
#define NIL NULL
  
struct node{
  struct node *r;
  struct node *l;
  struct node *parent;
  int key;
};
  
typedef struct node * Node;
  
Node root;
 
void pre(Node);
void ino(Node);
void ins(int);
void tD(Node);
Node tSuc(Node);
Node tM(Node);
Node tS(Node,int);
 
int main(){
  int n, i, x;
  char c[20];
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", c);
    if ( c[0] == 'f' ){
      scanf(" %d", &x);
        
      Node t = tS(root, x);
        
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( c[0] == 'i' ){
      scanf("%d", &x);
      ins(x);
    }
    else if(c[0] == 'p' ){
      ino(root);
      printf("\n");
      pre(root);
      printf("\n");
    }
    else if(c[0] == 'd'){
      scanf("%d", &x);
      tD(tS(root, x));
    }
  }
    
  return 0;
}
 
 
Node tM(Node x){
  while(x->l != NIL){
    x = x->l;
  }
  return x;
}
  
Node tS(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->l;
    else u = u->r;
  }
  return u;
}
  
Node tSuc(Node x){
  Node y;
  
  if(x->r != NIL) return tM(x->r);
    
  y = x->parent;
    
  while(y != NIL && x == y->r){
    x = y;
    y = y->parent;
  }
  return y;
}
  
void tD(Node z){
  Node y;
  Node x;
    
  if(z->l == NIL || z->r == NIL) y = z;
  else y = tSuc(z);
    
  if(y->l != NIL) x = y->l;
  else x = y->r;
    
  if(x != NIL) x->parent = y->parent;
    
  if(y->parent == NIL) root = x;
  else if(y == y->parent->l) y->parent->l = x;
  else y->parent->r = x;
    
  if(y != z){
    z->key = y->key;
      
  } 
}
  
void ins(int k){
  Node y = NIL;
  Node x = root;
  Node z;
    
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  
  while(x != NIL){
    y = x;
  
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  z->parent = y;
    
  if(y == NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z; 
}
  
void ino(Node k){
  if(k != NIL){
    ino(k->l);
    printf(" %d", k->key);
    ino(k->r);
  }
}
  
void pre(Node k){
  if(k != NIL){
    printf(" %d", k->key);
    pre(k->l);
    pre(k->r);
  }
}

Measured memory_bytes: 19364
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		
		if (W >= x+r && H >= y+r && x-r >= 0 && y-r >= 0){
			System.out.println("Yes");}
		else{
			System.out.println("No");}
	}
}


Measured memory_bytes: 26288
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> A(N + 2, 0);
	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
	}

	int T = 0;
	for (int i = 0; i < N + 1; ++i) {
		T += abs(A[i] - A[i + 1]);
	}

	for (int i = 0; i < N; ++i) {
		int ans = T;
		ans -= abs(A[i] - A[i + 1]);
		ans -= abs(A[i + 1] - A[i + 2]);
		ans += abs(A[i] - A[i + 2]);
		cout << ans << endl;
	}
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n;
    cin >> n;
    vi d1(n), d2(n), r(n, 0);
    rep(i, n){
        cin >> d1[i] >> d2[i];
        if(d1[i] == d2[i]) r[i] = 1;
    }
    bool ok = false;
    ll cont = 0;
    rep(i, n){
        if(r[i] == 1) cont++;
        else cont = 0;
        if(cont >= 3) ok = true;
    }
    ok ? Yes() : No();
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
    int bingo[3][3];
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            cin>>bingo[i][j];
    int N,b;
    cin>>N;
    for (int i=0;i<N;i++){
        cin>>b;
        for(int q=0;q<3;q++)
            for(int k=0;k<3;k++){
                if (bingo[q][k]==b){
                    bingo[q][k]=0;
                }
            }

    }

    if(bingo[0][0]==0&&bingo[1][1]==0&&bingo[2][2]==0)
        cout<<"Yes";
    else if(bingo[0][1]==0&&bingo[1][1]==0&&bingo[2][1]==0)
        cout<<"Yes";
    else if(bingo[0][2]==0&&bingo[1][1]==0&&bingo[2][0]==0)
        cout<<"Yes";
    else if(bingo[1][0]==0&&bingo[1][1]==0&&bingo[1][2]==0)
        cout<<"Yes";
    else if(bingo[0][0]==0&&bingo[0][1]==0&&bingo[0][2]==0)
        cout<<"Yes";
    else if(bingo[0][2]==0&&bingo[1][2]==0&&bingo[2][2]==0)
        cout<<"Yes";
    else if(bingo[2][0]==0&&bingo[2][1]==0&&bingo[2][2]==0)
        cout<<"Yes";
    else if(bingo[0][0]==0&&bingo[1][0]==0&&bingo[2][0]==0)
        cout<<"Yes";
    else
        cout<<"No";

}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int lmax = 0;
		int rmin = n;
		for(i = 0; i < m; i++) {
			lmax = Math.max(lmax, Integer.parseInt(sc.next()));
			rmin = Math.min(rmin, Integer.parseInt(sc.next()));
		}
		sc.close();
		sc = null;
		int ans = rmin-lmax+1;
		if(ans < 0) ans = 0;
		System.out.println(ans);
	}
}

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

int ar[1000005];

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


Measured memory_bytes: 4300
P = 998244353
fa = [1]
for i in range(1, 3000100):
    fa.append(fa[-1]*i%P)
fainv = [pow(fa[-1], P-2, P)%P]
for i in range(1, 3000100)[::-1]:
    fainv.append(fainv[-1]*i%P)
fainv = fainv[::-1]

def C(a, b):
    return fa[a]*fainv[a-b]*fainv[b]%P

N, M = map(int, input().split())
if N == 2:
    print(M+1)
else:
    ans = C(3*M+N-1, N-1)
    for K in range(2*M+1, 3*M+1):
        ans = (ans - N*C(3*M-K+N-2, N-2)) % P
    for K in range(M):
        if 3*M-K*2 <= N:
            ans = (ans - C(K+N-1, N-1)*C(N, 3*M-K*2)) % P
    print(ans)

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

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

const int MOD = 1e+9 + 7;

int main()
{
    int N, C;
    cin >> N >> C;
    vector<int> A(N), B(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];

    // coeff[i][j] = 0^i + 1^i + ... + j^i
    vector<vector<long long>> coeff(C+1, vector<long long>(401, 1));
    // まず coeff[i][j] = j^i とする
    REP(i, C){
        FOR(j, 1, 401) coeff[i+1][j] = coeff[i][j]*j % MOD;
    }
    // 累積和
    REP(i, C+1){
        REP(j, 400){
            coeff[i][j+1] += coeff[i][j];
            coeff[i][j+1] %= MOD;
        }
    }

    // dp[i][j]: A[1] ~ A[i] までを使って次数が j になる項の和 
    vector<vector<long long>> dp(N+1, vector<long long>(C+1));
    dp[0][0] = 1;
    REP(i, N){
        REP(j, C+1){
            REP(k, j+1){
                dp[i+1][j] += (dp[i][j-k]*(coeff[k][B[i]]-coeff[k][A[i]-1])) % MOD;
                dp[i+1][j] %= MOD;
            }
        }
    }
    cout << (dp[N][C]+MOD)%MOD << endl;


    return 0;
}

Measured memory_bytes: 2816
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			TrainEvent[] events = new TrainEvent[2*n];
			
			for(int i = 0; i < events.length; i+=2){
				String[] tmpArray = br.readLine().split(" ");

				events[i] = new TrainEvent(tmpArray[0], TrainEvent.DEPART);
				events[i + 1] = new TrainEvent(tmpArray[1], TrainEvent.ARRIVE);
				
			}
			
			System.out.println(solve(events));
			
		}
	}
	
	static int solve(TrainEvent[] events){
		
		int result = 0;
		Arrays.sort(events);
		
		int running = 0;
		//debug
		for(int i = 0; i < events.length ; i++){
			//System.out.println(events[i].time);
			if(events[i].type == TrainEvent.DEPART){
				running++;
				result = Math.max(running, result);
			}
			else {
				running--;
			}
		}
		
		return result;
	}

}

class TrainEvent implements Comparable<TrainEvent>{
	String time;
	int type;
	static final int DEPART = 1;
	static final int ARRIVE = 0;
	
	public TrainEvent(String time, int type){
		this.time = time;
		this.type = type;
	}

	@Override
	public int compareTo(TrainEvent event) {
		// TODO Auto-generated method stub
		return time.equals(event.time) ? this.type - event.type : time.compareTo(event.time);
	}
}



Measured memory_bytes: 64332
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    l, r, d = map(int, input().split())

    cnt = 0

    for i in range(l, r+1):
        if i % d == 0:
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    resolve()



Measured memory_bytes: 61696
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if ((a == b && b == c) || (a!=b && b!=c && a!=c)){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
 
 
using namespace std;
 
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()
const long MOD = pow(10, 9) + 7;
 
char alfa[] = { 'A','B' ,'C','D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y','Z' };
 
inline void finish() {
	cout << -1 << endl;
	exit(0);
}
 
unsigned GetDigit(unsigned num) {
	return log10(num) + 1;
}
 
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;
}
 
class Mod {
public:
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}
 
	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}
 
	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}
 
	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};
 
 
template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (ll i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}
 
void Main();
inline void DebugMain() {
	while (true) {
		Main();
	}
}
 
int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
 
	bool debug = false;
	if (debug) {
		cout << "\x1b[41m" << "Debug Mode " << endl;
	}
	(debug) ? DebugMain() : Main();
	return 0;
}
 
class man
{
public:
	int A;
	vector<pii> X;
	bool HeIsTrue;
private:
	
};
 
inline void Main() {
		ll X, Y, N;
		vector<ll> A;
		ll M1, D1, M2, D2;
		ll ans;
		ll sum=0,count =0;
		string S;
		string S2;
		int b[60];
		bool flag = false;
	
		cin >> N;
		
		for (int i = 0; i < 60; i++) {
			b[i] = 0;
		}
 
		for (int i = 0; i < N; i++) {
			cin >> X;
			for (int j = 0; j <60; j++) {
				if(X & (ll)1<<j) {
					b[j]++;
				}
			}
		}
 
 
 
		for (int i = 0; i < 60; i++) {
			sum = (sum + ((((N - b[i]) * (b[i]))%MOD) * ((ll)pow(2, i) % MOD)) % MOD) % MOD;
		}
		cout << sum;
}

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

int main(void){
	string str;
	int mt=0,ml=0;
	string ms,mst;
	map<string,int> m;

	while(cin>>str){
		if(str.length()>ml){
			ml=str.length();
			ms=str;
		}
		m[str]++;
	}
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
		if(it->second>mt){
			mt=it->second;
			mst=it->first;
		}
	}
	cout<<mst<<" "<<ms<<endl;

}

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

int main() {
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  char hand[3] = { 'r', 's', 'p' };
  int po[3]    = { r, s, p };
  int ans      = 0;
  string h     = "";
  for (int i = 0; i < n; i++) {
	  for (int j = 0; j < 3; j++) {
		  if (t[i] == hand[j]) {
			  if (i >= k && t[i] == h[i - k]) {
				  h = h + 'a';
				  continue;
				}
			  ans += po[(j + 2) % 3];
			  h    = h + hand[j];
			}
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 864
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

string S;

const string R1 = "iw(){}[]";
const string R2 = "iw)(}{][";

bool solve(string T)
{
	int is = 0, ws = 0;

	for (int i = 0; i < T.size(); i++)
	{
		if (T[i] == 'i') is++;
		if (T[i] == 'w') ws++;
	}

	if (!(is == 2 && ws == 1)) return false;

	bool flag = false;

	for (int i = 0; i < (int)(T.size()) - 2; i++)
	{
		if (T.substr(i, 3) == "iwi")
		{
			flag = true;
		}
	}

	if (!flag) return false;

	if (T.size() % 2 == 1)
	{
		char middle = T[T.size() / 2];

		if (!(middle == 'i' || middle == 'w')) return false;
	}

	for (int i = 0; i < T.size(); i++)
	{
		char c1 = T[i];
		char c2 = T[T.size() - i - 1];

		for (int j = 0; j < 8; j++)
		{
			if (R1[j] == c1)
			{
				if (R2[j] != c2)
				{
					return false;
				}
			}
		}
	}

	return true;
}

int main()
{
	cin >> S;

	int ret = 0;

	for (int i = 0; i < (1 << S.size()); i++)
	{
		string T;

		for (int j = 0; j < S.size(); j++)
		{
			if (i & (1 << j))
			{
				T += S[j];
			}
		}

		if (solve(T))
		{
			ret = max(ret, (int)(T.size()));
		}
	}

	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 3328
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

int n;
vector<ll> v;
set<ll> s1;
set<ll> s2;
ll ans = 0;
void compute()
{
    s1.insert(0);
    s1.insert(n+1);
    s2.insert(0);
    s2.insert(-n-1);
    rep(i,1,n+1)
    {
        auto it1 = s1.lower_bound(v[i]);
        auto it2 = s2.lower_bound(-v[i]);
        ans = ans + ((ll)(i))*(v[i] + *it2)*(*it1 - v[i]);
        s1.insert(v[i]);
        s2.insert(-v[i]);
    }
}
void solve()
{
    cin>>n;
    v.resize(n+1);
    rep(i,1,n+1)
    {
        int x; cin>>x;
        v[x] = i;
    }
    compute();
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

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

#define MAX 200004

char buf[MAX];
string s;

deque<int> v[MAX];

vector<pair<int, int> > star[MAX];

struct st {
	int bit[MAX];
	void add(int i, int x) {
		i++;
		while (i < MAX) {
			bit[i] += x;
			i += i&-i;
		}
	}
	int sum(int i) {
		int r = 0;
		i++;
		while (i) {
			r += bit[i];
			i -= i&-i;
		}
		return r;
	}
	st() {
		memset(bit, 0, sizeof(bit));
	}
};

st k;

int main() {
	scanf("%s", buf);
	s = buf;
	for (int i = 0; i < s.size(); i++) {
		v[s[i] - 'a'].push_back(i);
	}
	int cnt = 0;
	for (int i = 0; i < 26; i++) {
		cnt += v[i].size() % 2;
	}
	if (cnt > 1) {
		puts("-1");
		return 0;
	}
	long long int add = -1;
	for (int i = 0; i < 26; i++) {
		while (v[i].size() > 1) {
			int lef = v[i][0];
			v[i].pop_front();
			int rig = v[i].back();
			v[i].pop_back();
			star[lef].push_back(make_pair(rig, i));
		}
		if (v[i].size() == 1) {
			add = v[i][0];
		}
	}
	long long int way = 0;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < star[i].size(); j++) {
			
			int en = star[i][j].first;
			if (add != -1) {
				if (i >= add || en <= add) {
					way++;
				}
			}
			way += k.sum(en) - k.sum(i);
			way += k.sum(i) * 2;
			k.add(en, 1);
		}
	}
	//way += add;
	printf("%lld\n", way);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> P(0);
  vector<pair<int, int>> M(0);
  int l, r, pp, pm, pos, n, b, h;
  string s;
  bool flgL = true, flgR = true;
  for (int i=0;i<N;i++){
    cin >> s;
    b = 0, h = 0;
    n = s.size();
    for (int j=0;j<n;j++){
      if (s[j] == '('){
        h++;
      }
      else{
        h--;
        if (b > h){
          b = h;
        }
      }
    }
    if (h < 0){
      M.push_back(make_pair(b-h, -h));
    }
    else if (h == 0){
      if (b < 0){
        M.push_back(make_pair(b-h, -h));
      }
      else{
        P.push_back(make_pair(b, h));
      }
    }
    else{
      P.push_back(make_pair(b, h));
    }
  }
  sort(P.rbegin(), P.rend());
  sort(M.rbegin(), M.rend());
  l = P.size(), r = M.size();
  pp = 0, pm = 0;
  for (int i=0;i<l;i++){
    if (P[i].first + pp < 0){
      flgL = false;
      break;
    }
    else{
      pp += P[i].second;
    }
  }
  for (int i=0;i<r;i++){
    if (M[i].first + pm < 0){
      flgR = false;
      break;
    }
    else{
      pm += M[i].second;
    }
  }
  if (flgL && flgR && pp == pm){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 11152
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

vector<vector<P>> G(20);
vector<bool> visited(20);

int tsum;
int chsum;
int ans = 1e9;

void dfs(int cv, int ptime){
    visited[cv] = true;

    bool haveChild = false;

    for(auto x : G[cv]){
        int nv, ntime;
        tie(nv, ntime) = x;

        if(!visited[nv]){
            haveChild = true;
            dfs(nv, ntime);
        }
    }

    if(!haveChild){
        chsum += ptime;
    }
}

void dfs2(int cv, int sum, int ptime){
    visited[cv] = true;

    bool haveChild = false;

    for(auto x : G[cv]){
        int nv, ntime;
        tie(nv, ntime) = x;

        if(!visited[nv]){
            haveChild = true;
            dfs2(nv, sum + ntime, ntime);
        }
    }

    if(!haveChild){
        ans = min(ans, tsum * 2 - (sum - ptime));
    }
}

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        for(int i=0; i<n-1; i++){
            int a, b, t; cin>>a>>b>>t;
            a--, b--;
            G[a].emplace_back(b, t);
            G[b].emplace_back(a, t);
            tsum += t;
        }

        dfs(0, 0);
        tsum -= chsum;
        for(int i=0; i<20; i++){
            visited[i] = false;
        }

        dfs2(0, 0, 0);

        cout << ans << endl;

        tsum = 0;
        chsum = 0;
        ans = 1e9;
        for(int i=0; i<20; i++){
            G[i].clear();
            visited[i] = false;
        }
    }
}


Measured memory_bytes: 3012
import itertools

n = int(input().split()[0])

a_matrix = []
a_matrix.append(list(map(int, input().split())))
a_matrix.append(list(map(int, input().split())))

max_cost = -float('inf')

for i in range(n):
    cost_list = []
    cost_list.append(a_matrix[0][:i+1])
    cost_list.append(a_matrix[1][i:])
    cost_list = list(itertools.chain.from_iterable(cost_list))
    if sum(cost_list) > max_cost:
        max_cost = sum(cost_list)

print(max_cost)


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

typedef long long ll;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll>A(N);
    vector<pair<ll, ll>>cb(M);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> cb[i].second >> cb[i].first;
    }
    sort(A.begin(), A.end());
    sort(cb.begin(), cb.end(), greater<pair<ll,ll>>());

    int p = 0;
    int q = cb[0].second;
    int r = 0;
    while (true) {
        if (A[p] < cb[r].first) {
            A[p] = cb[r].first;
            q--;
            p++;
        } else {
            break;
        }
        if (q <= 0) {
            r++;
            q = cb[r].second;
            if (r >= M) {
                break;
            }
            q = cb[r].second;
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += A[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
n, m  = map(int, input().split())

if n == 1:
  print(1)
  exit()

f = [0 for i in range(n)]
f[-2:] = [1, 1]
for i in range(m):
  f[int(input())-1] = -1

div_num = 1000000007

for i in range(n-2)[::-1]:
  if f[i] == -1:
    continue
  if f[i+1] == -1 and f[i+2] == -1:
    print(0)
    exit()
  elif f[i+1] == -1 and f[i+2] != -1:
    f[i] = f[i+2]
  elif f[i+1] != -1 and f[i+2] == -1:
    f[i] = f[i+1]
  else:
    f[i] = f[i+1]+f[i+2]

if f[0] != -1 and f[1] != -1:
  print(int((f[0]+f[1])%div_num))
elif f[0] == -1 and f[1] != -1:
  print(int(f[1]%div_num))
elif f[0] != -1 and f[1] == -1:
  print(int(f[0]%div_num))
else:
  print(0)

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

int main() {
  int a;
  cin >> a; //二進数で0から111までのいずれかを入力
  
  int hundred, ten, one;
  one = a % 10; //一の位、10で割った余り
  ten = (a - one) % 100 /10; //十の位
  hundred = (a - one - ten) /100; //百の位
    
  cout << one + ten + hundred << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int n,cnt;
    double k;
    cnt=0;
    cin>>n>>k;
    while (n--)
    {
        int x,y;
        cin>>x>>y;
        double dis=sqrt(x*x+y*y);
        if (dis<=k) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3804
#include <vector>
#include <iostream>

using namespace std;

int main(){
  int a, flag;
  vector<int> prime_list;
  prime_list.push_back(2);
  // cout << "starting aaa" << endl;
  int size;
  for(int i=3; i<=123456*2; i+=2){
    flag = 0;
    size = prime_list.size();
    for(int j=0; j<size; j++){
      if((i % prime_list[j]) == 0){
        flag = 1;
        break;
      }
    }
    if (flag == 0){
      prime_list.push_back(i);
    }
  }
  // cout << "ending aaa" << endl;
  int count;
  while (true){
    cin >> a;
    if (a == 0) break;
    count = 0;
    for (int i=0; i< prime_list.size(); i++){
      if(prime_list[i] > a){
        if (prime_list[i] <= 2*a){
          //cout << prime_list[i];
          count++;
        }
      }
    }
    cout << count << endl;
  }

  return 0;

}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  ll k,s;cin>>k>>s;
  if(k*3==s)res=1;
  else{
  for(i=0;i<=k;i++){
    if(i>s)break;
    for(j=i;j<=k;j++){
      if(i+j>s)break;
      for(o=j;o<=k;o++){
        if(i+j+o>s)break;
        if(i+j+o==s){
          if(i==j&&j==o)res++;
          else if(i==j||j==o||o==i)res+=3;
          else res+=6;
        }
      }
    }
  }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
from copy import copy
n = int(input())
x, y = [], []
for i in range(n):
    q, p = map(int, input().split())
    x.append(q)
    y.append(p)

x1 = copy(x)
y1 = copy(y)

ans = 0
for i in range(len(x)):
    for j in range(i + 1, len(x)):
        ans += ((x1[i] - x[j]) ** 2 + (y1[i] - y[j]) ** 2) ** (1 / 2)
        
      

print(ans * 2 / n)


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

constexpr int INFI = 1145141919;

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

    int N;
    std::cin >> N;

    std::vector<int> a;
    for(int i=0; i<N; i++){
        int buf;
        std::cin >> buf;
        buf = buf - 1;
        a.push_back(buf);
    }

    int light=0;
    for(int i=0; i<N+1; i++){
        if(light==1){
            std::cout << i;
            return 0;
        }
        light=a.at(light);
    }

    std::cout << -1;

    return 0;
}


Measured memory_bytes: 892