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

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

int main()
{
	int N, K;
	cin >> N >> K;

	int MAX = 300000;
	SegmentTree<int> seg( MAX + 1, [](int a, int b) { return max(a, b); }, 0 );
	for( int i = 0; i < N; i++ ) {
		int A;
		cin >> A;
		int l = max( 0, A - K );
		int r = min( MAX, A + K );
		int n = seg.query( l, r + 1 );
		seg.update( A, n + 1 );
	}

	int ans = 0;
	for( int i = 0; i < MAX + 1; i++ ) {
		ans = max( ans, seg.query( i, i + 1 ) );
	}

	cout << ans << endl;
}


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

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  rep(i,a,n) for(int i=a; i<n; i++)
#define  fn  for(int i=0;i<n;i++)
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

void solve()
{
	// write your code here :
	int x;
	cin >> x;
	if(!x) cout << 1; 
	else cout << 0;
}

int main()
{
	fast
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t; while (t--)
		solve();
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		String input = scanner.nextLine();
		String input2 = scanner.nextLine();

		int j = 0;
		int OK = 0;

		for(String i  : input.split("")) {
			if(i.equals(input2.split("")[j])) {
				OK=OK+1;
			}
			j=j+1;
		}
		System.out.println(OK);
	}
}

Measured memory_bytes: 22996
N, M = map(int, input().split())

L = []
R = []

for i in range(M) : 
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
    
j = min(R) -max(L) + 1

if j < 0 : 
    print(0)
else : 
    print(j)

Measured memory_bytes: 10996
N = int(input())
t = 0
x = 0
y = 0
for ti, xi, yi in [map(int, input().split(' ')) for n in range(N)]:
    if not (abs(xi-x)+abs(yi-y) <= ti-t and ti%2 == (xi+yi)%2):
        print('No')
        exit()
    else:
        t = ti
        x = xi
        y = yi
print('Yes')

Measured memory_bytes: 52448
import sys
input = sys.stdin.readline
#-------------------------------------

n = int(input())
ab = []
for _ in range(n):
        ab.append(list(map(int,input().split())))

ab = sorted(ab, key=lambda x: x[1])

c = 0
for v in ab:
        c += v[0]
        if c>v[1]:
                print("No")
                break
else:
        print("Yes")

Measured memory_bytes: 55164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

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

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

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

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
int n,k;
vector<int> ch[N];
bool bio[N];
int ans=1;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

void dfs(int i)
{
	bio[i]=1;
	if (i==1)
	{
		ans=mult(ans,k);
		for (int o=0;o<ch[i].size();++o) if (!bio[ch[i][o]])
		{
			ans=mult(ans,k-o-1);
			dfs(ch[i][o]);
		}
	}
	else
	{
		int ii=0;
		for (int o=0;o<ch[i].size();++o) if (!bio[ch[i][o]])
		{
			ans=mult(ans,k-ii-2);
			++ii;
			dfs(ch[i][o]);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n>>k;
	for (int i=1;i<n;++i)
	{
		int a,b;
		cin>>a>>b;
		ch[a].pb(b);
		ch[b].pb(a);
	}
	dfs(1);
	cout<<ans;
}




Measured memory_bytes: 14080
use std::str::FromStr;
use std::string::String;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn dfs(edges : &Vec<Vec<u32>>, mut visited : &mut Vec<i32>, cur : u32, mark : u32) -> i32 {
    visited[cur as usize] = mark as i32;
    let mut cnt = 0;
    for next in &edges[cur as usize] {
        if visited[*next as usize] == -1 {
            let x = dfs(&edges, &mut visited, *next, mark);
            cnt += x;
        }
    }
    return cnt+1;
}

fn main() {
    let nmk : Vec<usize> = get_vec();
    let mut edges : Vec<Vec<u32>> = vec!(Vec::new();nmk[0]);
    let mut ecnt = vec!(0;nmk[0]);
    for i in 0..nmk[1] {
        let ab : Vec<u32> = get_vec();
        edges[ab[0] as usize -1].push(ab[1]-1);
        ecnt[ab[0] as usize -1] +=1;
        ecnt[ab[1] as usize -1] +=1;
        edges[ab[1] as usize -1].push(ab[0]-1);
    }

    let mut visited : Vec<i32> = vec!(-1;nmk[0]);
    let mut cnt : Vec<i32> = vec!(0;nmk[0]);
    for i in 0..nmk[0] {
        if visited[i] == -1 {
            let ret = dfs(&edges, &mut visited, i as u32, i as u32);
            cnt[i] = ret;
        }
        cnt[i] = cnt[visited[i] as usize];
    }
    let mut blocks : Vec<i32> = vec!(0;nmk[0]);
    for i in 0..nmk[2] {
        let cd : Vec<u32> = get_vec();
        if visited[cd[0] as usize -1 as usize] == visited[cd[1] as usize -1 as usize] {
            blocks[cd[0] as usize -1] += 1;
            blocks[cd[1] as usize -1] += 1;
        }
    }
    let mut a = vec!(0;nmk[0]);
    for i in 0..nmk[0]{
        let x = cnt[i] - ecnt[i] as i32 - blocks[i] -1;
        a[i] = x;
    }
    let s = a.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" ");
    println!("{}", s.trim());
}


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

int main(){
    ll n,k;
    cin>>n>>k;
    deque<ll> v(n);
    rep(i,n) cin>>v[i];
    ll mx=0;
    for(ll i=0;i<=k;i++){
        for(ll l=0;l<=i;l++){
            ll sum=0;
            vector<ll> h;
            deque<ll> cv(n);
            cv=v;
            rep(j,l){
                if(cv.empty()) break;
                h.push_back(cv.front());
                sum+=cv.front();
                cv.pop_front();
            }
            rep(j,i-l){
                if(cv.empty()) break;
                h.push_back(cv.back());
                sum+=cv.back();
                cv.pop_back();
            }
            sort(all(h));
            rep(j,k-i){
                if(j>(ll)h.size()-1) break;
                else{
                    if(h[j]<0) sum-=h[j];
                    else break;
                }
            }
            mx=max(mx,sum);
        }

    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <string>
#include <cstdio>
#include <iostream>
using namespace std;
 
int main(){
  string s;
  while(cin>>s){
    for(int i=0; i<s.size(); i++){
      if(s[i]!='@') putchar(s[i]);
      else {
    i++;
    int n=s[i]-'0';
    i++;
    for(int j=0; j<n; j++){
      putchar(s[i]);
    }
      }
    }
    putchar('\n');
  }
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<ll> lis(n), ruiseki(n, 0);
    REP(i, 0, n){cin >> lis[i];}
    sort(ALL(lis));
    ruiseki[0] = lis[0];
    REP(i, 1, n){
        ruiseki[i] = ruiseki[i-1] + lis[i];
    }
    ll ans = n;
    REP(i, 0, n-1){
        if(ruiseki[i] * 2 < (ruiseki[i+1] - ruiseki[i])){
            ans = n-(i+1);
        }
    }
    cout << ans << endl;
}

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

int main() {
  int s;
  cin >> s;
  int a = s / 100;
  int b = s % 100;
  if(a >= 1 && a <= 12) {
    if(b >= 1 && b <= 12) {
      cout << "AMBIGUOUS" << endl;
    }
    else {
      cout << "MMYY" << endl;
    }
  }
  else {
    if(b >= 1 && b <= 12) {
      cout << "YYMM" << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        String[] s =in.nextLine().split(" ");
        int x = Integer.parseInt(s[0]);
        int y = Integer.parseInt(s[1]);
        boolean ans = false;
        for(int i=0;i<=x;i++){
            int j = x-i;
            if(2*i+4*j==y){
                ans = true;
                break;
            }
        }
        if(ans)
        System.out.println("Yes");
        else System.out.println("No");
    }
}

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

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

    vector<int> L(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end(), greater<int>());
    int biggest = L[0];
    int rest = 0;
    for (int i = 1; i < N; i++)
    {
        rest += L[i];
    }
    // printf("biggest = %d, rest = %d\n", biggest, rest);
    if (biggest < rest)
        cout
            << "Yes" << endl;
    else
        cout << "No" << endl;

    return (0);
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

class Program
{
	static void Main()
	{
		var s = Console.ReadLine();
		if (s.Length == 1) {
			Console.WriteLine(int.Parse(s));
		} else {
			var builder = new StringBuilder();
			for (var i = 0; i < s.Length - 1; ++i) {
				builder.Append("9");
			}

			var answer = int.Parse(s.First().ToString());
			if (builder.ToString() != s.Substring(1)) {
				--answer;
			}

			answer += 9 * (s.Length - 1);
			Console.WriteLine(answer);
		}
	}
}


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

int main()
{
 string S;
  cin>>S;
  int N;
  N= S.length();
  int judge =0;
  for(int i=0;i<N;i++)
  {
   if(i%2==0)//1.3.5
   {
     if(S[i]=='L')
     {
      judge=1;
     }
   }
    if(i%2==1)
   {
      if(S[i]=='R')
      {
       judge=1;
      }
   }
    if(judge==1)
    {
      break;
    }
  }
  if(judge==1)
  {
   cout<<"No"<<endl;
  }
  else if(judge==0)
  {
   cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n, m, ans=0;
    cin >> n >> m;
    vector<vector<ll>> s(m);
    rep(i,m){
        ll k;
        cin >> k;
        rep(j,k){
            ll a;
            cin >> a;
            a--;
            s[i].push_back(a);
        }
    }
    vector<ll> p(m);
    rep(i,m) cin >> p[i];

    rep(bit,(1<<n)){
        bool ok = true;
        rep(i,m){
            ll cnt = 0;
            for(auto j:s[i]){
                if(bit & (1<<j)) cnt++;
            }
            if(cnt%2 != p[i]) ok = false;
        }
        if(ok) ans++;
    }

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

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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    cin>>n>>s;
    int red[4010]{}; int green[4010]{}; int blue[4010]{};
    long long int sum =0;
    for(int i=0;i<n;i++)

    {
        if(s[i]=='R')
        {
            red[i]++;
        }
        if(s[i]=='G')
        {
            green[i]++;
        }
        if(s[i]=='B')
        {
            blue[i]++;
        }
        if(i>0)
        {
            red[i]=red[i]+red[i-1];
            green[i]=green[i]+green[i-1];
            blue[i]=blue[i]+blue[i-1];
        }
    }

        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if(s[i]=='R'&&s[j]=='G' || s[i]=='G'&&s[j]=='R')
                {
                    long long int x = blue[n-1]-blue[j];
                    sum = sum + x;
                    if(j+j-i<n && s[j+j-i]=='B')
                    {
                        sum--;
                    }
                }
            if(s[i]=='R'&&s[j]=='B' || s[i]=='B'&&s[j]=='R')
                {
                    long long int x = green[n-1]-green[j];
                    sum = sum + x;
                    if(j+j-i<n && s[j+j-i]=='G')
                    {
                        sum--;
                    }
                }
                if(s[i]=='B'&&s[j]=='G' || s[i]=='G'&&s[j]=='B')
                {
                    long long int x = red[n-1]-red[j];
                    sum = sum + x;
                    if(j+j-i<n && s[j+j-i]=='R')
                    {
                        sum--;
                    }
                }
            }
        }
        cout<<sum<<endl;

    }


Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int ma = 0, mi = 1000;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ma = max(a[i], ma);
		mi = min(a[i], mi);
	}

	cout << ma - mi << endl;

	return 0;
}

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

typedef long long LL;

int mod;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int gcd(int a,int b){return b?gcd(b,a%b):a;}

void Ex_gcd(int a,int b,int &x,int &y){
  if (!b) {x=1;y=0;return;}
  Ex_gcd(b,a%b,y,x);
  y-=a/b*x;
}

int Get_inv(int a,int p=mod){int x,y;Ex_gcd(a,p,x,y);return (x%p+p)%p;}

int a,x,b,y;

void into(){
  scanf("%d%d%d%d%d",&a,&x,&b,&y,&mod);
}

void Get_abc(){
  int g=gcd(a,b);
  a/=g;b/=g;mod/=gcd(g,mod);
  g=gcd(a,mod);
  a/=g;y/=g;mod/=g;
  g=gcd(b,mod);
  x/=g;b/=g;mod/=g;
  a%=mod;b%=mod;
}

int d;
vector<int>p,cnt;

void Get_p(){
  if (mod==1) return;
  p.clear();
  cnt.clear();
  d=mul(a,Get_inv(b));
  int invd=Get_inv(d),now=0;
  for (int n=mod,m=d;n;){
	m=(m-1)%n+1;
	int t=n/m;
	p.push_back(mul(now,invd));
	cnt.push_back(t);
	now+=t*m;n-=t*m;
  }
  p.push_back(mod);
}

LL ans;

int Get_y(int x){return x?sub(0,mul(d,x)):mod;}

void Get_ans(){
  if (mod==1) {ans=x+y;return;}
  ans=0;
  for (int vs=cnt.size(),i=0;i<vs;++i){
	int lx=p[i],ly=Get_y(lx),rx=p[i+1],ry=Get_y(rx);
	int dx=(rx-lx)/cnt[i],dy=(ly-ry)/cnt[i];
	//printf("%d %d %d %d %d %d\n",lx,ly,rx,ry,dx,dy);
	LL l=0,r=x+y,s=0;
	for (;l<=r;){
	  LL mid=l+r>>1,p=x-lx*mid,q=y-ry*mid;
	  p>=0&&q>=0&&p/dx+q/dy>=mid*cnt[i]?(s=mid,l=mid+1):r=mid-1;
	}
	ans=max(ans,s);
  }
}

void work(){
  Get_abc();
  Get_p();
  Get_ans();
}

void outo(){
  printf("%lld\n",ans);
}

int main(){
  int T;
  scanf("%d",&T);
  for (;T--;){
    into();
    work();
    outo();
  }
  return 0;
}

Measured memory_bytes: 3796
#include <algorithm>
#include <array>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define vint vector<int>

int main() {
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    int mid = N / 2;
    string s1 = "", s2 = "";
    rep(i, mid) {
        s1 += S[i];
        s2 += S[i + mid];
    }
    if (s1 == s2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c){
		cout<<1;
	}else if(a==b||b==c||c==a){
		cout<<2;
	}else{
		cout<<3;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  cioacc();
  ll n;
  cin >> n;
  unordered_multiset<ll> gr;
  ll ans = 0;
  vl v(n);
  REP(i,n) cin >> v[i];
  sort(ALL(v));
  REP(i,n){
    ll tmp = v[v.size()-i-1];
    ll t = 1;
    bool flag = false;
    REP(j,30){
      t <<= 1;
      auto itr = gr.find(abs(tmp-t));
      if(itr!=gr.end()){
        flag = true;
        gr.erase(itr);
        ++ans;
        break;
      }
    }
    if(!flag){
      gr.insert(tmp);
    }
  }
  cout << ans << endl;
}


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

int main(){
  long long q, h, s, d, n; cin >> q >> h >> s >> d >> n;
  long long two = 8 * q;
  if(two > 4 * h) two = 4 * h;
  if(two > 2 * s) two = 2 * s;
  if(two > d) two = d;
  long long out = 0;
  out += (n / 2) * two;
  long long one = 4 * q;
  if(one > 2 * h) one = 2 * h;
  if(one > s) one = s;
  out += (n % 2) * one;
  cout << out;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N = int(input())
W = [int(x) for x in input().split()]
diffS = list()

for i in range(0,N-1):
    S1 = sum(W[0:i+1])
    S2 = sum(W[i+1:])
    diffS.append(abs(S2-S1))

print(min(diffS))

Measured memory_bytes: 3060
#include<stdio.h>

int down(const void *a,const void *b){
  return *(int *)b - *(int *)a; 
}

int main(void){
  int n , h;
  scanf("%d %d",&n ,&h);

  int a[n] , b[n];
  int amax = 0;
  for(int i = 0;i < n;i ++){
    scanf("%d %d",&a[i] ,&b[i]);
    if(amax < a[i]){
      amax = a[i];
    }
  }

  qsort(b,n,sizeof(int),down);

  int count = 0;
  for(int i = 0;i < n;i ++){
    if(b[i] >= amax){
      h -= b[i];
      count ++;
      if(h <= 0){
        i += n+1;
        h = 0;
      }
    }
  }

  count += h/amax;
  if(h%amax != 0){
    count ++;
  }

  printf("%d",count);

  return 0;

}

Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
const int N = 3e2+5, oo = 0x3f3f3f3f;
int n, m, c[N], ans, d[N][N]; char s[N][N];
void dfs(int x, int w)
{
    c[x] = w;
    for(int y = 1; y <= n; ++y) if(s[x][y] == '1')
    {
        if(!c[y]) dfs(y, w^1);
        else if(c[y] != (w^1)) puts("-1"), exit(0);
    }
}
int main()
{
    scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%s", s[i]+1);
    dfs(1, 2); for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) 
        if(i == j) d[i][j] = 0; else if(s[i][j] == '1') d[i][j] = 1; else d[i][j] = oo;
    for(int k = 1; k <= n; ++k) for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j)
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    for(int i = 1; i <= n; ++i) ans = max(ans, *max_element(d[i]+1, d[i]+n+1));
    printf("%d\n", ans+1);
    return 0;
}

Measured memory_bytes: 4120
#include <stdio.h>
int main(void){
    double a,b,r;
    scanf("%lf\n",&r);
    
    a= r*r*3.141592653589;
    b= 2*r*3.141592653589;
    
    printf("%f %f\n",a,b);
    
    return 0;
}



Measured memory_bytes: 2032
n = int(input())
a = list(map(int,input().split()))
c = 0
ansls = [0 for i in range(n)]
for i in range(n-1):
    if a[i] >= a[i+1]:
        c += 1
    else:
        ansls[i] = c
        c = 0
ansls[-1] = c
m = max(ansls)
print(m)

Measured memory_bytes: 64228
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;



llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N;
llong ANS = 0, A[10100];

int main() {
	cin >> N;



	for (int i = 0; i < N; i++) {
		cin >> A[i];
		for (;;) {
			if (A[i] % 2 == 0) {
				A[i] /= 2;
				ANS++;
			}
			else break;
		}
	}

	cout << ANS;


}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int kai = b /a;
        if (kai < c) {
            System.out.println(kai);
        } else {
            System.out.println(c);
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

ll X, Y;

int main(void){
    cin >> X >> Y;

    int len = 0;
    while(X <= Y){
        len++;
        X *= 2;
    }

    cout << len << '\n';

    return 0;
}

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

int main() {
    string S;
    cin >> S;
    S = S.substr(0, 4) + S.substr(5, 2) + S.substr(8, 2);
    int n = stoi(S);
    if (n <= 20190430) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    int b;
    for (int i = 0; i < N; i++){
        cin >> b;
        A[b-1] = A[b-1] + 1;
    }
    sort(A.begin(), A.end());
    ll ans = 0;
    for (int i = 0; i < N-K; i++){
        ans += A[i];
    }
    cout << ans << endl;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	if (9 < A) {
		cout << "-1" << endl;
		return 0;
	}
	if (9 < B) {
		cout << "-1" << endl;
		return 0;
	}

	int V = A * B;

	for (int a = 1; a <= 9; a++) {
		for (int b = 1; b <= 9; b++) {
			if ((a * b) == V){
				cout << V << endl;
				return 0;
			}
		}
	}
	cout << "-1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define ull unsigned long long
#define ld long double
#define uint unsigned int
struct debug {
~debug() {cerr << "\n";}template<class C> debug& operator<<(C c) {cerr << c;return *this;}
};
#define var(x) " [" << #x << ": " << x << "]"

int n;

void solve() {
    cin >> n;
    ll ans=0;
    for(int i=1; i<=n; ++i) {
        if(n%i==0) {
            ans+=n/i-1;
        }
        else {
            ans+=n/i;
        }
    }
    cout << ans << "\n";
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3600
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    
    int min_time = 2e9;
    for (int i = 0; i <= n - k; ++i)
    {
        int R = max(0, x[i + k - 1]);
        int L = abs(min(0, x[i]));
        int time = 2 * min(R, L) + max(R, L);
        if (min_time > time) min_time = time;
    }
    
    cout << min_time << endl;
    
    return 0;
}

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

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

const int INF = 1001001001;

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    int n;cin>>n;
    mint dp[105][4][4][4];
    //A0 C1 G2 T3
    dp[0][3][3][3]=1;
    rep(i,n){
      rep(a,4){
        rep(b,4){
          rep(c,4){
            rep(d,4){
              if (b==0 & c==2 & d==1) continue;
              if (b==0 & c==1 & d==2) continue;
              if (b==2 & c==0 & d==1) continue;
              if (a==0 & b==2 & d==1) continue;
              if (a==0 & c==2 & d==1) continue;
            dp[i+1][b][c][d]+=dp[i][a][b][c];
            }

          }
        }
      }
    }
    mint ans=0;
    rep(a,4){
      rep(b,4){
        rep(c,4){
          ans+=dp[n][a][b][c];
        }
      }
    }
    cout<<ans;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int mx = min(a, b);
    int mn = max(a + b - n, 0);
    cout << mx << " " << mn << endl;
    return 0;
}


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

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

int main(){

    int64_t A, B, K;
    cin >> A >> B >> K;

    if(A-K<0){
        K -= A;
        A = 0;
        if(B-K<0){
            B = 0;
        }
        else{
            B -= K;
        }
    }
    else{
        A -= K;
    }
    cout << A <<' '<< B << endl;
}

Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
D.sort()

hour = [0]

for i, d in enumerate(D):
    if i % 2 == 0:
        hour.append(d)
    else:
        hour.append(24 - d)

ans = float('inf')
for i in range(N + 1):
    for j in range(i + 1, N + 1):
        ti = hour[i]
        tj = hour[j]
        ti, tj = ti - min(ti, tj), tj - min(ti, tj)
        gap = max(ti, tj)
        ans = min(ans, gap, 24 - gap)

print(ans)

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

int h, w;
int a[90][90];
const int D = 80 * 160;
const int D2 = D * 2;
bitset<D2> dp[90][90];


void Main() {
  cin >> h >> w;

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

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x;
      cin >> x;
      a[i][j] = abs(a[i][j] - x);
    }
  }

  dp[0][0][D - a[0][0]] = 1;
  dp[0][0][D + a[0][0]] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i) {
        dp[i][j] |= dp[i - 1][j] << a[i][j];
        dp[i][j] |= dp[i - 1][j] >> a[i][j];
      }
      if (j) {
        dp[i][j] |= dp[i][j - 1] << a[i][j];
        dp[i][j] |= dp[i][j - 1] >> a[i][j];
      }
    }
  }
  int ans = D2;
  for (int i = 0; i < D2; i++) {
    if (dp[h - 1][w - 1][i]) {
      ans = min(ans, abs(i - D));
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 22656
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

ll a[12],F[110][11],P[110][12];

//利益を求める関数
ll score(int n){
    ll ans=0;
    for(int i=0;i<n;i++){
        int cnt=0;
        for(int j=0;j<10;j++){
            if(a[j]==1 && F[i][j]==1){
                cnt++;
            }
        }
        ans+=P[i][cnt];
    }
    return ans;
}

ll dfs(int cnt,int n,int cc){
    if(cnt==10){
        //どの時間帯も営業してない場合
        if(cc==0){
            ll tmp=-1e15;
            return tmp;
        }else{
            return score(n);
        }
    }
    ll ans;
    a[cnt]=0;ans=dfs(cnt+1,n,cc);
    a[cnt]=1;ans=max(ans,dfs(cnt+1,n,cc+1));
    return ans;
}

int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<10;j++){
            cin>>F[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<11;j++){
            cin>>P[i][j];
        }
    }
    cout<<dfs(0,N,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
# import numpy as np

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    S = input()
    Q = int(input())
    print(solve(S, Q))


def solve(S, Q):
    input = sys.stdin.readline

    prefix = ''
    suffix = ''

    switch1 = 1
    switch2 = 1

    for i in range(Q):
        query = input().split()

        q0 = int(query[0])

        if q0 == 1:
            switch1 *= -1
            continue

        F = int(query[1])
        C = query[2]

        if F == 2:
            F = -1

        switch2 = switch1 * F

        if switch2 == 1:
            prefix = C + prefix

        else:
            suffix = suffix + C

    ans = prefix + S + suffix

    if switch1 == -1:
        ans = ans[::-1]

    return ans


if __name__ == '__main__':
    main()


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

int main() {
	int x, a, b; cin >> x >> a >> b;
	a = -a;
	int cur = b + a;
	if (cur <= 0) cout << "delicious" << endl;
	else if (cur > 0 && cur <= x) cout << "safe" << endl;
	else cout << "dangerous" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S, T;
    cin >> S >> T;
 
    bool check = false;
    for(int i = 0; i < S.size(); i++) {
        int string_size = S.size() - 1;
        char back_string = S.at(string_size);
        char front_string = S.at(0);
        
        S.erase(S.begin());
        S.push_back(front_string);

        if(S==T){
             check=true;
             break;
       }
    }
    
	
    cout << (check?"Yes":"No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define y1 Emilia
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n, k;

int main(){
    dracarys
    cin >> n >> k;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        if (x >= k) ++ans;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
char maz[110][20],last;
int n,len;
void work(){
    bool flag = true;
    scanf("%s",maz[0]);
    len = strlen(maz[0]);
    last = maz[0][len-1];
    for (int i=1;i<n;i++){
        scanf("%s",maz[i]);
        if (maz[i][0] != last) flag = false;
        len = strlen(maz[i]);
        last = maz[i][len-1];

        for (int j=0;j<i;j++) if (strcmp(maz[i],maz[j]) == 0) flag = false;
    }
    if (flag) puts("Yes");else puts("No");
}
int main(){
    while(~scanf("%d",&n)) work();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
typedef long long ll;
#define N 100010
using namespace std;
set <int> v[N];
int h[N];
void solve()
{
	int n,m;
	cin>>n>>m;
	int ans=0;
	for (int i=1;i<=n;i++)
		cin>>h[i];
	for (int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		v[b].insert(a);
		v[a].insert(b);
	}
	
		
//	for (int i=1;i<=n;i++)
//	{
		
	//	for (set<int>::iterator it=v[i].begin();it!=v[i].end();it++)
		//	cout<<"$"<<i<<" "<<*it;
		//cout<<endl;
	//}
	
	for (int i=1;i<=n;i++)
	{
		int flag=1;
		for (set<int>::iterator it=v[i].begin();it!=v[i].end();it++)
			if (h[*it]>=h[i])
			{
				flag=0;
			//	cout<<*it<<" # "<<i<<endl;
				break;
			}	
		ans+=flag;
	}
	cout<<ans;
}
int main() 
{
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 18072
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string N;
  cin >> N;

  int sum = 0;
  for (int i = 0; i < N.size(); i++) {
    sum += N[i] - '0';
  }

  // 解答
  cout << (stoi(N) % sum == 0 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#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.at(i);
  }
  bool hantei[3][N];
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      hantei[j][i]=false;
    }
  }
  for(int i=0;i<N;i++){
    if(A.at(i)%2==0){
      hantei[1][i]=true;
    }else{
      hantei[0][i]=true;
      hantei[2][i]=true;
    } 
  }
  int sum=1;
  for(int i=0;i<N;i++){
    int kazu=0;
    for(int j=0;j<3;j++){
      if(hantei[j][i]==false){
        kazu++;
      }
    }
    //cout<<kazu<<endl;
    sum*=kazu;
  }  
  long long kotae;
  kotae=pow(3,N)-sum;
  cout<<kotae<<endl;
}
  
  


Measured memory_bytes: 640
N = int(input())
words = []
s = []
for i in range(N):
    si = input()
    s.append(si)
    if si not in words:
        words.append(si)
M = int(input())
t = []
for i in range(M):
    ti = input()
    t.append(ti)
    if ti not in words:
        words.append(si)
ans = 0
for word in words:
    ans = max(ans, (s.count(word) - t.count(word)))
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

int get_ab(string str) {
	bool isA = false;
	int res = 0;
	if (str[0] == 'A') isA = true;
	for (int i = 1; i < str.length(); i++) {
		if (isA && str[i] == 'B') { res++; isA = false; }
		else if (str[i] == 'A') isA = true;
		else isA = false;
	}
	return res;
}

int main(void) {
	//Program Start	

	int H, W, h, w;
	cin >> H >> W >> h >> w;

	cout << (H * W) - (W * h + H * w) + (h * w) << endl;


ProgramEndPointLabel:;


	//Program End
	system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


Measured memory_bytes: 504
#include <cstdio>
#include <cstring>
using namespace std;
char s[1002];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	printf("%s",s);
	if(s[n-1]=='s')
		putchar('e');
	printf("s\n");
	return 0;
}

Measured memory_bytes: 1724
INF = 10 ** 9 + 7
n = gets.to_i
nums = gets.split.map(&:to_i)
hash = Hash.new(0)
61.times do |pos|
  tmp = 0
  nums.each do |num|
    tmp += num[pos]
  end
  hash[pos] = tmp
end
ans = 0
hash.each do |key, value|
  tmp = 1
  key.times do |k|
    tmp *= 2
    tmp %= INF
  end
  ans += tmp * value * (n - value)
  ans %= INF
end
puts ans


Measured memory_bytes: 36892
#include<stdio.h>
int main() {
	int n,a=0;
	scanf("%d", &n);
	for (int i = 0; i <= 50; i++) {
		for (int j = 0; j <= 28; j++) {
			if (4 * i + j * 7 == n) { printf("Yes"); return 0; }
		}
	}
	printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include<queue>
#include<map>
using namespace std;
int main() {
	long long int I,K,J,H;

	long long int Z = 1000;
	long long int W = 0;
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	
	for (int i = 0; A*100*i <=F; i++) {
		for (int k = 0; B*k*100+A*100*i <=F; k++) {
			for (int h = 0; h*C+ B * k * 100 + A * 100 * i <= F; h++) {
				for (int j = 0; 100 * A*i + 100 * B*k + h * C + j * D  <=F; j++) {
					if ((100 * A*i + 100 * B*k)*E >= 100 * (h * C + j * D)) {
						if (Z*(h * C + j * D)>=W*(100 * A*i + 100 * B*k)) {

							Z = 100 * A*i + 100 * B*k;
							W = (h * C + j * D);

							
						}
					}
				}
			}
		}
	}

	cout << Z + W <<" "<< W << endl;

	return 0;
}


Measured memory_bytes: 256
/**
*    created: 31.05.2020 22:18:32
**/
#include <bits/stdc++.h>
#define int long long
#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++)
using namespace std;

signed main() {

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

    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int ma, mb;
    if (n % 2 == 1) {
        ma = a[(n+1)/2-1];
        mb = b[(n+1)/2-1];
        cout << mb - ma + 1 << endl;
        return 0;
    }
    else {
        ma = (a[n/2-1] + a[n/2]);
        mb = (b[n/2-1] + b[n/2]);
        cout << mb - ma + 1 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 6296
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 5050, mlg = 17, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool can(vi a) {
	//for(auto i : a) cout << i << " "; cout << '\n';
	int n = a.size();
	int l, r; l = r = n/2;
	while(l > 0 && a[l-1] != a[l]) l--;
	while(r+1 < n && a[r+1] != a[r]) r++;
	int mid = (l+r)/2;
	//cout << l << " " << r << " = " << (n/2 <= mid ? a[l] : a[r]) << '\n';
	return n/2 <= mid ? a[l] : a[r];
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	n = 2*n - 1;
	vi a(n);
	for(auto &i : a) cin >> i;
	int ans = 0;
	for(int i = 1<<18; i>>=1;) {
		vi b;
		ans += i;
		for(auto j : a) b.pb(j>=ans);
		if(!can(b)) ans -= i;
	}
	cout << ans;
}


Measured memory_bytes: 6100