akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k;cin >> k;string s;cin >> s;string ans;
    for (int i = 0; i < s.size(); ++i)
    {
        if(i<k)ans+=s[i];
        else break;
    }
    if(s.size()>k)ans+="...";
    cout << ans;
    }

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

const int INF=0x3f3f3f3f;
int a[55];

int main(){
    int n,idx1,idx2;
    int MAX=-1,MIN=INF;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]<MIN) {MIN=a[i];idx1=i;}
        if(a[i]>MAX) {MAX=a[i];idx2=i;}
    }
    if(MIN>=0){
        cout<<n-1<<endl;
        for(int i=1;i<n;i++){
            cout<<i<<" "<<i+1<<endl;
        }
    }
    else if(MAX<=0){
        cout<<n-1<<endl;
        for(int i=n;i>1;i--){
            cout<<i<<" "<<i-1<<endl;
        }
    }
    else if(abs(MAX)>=abs(MIN)){
        cout<<2*n-1<<endl;
        for(int i=1;i<=n;i++){
            cout<<idx2<<" "<<i<<endl;
        }
        for(int i=1;i<n;i++){
            cout<<i<<" "<<i+1<<endl;
        }
    }
    else{
        cout<<2*n-1<<endl;
        for(int i=1;i<=n;i++){
            cout<<idx1<<" "<<i<<endl;
        }
        for(int i=n;i>1;i--){
            cout<<i<<" "<<i-1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 200002
int n;
struct node
{
	int to,next;
}a[MAXN];
int f[MAXN],b[MAXN],head[MAXN];
bool cmp(int a,int b)
{
	return a>b;
}
void dfs(int u)
{
	int s=0,minn=0;
	for(int i=head[u];~i;i=a[i].next)
		dfs(a[i].to);
	for(int i=head[u];~i;i=a[i].next)
		b[++s]=f[a[i].to];
	if(s==0)return;
	sort(b+1,b+s+1,cmp);
	for(int i=1;i<=s;i++)
		minn=max(minn,i+b[i]);
	f[u]=minn;
}
int main()
{
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	int x;
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&x);
		a[i]=(node){i,head[x]};
		head[x]=i;
	}
	dfs(1);
	printf("%d",f[1]);
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef unsigned long long int lli;
typedef pair<int, string> pi;


int main()
{
    int a, b;
    cin >> a >> b ;
    int k = abs(a-b);
    if(k%2){
        cout << "IMPOSSIBLE\n";
    }
    else{
        cout << min(a, b)+k/2 << '\n';
    }

    return 0;
}


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

int main() {
    int n;
    string a,b,c;
    cin>>n>>a>>b>>c;

    int ans = 0;
    for(int i=0; i<n; i++) {
        if(a.at(i)!=b.at(i) && b.at(i)!=c.at(i) && c.at(i)!=a.at(i)) ans += 2;
        else if(a.at(i)!=b.at(i) || b.at(i)!=c.at(i)) ans++;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
ans = 0
perms = list(itertools.permutations(arr))

for perm in perms:
    for i in range(n - 1):
        x1, y1 = perm[i]
        x2, y2 = perm[i + 1]
        ans += ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
print(ans / len(perms))

Measured memory_bytes: 8052
import sys
a,b,o,ab = 0,0,0,0
for line in sys.stdin.readlines():
  i,t = line.split(',')
  if t == 'A\n':
    a += 1
  if t == 'B\n':
    b += 1
  if t == 'O\n':
    o += 1
  if t == 'AB\n':
    ab += 1
print(a)
print(b)
print(ab)
print(o)

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

int main()
{
    int k, s;
    cin >> k >> s;

    int x, y, z = 0;
    int cnt = 0;

    for (x = 0; x <= k; x++)
    {
        for (y = 0; y <= k; y++)
        {
            z = s - x - y;
            if ((0 <= z) && (z <= k))
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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 k = stdIn.nextInt();
        int q = stdIn.nextInt();
        int win[] = new int [n];
        for(int i = 0; i < q; i++)
            win[stdIn.nextInt() - 1]++;
        for(int i = 0; i < n ; i++){
            System.out.println(k - (q-win[i]) <= 0 ?  "No" :"Yes");
        }

   }
}


Measured memory_bytes: 58824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=1e4+10;
int prime[MAXN],cnt=0,ism[MAXN];
int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}
int a[MAXN],n;
int sum[MAXN];
bool check(int p)
{
	for(int i=0;i<p-1;++i)
		sum[i]=0;
	for(int i=0;i<=n;++i)
	{
		sum[i%(p-1)]=(sum[i%(p-1)]+a[i])%p;
	}
	for(int i=0;i<p-1;++i)
		if(sum[i]%p)
			return false;
	return true;
}
void init()
{
	ism[1]=1;
	for(int i=2;i<=n;++i)
	{
		if(!ism[i])
			prime[++cnt]=i;
		for(int j=1;j<=cnt;++j)
		{
			if(1LL*prime[j]*i>n)
				break;
			ism[i*prime[j]]=1;
			if(i%prime[j]==0)
				break;
		}
	}
}
set<int> ans;
void pr()
{
	for(auto x:ans)
		printf("%d\n",x);
}
int main()
{
	n=read();
	init();
	int g=0;
	for(int i=n;i>=0;--i)
	{
		a[i]=read();
		if(a[i])
			g=gcd(g,abs(a[i]));
	}
	for(int i=2;i*i<=g;++i)
	{
		if(g%i==0)
		{
			ans.insert(i);
			while(g%i==0)
				g/=i;
		}
	}
	if(g>1)
		ans.insert(g);
	for(int i=1;i<=cnt;++i)
	{
		if(a[0]%prime[i]==0 && check(prime[i]))
			ans.insert(prime[i]);
	}
	pr();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> ab(n);
    ll res = 0;
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        res -= b;
        ab[i] = a + b;
    }
    
    sort(ab.begin(), ab.end(), greater<int>());
    int num = ceil((double)n / 2);
    ll sum = 0;
    for(int i = 0; i < n; i += 2){
        sum += ab[i];
    }
    res += sum;
    
    cout << res << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100005;
int n;
void print(int u,int v){printf("%d %d\n",u,v);}

int main(){
	scanf("%d",&n);
	int t=1;
	while(t<n)t<<=1;
	if(t==n){
		puts("No");
		return 0;
	}
	puts("Yes");
	print(1,2);
	print(2,3);
	print(3,1+n);
	print(1+n,2+n);
	print(2+n,3+n);
	for(int i=4;i<n;i+=2){
		print(i,i+1);
		print(i+1,1);
		print(1,i+n);
		print(i+n,i+1+n);
	}
	if(n%2==0){
		print(n-1,n);
		print((n^(n-1))-1+n,n+n);
	}
	return 0;
} 

Measured memory_bytes: 2304
#include<stdio.h>
main(){
  int r,c=0;
  int a,b,d,e=0;
  int f,g,h,i=0;
  int j,k,l=0;
  int A[101][101]={0};
  scanf("%d %d",&r,&c);
  for(a=0;a<r;a++){
    for(b=0;b<c;b++){
      scanf("%d",&A[a][b]);
    }
  }
  for(d=0;d<r;d++){
    for(e=0;e<c;e++){
      A[d][c]=A[d][c]+A[d][e];
    }
  }
  for(f=0;f<c;f++){
    for(g=0;g<r;g++){
      A[r][f]=A[r][f]+A[g][f];
    }
  }
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      A[r][c]=A[r][c]+A[i][j];
    }
  }
  for(k=0;k<=r;k++){
    for(l=0;l<=c;l++){
      if(l==c){
	printf("%d\n",A[k][l]);
      }
      else{
	printf("%d ",A[k][l]);
      }
    }
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)

#define all(v) (v).begin(), (v).end();
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

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

    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<int> dp(n);

    repr(i, 1, n) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        rrepr(j, i - k, i - 1) {
            if (j < 0) break;
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

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

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

inline int gcd(int a, int b) { return (a%b == 0) ? b : gcd(b, a%b); }
inline int fac(int n) { return (n==0) ? 1 : n * fac(n - 1); }

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

    sort(a, a + 3 * n);
    ll ans = 0;
    for (int i = n; i < 3 * n; i += 2) {
        ans += a[i];
    }

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


Measured memory_bytes: 4612
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> a(n),b(m);
    for(auto&i:a) cin>>i;
    for(auto&i:b) cin>>i;
    ll s{},t{},u{},ans{};
    fr(i,n){
        if(s+a[i]>k) break;
        s+=a[i];
        ++t;
    }
    fr(i,m){
        if(s+b[i]>k) break;
        s+=b[i];
        ++u;
    }
    ans=t+u;
    ifr(i,t){
        s-=a[i];
        for(int j=u;j<m;++j){
            if(s+b[j]>k) break;
            s+=b[j];
            ++u;
        }
        chmax(ans,i+u);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 4696
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int n,max_num = -1000001,min_num = 1000001,tmp;
	long long int sum = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&tmp);
		sum += tmp;
		max_num = max(max_num,tmp);
		min_num = min(min_num,tmp);
	}
	printf("%d %d %lld\n",min_num,max_num,sum);
}



Measured memory_bytes: 2764
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {


    public static void solve() {
        int n = in.nextInt();
        int[] nodes = new int[n];

        for(int i = 0; i < n; i += 1)
            nodes[i] = in.nextInt();

        long[] sum = new long[n+1];

        for(int i = 0; i < n ; i += 1) {
            sum[i+1] = sum[i] + nodes[i];
        }

        long[][] store = new long[n][n];

        for(int i = n-1; i >= 0; i -= 1) {
            for(int j = i; j < n; j += 1) {
                if(i == j)
                    store[i][j] = 0;
                else {
                    store[i][j] = Long.MAX_VALUE;

                    for(int l = i; l < j; l += 1) {
                        store[i][j] = Math.min(store[i][j], store[i][l] + store[l+1][j] + sum[j+1]-sum[i]);
                    }
                }
            }
        }

        out.println(store[0][n-1]);
    }


    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    cout << ceil(n * 1.0 / 2) * 1.0 / n << "\n";
    return 0;
}

Measured memory_bytes: 3788
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    S = input().rstrip()
    T = input().rstrip()
    cnt = 0
    for i in range(3):
        if S[i] == T[i]:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include"bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = b - 1; i >= a; i--)
#define RREP(i, n) RFOR(i, 0, n)
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define rrep(i, a, b) for (auto i = a; i > b; i--)
#define range(i, a, b) (a <= i && i < b)
#define fi first
#define fs first
#define se second
#define sc second
using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
typedef pair<int, int> P;
#define ll long long

void solve() {
	int y, m, d;
	cin >> y >> m >> d;

	int base = 39*5*666 + 40*5*333+1;
	int tmp = 0;

	FOR(i, 1, y) {
		if(i%3 == 0) tmp += 40 * 5;
		else tmp += 39 * 5;
	}

	FOR(i, 1, m) {
		if (i % 2 || y % 3 == 0) tmp += 20;
		else tmp += 19;
	}

	tmp += d;

	cout << base - tmp << endl;



}

int main() {
	int n;
	cin >> n;
	REP(_, n) solve();
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int ans = 0;
  int x;
  for (int i = 0; i < N; i++) {
    cin >> x;
   if (x < K - x) {
     ans += 2 * x;
   }
   else {
     ans += 2 * (K - x);
   }
  }

  cout << ans << endl;

}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;

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

  std::cin >> N;

  int res = (N + 1) / 2;
  std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,ans;
int l[205];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
		scanf("%d",&l[i]);
	sort(l+1,l+2*n+1);
	for(int i=1;i<=2*n;i+=2)
		ans+=l[i];
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
    int s_num = 0;
    int sum1 = 0;
    int sum2 = 0;
    
    while(1){
        int i;
        scanf("%d",&s_num);
        if(s_num == 0) break;
        for(i = 0;i < s_num; i++){
            int sam1 = 0;
            int sam2 = 0;
            
            scanf("%d %d",&sam1,&sam2);
            
            if(sam1 > sam2){
                sum1 += (sam1 + sam2);
            }else if(sam1 < sam2){
                sum2 += (sam1 +sam2);
            }else{
                sum1 += sam1;
                sum2 += sam2;
            }
            
            
        }
         
    printf("%d %d\n",sum1,sum2);
    sum1 = sum2 = 0;
   
    }
    
    return 0;

}

Measured memory_bytes: 600
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define int long long
#define pb push_back
#define mkp make_pair
#define endl '\n'
using namespace std;
const int MAX=1e6+3;
int hcf;
int solve()
{
	int n;
	cin>>n;
	int a[n];
	unordered_map<int,int> mp;
	int hcf=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	for(int i=0;i<MAX;i++){
		if(mp[i])
			hcf=__gcd(hcf,i);
	}
	if(hcf>1){
		cout<<"not coprime";
		return 0;
	}
	for(int i=2;i<MAX;i++){
		int cnt=0;
		for(int j=i;j<MAX;j+=i){
			if(mp[j])	cnt++;
			if(cnt>1){
				cout<<"setwise coprime";
				return 0;
			}
		}
		if(cnt>1){
			cout<<"setwise coprime";
			return 0;
		}
	}
	cout<<"pairwise coprime";
	return 0;
}
signed main()
{
	fastio;
	solve();
}



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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    ll n;
    cin>>n;
    if(n==1) {
        cout<<0;
    }
    else {
        ll ans = (3*mod+power(10, n, mod)+power(8, n, mod)-power(9, n, mod)-power(9, n, mod))%mod;
        cout<<ans;
    }
}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

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

	int x[4] = { 0 };
	for (int i = 0; i < 3; i++) {
		if (a[i] == 1) {
			x[0] += 1;
		}
		else if (a[i] == 2) {
			x[1] += 1;
		}
		else if (a[i] == 3) {
			x[2] += 1;
		}
		else if (a[i] == 4) {
			x[3] += 1;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (b[i] == 1) {
			x[0] += 1;
		}
		else if (b[i] == 2) {
			x[1] += 1;
		}
		else if (b[i] == 3) {
			x[2] += 1;
		}
		else if (b[i] == 4) {
			x[3] += 1;
		}
	}

	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (x[i] > 2) {
			ans = 1;
		}
	}

	if (ans == 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         998244353
#define mode        1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323

ll a,b,c;

void solve()
{
       cin>>a>>b>>c;
       if(a==b && b==c )
       {
              if(a&1) { cout<<0; exit(0); }
              cout<<-1;
              exit(0);
       }
       ll ans=0;
       while(!(a&1 || b&1 || c&1))
       {
              ll ta=a/2, tb=b/2, tc=c/2;
              a=tb+tc;
              b=ta+tc;
              c=ta+tb;
              ans++;
       }
       cout<<ans;
}


int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    ll sum = 0;
    ll ans = INF, sunuke_score = 0, bear_score = 0;

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

    for(int i=0; i<N-1; i++) {
        sunuke_score += a[i];
        bear_score = sum - sunuke_score;
        ans = min(ans, abs(sunuke_score-bear_score));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */



signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  cin >> N;
  cout << (N-2)*180 << endl;

  return 0;
}

Measured memory_bytes: 256
import heapq
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

import functools
@functools.lru_cache(maxsize=None)
def tami(n, x):
	if x == 1:
		return n
	elif x%2 == 0:
		return tami(n, x//2)**2 %mod
	else:
		return tami(n, x-1)*n %mod

def nCr(n, r):
	r = min(r, n-r)
	numer = denom = 1
	for i in range(1, r+1):
		numer = numer * (n+1-i) % mod
		denom = denom * i % mod
	return numer * pow(denom, mod-2, mod) % mod

N,a,b = IL()

n = tami(2, N) -1
aa = nCr(N, a)
bb = nCr(N, b)
ans = n-aa-bb
while ans < 0:
	ans += mod
print(ans)

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

//#define int long long


/*https://github.com/kurokoji/.cpp-Template/wiki#struct-fast*/
//理解できていないものはコメントアウト
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

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

/* short */
//#define pb push_back
//#define eb emplace_back
//#define mp make_pair
//#define Fi first
//#define Se second
#define ALL(v) begin(v), end(v) // sort(ALL(v));みたいに使う
//#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

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

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

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

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


signed main() {
	int N = in();

	vector<double> x;
	vs u;

	double ans = 0.0;

	REP(i, N) {
		double td;
		string s;

		cin >> td >> s;

		if (s == "JPY") {
			ans += td;
		}
		else {
			ans += td * 380000.0;
		}
	}

	cout << ans << endl;


	#ifdef _DEBUG
		system("pause");
	#endif
	return 0;
}



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

const int N = (int)1e5 + 9;
const int MOD = (int)1e9 + 7;
bool ok[N];
int dp[N];
int get(int i1, int i2){
    int res = 0;
    if(i1 >= 0) res += dp[i1];
    if(i2 >= 0) res += dp[i2];
    res %= MOD;
    return res;
}

int main(){
    fastIO;
    for(int i = 0 ; i < N ;i ++ ) ok[i] = true;
    int n, m;
    cin >> n >> m;
    dp[0] = 1;
    int x;
    for(int i = 1; i <= m ; i ++ ){
        cin >> x;
        ok[x] = false;
    }
    for(int i = 1; i <= n; i ++ ){
        if(ok[i]){
           dp[i] = get(i-1,i-2); 
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n)cin >> c[i];

    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll cnt = 0;

    for(int i = 0; i < n; i++){ //bの要素を順繰りに見ていく
        int right = n;
        int left = -1;
        while(right - left > 1){
            int mid = (right + left)/2;
            if(a[mid] >= b[i]){
                right = mid;
            }else{
                left = mid;
            }
        }
        int num1 = left + 1;
        //cout << "num1:" << num1 << endl;
        right = n;
        left = -1;
        while(right - left > 1){
            int mid = (right + left)/2;
            if(c[mid] > b[i]){
                right = mid;
            }else{
                left = mid;
            }
        }
        int num2 = n - right;
        //cout << "num2:" << num2 << endl;
        cnt += (ll)num1 * num2;
    }

    cout << cnt << endl;


}

Measured memory_bytes: 4568
n = int(input())
a = list(map(int, input().split()))
cnt = -1
flg = 0
while flg==0:
	cnt+=1
	for i in range(n):
		if a[i] % 2 ==0:
			a[i] = a[i] // 2
		else:
			flg=1
print (cnt)

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

int main() {
  int n; cin >> n;
  rep(i,n/4+1)rep(j,n/7+1) {
     if (4*i + 7*j == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3616
import numpy as np
import math


A, B, H, M = map(int, input().split())

d = np.sqrt((B*math.cos(math.radians(6*M))-A*math.cos(math.radians(30*H+M/2)))**2+(B*math.sin(math.radians(6*M))-A*math.sin(math.radians(30*H+M/2)))**2)
print(d)

Measured memory_bytes: 27160
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        System.out.println(Arrays.stream(array).filter(Main::isPrime).count());
    }

    public static boolean isPrime(int x){
        if (x == 2) {
            return true;
        }
        if (x < 2 || x % 2 == 0) {
            return false;
        }
        int i = 3;
        while (i <= Math.sqrt(x)) {
            if (x % i == 0) {
                return false;
            }
            i += 2;
        }
        return true;
    }
}



Measured memory_bytes: 44080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  if (n == 1) {
    cout << 0 << endl;
    return;
  }
  vector<vector<ll> > dp(n + 1, vector<ll>(3, -INF));
  rep(j, 3) {
    if (-1 / 2 - 1 + j == 0) {
      dp[0][j] = 0;
    }
  }
  ll ans = -INF;
  rep(j, 3) {
    int j2 = 0 / 2 - 1 + j;
    if (j2 == 0) {
      dp[1][j] = 0;
    } else if (j2 == 1) {
      dp[1][j] = a[0];
    }
    if (j2 == n / 2) chmax(ans, dp[1][j]);
  }
  rep3(i, 1, n) {
    rep3(i2, i - 4, i - 1) { // どこから遷移するか
      if (i2 < -1) continue;
      rep(j, 3) {
        int j2 = i / 2 - 1 + j;
        rep(k, 3) {
          int k2 = i2 / 2 - 1 + k;
          if (j2 == k2) chmax(dp[i + 1][j], dp[i2 + 1][k]);
          else if (k2 + 1 == j2) chmax(dp[i + 1][j], dp[i2 + 1][k] + a[i]);
        }
        if (j2 == n / 2) chmax(ans, dp[i + 1][j]);
      }
    }
  }
  cout << ans << endl;
  // rep(i, n + 1) cout << dp[i] << endl;
}


Measured memory_bytes: 15060
// C - Make a Rectangle

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	map<int, int, greater<int>> cnt;

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

	ll H = 0, W = 0;
	for (auto itr : cnt) {
		if (H == 0 && itr.second >= 4) {
			H = itr.first;
			W = H;
			break;
		} else if (itr.second >= 2) {
			if (H == 0) {
				H = itr.first;
			} else {
				W = itr.first;
				break;
			}
		}
	}

	ll ans = H * W;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll r,g,b;
    cin>>r>>g>>b;
    ll k;
    cin>>k;
    while( k>0 && r>=g)
    {
        k--;
        g=g*2;
    }
    
    while(k>0 && g>=b)
    {
        b=b*2;
        k--;
    }
  //  cout<<r<<" "<<g<<" "<<b<<"\n";
    if(b>g && g>r) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3632
package main

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

func main() {
	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	if N == 1 && M == 1 {
		fmt.Println(1)
		return
	}
	if N == 1 {
		fmt.Println(M - 2)
		return
	}
	if M == 1 {
		fmt.Println(N - 2)
		return
	}

	fmt.Println((N - 2) * (M - 2))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int T;
ll A,B,C,D;
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
        if(A<B||D<B) puts("No");
        else if(C>=B) puts("Yes");
        else
        {
            A=A%B;
            ll g=__gcd(D,B);
            A=A%g;
            ll need=(C-A)/g;
            A+=need*g;
            if(A<=C) A+=g;
            if(A>=B) puts("Yes"); else puts("No");
        }
    }
    return 0;
}



Measured memory_bytes: 256
#![allow(dead_code)]
use std::io;
use std::f64;

fn main() {
    solve_b();
}

fn solve_b() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let elm: Vec<_> = line.trim()
        .split_whitespace()
        .map(|s| s.parse::<f64>().unwrap())
        .collect();

    let a = elm[0];
    let b = elm[1];
    let c = f64::consts::PI * elm[2] / 180.0;

    let s = 0.5 * a * b * c.sin();
    print!("{:.4} ", s);
    let l = a + b + (a.powi(2) + b.powi(2) - 2.0 * a * b * c.cos()).sqrt();
    print!("{:.4} ", l);
    let h = b * c.sin();
    println!("{:.4}", h);
}



Measured memory_bytes: 5212
N, Q = (int(i) for i in input().split())
ab = [[int(i) for i in input().split()] for i in range(N-1)] 
px = [[int(i) for i in input().split()] for i in range(Q)] 
ab.sort()

weight = [0]*N
for i in range(len(px)):
	weight[px[i][0]-1]+=px[i][1]

for g in range(len(ab)):
	weight[ab[g][1]-1] += weight[ab[g][0]-1]

print(*weight)

Measured memory_bytes: 88692
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1<<16];
int N;
int h[16],w[16];
string s[4];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>h[i]>>w[i];
	}
	for(int i=0;i<4;i++)cin>>s[i];
	for(int i=0;i<1<<16;i++)dp[i]=114514;
	dp[(1<<16)-1]=0;
	for(int i=1<<16;i--;)
	{
		for(int j=0;j<N;j++)
		{
			for(int x=-3;x<4;x++)for(int y=-3;y<4;y++)
			{
				char c=0;
				int take=0;
				for(int I=0;I<h[j];I++)for(int J=0;J<w[j];J++)
				{
					if(x+I<0||x+I>=4||y+J<0||y+J>=4)continue;
					int now=(x+I)*4+y+J;
					take|=1<<now;
					if(i>>now&1)
					{
						if(c==0)c=s[x+I][y+J];
						else if(c!=s[x+I][y+J])c=1;
					}
				}
				if(c>1)
				{
					dp[i&~take]=min(dp[i&~take],dp[i]+1);
				}
			}
		}
	}
	cout<<dp[0]<<endl;
}



Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int mn = min({a, b, c});
	int mx = max({a, b, c});
	int md = a + b + c - mn - mx;

	rep(i, k) mx *= 2;

	cout << mn + md + mx << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll X;
  cin>>X;
  ll ans1, ans2;
  for(ll A=-3000;A<=3000;++A) {
    for(ll B=-3000;B<=3000;++B) {
      if(A*A*A*A*A-B*B*B*B*B==X) {
        ans1 = A;
        ans2 = B;
      }
    }
  }
  cout<<ans1<<" "<<ans2<<endl;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
  string b;
  cin >>b;
  if(b=="A"){
    cout <<"T";
  }else{
   if(b=="T"){
     cout <<"A";
  }else{
     if(b=="C"){
             cout <<"G";
     }else{
            cout <<"C";
     }
   }
  }
}


    
 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,m;
int main(void){
    cin>>n>>m;
    if(500*n>=m){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 3564
require 'pp'
require 'set'

n, m = gets.split.map(&:to_i)
x = []
path = {}
m.times do |i|
    a, b = gets.split.map(&:to_i)
    x << [a, b]
    path[a] ||= []
    path[a] << b
    path[b] ||= []
    path[b] << a
end

#spp path

if m == 0
    puts 1
    exit 0
end

visited = Array.new(n + 1, -1)
num = 0
i = 0

while path.empty?.!
    a, b = path.first
    path.delete(a)
    visited[a] = num

    stack = []
    b.each do |t|
        stack.push([t, num])
    end

    ##pp path
    #pp stack
    while stack.empty?.!
        k, num = stack.shift
        visited[k] = num
        nex = path.delete(k)
        if nex
            nex.each do |i|
                if visited[i] == -1
                    stack.push([i, num])
                end
            end
        end
    end

    num += 1
end

#pp visited
ans = visited.tally
ans.delete(-1)
puts ans.values.max


Measured memory_bytes: 52752
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MM 998244353

int main(){
  long long dp[3000][3001];
  long long N,S, ans=0;
  long long A[3000];
  scanf("%lld%lld", &N,&S);

  for (int i = 0; i < N; i++)
  {
      scanf("%lld", A+i);
  }

  for (int i = 0; i <= S; i++)
  {
      dp[0][i] = 0;
      if (A[0] == i)
      {
          dp[0][i] = 1;
      }
  }
  for (int i = 0; i < N; i++)
  {
      dp[i][0] = i+2;
  }
  
  for (int i = 1; i < N; i++)
  {
      for (int j = 1; j < A[i]; j++)
      {
          dp[i][j] = dp[i-1][j];
      }
      for (int j = A[i]; j <= S; j++)
      {
          dp[i][j] = (dp[i-1][j] + dp[i-1][j-A[i]]) % MM;
      }
  }
  for (int i = 0; i < N; i++)
  {
      ans = (ans + dp[i][S]) % MM;
    // printf("%lld ", dp[i][S]);
  }
//   printf("%lld ", dp[1][0]);
  printf("%lld", ans);

  return 0;
}

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

#define int long long

#define MOD 1000000007
int n, m;

int s[2010];
int t[2010];


template <class type> class SegmentTree{
    public:
        int size;
        vector<type> tree;
        type def;
        type (*marge)(type, type);

        SegmentTree(int n, type d, type (*m)(type, type)){
            size = 1;
            def = d;
            marge = m;
            n++;

            while(size < n){
                size *= 2;
            }

            tree.resize(2*size);

            for(int i = 0;i < size;i++){
                tree[size-1+i] = def;
            }

            for(int i = size-2;i >= 0;i--){
                tree[i] = marge(tree[i*2+1], tree[i*2+2]);
            }

            return;
        }

        SegmentTree(int n, type array[], type d, type (*m)(type, type)){
            size = 1;
            def = d;
            marge = m;
            n++;

            while(size < n){
                size *= 2;
            }

            tree.resize(2*size);

            for(int i = 0;i < size;i++){
                if(i < n) tree[size-1+i] = array[i];
                else tree[size-1+i] = def;
            }

            for(int i = size-2;i >= 0;i--){
                tree[i] = marge(tree[i*2+1], tree[i*2+2]);
            }

            return;
        }

        void update(int i, type val){
            i = size-1+i;
            tree[i] = val;

            while(i > 0){
                i = (i-1)/2;
                tree[i] = marge(tree[i*2+1], tree[i*2+2]);
            }

            return;
        }

        void add(int i, type val){
            i = size-1+i;
            tree[i] = (tree[i] + val) % MOD;

            while(i > 0){
                i = (i-1)/2;
                tree[i] = marge(tree[i*2+1], tree[i*2+2]);
            }

            return;
        }

        type get(int a, int b, int k, int l, int r){
            if(r <= a || b <= l) return def;
            if(a <= l && r <= b) return tree[k];

            type vl = get(a, b, 2*k+1, l, (l+r)/2);
            type vr = get(a, b, 2*k+2, (l+r)/2, r);

            return marge(vl, vr);
        }

        type get(int a, int b){
            return get(a, b, 0, 0, size);
        }
};

int marge(int i, int j){
    return (i + j) % MOD;
}


signed main(){
    cin >> n >> m;

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

    for(int j = 0;j < m;j++){
        cin >> t[j];
    }

    int ans = 0;
    SegmentTree<int> seg(m, 0, marge);

    for(int i = n-1;i >= 0;i--){
        for(int j = 0;j < m;j++){
            if(s[i] == t[j]){
                int tmp = 1 + seg.get(j+1, m);
                seg.add(j, tmp);
                ans = (ans + tmp) % MOD;
            }
        }
    }

    cout << (ans+1) % MOD << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
		sum+=a[i];
		flag+=a[i];
		cnt += a[i];
	}

	sort(a,a+n);
	for(int i=0; i<n; i++){
		if(sum%10!=0){
			ans = sum;
			break;
		}
		else sum -=a[i];
	}
	reverse(a,a+n);
	for(int i=0; i<n ; i++){
		if(flag%10!=0){
			mx = flag;
			break;
		}
		else flag -= a[i];
	}
	for(int i=0; i<n; i++){
		if((cnt-a[i])%10!=0){
			mn = max(mn,cnt-a[i]);
		}
	}
	ll ko = max(mn,ans);
	cout<<max(ko,mx)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;


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

    int ans=0;
    for(auto itr=mp.begin(); itr!=mp.end(); ++itr) {
        if(itr->second>0 && itr->second%2==1)
            ++ans;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define MAX 10000007
#define PI acos(-1)
#define eps 1e-10

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);

    int ara[5];
    for(int i=1;i<=3;i++)
        cin>>ara[i];

    int cnt5=0,cnt7=0;

    for(int i=1;i<=3;i++)
    {
        if(ara[i]>=7)
            cnt7++;
        else if(ara[i]>=5)
            cnt5++;
    }

    if(cnt5==2 && cnt7==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;





    return 0;
}


Measured memory_bytes: 256