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

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;

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

  vector< Pi > Calclation;
  Calclation.push_back(make_pair(a[0], 1));
  for(int i = 1; i < N; i++) {
    if(a[i - 1] == a[i]) Calclation[Calclation.size() - 1].second++;
    else Calclation.push_back(make_pair(a[i], 1));
  }

  int ret = 0;
  for(int i = 2; i < Calclation.size(); i++) {
    if(Calclation[i - 1].second >= 2) {
      if(Calclation[i - 2].first < Calclation[i - 1].first && Calclation[i - 1].first > Calclation[i].first) ++ret;
    }
  }
  cout << ret << " ";

  ret = 0;
  for(int i = 2; i < Calclation.size(); i++) {
    if(Calclation[i - 1].second >= 2) {
      if(Calclation[i - 2].first > Calclation[i - 1].first && Calclation[i - 1].first < Calclation[i].first) ++ret;
    }
  }
  cout << ret << " ";

  ret = 0;
  for(int i = 2; i < Calclation.size(); i++) {
    if(Calclation[i - 1].second >= 2) {
      if(Calclation[i - 2].first < Calclation[i - 1].first && Calclation[i - 1].first < Calclation[i].first) ++ret;
      else if(Calclation[i - 2].first > Calclation[i - 1].first && Calclation[i - 1].first > Calclation[i].first) ++ret;
    }
  }
  cout << ret << " ";

  ret = 0;
  for(int i = 2; i < Calclation.size(); i++) {
    if(Calclation[i - 1].second == 1) {
      if(Calclation[i - 2].first < Calclation[i - 1].first && Calclation[i - 1].first > Calclation[i].first) ++ret;
    }
  }
  cout << ret << " ";

  ret = 0;
  for(int i = 2; i < Calclation.size(); i++) {
    if(Calclation[i - 1].second == 1) {
      if(Calclation[i - 2].first > Calclation[i - 1].first && Calclation[i - 1].first < Calclation[i].first) ++ret;
    }
  }
  cout << ret << endl;

}


Measured memory_bytes: 2440
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	char a,b;

	cin >> a >>b;

	if ((a == 'D' && b == 'H') || (a == 'H' && b == 'D')) {
		cout << 'D' << endl;
	}
	else {
		cout << 'H' << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define INF 1000000000
#define ll long long

int n, m;
string s;
int main()
{
	cin >> s;
	bool flag = false;
	REP(i, 0, s.size() - 1) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			flag = true;
			break;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      string s;
      cin>>s;
      for(i=0;i<3;i++)
      {
          count=0;
          for(j=i;j<3;j++)
          {
              if(s[j]=='R')
              count++;
              else
              break;
          }
          ans=max(ans,count);
      }
      cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
n = int(input())
l = list(map(int,input().split()))
count = [abs(l[0])]
for i in range(1,n):
    count.append(count[-1]+abs(l[i]-l[i-1]))
count.append(count[-1]+abs(l[n-1]))
if 0 <= l[0] <= l[1] or 0 >= l[0] >= l[1]:
    print(count[-1])
else:
    ans = count[-1]-(abs(l[0])+abs(l[1]-l[0]))+abs(l[1])
    print(ans)
for i in range(1,n-1):
    if l[i-1] <= l[i] <= l[i+1] or l[i-1] >= l[i] >= l[i+1]:
        print(count[-1])
    else:
        ans = count[-1]-(abs(l[i]-l[i-1])+abs(l[i+1]-l[i]))+abs(l[i+1]-l[i-1])
        print(ans)
if 0 <= l[n-1] <= l[n-2] or 0>= l[n-1] >= l[n-2]:
    print(count[-1])
else:
    ans = count[-1]-(abs(l[n-1])+abs(l[n-1]-l[n-2]))+abs(l[n-2])
    print(ans)

Measured memory_bytes: 13928
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int k = scanner.nextInt();
		List<Pair>[] list = new List[n];
		for (int i = 0; i < n; i++)
			list[i] = new ArrayList<Pair>();
		while (m-- > 0) {
			int a = scanner.nextInt() - 1;
			int b = scanner.nextInt() - 1;
			int l = scanner.nextInt();
			list[a].add(new Pair(b, l));
			list[b].add(new Pair(a, l));
		}
		int[] dp = new int[n];
		Arrays.fill(dp, 1 << 25);
		PriorityQueue<Pair> pq = new PriorityQueue<Main.Pair>();
		for (int i = 0; i < k; i++) {
			int s = scanner.nextInt() - 1;
			dp[s] = 0;
			pq.offer(new Pair(0, s));
		}
		while (!pq.isEmpty()) {
			Pair pair = pq.poll();
			int f = pair.f;
			int s = pair.s;
			if (dp[s] < f)
				continue;
			for (Pair p : list[s]) {
				if (dp[p.f] <= f + p.s)
					continue;
				dp[p.f] = f + p.s;
				pq.offer(new Pair(f + p.s, p.f));
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (Pair p : list[i]) {
				if(dp[p.f]==0)
					continue;
				int a = Math.max(dp[i], dp[p.f]);
				int b = a + (p.s - Math.abs(dp[i] - dp[p.f]) + 1) / 2;
				ans = Math.max(ans, b);
			}
		}
		System.out.println(ans);
	}

	class Pair implements Comparable<Pair> {
		int f, s;

		public Pair(int f, int s) {
			super();
			this.f = f;
			this.s = s;
		}

		@Override
		public String toString() {
			return "Pair [f=" + f + ", s=" + s + "]";
		}

		@Override
		public int compareTo(Pair o) {
			return f - o.f;
		}

	}
}

Measured memory_bytes: 109224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

const int maxx = 1e5 + 5;
typedef long long ll;

map<char, char> p;

int main(){
	char c;
	p['A'] = 'T'; p['T'] = 'A'; p['C'] = 'G'; p['G'] = 'C';
	while(scanf(" %c", &c) == 1){
		printf("%c\n", p[c]);
	}
	return 0;
}

Measured memory_bytes: 256
r,c = map(int,raw_input().split(' '))
sheet = [[0 for i in range((c+1))]for j in range((r+1))]
for i in range(r):
	s = map(int,raw_input().split(' '))
	for j in range(c):
		sheet[i][j] = s[j]
		sheet[i][c] += s[j]
		sheet[r][j] += s[j]
		print sheet[i][j],
	sheet[r][c] += sheet[i][c]
	print sheet[i][c]
for i in range(c):
	print sheet[r][i],
print sheet[r][c]

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n,uc[1000005]={0},dc[1000005]={0},sz[1000005],us=0,ds=0,mg=0,ug=0,zt;
    string s[1000005];
    vector<prl> vp,vm;
    cin >> n;
    rep(i,1,n){
        cin >> s[i];
        sz[i]=s[i].size();
        rep(j,0,sz[i]-1){
            if(s[i][j]=='(') uc[i]++;
            else dc[i]++;
        }
        us+=uc[i];
        ds+=dc[i];
    }
    if(us!=ds){
        cout << "No" << endl;
        return 0;
    }
    rep(i,1,n){
        bool dt=false;
        ll ct=0,ps=0;
        rep(j,0,sz[i]-1){
            if(s[i][j]=='('){
                dt=true;
                ct++;
            } else {
                dt=false;
                if(ct>0){
                    ct--;
                } else {
                    ps++;
                }
            }
        }
        if(ct==0){
            ug+=ps;
        } else if(ps==0) {
            mg+=ct;
        } else {
            if(ct>=ps){
                vp.pb({ps,ct});
            } else {
                vm.pb({ct,ps});
            }
        }
    }
    sort(all(vp));
    sort(all(vm));
    zt=mg;
    for(auto to: vp){
        if(zt<to.first){
            cout << "No" << endl;
            return 0;
        }
        zt -= to.first;
        zt += to.second;
    }
    zt=ug;
    for(auto to: vm){
        if(zt<to.first){
            cout << "No" << endl;
            return 0;
        }
        zt -= to.first;
        zt += to.second;
    }
    cout << "Yes" << endl;
    return 0;
}

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

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

int dp[10004];
int dig[10], cost[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    dp[0] = 1;

    for(int i = 0; i < m; ++i)
        cin >> dig[i];

    sort(dig, dig + m);

    for(int j = 0; j < m; ++j)
        for(int i = cost[dig[j]]; i <= n; ++i)
            dp[i] = max(dp[i], dp[i - cost[dig[j]]] + 1);

    for(int k = m - 1; n > 0;){
        if(n >= cost[dig[k]] && dp[n] == 1 + dp[n - cost[dig[k]]]){
            n -= cost[dig[k]];
            cout << dig[k];
        } else {
            --k;
        }
    }

    return 0;
}


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

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

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;

public class Main {
    private static IO io = new IO();
    public static void main(String[] args) {
        
        int n = io.nextInt();
        int m = io.nextInt();
        int ans = (int)Math.pow(2, m)*(1900*m + 100*(n-m));
        System.out.println(ans);
        
    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }
        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }
        boolean isPrintableChar(int c) {return 33<=c &&c <=126;}
        void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;}
        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>


int main()
{
	char S[11];
	for (int i = 0; i <= 9; i++)
		std::cin >> S[i];
	if (S[5] == '0' && (S[6] == '1' || S[6] == '2' || S[6] == '3' || S[6] == '4'))
		std::cout << "Heisei";
	else
		std::cout << "TBD";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    
    static class Point{
	double x,y;
	public Point(double x,double y){
	    this.x = x;
	    this.y = y;
	}
    }
	
    public static void main(String[] args){
	try(Scanner sc = new Scanner(System.in)){
	int n = sc.nextInt();
	System.out.println("0.00000000"+" "+"0.00000000");
	koch(n,new Point(0.0,0.0),new Point(100.0,0.0));
	System.out.println("100.00000000"+" "+"0.00000000");
	}
    }
    
    public static void koch(int n,Point p1,Point p2){
	if(n == 0) return;
	Point s = new Point(0.0,0.0);
	Point t = new Point(0.0,0.0);
	Point u = new Point(0.0,0.0);
	
	s.x = (2.0*p1.x+p2.x)/3.0;
	s.y = (2.0*p1.y+p2.y)/3.0;
	t.x = (p1.x+2.0*p2.x)/3.0;
	t.y = (p1.y+2.0*p2.y)/3.0;
	u.x = (t.x - s.x) / 2.0 - (t.y - s.y) * Math.sqrt(3.0)/2.0 +s.x;;
	u.y = (t.x - s.x) * Math.sqrt(3.0)/2.0 + (t.y - s.y)/2.0 +s.y;
	
	koch(n-1, p1, s);
	System.out.printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1, s, u);
	System.out.printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1, u, t);
	System.out.printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1, t, p2);
    }
}




Measured memory_bytes: 41776
def ins(A,N):
	for i in range(N):
		v=A[i]
		j=i-1
		while j>=0 and A[j]>v:
			A[j+1]=A[j]
			j-=1
		A[j+1]=v
		for k in range(len(A)):
			if k==len(A)-1:
				print(A[k])
			else:
				print(A[k],end=" ")
N=int(input())
A=list(map(int,input().split(" ")))
ins(A,N)

Measured memory_bytes: 8076
import java.util.*;
import java.io.*;
import java.math.*;
class Main{
	static int mod1 = (int)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();	
		long a = sc.nextLong();
		long b  =sc.nextLong();
		long muk = a*b;
		long div = muk/gcd(a,b);
		System.out.println(div);

    }
	
	
	public static long gcd(long a, long b){
		if(a==0)
			return b;
		
		return gcd(b%a,a);
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 
 
// 0 -> R, 1 -> G, 2 -> B
 
map<char, bool> usedColors;
int N; string s;
int R[4005];
int G[4005];
int B[4005];
ll ans = 0;
void dfs(int j, int diff) {
  if(!usedColors['R']) {
      ans+=R[j+1];
      if (j+diff<N && s[j+diff] == 'R') ans--;
  }
  if(!usedColors['G']) {
      ans+=G[j+1];
      if (j+diff<N && s[j+diff] == 'G') ans--;
  }
  if(!usedColors['B']) {
      ans+=B[j+1];
      if (j+diff<N && s[j+diff] == 'B') ans--;
  }
}
 
int main() {
  usedColors['R'] = false;
  usedColors['G'] = false;
  usedColors['B'] = false;
  cin>>N>>s;
  int r=0,g=0,b=0;
  rep(i,N) {
    if (s[i] == 'R') r++;
    if (s[i] == 'G') g++;
    if (s[i] == 'B') b++;
  }
  R[0] = r;
  G[0] = g;
  B[0] = b;
  rep(i,N) {
    R[i+1] = R[i];
    G[i+1] = G[i];
    B[i+1] = B[i];
    if (s[i]=='R') R[i+1]--;
    if (s[i]=='G') G[i+1]--;
    if (s[i]=='B') B[i+1]--;
  }
 
  rep(i,N) {
    usedColors[s[i]] = true;
    for (int j=i+1; j<N; j++) {
      if (usedColors[s[j]]) continue;
      usedColors[s[j]] = true;
      dfs(j, j-i);
      usedColors[s[j]] = false;
    }
    usedColors[s[i]] = false;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define endll '\n'
#define sz(a) (int)(a).size()
#define RWFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int dx[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int dy[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e5 + 5, oo = 2e9;
const double pi = acos(-1);
using namespace std;

int main()
{
    assem99
    int a, b; cin>>a>>b;
    cout<<(a + b) % 24;

    return 0;
}

Measured memory_bytes: 3580
#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[22][22];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;
int dp[(1<<22)];

void solve()
{
    cin>>n;

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

    dp[0] = 1;

    for(int mask = 0; mask < (1<<n) - 1; mask++){
        int i = __builtin_popcountll(mask);
        for(int j=0;j<n;j++){
            if(arr[i][j] and not (mask & (1<<j))){
                (dp[mask | (1<<j)] += dp[mask]);
                dp[mask | (1<<j)] %= MOD;
            }
        }
    }
    cout<<dp[(1<<n)-1];
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 18688
//Otoshidama

#include<bits/stdc++.h>
using namespace std;

int main (){
    int N, Y;
    bool fl = false;
    cin >> N >> Y;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            if(i*10000+j*5000+(N-(i+j))*1000==Y){
                cout << i << " " << j << " " << N-(i+j) << endl;
                fl = true;
                break;
            }
            if(fl==true)break;
        }
        if(fl==true)break;
    }
    if(fl==false)cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
d = {}
for c in s:
    if c in d:
        d[c] +=1
    else:
        d[c] = 1

ans = 'Yes'
if len(list(d.keys())) != 2:
    ans ='No'
else:
    for c in d.keys():
        if d[c] != 2:
            ans = 'No'
print(ans)


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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 3000

int N, K;
int a[MAX];

long long memo[MAX + 1][MAX + 1][2];

long long dfs( int h, int t, int turn )
{
	if( h > t ) {
		return 0;
	}
	if( memo[h][t][turn] != INF ) {
		return memo[h][t][turn];
	}
	int s = 1;
	if( turn ) {
		s = -1;
	}
	long long res1 = dfs( h + 1, t, 1 - turn ) + a[h] * s;
	long long res2 = dfs( h, t - 1, 1 - turn ) + a[t] * s;
	long long res;
	if( turn ) {
		res = min( res1, res2 );
	}
	else {
		res = max( res1, res2 );
	}
	return memo[h][t][turn] = res;

}

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

	for( int i = 0; i < MAX + 1; i++ ) {
		for( int j = 0; j < MAX + 1; j++ ) {
			for( int k = 0; k < 2; k++ ) {
				memo[i][j][k] = INF;
			}
		}
	}
	long long ans = dfs( 0, N - 1, 0 );

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 141184
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int MOD = 1e9 + 7;

// combination
class Com{
public:
    int n;
    int mod;

    Com(int n, int mod){
        this->n = n;
        this->mod = mod;

        f.resize(n + 1);
        fInv.resize(n + 1);
        inv.resize(n + 1);

        f[0] = f[1] = 1;
        fInv[0] = fInv[1] = 1;
        inv[1] = 1;

        for(int i = 2; i <= n; i++){
            f[i] = (f[i - 1] * i) % mod;
            inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;
            fInv[i] = (fInv[i - 1] * inv[i]) % mod;
        }
    }

    long long query(int n, int k){
        if(n < k){
            return 0;
        }
        if(n < 0 || k < 0){
            return 0;
        }
        return (((f[n] * fInv[k]) % mod) * fInv[n - k]) % mod;
    }
private:
    vector<long long> f, fInv, inv;
};

int main(){

    int H, W, A, B;
    cin >> H >> W >> A >> B;
    Com com(H + W, MOD);

    int ans = 0;
    for(int i = 0; i < H - A; i++){
        int temp1 = com.query(B - 1 + i, i);
        int temp2 = com.query(H + W - i - B - 2, W - B - 1);
        int plus = ((long long)temp1 * temp2) % MOD;
        ans = (ans + plus) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void) {
  int n, w;
  cin >> n >> w;
  vector<int> v1, v2, v3, v4;
  int minw, iniv;
  cin >> minw >> iniv;
  v1.push_back(iniv);
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == minw) {
      v1.push_back(b);
    } else if (a == minw + 1) {
      v2.push_back(b);
    } else if (a == minw + 2) {
      v3.push_back(b);
    } else if (a == minw + 3) {
      v4.push_back(b);
    }
  }
  sort(v1.begin(), v1.end(), greater<int>());
  sort(v2.begin(), v2.end(), greater<int>());
  sort(v3.begin(), v3.end(), greater<int>());
  sort(v4.begin(), v4.end(), greater<int>());
  vector<int> sum1(v1.size() + 1, 0), sum2(v2.size() + 1, 0), sum3(v3.size() + 1, 0), sum4(v4.size() + 1, 0);
  for (int i = 1; i <= v1.size(); i++) {
    sum1[i] = sum1[i - 1] + v1[i - 1];
  }
  for (int i = 1; i <= v2.size(); i++) {
    sum2[i] = sum2[i - 1] + v2[i - 1];
  }
  for (int i = 1; i <= v3.size(); i++) {
    sum3[i] = sum3[i - 1] + v3[i - 1];
  }
  for (int i = 1; i <= v4.size(); i++) {
    sum4[i] = sum4[i - 1] + v4[i - 1];
  }
  int ans = 0;
  for (int i = 0; i <= v4.size(); i++) {
    int wnow = (minw + 3) * i;
    if (wnow > w) break;
    for (int j = 0; j <= v3.size(); j++) {
      wnow = (minw + 3) * i + (minw + 2) * j;
      if (wnow > w) break;
      for (int k = 0; k <= v2.size(); k++) {
        wnow = (minw + 3) * i + (minw + 2) * j + (minw + 1) * k;
        if (wnow > w) break;
        int l = min((w - wnow) / minw, (int)v1.size());
        if (sum1[l] + sum2[k] + sum3[j] + sum4[i] > ans) ans = sum1[l] + sum2[k] + sum3[j] + sum4[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// IlyM

#include <bits/stdc++.h>
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
ll n,a,b,c,d;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>n>>a>>b;
	c=n/(a+b);
	n%=(a+b);
	c*=a;
	if (n>=a) c+=a;
	else c+=n;
	cout<<c;
	return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, N, B;
  cin >> N >> A >> B;
  cout << max(B *(N-1)+ A - ( A*(N-1) + B) + 1, 0LL);
  return 0;
}


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

using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
{    s.push_back('e');
    s.push_back('s');
 }   else
    s.push_back('s');
cout<<s;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  int one = a % 10;
  int ten = a % 100 - one;
  int hundred = a % 1000 - ten - one;
  ten = ten / 10;
  hundred = hundred / 100;
  //ここまでで位ごとに分解した
  cout << one + ten + hundred;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long lint;
typedef complex<double> point;

template<typename Key, typename Value>
using hash_map = cc_hash_table<Key, Value>;
template<typename T, typename Cmp = less<T>>
using oset = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 0x3f3f3f3f;
const lint INFL = 0x3f3f3f3f3f3f3f3fLL;
const double E = 1e-9, pi = 2 * acos(0);

template<typename T, typename U> void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if (x < y) x = y; }

bool solve(int testNumber) {
	int n;
	if (!(cin >> n)) {
		return false;
	}
	vector<int> A(n);
	int total = 1, odd = 1;
	for (int &x: A) {
		cin >> x;
		x %= 2;
		total *= 3;
		odd *= 1 + !x;
	}
	int ans = total - odd;
	printf("%d\n", ans);
	return true;
}

void init(const char *in = nullptr, const char *out = nullptr) {
	if (in) freopen(in, "r", stdin);
	if (out) freopen(out, "w", stdout);
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);
	init();
	for (int i=1; solve(i); i++);
	return 0;
}

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

vector<int> l(26, 0);
int last(int d, int i) { return l.at(i); }

int score(int d, int t, vector<int> &c, vector<vector<int>> &s) {
    int res = s.at(d).at(t);
    for(int i = 0; i < 26; i++) {
        if(i != t) {
            res -= c.at(i) * (d - last(d, i));
        }
    }
    return res;
}

int loss(int d, int t, vector<int> &c) {
    int diff = d - l.at(t);
    return diff * c.at(t);
}

int main() {
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D + 1, vector<int>(26));

    for(int i = 0; i < 26; i++) {
        cin >> c.at(i);
    }
    for(int d = 1; d <= D; d++) {
        for(int i = 0; i < 26; i++) {
            cin >> s.at(d).at(i);
        }
    }

    int v = 0;
    for(int d = 1; d <= D; d++) {
        int max_score = -9999999;
        int max_t = -1;
        for(int i = 0; i < 26; i++) {
            int is = score(d, i, c, s) + loss(d, i, c);
            if(max_score < is) {
                max_score = is;
                max_t = i;
            }
        }
        v += max_score;
        l.at(max_t) = d;
        cout << (max_t + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 3648
N=int(input())
listA=list(map(int,input().split()))
list1=[(-1)**(i+1)*listA[i] for i in range(N-1)]
SUM=sum(list1)
ans=listA[N-1]-SUM
listANS=[ans]
for i in range(N-1):
  ans=2*listA[i]-ans
  listANS+=[ans]
listANS=[str(i) for i in listANS]  
listANS=' '.join(listANS)
print(listANS)

Measured memory_bytes: 22084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const ll INF=1e18;


int main() {
  string s,sp;
  cin >>s>>sp;
  for(int i=s.size();i>=0;i--){
    bool ok =true;
    rep(j,sp.size()){
      if(s[i+j]!=sp[j]&&s[i+j] !='?'){
        ok=false;
      }
    }
    if(ok){
      string ans ="";
      int count=0;
      for(int j=i;j<sp.size()+i;j++){
        s[j]=sp[count];
        count++;
      }
      rep(j,s.size()){
        if(s[j]=='?'){
          ans+="a";
        }else{
          ans+=s[j];
        }
      }
      cout << ans <<endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" <<endl;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
int memo[maxn][maxn];
string s,t,sol;
int solve(int i,int j){
    if (i == s.size() || j == t.size())return 0;
    int &ans = memo[i][j];
    if(ans != -1)return ans;
    ans = solve(i,j+1);
    int x =
    ans = max(ans,solve(i+1,j));
    if (s[i] == t[j]){
        ans = max(ans,solve(i+1,j+1)+1);
    }
    return ans;
}
void rec(int i,int j){
    if (i == s.size() || j == t.size())return;
    int x = solve(i,j+1);
    int y = solve(i+1,j);
    int z = (s[i] == t[j])?solve(i+1,j+1)+1 : -1;
    if (z >= max(x,y)){
        rec(i+1,j+1);
        sol=s[i]+sol;
    }
    else if (y >= max(x,z)){
        rec(i+1,j);
    }
    else{
        rec(i,j+1);
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(".in","r",stdin);
    cin >> s >> t;
    memset(memo,-1,sizeof memo);
    solve(0,0);
    rec(0,0);
    cout << sol;
    return 0;
}


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


int main() { 
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    ll n = x;
    while (n <= y) {
        ans++;
        n = 2 * n;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <cstring>

template<typename T> bool chmax( T &a, const T b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;
template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();

int main()
{
	ll H, W, N; cin >> H >> W >> N;
	ll sr, sc; cin >> sr >> sc;
	--sr; --sc;
	string s, t; cin >> s >> t;
	string dstr = "LRUD";

	rep( j, 2 )
	{
		ll nxt = 2 * j + 1, prv = 2 * j;
		ll start = ( j == 0 ? sc : sr );
		ll end = ( j == 0 ? W : H );
		ll ns = 0, ne = end - 1;
		rrep( i, N )
		{
			ll ds = dstr.find( s[i] );
			ll dt = dstr.find( t[i] );

			if ( dt == prv )
				ne = min( end - 1, ne + 1 );
			else if ( dt == nxt )
				ns = max( 0LL, ns - 1 );

			if ( ds == prv )
				++ns;
			else if ( ds == nxt )
				--ne;

			if ( ns > ne ) { cout << "NO" << endl; return ( 0 ); }
		}
		if ( ( ns <= start && start <= ne ) == false )
		{ cout << "NO" << endl; return ( 0 ); }
	}

	cout << "YES" << endl;

	return ( 0 );
}


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

int main(){
  int n;cin >> n;
  vector<int> w(n);
  for(int i=0;i<n;++i)cin >> w.at(i);

  int mini;
  for(int t=1;t<n;++t){
      int s1 = 0, s2 = 0;
      for(int i=0;i<n;++i){
          if(t >= i)s1 += w.at(i);
          else s2 += w.at(i);
      }
      int diff = max(s1, s2) - min(s1, s2);
      if(t==1) mini = diff;
      else if(mini > diff)mini = diff;
      else  continue;
  }

  cout << mini << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e7;
const int maxn = 2e3 + 5;
ll mod = 1e9 + 7;

int n, a[maxn<<1]; char c[maxn<<1][2];
int pw[maxn], pb[maxn];

int w[maxn][maxn], b[maxn][maxn], f[maxn][maxn];

int t[maxn<<1];
void add(int x,int d)
{
	while (x && x <= 2*n)
	{
		t[x] += d;
		x += lowbit(x);
	}
}

int sum(int x)
{
	int ret = 0;
	while (x)
	{
		ret += t[x];
		x -= lowbit(x);
	}
	return ret;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= 2*n; i++)
	{
		scanf("%s%d", c[i], a+i);
		if (c[i][0] == 'W') pw[a[i]] = i;
		else pb[a[i]] = i;
	}

	for (int i = 0; i <= n; i++)
	{
		add(pw[i], 1);
		for (int j = 0; j <= n; j++)
		{
			add(pb[j], 1);
			w[i][j] = sum(2 * n) - sum(pw[i + 1]);
		}
		for (int j = 1; j <= n; j++)
		{
			add(pb[j], -1);
		}
	}

	for (int i = 1; i <= n; i++) add(pw[i], -1);

	for (int i = 0; i <= n; i++)
	{
		add(pb[i], 1);
		for (int j = 0; j <= n; j++)
		{
			add(pw[j], 1);
			b[j][i] = sum(2 * n) - sum(pb[i + 1]);
		}
		for (int j = 1; j <= n; j++)
		{
			add(pw[j], -1);
		}
	}

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++) if(i||j)
		{
			if (!i) f[i][j] = f[i][j - 1] + b[i][j - 1];
			else if (!j) f[i][j] = f[i - 1][j] + w[i - 1][j];
			else f[i][j] = MIN(f[i - 1][j] + w[i - 1][j], f[i][j - 1] + b[i][j-1]);
		}
	}
	printf("%d", f[n][n]);
}

Measured memory_bytes: 47360
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    vector<int> v(3);
    for(int i=0; i<3; i++) cin >> v[i];
    sort(v.begin(), v.end());
    //for(int i=0; i<3; i++) cout << v[i];
    cout << v[0] + v[1];
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; i++) {
        cout << i << ' ';
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();        
        int m = stdIn.nextInt();
        int[] k = new int[m];
        for(int i =  0; i < m; i++){
            int s = stdIn.nextInt();
            k[i] = 0;
            for(int j = 0; j < s; j++){
                k[i] = k[i] | (int)Math.pow(2, stdIn.nextInt()-1);    //繋がるスイッチに１を立てる
            }

        }

        int[] p = new int[m];
        Arrays.setAll(p, i -> stdIn.nextInt());
        boolean b = true;
        int answer = 0;
        for(int i = 0 ; i < (int)Math.pow(2, n); i++){
            for(int j = 0; j < m; j++){
                if(Integer.bitCount(k[j] & i) % 2 != p[j]){
                    b = false;
                    break;
                }
            }
            if(b) answer++;
            b = true;
        }
        System.out.println(answer);
   }
}

Measured memory_bytes: 28372
#include <iostream>
#include <set>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main() {
    int N, Q;
    cin >> N >> Q;
    static int memo[1000001];
    set<pair<int,int>> s;
    rep(q,Q){
        int a, v; 
        scanf("%d%d", &a, &v);
        s.erase(make_pair(-memo[a], a));
        memo[a] += v;
        s.insert(make_pair(-memo[a], a));
        printf("%d %d\n", s.begin()->second, -s.begin()->first);
    }
}

Measured memory_bytes: 9572
pattern = ["S", "H", "C", "D"]
n = int(input())
cards = []
for i in range(n):
    x,y = input().split()
    cards.append(pattern.index(x) * 13 + int(y))
for i in range(1,53):
    if not (i in cards):
        print(pattern[(i - 1) // 13] + " " + str((i - 1)  % 13 + 1))


Measured memory_bytes: 5600
#include <iostream>

using namespace std;

int main()
{
    int n,d1,d2,d3,d4;
    cin>>n;
    d1=n%10;
    n/=10;
    d2=n%10;
    n/=10;
    d3=n%10;
    n/=10 ;
    d4=n%10;
    if((d1==d2 && d2==d3 )||(d2==d3 && d3==d4) ){
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    string a;
    cin>>a;
    if((a[2] == a[3]) && (a[4]==a[5])){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define  mod 1000000007

ll power(ll a, ll n)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            res = (res*a)%mod;
        }
        a = (a*a)%mod;
        n = n/2;
    }
    return res;
}

inline void normal(ll &a)
{
    a %= mod;
    (a < 0) && (a += mod);
}
inline ll modMul(ll a, ll b)
{
    a %= mod, b %= mod;
    normal(a), normal(b);
    return (a * b) % mod;
}
inline ll modAdd(ll a, ll b)
{
    a %= mod, b %= mod;
    normal(a), normal(b);
    return (a + b) % mod;
}
inline ll modSub(ll a, ll b)
{
    a %= mod, b %= mod;
    normal(a), normal(b);
    a -= b;
    normal(a);
    return a;
}
inline ll modPow(ll b, ll p)
{
    ll r = 1;
    while (p)
    {
        if (p & 1) r = modMul(r, b);
        b = modMul(b, b);
        p >>= 1;
    }
    return r;
}
inline ll modInverse(ll a)
{
    return power(a, mod - 2);
}
inline ll modDiv(ll a, ll b)
{
    return modMul(a, modInverse(b));
}

ll pre[2000009];

void cal()
{
    pre[0] = 1;

    for(ll i=1; i<=2000000; i++)
    {
        pre[i] = (i*pre[i-1])%mod;
    }
}

ll ncr(ll n,ll r)
{
    return  modMul(pre[n],modMul(modInverse(pre[r]),modInverse(pre[n-r])));
}
int main()
{

    ll tst;

    cal();
    ll i,j,k,l,m,n,x,y;

    cin  >> n;



    ll ans = 0;


    for(i=2; i<=n; i++)
    {
        if(n-i<0)break;
        ll pt = power(2ll,i);
        pt = modSub(pt,2ll);

        pt = modMul(ncr(n,i),pt);
        pt = modMul(power(8ll,n-i),pt);
        ans = modAdd(ans,pt);


    }
    cout << ans << endl;
//    ll mn = -1,mx= -1,lmx=-1,lmn=-1;
//
//    vl v1,v2;
//    for(i=0; i<n; i++)
//    {
//        cin  >> x >> y;
//
//        if(mn == -1)mn = x+y;
//        else mn = min(mn,x+y);
//
//        if(mx == -1)mx = x+y;
//        else mx = max(mx,x+y);
//
//        v1.pb(x-y);
//        v2.pb(y-x);
//    }
//
//    ll ans = mx-mn;
//
//
//    sort(all(v1));
//    sort(all(v2));
//    reverse(all(v1));
//    reverse(all(v2));
//
//    ans = max(ans,v1[0]+v2[0]);
//
//    cout << ans << endl;



}


Measured memory_bytes: 19136
#include<bits/stdc++.h>
using namespace std;
#define intl unsigned long long int 

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,j,n;
	cin>>n;
	vector<intl> ar(n);
	intl ans=1;
	intl count1=0;
	for(i=0;i<n;i++){
		cin>>ar[i];
	}
	sort(ar.begin(),ar.end());
	for(i=0;i<n;i++){
		intl x=1000000000000000000;
		if(ans==0){
			break;
		}
		intl y=x/ans;
		// cout<<ar[i]<<" "<<ans<<" "<<x<<"\n";
		if(ar[i]<=y){
			ans*=ar[i];
		}
		else{
			count1=1;
			break;
		}
	}
	if(count1==1){
		cout<<"-1\n";
	}
	else{
		cout<<ans<<"\n";
	}
}


Measured memory_bytes: 3972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            //SolveA(args);
            SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        private const int M = 1000000007;
        private static void SolveA(string[] args)
        {
            int r = ReadAndParseInt();
            if( r < 1200)
            {
                Console.WriteLine("ABC");
            }else if( r < 2800)
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("AGC");
            }
        }
        private static void SolveB(string[] args)
        {
            string s = Console.ReadLine();
            bool success = Check(s);
            if( success)
            {
                Console.WriteLine("AC");
            }
            else
            {
                Console.WriteLine("WA");
            }
        }
        private static bool Check(string s)
        {
            if( s[0] != 'A') { return false; }

            int idx = -1;
            for(int i=1;i<s.Length;++i)
            {
                if( s[i] == 'C')
                {
                    idx = i;
                    break;
                }
            }
            if(idx == -1) { return false; }
            if( idx < 2 || s.Length - 2 < idx) { return false; }

            for(int i=1;i<s.Length;++i)
            {
                if(i != idx && char.IsUpper( s[i]))
                {
                    return false;
                }
            }

            return true;
        }
    }
}


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n, k;
    cin >> n;
    k = 2;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    constexpr ll INF = 1e18;
    vector<ll> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= i + k and j < n; ++j) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int T1 = 60*H1 + M1, T2 = 60*H2 + M2;

    cout << max(0,T2-T1-K) << endl;
}


Measured memory_bytes: 3636
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse = True)
D = [0] * N
pos = 1
D[0] = A[0] // N
A[0] = A[0] % N
while D[pos] != D[(pos - 1) % N]:
  pre = (pos - 1) % N
  a = D[pre] - D[pos]
  A[pos] += a
  D[pos] = D[pre] + A[pos] // N
  A[pos] %= N
  pos = (pos + 1) % N
print(D[pos])

Measured memory_bytes: 3188