akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

map<s64, s64> ans;

s64 popcount(string& x)
{
    int ret = 0;
    rep (i, x.size())
    {
        ret += x[i] == '1';
    }
    return ret;
}

s64 popcount(s64 x)
{
    s64 ret = 0;
    while (x)
    {
        if (x & 1) ++ret;
        x >>= 1;
    }
    return ret;
}

s64 f(string& x, s64 mod)
{
    if (mod == 0) return 0;
    s64 ret = 0;
    rep (i, x.size())
    {
        ret = ret * 2 + (x[i] - '0');
        ret %= mod;
    }
    return ret;
}

s64 calc(s64 x)
{
    if (x == 0) return 0;
    if (ans.find(x) != ans.end()) return ans[x];

    s64 pcnt = popcount(x);
    s64 ret = 0;
    ret += calc(x % pcnt) + 1;
    return ans[x] = ret;
}

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

    int n;
    cin >> n;

    string x;
    cin >> x;

    s64 pcnt = popcount(x);
    s64 xmod_plus, xmod_minus;
    if (pcnt == 0)
    {
        xmod_plus = f(x, pcnt + 1);
    }
    else if (pcnt == n)
    {
        if (pcnt - 1 != 0) xmod_minus = f(x, pcnt - 1);
    }
    else
    {
        xmod_plus = f(x, pcnt + 1);
        if (pcnt - 1 != 0) xmod_minus = f(x, pcnt - 1);
    }


    vs64 num_plus(n);
    vs64 num_minus(n);
    if (pcnt != n) num_plus[0] = 1 % (pcnt + 1);
    if (pcnt != 0 && pcnt - 1 != 0) num_minus[0] = 1 % (pcnt - 1);
    rep (i, n - 1)
    {
        if (pcnt != n) num_plus[i + 1] = num_plus[i] * 2 % (pcnt + 1);
        if (pcnt != 0 && pcnt - 1 != 0) num_minus[i + 1] = num_minus[i] * 2 % (pcnt - 1);
    }

    vs64 cnt(n);
    for (int i = n - 1; i >= 0; --i)
    {
        if (x[i] == '0')
        {
            s64 temp = xmod_plus + num_plus[n - i - 1];
            temp %= (pcnt + 1);
            cnt[i] = calc(temp) + 1;
        }
        else
        {
            if (pcnt - 1 == 0)
            {
                cnt[i] = 0;
                continue;
            }
            s64 temp = xmod_minus + (pcnt - 1) - num_minus[n - i - 1];
            temp %= (pcnt - 1);
            cnt[i] = calc(temp) + 1;
        }
    }

    rep (i, n)
    {
        cout << cnt[i] << "\n";
    }
    return 0;
}



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

int main(void){

    //入力
    int N;
    cin >> N;

    string S;
    cin >> S;

    //処理
    int black[N+1], white[N+1];

    black[0]=0;
    white[0]=0;

    for(int i=0;i<N;i++){
        if( S[i] == '.' )   white[0]++;
    }
    
    int ans = black[0]+ white[0];

    for(int i=0;i<N;i++){
        if(  S[i] == '#'){
            black[i+1]=black[i]+1;
            white[i+1]=white[i];
        }else{
            black[i+1]=black[i];
            white[i+1]=white[i]-1;
        }
        if( black[i+1]+white[i+1] < ans )   ans = black[i+1] + white[i+1];
    }

    cout << ans << endl;

}

Measured memory_bytes: 2180
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

int main() {

    string s;
    cin >> s;

    vector <vector <int>> v;
    v.resize(26);

    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        v[c - 'a'].push_back(i);
    }

    int ans = s.size();
    for (int i = 0; i < 26; i++) {

        if (v[i].empty()) continue;

        int curAns = 0;

        for (int j = 0; j < v[i].size(); j++) {
            if (j == 0) {
                curAns = max(curAns, v[i][j]);
            } else {
                curAns = max(curAns, (v[i][j] - v[i][j - 1] - 1));
            }
        }
        curAns = max(curAns, (int)s.size() - 1 - v[i].back());
        ans = min(ans, curAns);
    }
    cout << ans << endl;



    return 0;
}

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

using namespace std;

int main() {
	int a;
	vector<int> v;
	for (int i = 0; i < 5; i++) {
		cin >> a;
		v.emplace_back(a);
	}
	sort(v.begin(), v.end(), std::greater<int>());
	for (int i = 0; i < 5; i++) {
		cout << v[i];
		if (i != 4) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  ll V = 0, E = 0;
  for (int i = 1; i <= n; ++i) V += ll(i)*(n-i+1);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a,b);
    E += ll(a)*(n-b+1);
  }
  ll ans = V-E;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    StringBuffer s[]=new StringBuffer[n];
    String ss[]=new String[n];
    for(int i=0;i<n;i++){
      s[i]=new StringBuffer(sc.next());
    }
    
    for(int i=0;i<n;i++){
      for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      }
      ss[i]=new String(s[i]);
    }
    Arrays.sort(ss);
    
    long sum=0;
    int kk=0;
    int sk=0;
    while(kk<n){
        kk=calc(ss,n,sk);
        sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
        sk=kk;
    }
    sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
    System.out.println(sum);
  }
  static int calc(String[] ss,int n,int f){
    for(int i=f+1;i<n;i++){
      if(!ss[f].equals(ss[i])){
        return i;
      }
    }
    return n;
  }
}

Measured memory_bytes: 58000
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);



int main(){
	ll a,b,n;
	cin>>n>>a>>b;
	ll total=(ll)n/(a+b);
	ll ans=0;
	ans+=total*a;
	ll left=n-(a+b)*total;
	if(left>a) ans+=a;
	else ans+=left;
	cout<<ans<<endl;

    
}

Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
int main(){
    int k;
    cin >> k;
    ll s=7;
    ll ans=1;
    while(1){
        if(s%k==0){
            cout<<ans<<endl;
            return 0;
        }else{
            s%=k;
            s=s*10+7;
            ans++;
        }
        if(k%2==0){
            break;
        }
        if(ans>k+1){
            break;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3572
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] u = new int[M];
            int[] v = new int[M];
            ArrayList<Integer>[] v2 = new ArrayList[N];
            for (int i = 0; i < v2.length; i++) {
                v2[i] = new ArrayList<Integer>();
            }
            for (int i = 0; i < M; i++) {
                u[i] = in.nextInt() - 1;
                v[i] = in.nextInt() - 1;
                v2[u[i]].add(v[i]);
            }
            int S = in.nextInt() - 1;
            int T = in.nextInt() - 1;

//            ArrayList<Integer>[] v3 = new ArrayList[N];
//            for (int i = 0; i < v3.length; i++) {
//                v3[i] = new ArrayList<Integer>();
//            }
//            for (int i = 0; i < N; i++) {
//                for (Integer vertex : v2[i]) {
//                    for (Integer vertex2 : v2[vertex]) {
//                        for (Integer vertex3 : v2[vertex2]) {
//                            if (!v3[i].contains(vertex3)) {
//                                v3[i].add(vertex3);
//                            }
//                        }
//                    }
//                }
//            }

            LinkedList<Integer> queue = new LinkedList<>();
            boolean[][] used = new boolean[3][N];
            {
                queue.add(S);
                queue.add(0);
                used[0][S] = true;
            }
            for (; !queue.isEmpty();) {
                int n = queue.pollFirst().intValue();
                int dist = queue.pollFirst().intValue();
                if (dist % 3 == 0 && n == T) {
                    System.out.println(dist / 3);
                    return;
                }
                for (Integer vertex : v2[n]) {
                    if (used[(dist + 1) % 3][vertex.intValue()]) {
                        continue;
                    }
                    used[(dist + 1) % 3][vertex.intValue()] = true;
                    queue.add(vertex.intValue());
                    queue.add(dist + 1);
                }
            }
            System.out.println(-1);
        }
    }

}


Measured memory_bytes: 102712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();sc.nextLine();
		String[] B = sc.nextLine().split(" ");
		String[] A = new String[N];
		int AB = 0, cnt = 0;
		String[] AM;
		for(int i = 0;i < N; i++) {
			A[i] = sc.nextLine();
			AB = 0;
			for(int j = 0; j < M; j++) {
				AM = A[i].split(" ");
				AB += Integer.parseInt(AM[j]) * Integer.parseInt(B[j]);
				//System.out.println(Integer.parseInt(AM[j]) + " " + Integer.parseInt(B[j]));
			}
			if(AB + C > 0) cnt++;
		}

		sc.close();
		System.out.println(cnt);
	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
void solve(){
	string str;cin>>str;
	int cnt=0;
	for(int i=0;i<str.length();i++){
		cnt+=(str[i]-'0');
	}
	if(cnt%9==0) cout<<"Yes";
	else cout<<"No";
} 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3708
a=input().split()
ans='No'
if a[0] == a[1] and not a[2] == a[0] :
	ans = 'Yes'
elif a[0] == a[2] and not a[1] == a[0] :
	ans = 'Yes'
elif a[2] == a[1] and not a[2] == a[0] :
	ans = 'Yes'
print(ans)

Measured memory_bytes: 3060
def main():
    n = int(input())
    # t, a = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()

    if n == 25:
        print("Christmas")
    elif n== 24:
        print("Christmas Eve")
    elif n==23:
        print("Christmas Eve Eve")
    elif n==22:
        print("Christmas Eve Eve Eve")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61832
#include <stdio.h>
#include <string.h>

#define REP(i, n) for(i=0;i<n;i++)
#define MOD_NUM (1000000007)

int main(void)
{
	char str[21];
	int i;

	fgets(str, sizeof(str), stdin);

	for (int i = strlen(str) - 1; i >= 0; i--){
		if (str[i] == '\r' || str[i] == '\n') continue;
		
		printf("%c", str[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2404
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"yes":"no")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n;
    int ans=0;
    cin >>n;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }
    int q;
    cin>>q;
    int bef=0;
    vector<bool>m(2000*21,false);
    sort(all(a));
    for(int bit=0;bit<(1<<n);bit++){

       
        m[bef]=true;
        bef = 0;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                bef+=a[i];
            }
        }

    }
    rep(i,q){
        cin>>bef;
        cout<<solve(m[bef])<<endl;
    }
}


Measured memory_bytes: 3180
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<P> a(n);
  REP(i,n) cin >> a[i].fs >> a[i].sc;
  
  auto comp = [&](P a, P b){
    return min(a.fs,b.fs-a.sc) > min(b.fs,a.fs-b.sc);
  };
  sort(a.begin(),a.end(),comp);

  mat dp(n+1,vec(n+1,INF));
  dp[0][0] = 0;
  REP(i,n){
    REP(j,n+1){
      dp[i+1][j] = min(dp[i+1][j],dp[i][j]); //取らない
      if(dp[i][j] <= a[i].fs && j+1 < n+1) dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+a[i].sc); //取る
    }
  }

  RREP(i,n+1){
    if(dp[n][i] != INF){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 196096
#include <bits/stdc++.h>
using namespace std; 
string s;
int flg=0;
void dfs(int i,string ans,int sum){
     if(i==3){
         if(sum==7){
             cout << ans << "=7" << endl;
             flg=1;
         }
         return;
     }
     dfs(i+1,ans+"+"+s.at(i+1),sum+(s.at(i+1)-'0'));
     if(flg==1)
        return;
     dfs(i+1,ans+"-"+s.at(i+1),sum-(s.at(i+1)-'0'));
}

int main(){
    int i=0,sum=0;
    cin >> s;
    string ans = "";
    ans.push_back(s.at(0));
    dfs(0,ans,s.at(0)-'0');
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>

using namespace std;


#define INF pow(10, 9)
// typedef priority_queue<tuple<int,int,int>, vector< tuple<int, int, int> >, greater< tuple<int, int, int> > > PQ;

typedef long long int ll;


ll calc_pow(ll base, int pow, ll div)
{
    ll val = 1;
    while(pow>1)
    {
        if(pow%2==1)
        {
            val = val*base %div;
        }
        base = base*base % div;
        pow /= 2;
    }
    return val * base%div;
}

int main(void)
{

    int N;
    cin >> N;

    int comb = 0;
    for(int c = 1; c<N; c++)
    {
        int mul = N-c;
        int Max = floor( sqrt(mul) );
        for(int a = 1; a<= Max; a++)
        {
            if(mul%a==0)
            {
                if(a*a==mul) comb+= 1;
                else comb += 2;
            }
        }
    }
    cout << comb << endl;







    return 0;
}


Measured memory_bytes: 3648
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int W = sc.nextInt();

		int[] v = new int[N];
		int[] w = new int[N];

		for (int i = 0; i < N; i++) {
			v[i] = sc.nextInt();
			w[i] = sc.nextInt();
		}

		sc.close();

		int[][] dp = new int[N + 1][W + 1]; // dp[i][weight] iより前までで、重さwightとなるように選んだ時の最大のv

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

			for (int weight = 0; weight <= W; weight++) {
				dp[i + 1][weight] = dp[i][weight];
				if (weight - w[i] >= 0) {
					dp[i + 1][weight] = Math.max(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]);
				}
			}

		}

		out.println(dp[N][W]);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}



Measured memory_bytes: 31032
from collections import deque


def get_pow():
    cache = {}

    def func(x):
        if x not in cache:
            cache[x] = pow(2, x, mod)
        return cache[x]

    return func


mod = 1000000007
n = int(input())
parents = list(map(int, input().split()))
children = [set() for _ in range(n + 1)]
for c, p in enumerate(parents):
    children[p].add(c + 1)

levels = [{0}]
while True:
    level = set()
    for p in levels[-1]:
        level.update(children[p])
    if not level:
        break
    levels.append(level)
levels.reverse()

level_node_count = []
balls = [None] * (n + 1)

for i, level in enumerate(levels):
    level_node_count.append(len(level))
    for node in level:
        cn = children[node]
        if cn:
            if len(cn) == 1:
                bs = balls[cn.pop()]
                bs.appendleft([1, 1, 0])
                balls[node] = bs
                continue
            balls_from_children = [balls[c] for c in children[node]]
            balls_from_children.sort(key=len)
            bs1 = balls_from_children[0]
            for bs2 in balls_from_children[1:]:
                for (b10, b11, b12), b2 in zip(bs1, bs2):
                    b2[2] = ((b11 + b12) * b2[1] + b12 * b2[0]) % mod
                    b2[1] = (b10 * b2[1] + b11 * b2[0]) % mod
                    b2[0] = b2[0] * b10 % mod
                bs1 = bs2
            for b in bs1:
                b[0] = (b[0] + b[2]) % mod
                b[2] = 0
            bs1.appendleft([1, 1, 0])
            balls[node] = bs1
        else:
            balls[node] = deque([[1, 1, 0]])

level_node_count.reverse()

pow2 = get_pow()
print(sum(b[1] * pow2(n - l + 1) % mod for l, b in zip(level_node_count, balls[0])) % mod)


Measured memory_bytes: 234184
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;

typedef pair<int,int> pii;
const int MAX_N=20001;
int N;
bool used[2][MAX_N];
int headAng[2][MAX_N];
map<int,map<int,pii> > m;
pii futons[2][MAX_N];

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

void dfs(int s,int idx){
  used[idx][s]=true;
  pii p=futons[idx][s];
  int ncol=headAng[idx][s];
  for(int i=0;i<4;i++){
    int ny=p.first+dy[i];
    int nx=p.second+dx[i];
    if(m.count(ny)>0&&m[ny].count(nx)>0){
      int ns=m[ny][nx].first;
      int nidx=m[ny][nx].second;
      if(ns!=s){
	if(headAng[nidx][ns]==-1){
	  headAng[nidx][ns]=ncol;
	}
	else if(headAng[nidx][ns]!=ncol){
	  ok=false;
	  return;
	}
	if(!used[nidx][ns])dfs(ns,nidx);
      }
      else{
	if(headAng[nidx][ns]==-1){
	  headAng[nidx][ns]=1^ncol;
	}
	else if(headAng[nidx][ns]==ncol){
	  ok=false;
	  return;
	}
	if(!used[nidx][ns])dfs(ns,nidx);
      }
    }
  }
}

int main(){

  while(cin>>N&&N){
    ok=true;
    memset(used,0,sizeof(used));
    memset(headAng,-1,sizeof(headAng));
    m.clear();
    for(int i=0;i<N;i++){
      int x,y;
      char ang;
      cin>>x>>y>>ang;
      futons[0][i]=pii(y,x);
      if(ang=='x')futons[1][i]=pii(y,x+1);
      else futons[1][i]=pii(y+1,x);
      m[futons[0][i].first][futons[0][i].second]
	=pii(i,0);
      m[futons[1][i].first][futons[1][i].second]
	=pii(i,1);
    }
    for(int i=0;i<N;i++){
      if(used[0][i])continue;
      headAng[0][i]=0;
      dfs(i,0);
      if(!ok)break;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 14000
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N/100==7 || (N%100)/10==7 || ((N%100)%10)==7){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35820
class dfs:
    def __init__(self,W,H,m):
        self.W=W
        self.H=H
        self.m=m
        self.ans=0
        self.visited=[[False]*W for _ in range(H)]
    def trav(self,x,y):
        #print(x,y)
        self.visited[x][y]=True
        self.ans+=1
        offset=[(-1,0),(0,-1),(1,0),(0,1)]
        for dx,dy in offset:
            x2=x+dx
            y2=y+dy
            if 0<=x2<self.H and 0<=y2<self.W and self.m[x2][y2]=='.' and self.visited[x2][y2]==False:
                self.trav(x2,y2)
    

while True:
    W,H=map(int,input().split())
    if not (W and H): break
    m=[]
    for i in range(H):
        L=list(input())
        if '@' in L:
            (sx,sy)=(i,L.index('@'))
        m.append(L)
    D=dfs(W,H,m)
    D.trav(sx,sy)
    print(D.ans)


Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
 
  int cnt = 0;
  for (int i = 0; i < N-2; i++) {
    for (int j = i+1; j < N-1; j++) {
      for (int k = j+1; k < N; k++) {
        int a = L.at(i);
        int b = L.at(j);
        int c = L.at(k);
        if (a < b+c && b < a+c && c < a+b) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#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 int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 5005;

int i,n,ans;

void solve()
{
    cin>>n;
    ans=((n+1000-1)/1000)*1000-n;
    cout<<ans;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    S = list(map(int, S))
    N = len(S)

    ans = 0
    for bit in range(1 << (N - 1)):
        n = 0
        for i, s in enumerate(S):
            n = 10 * n + s
            if bit & (1 << i):
                ans += n
                n = 0
        ans += n

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9496
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll n, m, d;

int main() {
  cin >> n >> m >> d;
  ll p = 2*(n-d)*(m-1); ll q = n*n;
  if (d != 0)
    printf("%.10f\n", double(p)/double(q));
  else  
    printf("%.10f\n", double(p)/double(q*2));

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		//
		int height = 0;
		int width = 0;

		// 表の縦、横を決める入力値を持ってくる
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			height = sc.nextInt();
			width = sc.nextInt();
			break;
		}

		// シートのインスタンスを作る
		excel ex = new excel();

		// 入力値から表を作る
		ex.setSheet(height, width);

		// 表に入力する値を持ってくる
		while (sc.hasNext()) {

			// 入力された値を表のそれぞれの場所に入れる
			for (int i = 0; i < height; i++) {
				for (int s = 0; s < width; s++) {
					int input_number = sc.nextInt();
					ex.setSell(input_number, i, s);
				}
			}
			break;
		}
		// 表の最後の列に行の計算結果を挿入
		ex.sum_row();
		ex.sum_column();

		// 表全体を出力
		ex.out_sheet();

	}
}

class excel {

	// フィールド
	int[][] sheet;

	// 入力値から表(2次元配列)を作るメソッド
	public void setSheet(int height, int width) {

		// 最後に合計値を出す列を用意
		sheet = new int[height + 1][width + 1];
	}

	// 入力値をセルに入れる
	public void setSell(int input_number, int height, int width) {
		sheet[height][width] = input_number;
	}

	// 行の合計値を最後のセルに追加
	public void sum_row() {
		// 行の数だけ回す
		for (int i = 0; i < sheet.length; i++) {

			// 列の数だけ回す
			int sum = 0;
			for (int s = 0; s < sheet[0].length; s++) {

				// 行の合計値
				sum = sheet[i][s] + sum;
			}
			// 最後に追加
			sheet[i][(sheet[0].length - 1)] = sum;
		}
	}

	// 列の合計値を最後のセルに追加
	public void sum_column() {
		// 列の数だけ回す
		for (int c = 0; c < sheet[0].length; c++) {

			// 行の数だけ回す
			int sum = 0;
			for (int s = 0; s < sheet.length; s++) {

				// 行の合計値
				sum = sheet[s][c] + sum;
			}
			// 最後に追加
			sheet[sheet.length-1][c] = sum;
		}
	}

	// 表全体を出力
	public void out_sheet() {

		// 行の回数
		for (int i = 0; i < sheet.length; i++) {

			// 列の回数
			for (int s = 0; s < sheet[0].length - 1; s++) {
				// 空白を一つ空けて表示
				System.out.print(sheet[i][s] + " ");
			}
			// 最後の行を改行
			System.out.println(sheet[i][(sheet[0].length - 1)]);
		}
	}
}

Measured memory_bytes: 38752
S = list(input())
N = len(S)
child = [1] * N
memo = []

# RLのインデックスを取得する
for i in range(N-1):
    if S[i] == "R" and S[i+1] == "L":
        memo.append(i)
        memo.append(i+1)

memo.append("dummy")
count = 0
for i in range(N):
    if i != memo[count]:
        if S[i] == "R":
            if (memo[count] - i) % 2 == 0:
                child[memo[count]] += 1
                child[i] -= 1
            else:
                child[memo[count+1]] += 1
                child[i] -= 1
        elif S[i] == "L":
            if (i - memo[count-1]) % 2 == 0:
                child[memo[count-1]] += 1
                child[i] -= 1
            else:
                child[memo[count-2]] += 1
                child[i] -= 1
    else:
        count += 1

ans = [str(n) for n in child]
ans = " ".join(ans)
print(ans)

Measured memory_bytes: 15140
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    ll w = 0;
    P p;
    bool ok = false;
    rep1(n, 3500) {
        rep(h, 3500) {
            ll x = 4*h*n-N*n-N*h;
            ll y = N*h*n;
            if (x<=0) continue;
            if (y%x!=0) continue;
            w = y/x;
            if (w>3500) continue;
            debug(w);
            p = P(n, h);
            ok = true;
            break;
        }
        if (ok) break;
    }
    debug(w);
    
    printf("%lld %lld %lld\n", p.fi, p.se, w);
    return 0;
}


Measured memory_bytes: 3768
<?php
$stdin = fopen( "php://stdin", "r" );
fscanf( $stdin, "%[^\n]", $input );
$arr_input = explode( " ", $input);
$aux_5 = 0;
$aux_7 = 0;
foreach( $arr_input as $v ) {
	if( $v == 5 ) $aux_5++;
	if( $v == 7 ) $aux_7++;
} 
if( $aux_5 == 2 && $aux_7 == 1) {
	echo "YES";
} else {
	echo "NO";
}
fclose( $stdin );
?>



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

using namespace std;

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

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

    long long ans = 0;
    int maxh = 0;
    for(int i = 0; i < N; i++) {
        maxh = max(maxh, A[i]);
        ans += maxh - A[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4044
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str1 = sc.next();
    String str2 = sc.next();
    String str3 = sc.next();
    char a = str1.charAt(str1.length()-1);
    char b = str2.charAt(0);
    char c = str2.charAt(str2.length()-1);
    char d = str3.charAt(0);
    if(a==b&&c==d){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

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

using ll = long long;

int main(){
  string S;
  cin >> S;

  bool isABC = (S[1]=='B');
  cout << (isABC ? "ARC" : "ABC") << endl;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
	int m,d,x,y,i,j,s=0;
	cin>>m>>d;
	for(i=1;i<=m;i++){
		for(j=22;j<=d;j++){
			x=j%10;y=j/10;
			if(x>1&&y>1&&x*y==i){
				s++;
			}
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int w=0,h=0,x=0,y=0,r=0;
	cin >> w >> h >> x >> y >> r; 
	/*cout <<"長方形の座標:(" <<  w <<"," << h<< ")" << endl;
	cout <<"円の中心の座標:(" << x <<"," << y << ")";
	cout << ",円の半径:" << r << endl;
	*/
	if(w >= r+x and h >= r+y and 0 <= x-r and 0 <= y-r){
		cout <<"Yes" << endl;
	} 
	else{cout << "No" << endl;}
	return 0;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    int a = 0, b = 0;
    cin >> a >> b;
    string s = "";
    cin >> s;
    if (s.at(a) != '-') cout << "No" << endl;
    else {
        for (int i=0; i<a+b+1; i++) {
            if (i == a) continue;
            else if (s.at(i) < '0' || s.at(i) > '9') {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import collections

S=input()
S=collections.Counter(S)

if (S["N"]>0 and S["S"]>0) or (S["N"]==0 and S["S"]==0):
  if (S["E"]>0 and S["W"]>0) or (S["E"]==0 and S["W"]==0): 
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll ans[2000];
vi v[2001];
ll n,x,y;
void bfs(ll s){
	vi dis(n+1,inf);
	vi viz(n+1,false);
	queue<ll> q;
	q.push(s);
	dis[s]=0;
	viz[s]=true;
	while(q.size()){
		ll u=q.front();
		q.pop();
		for(ll i=0;i<v[u].size();i++){
			ll node= v[u][i];
			if(viz[node]) continue;
			dis[node] = dis[u]+1;
			q.push(node);
			viz[node]=true;
		}
	}
	for(ll i=1;i<=n;i++){
		ans[dis[i]]++;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>x>>y;
	for(ll i=1;i<n;i++){
		v[i].pb(i+1);
		v[i+1].pb(i);
	}
	v[x].pb(y);
	v[y].pb(x);
	for(ll i=1;i<n;i++) ans[i]=0;
	for(ll i=1;i<=n;i++){
		bfs(i);
	}
	for(ll i=1;i<n;i++) cout<<ans[i]/2<<"\n";
	
	return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n=in();
  int sum=0;
  rep(i,n) sum+=i+1;
  print(sum);

  return 0;
}

Measured memory_bytes: 256
def calc(a, b):
  return a ** 5 - b ** 5

x = int(input())
even = 0
if x % 2 == 0:
  even = 1
flag = 0
if even:
  a = 2
else:
  a = 1
b = 0
while (True):
  while (True):
    if calc(a,b) == x:
      flag = 1
      break
    elif calc(a,b) > x:
      break
    b -= 2
  if flag == 1:
    break
  a += 1
  if even:
    b = a - 2
  else:
    b = a - 1
print(a, b)
      

Measured memory_bytes: 9196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    string S,T; cin >> S >> T;
    for(int i = 0; i < N;i++){
        res += S[i];
        res += T[i];
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
import math
A, B, H, M = map(int,input().split(" "))

t1 = (H * 360 / 12) + (M * (360/12) / 60)
t2 = (M * 360 / 60)

theta1 = max(t1, t2) - min(t1, t2)
theta2 = 360 + min(t1, t2) - max(t1, t2)
theta = math.radians(min(theta1, theta2))
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)))

Measured memory_bytes: 9296
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):

    sa = [0]
    for a in A:
        sa.append(sa[-1]+a)
    
    s = []
    for i in range(N+1):
        for j in range(i+1, N+1):
            s.append(sa[j]-sa[i])
    s.sort()


    pool = s
    for b in range(s[-1].bit_length(), -1, -1):
        cnd = []
        v = 1 << b
        for a in pool:
            if a & v > 0:
                cnd.append(a)
        if len(cnd) >= K:
            pool = cnd

    return reduce(lambda x, y: x&y,  pool)

        




def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

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

  int n;
  cin >> n;
  int a[n];
  REP(i,n) cin >> a[i];

  vector<int> res(n);
  int idx = 0;
  for(int i=n-1;i>=0;i-=2){
    res[idx++] = a[i];
  }
  idx = n-1;
  for(int i=n-2;i>=0;i-=2){
    res[idx--] = a[i];
  }

  REP(i,n){
    cout << res[i] << " ";
  }
  
  return 0;
}


Measured memory_bytes: 4764
#include<stdio.h>

int main(void){
  int MAX = 100;
  int i, j, k, n, A[MAX], v;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", &A[i]);
  for(k=0;k<n-1;k++) printf("%d ", A[k]);
  printf("%d\n", A[n-1]);
  for(i=1;i<n;i++){
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
      //printf("j = %d\n", j);                                                  
      //printf("A[j] = %d, A[j+1] = %d\n", A[j], A[j+1]);                       
    }
    A[j+1] = v;
    for(k=0;k<n-1;k++) printf("%d ",A[k]);
    printf("%d\n", A[n-1]);
  }
}







Measured memory_bytes: 2036
#include <iostream>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
ll pre[maxn];
ll bsum[maxn],psum[maxn];
ll dp[maxn];
int main() {
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>pre[i];
    ll ans=0;
    for(int i=2;i<=n;i+=2) ans+=pre[i];
    psum[1]=pre[1];bsum[n]=pre[n];dp[n-3]=pre[n]+pre[n-3];
    for(int i=2;i<=n;i++) psum[i]=psum[i-2]+pre[i];
    for(int i=n-1;i>=1;i--) bsum[i]=bsum[i+2]+pre[i];
    if(n%2==0){
        ll a1=0,a2=0,ans;
        for(int i=1;i<=n;i++) if(i%2) a1+=pre[i];else a2+=pre[i];
        ans=max(a1,a2);
        for(int i=2;i<=n-1;i+=2) ans=max(ans,psum[i-1]+bsum[i+2]);
        cout<<ans<<endl;
        return 0;
    }
    for(int i=1;i<=n-1;i++) ans=max(ans,psum[i-1]+bsum[i+2]);
    for(int i=2;i<=n-3;i+=2) ans=max(ans,psum[i-1]+bsum[i+3]);
    for(int i=n-5;i>=2;i-=2) dp[i]=max(pre[i]+bsum[i+3],pre[i]+dp[i+2]);
    for(int i=2;i<=n-5;i+=2) ans=max(ans,psum[i-1]+dp[i+2]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9832
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int get_log(int x){
    return (log(x)/log(10));
}
int first(int n)
{
    while (n >= 10)
        n /= 10;
    return n;
}
int last(int n){
    return n%10;
}

int main()
{
    int n;
    cin>>n;
    int res = 0;
    int arr[10][10]= {0};
    for(int i=1;i<=n;++i){
        arr[first(i)][last(i)]++;

    }
    for(int i=1;i<=9;++i){
        for(int j=1;j<=9;++j){
            if(i==j){
                res+=(arr[i][j]*arr[j][i]);
            }
            else res+=(arr[i][j]*arr[j][i]);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
n, k, q =map(int, input().split())
a = [int(input()) for i in range(q)]

p = [0]*(n+1)

for i in range(q):
  p[a[i]] += 1
  

for i in range(1,n+1):
  if p[i]>q-k:
    print("Yes")
  else:
    print("No")

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

int main() {
  
  int N; string S; cin >> N >> S;
  
  int ans = 0; int tmp = 0;
  
  for (int i = 0; i < N; i++) {
    
    if (S.at(i) == 'I') tmp++;
    else tmp--;
    
    ans = max(ans, tmp);
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256