akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

const i64 INF = 1LL << 60;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<i64> A(N);
  for (auto& x : A) cin >> x;
  const int skip = (N % 2 == 0) ? 1 : 2;
  // pfilled[i][k] = maxsum at i, where i is selected and there's k room.
  vector<vector<i64>> pfilled(N, vector<i64>(3, -INF));
  // pempty[i][k] = maxsum at i, where i is not selected and there's k room.
  vector<vector<i64>> pempty(N, vector<i64>(3, -INF));

  pempty[0][skip - 1] = 0;
  pfilled[0][skip] = A[0];
  for (int i = 1; i < N; ++i) {
    REP(j, 3) {
      pfilled[i][j] = pempty[i - 1][j];
      if (pfilled[i][j] != -INF) {
        pfilled[i][j] += A[i];
      }
      pempty[i][j] = pfilled[i - 1][j];
      if (j < 2) {
        pempty[i][j] = max(pempty[i][j], pempty[i - 1][j + 1]);
      }
    }
  }

  i64 ans = -INF;
  REP(j, 2) {
    ans = max(ans, pfilled[N - 1][j]);
    ans = max(ans, pempty[N - 1][j]);
  }
  assert(ans != -INF);
  cout << ans << endl;
}

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

#define ll long long int

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll d=(b/n);
    d=d*n;
    if(d>=a)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll n,m,v,p;
    in>>n>>m>>v>>p;
    vector<ll> a(n),s(n+1);
    for(auto&i:a) in>>i;
    sort(a.begin(),a.end());
    fr(i,n) s[i+1]=s[i]+a[i];
    ll l=-1,r=n-p,d;
    while(r-l>1){
        d=(l+r)>>1;
        if(v<=p+d){
            if(a[d]+m>=a[n-p]) r=d;
            else l=d;
        }
        else{
            ll V=v-p-d,S=a[d]+m;
            ll y=(n-p-d)*S-(s[n-p+1]-s[d+1]);
            if(S<a[n-p]) l=d;
            else if(y>=V*m) r=d;
            else l=d;
        }
    }
    cout<<n-r<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

void OutPut(bool* tmp, char mark)
{
	for (int i = 0; i < 13; i++) {
		if (tmp[i] == false) {
			printf("%c %d\n", mark, i + 1);
		}
	}
}

int main() {
	bool s[13], h[13], c[13], d[13];
	for (int i = 0; i < 13; i++) {
		s[i] = h[i] = c[i] = d[i] = false;
	}
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int num;
		char mark[2];
		scanf("%s %d", mark, &num);
		switch (mark[0]) {
		case 'S':
			s[num - 1] = true;
			break;
		case 'H':
			h[num - 1] = true;
			break;
		case 'C':
			c[num - 1] = true;
			break;
		case 'D':
			d[num - 1] = true;
			break;
		default:
			break;
		}
	}
	OutPut(s, 'S');
	OutPut(h, 'H');
	OutPut(c, 'C');
	OutPut(d, 'D');
}



Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int x,n;
    cin >> x >> n;
    vector<bool>a(2000,true);
    for(int i=0;i<n;i++){
        int z;
        cin >>z;
        a.at(z)=false;
    }
    for(int j=0;j<=1030;j++){
        int mae = j+x;
        int usiro = x-j;
        if(usiro<0){
            cout<<0<<endl;
            return 0;
        }
                 if(a.at(usiro)){
            cout<<usiro<<endl;
            return 0;
        }
        if(a.at(mae)){
            cout<<mae<<endl;
            return 0;
        }
        
    }
}
    



Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    ll ans = 0, sub = 0;
    rep(i, 60){
        int cnt = 0;
        rep(j, N) if(A[j] & (1LL<<i)) cnt++;
        if(cnt&1){
            ans |= (1LL<<i);
            rep(j, N) if(A[j] & (1LL<<i)) A[j] ^= (1LL<<i);
        }
    }
    rep3(i, 59, 0){
        int k = -1;
        rep(j, N){
            if(A[j] < (1LL<<(i+1)) && (A[j] & (1LL<<i))) k = j;
        }
        if(k == -1) continue;
        rep(j, N){
            if((A[j] & (1LL<<i)) && j != k) A[j] ^= A[k];
        }
    }
    rep(i, N) sub ^= A[i];
    cout << ans+(sub<<1) << endl;
}

Measured memory_bytes: 1024
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, x;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            x = a * n;
            if (x > b) x = b;

            Console.WriteLine(x);

            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n;
    cin >> n;
    vector<int> a, b, c;
    rep(i, n){
        int x;
        cin >> x;
        a.push_back(x);
    }
    rep(i, n) {
      int x;
      cin >> x;
      b.push_back(x);
    }
    rep(i, n-1) {
      int x;
      cin >> x;
      c.push_back(x);
    }
    int res=0;
    rep(i, n){
        res += b[a[i]-1];
        if(i!=0&&a[i]-a[i-1]==1){
            res += c[a[i-1]-1];
        }
    }
    cout << res << endl;
    return 0;
}

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

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

    int trans_map['z'+1] = {0};
    bool flag = true;
    for(int i=0;i<S.size();i++){
        unsigned char s = S[i];
        unsigned char t = T[i];

        if(trans_map[(int)s]==0){
            trans_map[(int)s] = (int)t;
        }
        else{
            if(trans_map[s] != (int)t){
                flag = false;
                break;
            }
        }
    }


    if(flag){
        int use_alphabet['z'+1] = {0};

        for(int i='a';i<='z';i++){
            use_alphabet[trans_map[i]]++;
        }

        for(int i='a';i<='z';i++){
            if(use_alphabet[i] >= 2){
                flag = false;
            }
        }
    }

    if(flag)
        cout << "Yes" << endl;
    else   
        cout << "No" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int main(){
 ll a ,b ,n ,cont=1;
     cin>>a>>b;
     n =b ;
    while(b<=a)
    {
        b=b*n ;
        cont++;
    }

        cout<<cont <<endl;
 return 0  ;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n),b(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ll ans;
  if(n%2) {
    ll l=a[n/2];
    ll r=b[n/2];
    ans=r-l+1;
  }
  else {
    ll l=a[n/2]+a[n/2-1];
    ll r=b[n/2]+b[n/2-1];
    ans=r-l+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6428
N,M=map(int,input().split())
H=[-1]
H.extend(list(map(int,input().split())))

lose = set()

for _ in range(M):
    A,B=map(int,input().split())
    if H[A]<H[B]:
        lose.add(A)
    elif H[A]>H[B]:
        lose.add(B)
    elif H[A]==H[B]:
        lose.add(A)
        lose.add(B)

print(N-len(lose))

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

int main() {
  string S;
  cin >> S;
  
  int N = S.size();
  
  
  for (int i = 0; i < N / 2; i++) {
    if (S.at(i) != S.at(N-1-i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  for (int i = 0; i < N/4; i++) {
    if (S.at(i) != S.at(N/2 -1-i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
}


Measured memory_bytes: 256
#%%
import collections
import bisect
#%%
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
for x,y in sorted(p): # p自体を変えないことで、市の順番は保っておく
    a[x]+=[y] # 各県に対し、存在する生誕年を昇順でリスト化する。最初の1つはdefaultdictよりOK
for x,y in p: # 各市を1つずつ取得
    z=bisect.bisect(a[x],y) # bisectでindexを探索。bisect_rightに注意。
    print("%06d%06d"%(x,z))


Measured memory_bytes: 80980
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	N := getInt()
	K := getInt()

	var H []int
	for i := 0; i < N; i++ {
		H = append(H, getInt())
	}

	sort.Sort(sort.Reverse(sort.IntSlice(H)))

	for i := 0; i < K; i++ {
		if i == N {
			break
		}
		H[i] = 0
	}

	sum := 0
	for i := 0; i < N; i++ {
		sum += H[i]
	}

	fmt.Println(sum)
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 8576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		long r = scanner.nextLong();
		
		System.out.println(r*r);

	}
} 

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;

ll power(ll a,ll b)
{
   ll res=1;
    while(b)
    {
     if(b&1)res=res*a;
        a=a*a;
        b/=2;
    }
    return res;
}


void solve()
{
ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max({a*c,a*d,b*c,b*d});
    cout<<ans<<endl;
}


int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector <ll> a;
  REP(i,3*n){
    ll b;
    cin >> b;
    a.pb(b);
  }
  ll sum = 0;
  sort(a.begin(),a.end());
  for(int i = n;i < a.size()-1;i = i+2){
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 5744
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}


bool check(int dt, int dx, int dy) {
	int diff = abs(dx) + abs(dy);
	return (dt >= diff) && (dt - diff) % 2 == 0;
}
int main() {
	int N, pt=0, px=0, py=0, t, x, y;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> t >> x >> y;
		bool ok = check(t-pt, x - px, y - py);
		if (ok) {
			pt = t;
			px = x;
			py = y;
		}
		else {
			print("No");
			return 0;
		}
	}
	print("Yes");
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
  int H,W;
  cin >> H >> W;

  vector<vector<char> >grid(H + 2,vector<char>(W + 2,'p'));

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++)
    cin >> grid[i][j];
  }

  bool ans = true;

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(grid[i][j] == '#'){
        if(grid[i - 1][j] != '#' && grid[i + 1][j] != '#' && grid[i][j - 1] != '#' && grid[i][j + 1] != '#')
          ans = false;
      }
    }
  }

  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

using namespace std;

long lis_fast(long *arr, long n)
{
    vector<long> parent(n, -1);
    vector<long> lis_actual;
    lis_actual.push_back(arr[0]);

    for(long i=1; i<n; i++)
    {
        long ind = lower_bound(lis_actual.begin(), lis_actual.end(), arr[i]) - lis_actual.begin();
        if(ind < lis_actual.size()) lis_actual[ind] = arr[i];
        else lis_actual.push_back(arr[i]);
        parent[i] = lis_actual[ind-1];
    }

    // for(long )

    return lis_actual.size();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    long n, k; cin>>n>>k;

    long h[n];

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

    vector<long> dp(n, INT_MAX);

    dp[0] = 0;

    for(int i=1; i<n; i++)
    {
        for(int j=1; j<=k; j++)
        {
            if(i-j>=0)
            {
                long x = dp[i-j]+abs(h[i]-h[i-j]);
                if(x<dp[i]) dp[i] = x;
            }
        }
    }

    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  string s; cin >>s;
  vector<string> a(4);
  rep(i,4) a[i]=s[i];
  vector<int> v(4);
  rep(i,4) v[i]=stoi(a[i]);
  if(v[0]+v[1]+v[2]+v[3]==7){
    cout <<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
    return 0;
  }
  if(v[0]+v[1]+v[2]-v[3]==7) {
    cout <<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
    return 0;
  }
  if(v[0]+v[1]-v[2]+v[3]==7){
    cout <<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
     return 0;
  }
  if(v[0]+v[1]-v[2]-v[3]==7) {
    cout <<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
     return 0;
  }
  if(v[0]-v[1]+v[2]+v[3]==7) {
    cout <<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
     return 0;
  }
  if(v[0]-v[1]+v[2]-v[3]==7) {
    cout <<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
     return 0;
  }
  if(v[0]-v[1]-v[2]+v[3]==7){
    cout <<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
    return 0;
  }
  if(v[0]-v[1]-v[2]-v[3]==7){
    cout <<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
    return 0;
  } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  rep(i, h) {
    rep(j, w) {
      if(i < b && j < a) cout << 0;
      else if(i >= b && j >= a) cout << 0;
      else cout << 1;
    }

    cout << endl;
  }
}


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

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  bool ans=0;
  for(int i=0; i<=m; i++){
    for(int j=0; j<=n; j++){
      int cnt=i*n+j*m-i*j*2;
      if(cnt==k) ans=1; 
    }
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define N 200005
ll mod=1000000007;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) x.begin(),x.end()
#define lb lower_bound
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
 
int main(){
    
    fast;
    
    ll n,m;
    cin>>n>>m;
    if(n>=1 && n<=9 && m>=1 && m<=9){
        cout<<n*m;
    }
    else{
        cout<<"-1";
    }
    
    return 0;
}

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

using namespace std;

int main(){
	int N;
	scanf("%d",&N);
	
	char s[100];
	char t[100];
	scanf("%s",&s);
	scanf("%s",&t);
	
	int ans=N*2;
	
	for(int i=0;i<N;i++){//ズレ
		
		int miss=0;
		for(int j=0;j<N-i;j++){
			if(t[j]!=s[j+i])miss=1;	
		}		
		if(miss==0){
			ans=N+i;
			break;
		}
	}
	printf("%d\n",ans);
	

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if (c == 'a'||c == 'e'||c == 'i'||c == 'o'||c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
// 20.txt, 21.txt で, WA版となったので修正.
// m[0] = -10000, m[1] = -10000 のようなテストケースで, WA となった.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int main() {
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    int A[N];
    for(int i = 0; i < N; i++) scanf("%d", &A[i]);
    
    // 2. sort.
    sort(A, A + N);
    
    // 3. マイナス部分, プラス部分(※0含む) を 取得.
    vector<int> m, p;
    for(int i = 0; i < N; i++){
        if(A[i] < 0) m.pb(A[i]);
        else         p.pb(A[i]);
    }
    
    // 4. 操作列 の 特定.
    // 3-1. マイナス部分が, 無い場合.
    int ml = m.size(), pl = p.size();
    if(ml == 0){
        if(pl == 2){
            printf("%d\n", p[1] - p[0]);
            printf("%d %d\n", p[1], p[0]);
            return 0;
        }else{
            int M = p[0] - p[pl - 1];
            for(int i = 1; i < pl - 2; i++) M -= p[i];
            M = p[pl - 2] - M;
            printf("%d\n", M);
            int memo = p[0] - p[pl - 1];
            printf("%d %d\n", p[0], p[pl - 1]);
            for(int i = 1; i < pl - 2; i++){
                printf("%d %d\n", memo, p[i]);
                memo -= p[i];
            }
            printf("%d %d\n", p[pl - 2], memo);
            return 0;
        }
    }
    
    // 3-2. プラス部分が, 無い場合.
    if(pl == 0){
        if(ml == 2){
            printf("%d\n", m[1] - m[0]);
            printf("%d %d\n", m[1], m[0]);
            return 0;
        }else{
            int M = m[ml - 1] - m[0];
            for(int i = 1; i < ml - 1; i++) M -= m[i];
            printf("%d\n", M);
            int memo = m[ml - 1] - m[0];
            printf("%d %d\n", m[ml - 1], m[0]);
            for(int i = 1; i < ml - 1; i++){
                printf("%d %d\n", memo, m[i]);
                memo -= m[i];
            }
            return 0;
        }
    }
    
    // 3-3. マイナス部分, プラス部分が, 共に存在する場合.
    if(pl > 0 && ml > 0){
        if(pl == 1){
            int M = p[0];
            for(int i = 0; i < ml; i++) M -= m[i];
            printf("%d\n", M);
            int memo = p[0] - m[0];
            printf("%d %d\n", p[0], m[0]);
            for(int i = 1; i < ml; i++){
                printf("%d %d\n", memo, m[i]);
                memo -= m[i];
            }
            return 0;
        }else{
            int M = m[0] - p[0];
            for(int i = 1; i < pl - 1; i++) M -= p[i];
            M = p[pl - 1] - M;
            for(int i = 1; i < ml; i++) M -= m[i];
            printf("%d\n", M);
            int memo = m[0] - p[0];
            printf("%d %d\n", m[0], p[0]);
            for(int i = 1; i < pl - 1; i++){
                printf("%d %d\n", memo, p[i]);
                memo -= p[i];
            }
            printf("%d %d\n", p[pl - 1], memo);
            memo = p[pl - 1] - memo;
            for(int i = 1; i < ml; i++){
                printf("%d %d\n", memo, m[i]);
                memo -= m[i];
            }
            return 0;
        }
    }
    return 0;
    
}

Measured memory_bytes: 2808
#include <stdio.h>

int width,height;
int map[50][50];

void visit(int x,int y) {
	int i,j;
	if(x<0 || x>=width || y<0 || y>=height)return;
	if(map[y][x]==0)return;
	map[y][x]=0;
	for(i=-1;i<=1;i++) {
		for(j=-1;j<=1;j++)visit(x+i,y+j);
	}
}

int main(void) {
	int i,j;
	int result;
	while(1) {
		scanf("%d%d",&width,&height);
		if(width==0 && height==0)break;
		for(i=0;i<height;i++) {
			for(j=0;j<width;j++)scanf("%d",&map[i][j]);
		}
		result=0;
		for(i=0;i<height;i++) {
			for(j=0;j<width;j++) {
				if(map[i][j]) {
					result++;
					visit(j,i);
				}
			}
		}
		printf("%d\n",result);
	}
	return 0;
}

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

int main(){
    int A[4][3][10]{0};
    int n, b, f, r, v;
    cin >> n;

    for (int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        A[b-1][f-1][r-1] += v;
    }
    for (int b=0;b<4;b++){
        for(int f=0; f<3;f++){
            for(int r=0;r<10;r++){
                cout << ' ' << A[b][f][r];
            }
            cout << endl;
        }
        if (b != 3){
            cout << "####################" << endl;
        }
    }
}


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}


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

  
  ll N, K ;  cin >> N >> K;
  if(K==0) {cout << N*N << endl; return 0;}
  
  ll ans = 0;
  for(ll i = K+1; i<= N; i++){
    ll b = i;
    //a<bの個数
    ans += ((b-1)-(K)+1);


    //a>bの個数
    ll n = N/b;
    ans += ((n-1)*((2*b-1)-(b+K)+1));
    
    ans +=  max((ll)0, N-(n*b+K)+1);
    
  }

  cout << ans << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*
  Esteban Arango Medina
*/
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

using ll=long long;
#define int ll

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <char,int> mci;
typedef map <int,int> mii;
typedef map <string,string> mss;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define endl '\n' // Normal `cout << endl` flushes the output every time wich hit performance badly
#define INF 1000000000
#define deb(x) cout<<#x<<": "<<x<<endl;
#define printArray(arr) for(auto x: arr) { cout<<x<<", "; }
#define printMatrix(mat) for(auto x: mat) { cout<<" "; printArray(x); cout<<endl; }
#define printMap(mmap) for(auto p: mmap) { cout<< p.first<<": "<<p.second<<endl; }

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); // Fast input
  #ifdef LOCAL_PROJECT
    freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
  #endif

  int T = 1; //cin>>T;
  while(T--) {
    int k; cin>>k;
    int a, b; cin>>a>>b;

    bool ok = false;
    while(a <= b) {
      if (a%k == 0) { ok = true; break; }
      a++;
    }
    cout<<((ok) ? "OK" :"NG")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int count,count2;
    int win=0;
    int n;
    scanf("%d",&n);
    for(count2=1;count2<=9;count2++){
        for(count=1;count<=9;count++){
            if(count*count2==n){printf("Yes");goto exit;}
        }
    }
    printf("No");
    return 0;
    exit:
    return 0;
}

int min(int a,int b){
    int ans;
    if(a>b){return b;}
    else {return a;}
}

int max(int a,int b){
    int ans;
    if(a>b){return a;}
    else {return b;}
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
const int N=10005;
int n,m,p,u,v,d,cnt,ee,head[N],dis[N],tot[N],to[N*2],nxt[N*2],dd[N*2];
queue<int> q;
bool inq[N];
void adde(int u,int v,int d){
	to[++cnt]=v;
	nxt[cnt]=head[u];
	dd[cnt]=d;
	head[u]=cnt;
}
int spfa(){
	while(!q.empty()){
		q.pop();
	}
	for(int i=1;i<=n;i++){
		dis[i]=-2e9;
		inq[i]=false;
		tot[i]=0;
	}
	dis[1]=0;
	inq[1]=true;
	q.push(1);
	tot[1]=1;
	while(!q.empty()){
		int u=q.front(),v;
		q.pop();
		inq[u]=false;
		for(int i=head[u];i;i=nxt[i]){
			v=to[i];
			if(dis[u]+dd[i]>dis[v]){
				dis[v]=dis[u]+dd[i];
				if(!inq[v]){
					inq[v]=true;
					q.push(v);
					tot[v]++;
					if(tot[n]>n){
						return -2e9;
					}
				}
			}
		}
	}
	if(tot[n]>n){
		return -2e9;
	}
	return dis[n];
}
int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&u,&v,&d);
		adde(u,v,d);
	}
//	if(spfa()==-2e9){
//		puts("-1");
//		return 0;
//	}
	for(int i=1;i<=m;i++){
		dd[i]-=p;
	}
	printf("%d\n",spfa()==-2e9?-1:max(0,dis[n]));
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int N; cin >> N;
    vector<int> v;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        v.push_back(a);
    }
    int flag = 1, cnt = 0;
    while(flag){
        flag = 0;
        for(int j = N-1; j >= 1; j--){
            if(v[j] < v[j-1]){
                swap(v[j], v[j-1]);
                cnt++;
                flag = 1;
            }
        }
    }
    for(int i = 0; i < N; i++){
        if(i == N-1){
            cout << v[i] << endl;
            break;
        }
        cout << v[i] << " ";
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,bell=0,math=0,moji=0,MOJI=0;
  string s;
  cin >> s;
  n=s.size();
  if(n>=6){
    bell++;
  }
  for(int i=0;i<n;i++){
    if(s[i]>=48 && s[i]<=57){
      math++;
    }
    else if(s[i]>=65 && s[i]<=90){
      MOJI++;
    }
    else if(s[i]>=97 && s[i]<=122){
      moji++;
    }
  }
  if(bell!=0 && math!=0 && MOJI!=0 && moji!=0){
    cout << "VALID" << endl;
  }
  else{
    cout << "INVALID" << endl;
  }
}

Measured memory_bytes: 1180
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[] A = nextIntArray(sc, N);
		int[] B = nextIntArray(sc, N);

		sc.close();

		int[] d = new int[N];
		for (int i = 0; i < N; i++) {
			d[i] = A[i] - B[i];
		}

		Arrays.sort(d);

		int ans = 0;

		// dのうち、負の値を合計する
		long sum = 0;
		for (int i = 0; i < N; i++) {
			if (d[i] < 0) {
				sum += d[i];
				ans++; // 負は必ず変更しないといけない
			}
		}

		// 正の値を大きいものから順にみて、sumが0以上になるまで足し込む。
		for (int i = N - 1; i >= 0; i--) {
			if (sum >= 0) {
				break;
			}

			if (d[i] > 0) {
				sum += d[i];
				ans++;
			}
		}

		if (sum < 0) {
			out.println(-1);
		} else {
			out.println(ans);
		}
	}

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

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


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

int main() {
    int a, b, c, d;
    int ans = 0;
    cin >> a >> b >> c >> d;
    ans += min(a, b);
    ans += min(c, d);
    cout << ans << endl;
    return 0;
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int a,b;
  int ans =1;
  int c = 0 ;
  cin >> a >> b;
  while (ans < b){
	  ans += a - 1;
	  c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 3672
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 110
#define LL long long
using namespace std;

const LL P=1000000007;

int n,n2;
int a[MAXN],d1[MAXN],d2[MAXN];
LL f[MAXN][MAXN][MAXN];

inline void update(LL &x,LL y){ x=(x+y)%P; }

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	scanf("%d",&n);
	n2=n*2-1;
	for(int i=1;i<=n2;i++) scanf("%d",a+i);
	sort(a+1,a+n2+1);
	for(int i=2;i<=n2;i++)
		if(a[i]!=a[i-1]){
			if(i<=n) d1[n-i+2]++;
			if(i>n) d2[i-n+1]++;
		}
	f[1][1+d1[2]+d2[2]][1+d1[2]]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=n2;j++)
			for(int k=1;k<=j;k++){
				if(!f[i-1][j][k]) continue;
				for(int l=1;l<=j;l++){
					int delta=max(abs(l-k)-1,0);
					int k2=l+d1[i+1]-(l>k?delta:0);
					update(f[i][j+d1[i+1]+d2[i+1]-delta][k2],f[i-1][j][k]);
				}
			}
	}
	LL ans=0;
	for(int i=1;i<=n2;i++)
		for(int j=1;j<=i;j++)
			update(ans,f[n][i][j]);
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s;
  cin >> s;
  bool t=false;
  if (s[0]==s[1] && s[0]==s[2]) t=true;
  if (s[1]==s[2] && s[1]==s[3]) t=true;
  if (t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
  ll n,ans=0;
  cin>>n;
  if(n==1){
    cout << 1 << endl;
    return 0;
  }

  vector<ll> v(n),sum(n+1),xo(n+1);
  sum[0]=0;xo[0]=0;

  for(int i=0;i < n;i++)
  {
     cin>>v.at(i);
     sum.at(i+1)=sum.at(i)+v.at(i);
     xo.at(i+1)=xo.at(i)^v.at(i);
  }

  for(int i=1;i <= n;i++)
  {
    ll ok=n+1,ng=i-1;
    while(abs(ok-ng)>1){
      ll mid=(ok+ng)/2;
      if(sum.at(mid)-sum.at(i-1)-(xo.at(mid)^xo.at(i-1))>=0){
        ok=mid;
      }else{
        ng=mid;
      }
    }

    ll ko=n+1,gn=i-1;
    while(abs(ko-gn)>1){
      ll mid=(ko+gn)/2;
      if(sum.at(mid)-sum.at(i-1)-(xo.at(mid)^xo.at(i-1))>=1){
        ko=mid;
      }else{
        gn=mid;
      }
    }
    ans+=ko-ok;
    //cout<<ko<<ok<<endl;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int v[N];
    int c[N];
    int min[N];
    int total = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    for(int i = 0; i < N; i++)
    {
        cin >> c[i];
    }
    for(int i = 0; i < N; i++)
    {
        min[i] = v[i] - c[i];
    }
    for (int i = 0; i < N; i++)
    {
        if (min[i] > 0)
        {
            total = total + min[i];
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < long long > vll;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef vector < int > vi;
typedef vector<vector<int>> vvi;
#define deb(x) cout << #x << " : " << x << endl
#define deb2(x , y) cout << #x << " : " << x << " , "<< #y << " : " << y << endl
#define debv(x) for(auto i=x.begin();i!=x.end();i++) cout<<*i<<' ';cout<<endl
#define debp(x) for(auto i=x.begin();i!=x.end();i++) cout<<i->first<<':'<<i->second<<' ';cout<<endl
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,a,n) for(int i = a; i < n; i++)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define INF (1e9 + 7)
#define endl '\n'
int nn=1e5+7;
void solve() {
	ll n,w;
	cin>>n>>w;
	vi dp(nn,-1);
	dp[0]=0;
	int ans=0;
	rep(j,n){
		int a,b;
		cin>>a>>b;
		for(int i=1e5+7;i>=0;i--){
			if(dp[i]!=-1&&(dp[i]+a)<=w && (i+b)<1e5+7){
              	if(dp[i+b]!=-1)
					dp[i+b]=min(dp[i+b],dp[i]+a);
              	else{
                  	dp[i+b]=dp[i]+a;
                }
			}
		}
      	//debv(dp);
	}
  	for(int i=1e5;i>=0;i--){
      if(dp[i]!=-1)	{
      	ans=max(ans,i);
      }
    }  
  	cout<<ans<<endl;
}

int main() {
	csl;
	int testcase=1;
//	cin >> testcase;
	for (int i = 0; i < testcase; i++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3704
Sa = input()
Sb = input()
Sc = input()
Na = len(Sa)
Nb = len(Sb)
Nc = len(Sc)
t = 'a'
while Na >= 0 and Nb >= 0 and Nc >= 0:
    if t == 'a':
        if Na > 0:
            t = Sa[0]
            Sa = Sa[1:len(Sa)]
        Na -= 1
    if t == 'b':
        if Nb > 0:
            t = Sb[0]
            Sb = Sb[1:len(Sb)]
        Nb -= 1
    if t == 'c':
        if Nc > 0:
            t = Sc[0]
            Sc = Sc[1:len(Sc)]
        Nc -= 1

if Na < 0:
    print('A')
elif Nb < 0:
    print('B')
elif Nc < 0:
    print('C')

Measured memory_bytes: 3192
from itertools import product

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
ans=0

for row_bit in product(range(2),repeat=h):
  for col_bit in product(range(2),repeat=w):
    cnt = 0
    for row in range(h):
      for col in range(w):
        if c[row][col] == "#" and (row_bit[row] and col_bit[col]):
          cnt += 1
    if k == cnt:
      ans += 1
print(ans)

Measured memory_bytes: 9200
n,m=map(int,input().split())
x,y,z=[],[],[]
for i in range(n):
  xi,yi,zi=map(int,input().split())
  x.append(xi)
  y.append(yi)
  z.append(zi)

ans=0
for i in range(2**3):
  op=['-','-','-']
  for j in range(3):
    if (i>>j)&1:
      op[j]='+'

  t_x=x[::]
  t_y=y[::]
  t_z=z[::]

  if op[0]=='-':
    t_x=list(map(lambda a : -1*a, t_x))
  if op[1]=='-':
    t_y=list(map(lambda a : -1*a, t_y))
  if op[2]=='-':
    t_z=list(map(lambda a : -1*a, t_z))

  xyz_l=[t_x[i]+t_y[i]+t_z[i] for i in range(n)]
  xyz_l.sort(reverse=True)

#  print(xyz_l)
#  print(t_x,t_y,t_z)

  ans=max(ans,sum(xyz_l[:m]))

print(ans)

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

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

    vector<vector<int>> s(m);
    for(int i=0; i<m; i++){
        int k;
        cin >> k;
        s[i].resize(k);
        for(int j=0; j<k; j++){
            cin >> s[i][j];
            s[i][j] -= 1;
        }
    }

    vector<int> p(m);
    for(int i=0; i<m; i++){
        cin >> p[i];
    }

    int count = 0;
    for(int b=0; b<(1<<n); b++){
        bool flag = true;
        for(int i=0; i<m; i++){
            int k_sum = 0;
            for(int m : s[i]){
                if((b >> m) & 1 == 1) k_sum += 1;
            }
            if(k_sum % 2 != p[i]) flag = false;
        }
        if(flag == true) count += 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

class UnionFind {
public:
  // 親の番号を格納する。親だった場合は-(その集合のサイズ)
  vector<int> parent;

  // 作るときは parent の値を全て -1 にする
  // こうすると全てバラバラになる
  UnionFind(const int& n = 0) : parent(n, -1) {}

  // x がどのグループに属しているか調べる
  int find(const int& x) {
    if (parent[x] < 0) return x;
    return parent[x] = find(parent[x]);
  }

  // x と y をくっつける  O(log n)
  bool unite(int x, int y) {
    // x と y を直接くっつけるのではなく，root(x) に root(y) をくっつける
    x = find(x);
    y = find(y);
    if (x == y) return false;  // すでにくっついているからくっつけない

    // 大きい方(x) に小さい方(y)をくっつけたい 大小が逆だったらひっくり返す
    if (size(x) < size(y)) swap(x, y);

    parent[x] += parent[y];  // x のサイズを更新する
    parent[y] = x;  // y の親を x に変更する
    return true;
  }

  // 自分のいるグループの頂点数を調べる
  int size(const int& x) { return -parent[find(x)]; }

  // x と y が同じグループに属しているか否か
  bool same(const int& x, const int& y) { return find(x) == find(y); }
};

struct edge {
  int u, v, cost;
};

bool comp(const edge& e1, const edge& e2) {
  return e1.cost < e2.cost;
}

int kruskal(const int& n, vector<edge>& es) {
  sort(es.begin(), es.end(), comp);
  UnionFind uf(n);
  int res = 0;
  for (int i = 0; i < es.size(); i++) {
    edge e = es[i];
    if (!uf.same(e.u, e.v)) {
      uf.unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

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

  int n, m;
  cin >> n >> m;

  vector<edge> es;
  rep(i, m) {
    int a, b, c; cin >> a >> b >> c;
    es.push_back({a, b, c});
  }

  cout << kruskal(n, es) << endl;

  return 0;
}



Measured memory_bytes: 4572
(N,) = [int(x) for x in input().split()]

divs = [0 for i in range(N + 1)]
for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        divs[j] += 1

total = 0
for i in range(1, N + 1):
    total += i * divs[i]

print(total)


Measured memory_bytes: 219364
S = input()
A = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == "<":
        A[i + 1] = max(A[i + 1], A[i] + 1)

for i in reversed(range(len(S))):
    if S[i] == ">":
        A[i] = max(A[i], A[i + 1] + 1)

print(sum(A))


Measured memory_bytes: 29024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = 300009;

struct Node{    
    int value;
    int lef;
    int rig;
};

Node T[6000000];
int root[N];
int cnt;

int build(int cl, int cr){
    int nd = cnt;
    T[nd] = {0,-1,-1};
    cnt ++ ;
    if(cl == cr)
        return nd;
    int mid = (cl + cr) / 2;
    T[nd].lef = build(cl,mid);
    T[nd].rig = build(mid+1,cr);
    return nd;
}

int update(int node, int cl, int cr, int pos){
    T[cnt] = T[node];
    node = cnt++;
    T[node].value ++ ;
    if(cl==cr)
        return node;
    int mid = (cl + cr) / 2;
    int f;
    if(mid >= pos){
        f = update(T[node].lef, cl, mid, pos);
        T[node].lef = f;
    }
    else{
        f = update(T[node].rig, mid + 1, cr, pos);
        T[node].rig = f;
    }
    return node;
}

int query(int node, int cl, int cr, int tl, int tr){
    if(cr < tl)
        return 0;
    if(cl > tr)
        return 0;
    if(cl >= tl && cr <= tr)
        return T[node].value;
    int mid = (cl + cr) / 2;
    return query(T[node].lef, cl, mid, tl, tr) + query(T[node].rig, mid + 1, cr, tl, tr);
}

vector<int> P[N];

int main(){
    int n, m;
    cin >> n >> m;
    int li, ri;
    for(int i = 0 ; i < n ; i ++ ){
        cin >> li >> ri;
        P[li].push_back(ri);
    }
    root[0] = build(1, m);
    int fi;
    for(int i = 1; i <= m ; i ++ ){
        root[i] = root[i-1];
        for(auto x : P[i]){
            fi = update(root[i], 1, m, x);
            root[i] = fi;
        }
    }
    int L,R;
    int res;
    for(int i = 1; i <= m ; i ++ ){
        res = 0;
        for(int j = i ; j <= m ; j += i){
            L = j;
            R = min(m, L + i - 1);
            res += query(root[j], 1, m, L, R);
        }
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 77312
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define tp          tuple<int,int,int>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
int main() {
    int x;
    cin>>x;
    cout<<(1-x)<<'\n';
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define eb emplace_back
#define debug(x) cout << '>' << #x << ':' << x << '\n';
#define debug2(x,y) cout << '>' << #x <<" = "<< x <<" & "<< #y <<" = "<< y << '\n';
#define rep(i,n) for(ll i=0;i<(n);i++)
#define fr(i,a,b) for(ll i=(a);i<(b);i++)
#define frd(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl "\n"
#define fileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define inf ((long long) 1e18 + 10)
#define ve vector<ll>
#define mod 100007
using namespace std;
const int N = 1e3 + 2;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
    fileIO
    #endif
    ll t;
    t = 1;
    while(t--){
        int a, b;
        cin >> a >> b;
        cout << a * b << endl;
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    map<string, int> mp;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ans += mp[s];
        mp[s]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
using namespace std;
#define rep(i,s,n) for(int i=s;i<n;i++)
#define REP(i,n) rep(i,0,n)
#define NMAX 21
#define INF 1<<26
int dist[NMAX][NMAX];
int n,m;
int x1,x2,y1,y2;
void init(){
	REP(i,NMAX)REP(j,NMAX)dist[i][j]=INF;	
}
void wf(){
	rep(k,1,n+1){
		rep(i,1,n+1){
			rep(j,1,n+1){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}	
	}
}
void solve(){
	cout<<y1-y2-dist[x1][x2]-dist[x2][x1]<<endl;
}
int main(){
	int a,b,c,d;
	char dummy;
	cin>>n>>m;	
	init();
	REP(i,m){
		cin>>a>>dummy>>b>>dummy>>c>>dummy>>d;
		dist[a][b]=c;
		dist[b][a]=d;
	}
	wf();
	cin>>x1>>dummy>>x2>>dummy>>y1>>dummy>>y2;
	solve();
	return 0;
}

Measured memory_bytes: 0
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    s = S()
    t = S()
    if s+t == t[::-1]+s[::-1]:
        print("YES")
    else:
        print("NO")

#B
def B():
    n = I()
    for i in range(int(n**0.5)+2)[::-1]:
        if i*i <= n:
            print(i*i)
            quit()
#C
def C():
    n = I()
    a = LI()
    b = LI()
    c = LI()
    q = [0 for i in range(n)]
    ans = 0
    a.sort()
    b.sort()
    c.sort()
    for i in range(n):
        j = bisect.bisect_left(a,b[i])
        q[i] = j
    for i in range(n-1):
        q[i+1] += q[i]
    q.insert(0,0)
    for i in range(n):
        j = bisect.bisect_left(b,c[i])
        ans += q[j]
    print(ans)
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


Measured memory_bytes: 101428