akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

main(){
  int n;
  cin >> n;
  int W;
  cin >> W;
  int weight[n+1],value[n+1];
  for(int ii=0;ii<n;ii++){
    cin >> weight[ii] >> value[ii];
  }
  long dp[n+2][W+2];
  for(int ii=0;ii<=n;ii++){
    for(int jj=0;jj<=W;jj++){
      dp[ii][jj]=0;
    }
  }
  for(int ii=0;ii<n;ii++){
    for(int jj=0;jj<=W;jj++){
      if(jj-weight[ii]>=0)dp[ii+1][jj]=max(dp[ii][jj],dp[ii][jj-weight[ii]]+value[ii]);
      else dp[ii+1][jj]=dp[ii][jj];
    }
  }
  cout << dp[n][W] << endl;
}


Measured memory_bytes: 79104
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String []s=br.readLine().split(" ");
		long H = Long.parseLong(s[0]);
		long N = Long.parseLong(s[1]);
		long sum=0;
		
		s=br.readLine().split(" ");
		for(int i=0;i<N;i++)
			sum+=Long.parseLong(s[i]);
			
				
		if(sum>=H)
			out.println("Yes");
		else
			out.println("No");
	
	}
}




Measured memory_bytes: 35672
import numpy as np
import time
import random
import collections
import bisect  

start = time.time()

def insert(list, n): 
    bisect.insort(list, n)  
    return list

def read_input():
  D = int(input())
  c = list(map(int, input().split()))
  s = [list(map(int, input().split())) for _ in range(D)]
  return D, c, s
D, c, s = read_input()

c = np.array(c)
s = np.array(s)
tests = np.argmax(s, axis=1)

def get_dates_for_tests(tests):
  dates_for_tests = [list([-1]) for _ in range(26)]
  for i, t in enumerate(tests):
    dates_for_tests[t].append(i)
  for t in range(26):
    dates_for_tests[t].append(D)
  return dates_for_tests

dates_for_tests = get_dates_for_tests(tests)

def get_score(tests):
  dates_for_tests = get_dates_for_tests(tests)
  score = 0
  d = np.zeros(26, dtype=np.int64)
  for selected, S in zip(tests, s):
    d += 1
    d[selected] = 0
    score += S[selected] - (c * d).sum()
  return score

def score_diff(date, test):
  #print(date, test)
  before = tests[date]
  if test == before:
    return 0, None, None
  pos_diff = s[date, test] - s[date, before]
  new_index = bisect.bisect_left(dates_for_tests[test], date, 1)
  new_diff = c[test] * (dates_for_tests[test][new_index] - date) * (date - dates_for_tests[test][new_index-1])

  old_index = bisect.bisect_left(dates_for_tests[before], date, 1)
  #print(c[test], dates_for_tests[test])
  #print(c[before], dates_for_tests[before])
  old_diff = c[before] * (dates_for_tests[before][old_index+1] - date) * (date - dates_for_tests[before][old_index-1])
  
  total_diff = pos_diff + new_diff - old_diff
  #print(test, total_diff, pos_diff, new_diff, -old_diff)
  return total_diff, new_index, old_index

# current_score = get_score(tests)
while time.time() < start + 1.8:
  for date in range(D):
    for test in range(26):
      # date = 4
      # test = 23

      total_diff, new_index, old_index= score_diff(date, test)
      if total_diff > 0:
        # print('INCREASING')
        #print(date, tests[date], test)
        #print(c[[tests[date], test]])
        #print(s[date, [tests[date], test]])
        del dates_for_tests[tests[date]][old_index]
        insert(dates_for_tests[test], date)
        tests[date] = test

        #assert dates_for_tests == get_dates_for_tests(tests)
        #new_score = get_score(tests)
        #print(total_diff, new_score - current_score , current_score, new_score) 
        #assert new_score == current_score + total_diff
        #current_score = new_score
        # raise ValueError
        
# print(get_score(tests))
for t in tests:
  print(t+1)


Measured memory_bytes: 27312
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    int n,r;
    cin >> n >> r;
    int ans = 0;
    if(n >= 10) ans = r;
    else{
        ans = r + (100*(10-n));
    }
    cout << ans;
    
}


Measured memory_bytes: 256
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*define
*********************************/
#define NUM	( 3 )

/*********************************
*function
*********************************/
int main( void )
{
    int W,H,x,y,r;

	scanf( "%d %d %d %d %d", &W, &H, &x, &y, &r );

    if ( ( x - r >= 0 ) && ( x + r <= W ) && ( y - r >= 0 ) && ( y + r <= H ) ) {
		printf( "Yes\n" );
    } else {
		printf( "No\n" );
    }
 
 return 0;
}

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

#define INF (1<<30)
#define MAX 100010

int dp[MAX];
int h[MAX];

int main(){
	int n;	cin>>n;
	for(int i=0;i<n;i++){
		cin>>h[i];
		dp[i]=INF;
	}
	dp[0]=0;

	for(int i=0;i<n;i++){
		dp[i+1]=min(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
		dp[i+2]=min(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
	}

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

	return 0;
}


Measured memory_bytes: 1024
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            a+=i+1
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    d=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]+int(s[i])*d)%p
        a+=t[g[i]]
        t[g[i]]+=1
        d*=10
        d%=p
    print(a)

Measured memory_bytes: 10984
#include <stdio.h>

int main(void){
  int N;
  int a[10],b,c;
  int i,j;
  int state;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    for(j=0;j<10;j++){
      scanf("%d",&a[j]);
    }
    b=a[0]; c=0;
    for(j=1;j<10;j++){
      if(b>c){
	if(c>a[j]){ state++;
	}else if(b<a[j]){ b=a[j];
	}else{ c=a[j]; }
      }else{
	if(b>a[j]){ state++;
	}else if(c<a[j]){ c=a[j];
	}else{ b=a[j]; }
      }
      if(state!=0) break;
    }
    if(state==0) printf("YES\n");
    else printf("NO\n");
    
  }
  return 0;
}

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

int main() {
  int N; cin >> N;
  if (N % 2 == 0) {
    cout << N * N / 4 << endl;
  }
  else {
    cout << N / 2 * (N + 1) / 2 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x,y,d;
    bool operator<(const node &a)const
    {
        return d>a.d;
    }
};
int vis[1003][1003];
priority_queue<node>q;
int h,w;
char s[1003][1003];
int num[1003][1003];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int ma=0;
int main()
{
    cin>>h>>w;
    for(int i=1;i<=h;i++)
        scanf("%s",s[i]+1);
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            num[i][j]=2050;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            if(s[i][j]=='#')
            {
                node temp;
                temp.x=i;
                temp.y=j;
                temp.d=0;
                q.push(temp);
            }
    while(!q.empty())
    {
        node temp=q.top();
        ma=max(temp.d,ma);
        q.pop();
        for(int i=0;i<4;i++)
        {
            node t;
            t.x=temp.x+dx[i];
            t.y=temp.y+dy[i];
            t.d=temp.d+1;
            if(t.x<1||t.x>h||t.y<1||t.y>w||vis[t.x][t.y]==1||s[t.x][t.y]=='#'||num[t.x][t.y]<=t.d)
                continue;
            num[t.x][t.y]=t.d;
            q.push(t);
        }
    }
    cout<<ma<<endl;
}


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

int main() {
	int a,b,c,i,x;
	cin >>a>>b>>c;
	for (i=a, x=0; i<=b; i++) {
		if (c%i==0) {
			x=x+1;
		}
	}
	cout <<x<<endl;
}



Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int w[26];
char s[200010];
int main() {
    scanf("%s",s);
    int n=strlen(s);
    for(int i=0;i<n;i++) ++w[s[i]-'a'];
    long long ans=1LL*n*(n-1)/2;
    for(int i=0;i<26;i++) ans-=1LL*w[i]*(w[i]-1)/2;
    cout<<ans+1;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<bitset>
using namespace std;
bitset<4000001> b;
int n,sum=0,a;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	b[0]=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		b=b|(b<<a);
		sum+=a;
		}
	for(int i=(sum+1)/2;;i++)
	{
		if(b[i])
		{
			cout<<i<<endl;
			break;
			}
		}
	return 0;
	}

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

typedef long long ll;

struct pt {
	ll x, y;
	pt(ll xx = 0, ll yy = 0) :x(xx), y(yy) {}
	bool operator == (pt &a) { return (a.x - x == 0) && (a.y - y == 0); }
};

bool operator < (const pt &a, const pt &b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}

pt operator-(pt a, pt b) { return pt(a.x - b.x, a.y - b.y); }
ll vec(pt a, pt b) { return a.x*b.y - a.y*b.x; }
ll det(pt a, pt b, pt c) { return vec(b - a, c - a); }

bool right(pt X, pt Y, pt Z) { return (det(X, Y, Z) <= 0); }

vector<pt> convexhull(vector<pt> &ab) {
	int l = (int)ab.size(), i, j = 0, k;
	vector<pt> res(l + 1); if (l < 3) { return ab; }

	for (i = 0; i < l; i++) {
		while (j - 2 >= 0 && right(res[j - 2], res[j - 1], ab[i])) { j--; }
		res[j++] = ab[i];
	}
	k = j;
	for (i = l - 2; i >= 0; i--) {
		while (j - 1 >= k && right(res[j - 2], res[j - 1], ab[i])) { j--; }
		res[j++] = ab[i];
	}
	if (res[j - 1] == res[0]) { j--; }
	return move(vector<pt>(res.begin(), res.begin() + j));
}

ll dist(pt &a, pt &b) { return abs(a.x - b.x) + abs(a.y - b.y); }

ll bruteForce(vector<pt> &v) {
	int n = (int)v.size(); ll res = 0;
	for (int i = 0; i < n; i++) 
		for (int j = i + 1; j < n; j++)
			res = max(res, dist(v[i], v[j]));
	return res;
}

vector<pt> v;

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

	int n; cin >> n; v.resize(n);
	for (auto &x : v) { cin >> x.x >> x.y; }
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());

	if (v.size() < 10) { cout << bruteForce(v) << '\n'; return 0; }
	v = convexhull(v); n = (int)v.size(); int i = 0, j = 0;
	while (j + 1 < n && dist(v[j + 1], v[i]) > dist(v[j], v[i])) { j++; }
	ll res = dist(v[i++], v[j]); while (i != n) {
		while (dist(v[(j + 1) % n], v[i]) > dist(v[j], v[i])) { j = (j + 1) % n; }
		res = max(res, dist(v[i++], v[j]));
	}
	cout << res << '\n';
	cin.ignore(2); return 0;
}

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

int main(){
  int N,sum = 0;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) cin >> d.at(i);
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      sum += d.at(i) * d.at(j);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll n;
void solve(){
	cin>>n;
	string s;
	cin>>s;
	s.erase(unique(all(s)),s.end());
	cout<<sz(s);
}
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define PB push_back
#define INF 100000000000000000

bool IsPrime(int num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
  
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
    {
      // 素数ではない
      return false;
    }
  }
  
  // 素数である
  return true;
}

/*********************************************************/
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************/
ll gcd( ll m, ll n )
{
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;
  
  // ユークリッドの方法
  while( m != n )
  {
    if ( m > n ) m = m - n;
    else         n = n - m;
  }
  return m;
}//gcd

//*********************************************************
// 最小公倍数（Least Common Multiple）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll lcm( ll m, ll n )
{
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;
  
  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

/********************************************************/

int main() {
  ll N,i,ans,ans2;
  cin >> N;
  vector<ll>A(N);
  vector<ll>ABig(N);
  vector<ll>ASmall(N);
  for(i=0;i<N;i++){
    cin >> A.at(i);
  }
  ans=0;
  ans2=0;
  sort(A.begin(),A.end());
  
  if(N%2==1){
    //Aでかパターン
    for(i=0;i<N;i++){
      if(i==0){
        ABig.at(i) = 1;
      } else if (i==N-1){
        ABig.at(i) = 1;
      }else if (i%2==1){
        ABig.at(i) = -2;
      } else {
        ABig.at(i) = 2;
      }
    }
    sort(ABig.begin(),ABig.end());
    for(i=0;i<N;i++){
      ans += A.at(i)*ABig.at(i);
    }
    
    //Aちいさパターン
    for(i=0;i<N;i++){
      if(i==0){
        ASmall.at(i) = -1;
      } else if (i==N-1){
        ASmall.at(i) = -1;
      } else if (i%2==1){
        ASmall.at(i) = 2;
      } else {
        ASmall.at(i) = -2;
      }
    }
    sort(ASmall.begin(),ASmall.end());
    
    for(i=0;i<N;i++){
      ans2 += A.at(i)*ASmall.at(i);
    }
    
    cout << max(ans,ans2) << endl;
  }
  
  if(N%2==0){
    //Aでかパターン
    for(i=0;i<N;i++){
      if(i==0){
        ABig.at(i) = 1;
      } else if (i==N-1){
        ABig.at(i) = -1;
      }else if (i%2==1){
        ABig.at(i) = -2;
      } else {
        ABig.at(i) = 2;
      }
    }
    sort(ABig.begin(),ABig.end());
    for(i=0;i<N;i++){
      ans += A.at(i)*ABig.at(i);
    }
    
    //Aちいさパターン
    for(i=0;i<N;i++){
      if(i==0){
        ASmall.at(i) = -1;
      } else if (i==N-1){
        ASmall.at(i) = 1;
      } else if (i%2==1){
        ASmall.at(i) = 2;
      } else {
        ASmall.at(i) = -2;
      }
    }
    sort(ASmall.begin(),ASmall.end());
    
    for(i=0;i<N;i++){
      ans2 += A.at(i)*ASmall.at(i);
    }
    cout << max(ans,ans2) << endl;
  }
  
  return 0;
}




Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
import sys


def main():
    S = int( sys.stdin.readline() )

    dp = [0]*(S+1)
    dp[0] = 1
    mod = 10**9 + 7

    for i in range(3, S+1):
        dp[i] = dp[i-3] + dp[i-1]
        dp[i] %= mod
    

    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 9000
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }

    ll x=-1,y=-1,z=-1;
    x=a[0];
    for(ll i=1;i<n;i++){
        if(a[i]!=x){
            y=a[i];
        }
    }

    for(ll i=1;i<n;i++){
        if(a[i]!=x && a[i] != y){
            z=a[i];
        }
    }

    for(ll i=1;i<n;i++){
        if(a[i]!=x && a[i] != y && a[i] != z){
            cout << "No" << endl;
            return 0;
        }
    }
    bool zeroflag = true;
    for(ll i=0;i<n;i++){
        if(a[i]!=0)zeroflag=false;
    }
    if(zeroflag){
        cout << "Yes" << endl;
        return 0;
    }
    if(n%3 != 0){
        cout << "No" << endl;
        return 0;
    }
    ll ans=0;
    for(int i=0;i<n;i++)ans ^= a[i];

    if(ans == 0){
        cout << "Yes" << endl;
    } 
    else{
        cout << "No" << endl;
    }




    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ld = long double;
const ld eps = 1e-9;
vector<int>path;
vector<int>oks;

bool out(long long int n) {
	cout <<"? "<< n << endl;
	flush(cout);
	string ok; cin >> ok;
	return ok == "Y";
}
bool check(long long int n) {
	return out(n);
}

int main() {
	long long int amin = 1e8-1;
	long long int amax = 1e9-1;
	while (amin + 1 != amax) {
		long long int amid = (amin + amax+1) / 2;
		if (check(amid*100)) {
			amax = amid;
		}
		else {
			amin = amid;
		}
	}
	vector<int>kouho;
	int t(amax);
	if (t == 1e8)t = 1e9;
	while (t) {
		kouho.push_back(t);
		if (t % 10)break;
		else t /= 10;
	}
	reverse(kouho.begin(), kouho.end());
	bool flag = false;
	{
		string st(to_string(kouho[0]));
		if (all_of(st.begin(), st.end(), [](const char&c) {return c == '9'; }))flag = true;
	}
	int ans = -1;
	for (int i = 0; i < kouho.size(); ++i) {
		bool aa = check(kouho[i] + 1);
		if (aa^(flag&&i==0)) {
			ans = kouho[i];
			break;
		}
	}
	if (ans == -1)assert(false);
	cout << "! " << ans << endl;
	flush(cout);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll par[200010];
ll len[200010];
void init(ll n){
    for(int i=0;i<n;i++){
        par[i]=i;
        len[i]=0;
    }
}
ll root(ll n){
    if(par[n]==n)return n;
    return par[n]=root(par[n]);
}
void unit(ll a,ll b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(len[a]<len[b]){
        par[a]=b;
    }
    else{
        par[b]=a;
        if(len[a]==len[b])len[a]++;
    }
}
int main(){
    ll n;cin>>n;
    ll x[n],y[n];
    vector<ll> vx[100001],vy[100001];
    rep(i,0,n){
        cin>>x[i]>>y[i];
        vx[x[i]].push_back(y[i]);
        vy[y[i]].push_back(x[i]);
    }
    init(100001);
    //cout<<root(1)<<endl;
    //return 0;
    rep(i,1,100001){
        rep(j,1,vx[i].size())unit(vx[i][0],vx[i][j]);
    }
    set<ll> st[100001];
    rep(i,1,100001){
        int r=root(i);
        rep(j,0,vy[i].size())st[r].insert(vy[i][j]);
    }
    ll ans=0;
    rep(i,1,100001){
        int r=root(i);
        ans+=st[r].size();
    }
    ans-=n;
    cout<<ans<<endl;
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  const int MOD = 1e9+7;
  int n; cin >> n;
  string s1,s2; cin >> s1 >> s2;
  ll ans = 0;
  int i = 0;
  if(s1[0] == s2[0]){
    ans = 3;
    i = 1;
  }else{
    ans = 6;
    i = 2;
  }
  for(; i < n; i++){
    if(s1[i] == s2[i]){
      if(s1[i-1] == s2[i-1]) ans *= 2;
      else ans *= 1;
    }else{
      if(s1[i-1] == s2[i-1]) ans *= 2;
      else ans *= 3;
      i++;
    }
    ans %= MOD;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3652
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()

sen = []
for i in range(m):
    sen.append(li())

p = li()
ans = 0

#全通り
for i in range(2**n):
    swc = []
    # １通りの中の各桁について
    for j in range(n):
        # print((i>>j) & 1)
        swc.append((i>>j) & 1)
    # print(swc)
    
    # 各電球について
    for j in range(m):
        l = sen[j]
        km = l[0]
        on_cnt = 0
        for k in l[1:]:
            if swc[k-1]:
                on_cnt += 1
        if on_cnt%2 != p[j]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 3064
// ??????????¶??°???????????????\?????????
//
// ????????????????????????4?¨?????????????????????????????????§12????????¨?±??????£????????????
// ?????????????????¨????????????????????????????????¨?????????????????????????????\???
// ?????????????????????????????§????????°?????????
// ????????????12?????????????????§????????° 4^12 ?????¨??????????????°???????????????
// ????????°??? 1 ??? 12 ???????????????????????§??????????????§????¶?????????????
// ????????°????????? A,B,C ?????????????????§??????????????????????????§3????????£?????´??????
//  ?????????????????????1???????????£??????????????¨??????????????????
//  2???????????£??????????????¨??????????????????
//  3???????????£??????????????¨???????????????
// ?????¨?????????????????????????¨?????????????????????°???????????????
//  (3 ^ 1 + 3 ^ 2 + 3 ^ 3)
// ?????£?????????????????? 4^1 + 4^2 + .. + 4^12 ?????¨??????????????°??¨?????????
// ???????????????????????????????????°?????????????????°?????????4?????°???????????§
// ???????¢??????????????????°????°????????????§???????????\???????????§???????¨???§?????????


/* ALDS1_4_C: Dictionary */

#include <iostream>
#include <cstdio>

const int MAX_KEY_LENGTH = 12;
const int N_KEY_CHARS = 4;

class Dict {
    int *KEYS;
    int char_to_id(char);
    int to_hash(char*);
    public:
        Dict();
        void insert(char*);
        bool has(char*);
};

Dict::Dict() {
    int max_hash = 0, w = 1;
    for (int i = 0; i < MAX_KEY_LENGTH; i++, w *= N_KEY_CHARS) {
        max_hash += N_KEY_CHARS * w;
    }
    KEYS = new int[max_hash + 1];
    std::fill_n(KEYS, max_hash, 0);
}

void Dict::insert(char *key) {
    KEYS[ to_hash(key) ] = true;
}

bool Dict::has(char *key) {
    return KEYS[ to_hash(key) ];
}

int Dict::char_to_id(char c) {
    switch (c) {
        case 'A': return 1;
        case 'C': return 2;
        case 'G': return 3;
        case 'T': return 4;
    }
    return 0;
}

int Dict::to_hash(char *key) {
    int hash = 0;
    int w = 1;
    for (int i = 0; key[i]; i++, w *= N_KEY_CHARS) {
        hash += w * char_to_id(key[i]);
    }
    return hash;
}

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

    Dict dict;
    char op[10], key[MAX_KEY_LENGTH + 1];

    for (int i = 0; i < n_ops; i++) {
        scanf("%s %s", op, key);
        switch (op[0]) {
            case 'i': // insert
                dict.insert(key);
                break;
            case 'f': // find
                puts( dict.has(key) ? "yes" : "no" );
                break;
        }
    }

    return 0;
}

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

using namespace std;

int main() {
  int n,m;
  cin>>n>>m;
  int sum = 0;
  int flag = 0;
  for(int i=0;i<m;i++)
  {
    int x;cin>>x;
    sum+=x;
    if (sum>n)
    {
      flag = 1;
    }
  }
  if(flag==1)
    cout<<-1<<endl;
  else
    cout<<n-sum<<endl;
  return 0;
}

Measured memory_bytes: 3636
/*s の i 文字目からとったものは、s.substr(i)　(これは N-i 文字)
t の前から N-i 文字とったものは、t.substr(0, N-i)*/
#include <bits/stdc++.h>
using namespace std;
int N;
string s, t;
int solve() {
  for (int i = 0; i < N; ++i) {
    if (s.substr(i) == t.substr(0, N-i)) return i + N;
  }
return N*2;
}

int main() {
  cin >> N >> s >> t;
  cout << solve() << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, x = map(int, input().split())
aList = map(int, input().split())
sortedAList = sorted(aList)

cnt = 0
for i in range(0, len(sortedAList)):
	if x >= sortedAList[i]:
		if i + 1 != len(sortedAList) or x == sortedAList[i]:
			cnt += 1
			x   -= sortedAList[i]
		else:
			break
	else:
		break
	
print(cnt)
	

Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,q = LI()
    v = [[] for i in range(n)]
    for _ in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    f = [0]*n
    for _ in range(q):
        p,x = LI()
        p -= 1
        f[p] += x
    d = [0]*n
    d[0] = 1
    q = deque([0])
    while q:
        x = q.popleft()
        fx = f[x]
        for y in v[x]:
            if not d[y]:
                d[y] = 1
                f[y] += fx
                q.append(y)
    print(*f)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 94484
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

bool Sieve(int x)
{
  for(int i=2;i<=sqrt(x);i++) if(x%i==0) return false;
  return true;
}
int main()
{
  int n;
  vector<int> items;
  //input
  cin >> n; items.resize(n);
  for(int i = 0; i < n; i++)cin >> items[i];
  
  //process
  int count = 0;
  for(int i=0;i<n;i++) if(Sieve(items[i])) count++;
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define xlson kx<<1, xl, mid
#define xrson kx<<1|1, mid+1, xr
#define ylson ky<<1, yl, mid
#define yrson ky<<1|1, mid+1, yr
#define MAXN 1005
#define mem(a) memset(a, 0, sizeof(a))

using namespace std;

int main(void)
{
	int x,y,z;
	cin>>x>>y>>z;
	x-=z;
	printf("%d",x/(y+z));
	return 0;
}

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

#define MAX_N 1000006
#define LOG_N 20

int twos[MAX_N] ,lg2[MAX_N];

int main()
{
    for(int i=0; i<LOG_N; i++)
        lg2[1<<i] = i;
    for(int i=1; i<MAX_N; i++)
        twos[i] += twos[i-1] + lg2[i&-i];

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

    if(count(s.begin() ,s.end() ,'2') == 0){
        bool on = 0;
        for(int i=0; i<n; i++)
            on ^= (s[i] == '3')&!(twos[n-1]-twos[n-i-1]-twos[i]);
        cout << 2*on << endl;
    }
    else{
        bool on = 0;
        for(int i=0; i<n; i++)
            on ^= !(s[i]&1)&!(twos[n-1]-twos[n-i-1]-twos[i]);
        cout << on << endl;
    }
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	map<string, int> s;
	for(int i = 0; i < n; i++) {
		string tmp;
		cin >> tmp;
		try {
			s.at(tmp)++;
		} catch (out_of_range) {
			s.insert(make_pair(tmp, 1));
		}
	}
	int m = 0;
	for (auto itr = s.begin(); itr != s.end(); itr++) m = max(itr->second, m);

	for (auto itr = s.begin(); itr != s.end(); itr++)
		if (itr->second == m) cout << itr->first << endl;
	return 0;
}

Measured memory_bytes: 26240
s = gets.chomp.chars
a = Array.new(s.size + 1, 0)
m = 0
s.each_with_index do |x, i|
  if x == '<'
    if m > 0
      m.next.times do |j|
        a[i - j] = [a[i - j], j].max
      end
      m = 0
    end
    a[i + 1] = a[i] + 1
  else
    m += 1
  end
end
if m > 0
  m.next.times do |j|
    a[-1 - j] = j
  end
  m = 0
end
puts a.inject(:+)

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

int main() {
	int p, q, r;
	cin >> p >> q >> r;
	int ans = p + q + r;
	int m = max({ p,q,r });
	cout << ans - m << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = input()
x = X[::-1]
one = X.count('1')
up = 0
down = 0
for i in range(N):
    up += (int(x[i]) * pow(2,i,one+1) % (one+1))
    up %= one+1
    if one > 1:
        down += (int(x[i]) * pow(2,i,one-1) % (one-1))
        down %= one-1
# print(up,down)
def f(ud,one):
    if one <= 0:
        return 0
    else:
        if ud == 0:
            return 1

        cnt = 0
        while ud != 0:
            ud = ud % one
            one = format(ud,'b').count('1')
            cnt += 1
        return cnt



for i in range(len(X)):
    if X[i] == '1':
        if one > 1:
            print(f((down - pow(2,(len(X)-1) - i, one-1)) % (one-1),one-1))
        #print(down - pow(2,(len(X)-1) - i, one-1) % (one-1))
        else:
            print(0)

    else:
        print(f((up + pow(2,(len(X)-1) - i, one+1)) % (one+1),one+1))
        #print(up + pow(2,(len(X)-1) - i, one+1) % (one+1))


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

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<pair<int, int>> sequence(N + 1);
  for (int i = 1; i <= N; i++) cin >> sequence[i].first >> sequence[i].second;

  sort(sequence.begin() + 1, sequence.end());

  long long n = 0;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    n += sequence[i].second;
    if (n >= K) {
      ans = sequence[i].first;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力

        //// スペース区切りの整数の入力
        int N = int.Parse(Console.ReadLine());
        int[] t = new int[N + 1];
        int[] x = new int[N + 1];
        int[] y = new int[N + 1];

        t[0] = 0;
        x[0] = 0;
        y[0] = 0;

        for (int i = 1; i < N + 1; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            t[i] = int.Parse(input[0]);
            x[i] = int.Parse(input[1]);
            y[i] = int.Parse(input[2]);
        }

        //出力
        Console.WriteLine(hantei(N, t, x, y));
    }

    private static string hantei(int N, int[] t, int[] x, int[] y)
    {
        for (int j = 1; j < N + 1; j++)
        {
            int distance = Math.Abs(x[j] - x[j - 1]) + Math.Abs(y[j] - y[j - 1]);
            int time = t[j] - t[j - 1];
            if (distance <= time
                && (distance == time || (time - distance) % 2 == 0)
                )
            {
                continue;
            }
            else
            {
                return "No";
            }
        }
        return "Yes";
    }

}


Measured memory_bytes: 16196
'''
>>> main(3,[2,3,1])
3 1 2

>>> main(5, [1, 2, 3, 4, 5])
1 2 3 4 5

>>> main(8,[8, 2, 7 ,3, 4, 5 ,6, 1])
8 2 4 5 6 7 3 1
'''


def main(n, a):
    l = [0 for _ in range(n)]

    count = 1
    for i in a:
        l[i - 1] = count
        count += 1

    print(' '.join(map(str, l)))


if __name__ == '__main__':
    n = int(input())
    a = map(int, input().split(' '))

    main(n, a)


Measured memory_bytes: 13880
/**
*    author:  Dooloper
*    created: 02.05.2020 20:53:33
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>


using namespace std;
typedef unsigned long long ll;

int main() {
    cin.tie(0);
    int K,A,B;
    cin>>K>>A>>B;
    for(int i = A; i <= B; i++){
        if(i%K ==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout << "NG" <<endl;
    return 0;
}

Measured memory_bytes: 3624
package main

import (
  "fmt"
)

func main() {
  var (
    s,t,u string
    a,b int
  )
  fmt.Scan(&s)
  fmt.Scan(&t)
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&u)

  switch(u) {
  case s:
    a--
  case t:
    b--
  }
  fmt.Print(a)
  fmt.Print(" ")
  fmt.Println(b)
}


Measured memory_bytes: 512
use proconio::{input, marker::Usize1};
use std::collections::HashSet;

fn main() {
    input! {
        h: usize,
        w: usize,
        m: usize,
        hw: [(Usize1, Usize1); m]
    }

    let mut sum_h = vec![HashSet::new(); h];
    let mut sum_v = vec![0; w];
    let mut max_h = 0;
    let mut max_v = 0;
    for (i, j) in hw {
        sum_h[i].insert(j);
        sum_v[j] += 1;
        max_h = max_h.max(sum_h[i].len());
        max_v = max_v.max(sum_v[j]);
    }

    let mut max_j = HashSet::new();
    for j in 0..w {
        if sum_v[j] >= max_v {
            max_j.insert(j);
        }
    }

    let mut f = false;
    for i in 0..h {
        if sum_h[i].len() >= max_h {
            for j in &max_j {
                if !sum_h[i].contains(&j) {
                    f = true;
                    break;
                }
            }
            if f {
                break;
            }
        }
    }

    println!("{}", max_h + max_v - if f { 0 } else { 1 });
}


Measured memory_bytes: 47836
#include <iostream>
#include <queue>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
bool mem[52][52][52][52] = {{{{}}}};
struct S{
	int a,b,c,d,t;
};
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};
int main(){
	int x, y, tx, ty, kx, ky, k;
	while(cin >> x >> y, (x || y)) {
		int b[52][52] = {};
		rep(i,52) {
			rep(j,52) {
				rep(l,52) {
					rep(m,52) {
						mem[i][j][l][m] = 0;
					}
				}
			}
		}
		cin >> tx >> ty >> kx >> ky;
		rep(i,y) {
			rep(j,x) {
				cin >> k;
				b[i+1][j+1] = 1-k;
			}
		}
		queue<S> q;
		S s = {tx,ty,kx,ky,0};
		q.push(s);
		while(!q.empty()) {
			S s = q.front();
			if(q.front().t >= 100) break;
			if(s.a==s.c&&s.b==s.d) break;
			q.pop();
			if(mem[s.a][s.b][s.c][s.d]++) continue;
			rep(i,4) {
				int na = s.a+dx[i], nb = s.b+dy[i], nc = s.c+dx[(i+2)%4], nd = s.d+dy[(i+2)%4];
				if(!b[nb][na]&&!b[nd][nc]) continue;
				if(!b[nb][na]) na = s.a, nb = s.b;
				if(!b[nd][nc]) nc = s.c, nd = s.d;
				S ns = {na, nb, nc, nd, s.t+1};
				q.push(ns);
			}
		}
		if(q.empty()) cout << "NA" << endl;
		else if(q.front().t >= 100) cout << "NA" << endl;
		else cout << q.front().t << endl;
	}
}

Measured memory_bytes: 9288
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
int N, M;
int p[200100];
int el[200100];
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	int i, j;
	for (i = -2000; i <= 2000; i++)
	{
		for (j = -2000; j <= 2000; j++)
		{
			if (i * i * i * i * i - j * j * j * j * j==N)
			{
				cout << i << ' ' << j;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define maxn 200000 + 10
int father[maxn];
int val[maxn];
int Find(int x)
{
    if (x == father[x])
        return x;
    int temp = father[x];
    father[x] = Find(father[x]);
    val[x] += val[temp];
    return father[x];
}
int n, m;
int main()
{
    while (~scanf("%d %d", &n, &m))
    {
        for (int i = 1; i <= n; i++)
        {
            father[i] = i;
            val[i] = 0;
        }
        int ans = 0;
        for (int i = 1; i <= m; i++)
        {
            int u, v, w;
            scanf("%d %d %d", &u, &v, &w);
//            u -= 1;
            int ru = Find(u), rv = Find(v);
            if (ru == rv)
            {
                if (val[u] + w != val[v])
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
            else
            {
                father[rv] = ru;
                val[rv] = val[u] - val[v] + w;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
(*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*)

open System;

let tmpn = Console.ReadLine();
let n = int(tmpn)
let tmpa = Console.ReadLine().Split(' ');
let a = [| for i in 0 .. n-1 -> 0|]

for i = 0 to n-1 do
    Array.set a i (int(tmpa.[i]))
let sortedArr = Array.sort a

let add1 k m =
    let oldValue = Map.find k m in
    let removed = Map.remove k m in 
    Map.add k (oldValue+1) removed
let counter num map =
    if (Map.containsKey num map) then add1 num map
    else Map.add num 1 map

let rec countMap i m =
    if i < 0 then m
    else countMap (i-1) (counter sortedArr.[i] m)

let listedMap = Map.toList (countMap (n-1) Map.empty)

let rec findAns l ans =
    match l with
    | [] -> ans
    | (num, count) :: t ->
        if num = count then findAns t ans
        elif num > count then findAns t (ans+count)
        else findAns t (ans + (count - num))

Console.WriteLine(findAns listedMap 0)

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

using namespace std;


long long f(long long x) {
    if (x == 0) return 0;
    if (x == 1) return 1;
    if (x == 2) return 3;
    if (x == 3) return 0;
    long long h = 1ll<<(63-__builtin_clzll(x));
    long long d = x - h;
    long long res = (d&1)? 0: h;
    return res ^ f(d);
}

void solve() {
    long long a, b;
    cin >> a >> b;
    long long res = f(a) ^ f(b) ^ a;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

ll dp[4][5000 + 5];
ll dp2[4][25'000'000+5];

int main()
{
    ciosup;
    int n;
    cin >> n;
    pint s[3];
    REP(i, 3) { cin >> s[i].FI; }
    REP(i, 3) { cin >> s[i].SE; }
    int g[3];
    REP(i,3){
        g[i] = s[i].SE - s[i].FI;
    }
    REP(i,3){
        REP(j,n+1){
            if (j - s[i].FI < 0)
            {
                dp[i + 1][j] = dp[i][j];
            }else
            {
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - s[i].FI] + g[i]);
            }
        }
    }
    ll resdon = n + dp[3][n];
    REP(i,3){
        g[i] *= -1;
    }
    REP(i, 3)
    {
        REP(j, resdon + 1)
        {
            if (j - s[i].SE < 0)
            {
                dp2[i + 1][j] = dp2[i][j];
            }
            else
            {
                dp2[i + 1][j] = max(dp2[i][j], dp2[i + 1][j - s[i].SE] + g[i]);
            }
        }
    }
    ll resdon2 = resdon + dp2[3][resdon];
    cout << resdon2 << endl;
}

Measured memory_bytes: 587136
#include <bits/stdc++.h>
#define maxn 65
#define MOD 998244353
#define INF 10000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll n, k;
ll x[maxn], y[maxn];
const double er = 0.00000001;

bool check(double t){
    for(ll i = 0; i  < n; i++){
        for(ll j = i; j < n; j++){
            if(i == j){
                ll cnt = 0;
                for(ll l = 0; l < n; l++){
                    double r = t;
                    double dis = (x[l]-x[i])*(x[l]-x[i]) + (y[l]-y[i])*(y[l]-y[i]);
                    if(dis <= r*r + er) cnt++;
                }
                if(cnt >= k) return true;

            }
            else{
                // calculate intersection
                // https://poporix.hatenablog.com/
                double xd = x[j]-x[i], yd = y[j]-y[i];
                double d = sqrt(xd*xd + yd*yd);
                double r1 = t, r2 = t;
                double costheta = (r1*r1 + d*d - r2*r2)/ (2*r1*d);
                double rc = r1 * costheta;
                double rs = sqrt(r1*r1 - rc*rc);

                double x1 = x[i] + (xd/d)*rc - (yd/d)*rs, y1 = y[i] + (yd/d)*rc + (xd/d)*rs;
                double x2 = x[i] + (xd/d)*rc + (yd/d)*rs, y2 = y[i] + (yd/d)*rc - (xd/d)*rs;

                ll cnt1 = 0, cnt2 = 0;
                for(ll l = 0; l < n; l++){
                    double r = t, dis = (x1-x[l])*(x1-x[l]) + (y1-y[l])*(y1-y[l]);
                    if(dis <= r*r + er) cnt1++;

                    dis = (x2-x[l])*(x2-x[l]) + (y2-y[l])*(y2-y[l]);
                    if(dis <= r*r + er) cnt2++;
                }
                if(cnt1 >= k || cnt2 >= k) return true;

            }
        }
    }

    return false;
}

void solve(){
    cin >> n; k = n;
    for(ll i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    cout << setprecision(10);

    double mn = 0.0, mx = 100000000.0;
    while(mx - mn > er){
        double md = mn + (mx - mn)/2; //cout << md << " ";
        if(check(md)){
            mx = md;
        }
        else mn = md;
    }
    cout << mn;
}

int main()
{
    fast();
    int t= 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/

int n, m;
int a[100005], b[100005];
vector<int>vec[100005];
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		vec[a[i]].push_back(b[i]);
	}
	rep(i, n + 1)sort(all(vec[i]));
	rep(i, m) {
		int si = to_string(a[i]).size();
		for (int j = si; j < 6; j++)cout << 0;
		cout << a[i];
		int me = lower_bound(all(vec[a[i]]), b[i]) - vec[a[i]].begin() + 1;
		si = to_string(me).size();
		for (int j = si; j < 6; j++)cout << 0;
		cout << me << endl;
	}
	endre;
}

Measured memory_bytes: 9344
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 3005

const ll INF = LLONG_MAX;

struct SegmentTree{

    int N;
    vector<ll> node;
    //const int INF = INT_MAX;

    void init(int siz){
        N = 1;
        while(N < siz){
            N *= 2;
        }
        node.resize(2*N-1,0);
    }

    void build(vector<int>& dat){
        for(int i = 0;i < dat.size();i++){
            node[i+N-1] = dat[i];
        }
        for(int i = N-2;i >= 0;i--){
            node[i] = max(node[2*i+1],node[2*i+2]);
        }
    }

    void update(int k,ll x){
        k += N-1;
        node[k] = x;
        while(k > 0){
            k = (k-1)/2;//親
            node[k] = max(node[2*k+1],node[2*k+2]);
        }
    }

    ll getMax(int a,int b,int k,int l,int r){
        if(r <= a || b <= l){
            return -INF;
        }
        if(a <= l && r <= b){
            return node[k];
        }
        ll vl = getMax(a,b,k*2+1,l,(l+r)/2);
        ll vr = getMax(a,b,k*2+2,(l+r)/2,r);
        return max(vl,vr);
    }

    ll getMax(int a,int b){
        return getMax(a,b,0,0,N);
    }
};


int main(){


    int n;
    cin >> n;
    vector<int> h(n),a(n);
    SegmentTree tree;
    tree.init(n);


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

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

        ll maxi = tree.getMax(0,h[i]) + a[i];//[0,h[i])までの最大値+h[i]での美しさ
        tree.update(h[i]-1,maxi);
    }

    cout << tree.getMax(0,n) << endl;

    return 0;
}

Measured memory_bytes: 5888
fun main(args: Array<String>) {
    val S = readLine()!!
    val f = S.substring(0..1).toInt(); val e = S.substring(2..3).toInt()
    when {
        f in 1..12 && e in 1..12 -> println("AMBIGUOUS")
        f in 1..12 && e !in 1..12 -> println("MMYY")
        f !in 1..12 && e in 1..12 -> println("YYMM")
        else -> println("NA")
    }
}

Measured memory_bytes: 31796
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

const long long INF=1e11;

int main(){
    int A,B,Q;
    cin>>A>>B>>Q;
    long long s[100000],t[100000];
    for(int i=0;i<A;i++){
        cin>>s[i];
    }
    for(int i=0;i<B;i++){
        cin>>t[i];
    }
    for(int i=0;i<Q;i++){
        long long x;
        long long ans=INF;
        cin>>x;
        long long* nextS=lower_bound(s,s+A,x);
        int posS=(int)(nextS-s);
        long long* nextT=lower_bound(t,t+B,x);
        int posT=(int)(nextT-t);
        long long leftS,rightS,leftT,rightT;
        if(posS==0){
            leftS=INF;
        }else{
            leftS=x-s[posS-1];
        }
        if(posS==A){
            rightS=INF;
        }else{
            rightS=s[posS]-x;
        }
        if(posT==0){
            leftT=INF;
        }else{
            leftT=x-t[posT-1];
        }
        if(posT==B){
            rightT=INF;
        }else{
            rightT=t[posT]-x;
        }
        ans=min(ans,max(leftS,leftT));
        ans=min(ans,max(rightS,rightT));
        ans=min(ans,2*leftS+rightT);
        ans=min(ans,2*leftT+rightS);
        ans=min(ans,2*rightS+leftT);
        ans=min(ans,2*rightT+leftS);
        cout<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 2816