akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>          // printf(), fgets()
#include <string.h>         // memset(), memcpy()

int
count1(int c[10])
{
	int i;

	int k = 0;
	for (i = 1; i <= 9 - 2;)
	{
		if (c[i] >= 1 && c[i + 1] >= 1 && c[i + 2] >= 1)
		{
			c[i]--; c[i + 1]--; c[i + 2]--;
			k++;
		}

		else
			i++;
	}

	return k;
}

int
count2(int c[10])
{
	int i;

	int k = 0;
	for (i = 1; i <= 9; ++i)
	{
		if (c[i] >= 3)
		{
			c[i] -= 3;
			k++;
		}
	}

	return k;
}

int
set(int *c)
{
	return count1(c) + count2(c);
}

int
set2(int *c)
{
	return count2(c) + count1(c);
}

int
main(int argc, char **argv)
{
	int d[13];
	int i, j;

	while (scanf("%1d", &d[0]) == 1)
	{
		int a[9];
		int c[10], c1[10], c2[10];

		for (i = 1; i < 13; ++i)
			scanf("%1d", &d[i]);

		memset(c, 0, sizeof(c));
		for (i = 0; i < 13; ++i)
			c[d[i]]++;

		int n = 0;
		for (i = 1; i <= 9; ++i)
		{
			if (c[i] + 1 > 4)
				continue;

			c[i]++;
			for (j = 1; j <= 9; ++j)
			{
				if (c[j] < 2)
					continue;

				memcpy(c1, c, sizeof(c1));
				c1[j] -= 2;
				memcpy(c2, c1, sizeof(c2));
				if (set(c1) == 4 || set2(c2) == 4)
				{
					a[n++] = i;
					break;
				}
			}

			c[i]--;
		}

		if (n == 0)
			printf("0\n");

		else
		{
			for (i = 0; i < n; ++i)
				printf("%d%c", a[i], i != n - 1 ? ' ' : '\n');
		}
	}

	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll P, Q, R;
  cin >> P >> Q >> R;

  cout << min({P + Q, Q + R, R + P}) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
    static void Main (string[] args) {
        // 整数の入力
        int N = int.Parse (Console.ReadLine ());
        // var s = Console.ReadLine ();
        // int[] numbers = new int[N];
        float ans = 0;
        string[] input = Console.ReadLine ().Split (' ');
        int[] numbers = input
            .Select (int.Parse)
            .ToArray ();

        for (int i = 0; i < numbers.Length; i++) {
            int j = i;
            int num = 0;
            while (true) {
                if (j == numbers.Length - 1) {
                    break;
                }
                if (numbers[j] >= numbers[j + 1]) {
                    num += 1;
                    i += 1;
                    if (num > ans) {
                        ans = num;
                    }
                    j += 1;
                } else {
                    break;
                }
            }
        }
        Console.WriteLine (ans);
    }
}

Measured memory_bytes: 30300
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        String str = s.replace("LR", "L,R");
        String[] array = str.split(",");
        Deque<Integer> countR = new ArrayDeque<>();
        Deque<Integer> countL = new ArrayDeque<>();
        for (int i = 0; i < array.length; i++) {
            int count = array[i].length();
            if (count % 2 == 0) {
                int half = count / 2;
                countR.add(half);
                countL.add(half);
            } else {
                int r = array[i].replace("L", "").length();
                // int l = array[i].replace("R", "").length();
                if (r % 2 == 1) {
                    countL.add(count / 2);
                    countR.add((int) Math.ceil(count / 2.0));
                } else {
                    countR.add(count / 2);
                    countL.add((int) Math.ceil(count / 2.0));
                }
            }
        }
        int[] countArray = new int[s.length()];
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'R' && s.charAt(i + 1) == 'L') {
                countArray[i] = countR.poll();
                countArray[i + 1] = countL.poll();
                i++;
            }
        }

        String[] strArray = new String[s.length()];
        for (int i = 0; i < strArray.length; i++) {
            strArray[i] = Integer.toString(countArray[i]);
        }
        String result = String.join(" ", strArray);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 46012
#include<stdio.h>
#include<stdlib.h>

static const int X = 101;

int s(int a, int b);
int main(){
  int i, j, y, z;
  int n, p[X], m[X][X];
  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ){
    scanf("%d %d", &p[i-1], &p[i]);
  }

  for ( i = 1; i <= n; i++ ) m[i][i] = 0;
  for ( z = 2; z <= n; z++ ){
    for ( i = 0; i <= n-z+1; i++ ){
      j = i+z-1;
      m[i][j] = (1<<21);
      for ( y = i; y <= j-1; y++ ){
	m[i][j] = s(m[i][j], m[i][y] + m[y+1][j] + p[i-1]*p[y]*p[j]);
      }
    }
  }
  printf("%d\n", m[1][n]);
  
  return 0;
}

int s(int a, int b){
  if(a<b){return a;
  }else{return b;
  }
}




Measured memory_bytes: 2140
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;

string s;
long long k;

int main()
{
   cin>>s>>k;
   if(k==1)
   {
        cout<<s[0]<<endl;
        return 0;
   }
   for(int i=0;i<s.size();i++)
   {
       if(s[i]!='1')
       {
           cout<<s[i]<<endl;
           return 0;
       }
       else
       {
           if(i==k-1)
           {
               cout<<1<<endl;
               return 0;
           }
       }
   }
   cout<<1<<endl;
}

Measured memory_bytes: 256
/**
 * A - 9x9
 * https://atcoder.jp/contests/abc144/tasks/abc144_a
 **/

#include<iostream>

using namespace std;

int main() {
    int A, B;
    int ans;
    cin >> A >> B;
    if((A>=1)&&(A<=9)&&(B>=1)&&(B<=9)) {
        ans = A * B;
    } else {
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
    cin>>n;
    cout<<n*(n+1)/2;
    return 0;
}       A
*/
#include <bits/stdc++.h>
using namespace std;
int l,i,j,k;
char sir[110],x[110];
int main()
{
    cin>>sir;
    l=strlen(sir);
    for(i=0;i<l;i++)
    {
        if(sir[i]=='1')
            x[k++]='1';
        else if(sir[i]=='0')
            x[k++]='0';
        else
        {
            if(k==0)
                continue;
            x[k-1]=0;
            k--;
        }
    }
    cout<<x;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C,K;
	cin>>A>>B>>C>>K;
	if(K<=A)
	cout<<K*1;
	if(K>A and K<=A+B)
	cout<<A*1+(K-A)*0;
	if(K>A+B and K<=A+B+C)
	cout<<A*1+B*0-(K-A-B)*1;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
	int n;
  	int i;
  	long a[100];
  	long max,min,tmp;
  
  	scanf("%d",&n);
  
  	max = 0; min = 10000000000;
  	for(i=0;i<n;i++){
      scanf("%ld",&a[i]);
      if(max <= a[i]){
		max = a[i];
      }
      if(min >= a[i]){
        min = a[i];
      }
    }
  
  	printf("%ld\n",max - min);
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
using namespace std;
int mod(int n, int div) {
  return (n - static_cast<int>(n/div)*div);
}
int main() {
  int num;
  int twos = 0;
  cin >> num;
  while (num > 0) {
    int digit = mod(num, 10);
    if (digit == 2) {
      twos++;
    }
    num = static_cast<int>(num / 10);
  }
  printf("%d\n", twos);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  double ans=ceil(n/1.08);
  if(n==int(ans*1.08))cout<<ans;
  else cout<<":(";
  return 0;
}

Measured memory_bytes: 256
import math
#import numpy as np
import itertools
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    way = [[] for i in range(n+1)]
    ans = 0
    for i in range(m):
        a,b = map(int,ipt().split())
        way[a].append(b)
        way[b].append(a)
    for i in itertools.permutations(list(range(2,n+1))):
        p = 1
        f = True
        for j in i:
            if not j in way[p]:
                f = False
                break
            else:
                p = j
        if f:
            ans += 1
    print(ans)

    return None

if __name__ == '__main__':
    main()


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

struct DICE {
  // 上/正面/裏/右/左

  vector<int> num;
  DICE(vector<int> num = {}) : num(num) {};

  int roll_North() {
    swap(num[0], num[3]);
    swap(num[0], num[2]);
    swap(num[0], num[1]);
    return num[0];
  }

  int roll_South() {
    swap(num[0], num[1]);
    swap(num[0], num[2]);
    swap(num[0], num[3]);
    return num[0];
  }

  int roll_West() {
    swap(num[0], num[5]);
    swap(num[0], num[2]);
    swap(num[0], num[4]);
    return num[0];
  }

  int roll_East() {
    swap(num[0], num[4]);
    swap(num[0], num[2]);
    swap(num[0], num[5]);
    return num[0];
  }

  int roll_Right() {
    swap(num[1], num[5]);
    swap(num[1], num[3]);
    swap(num[1], num[4]);
    return num[0];
  }

  int roll_Left() {
    swap(num[1], num[4]);
    swap(num[1], num[3]);
    swap(num[1], num[5]);
    return num[0];
  }
};

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

  int n;
  while (cin >> n && n) {
    DICE d({1, 2, 6, 5, 3, 4});
    int ans = 1;

    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;

      if (s[0] == 'N') ans += d.roll_North();
      else if (s[0] == 'E') ans += d.roll_East();
      else if (s[0] == 'W') ans += d.roll_West();
      else if (s[0] == 'S') ans += d.roll_South();
      else if (s[0] == 'R') ans += d.roll_Right();
      else if (s[0] == 'L') ans += d.roll_Left();
    }

    cout << ans << '\n';
  }

  return (0);
}



Measured memory_bytes: 2992
n, m = map(int, input().split())
sc = []
for _ in range(m):
    s_, c_ = map(int, input().split())
    sc.append([s_-1, c_])
ans = [-1 for _ in range(n)]
for s, c in sc:
    if s == 0 and c == 0:
        if n != 1:
            print(-1)
            exit()
    if ans[s] is -1: ans[s] = c
    elif ans[s] is not None and ans[s] != c:
        print(-1)
        exit()
for i in range(n):
    if ans[i] == -1:
        if i == 0:
            if n == 1: ans[i] = 0
            else: ans[i] = 1
        else:
            ans[i] = 0
print("".join(map(str, ans)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        "\n"
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define um           unordered_map<ll,ll>
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
#define int ll 
using namespace std;
int32_t main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

int n;
cin>>n;
string s;
cin>>s;
if(s.length()>n)
{
s=s.substr(0,n)+"...";	
}
cout<<s;
return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<set>
#define inf 0x3f3f3f3f
#define lowbit(x) (x&-x)
typedef long long ll;

const int maxn=2e5+5;
const int mod=1e9+7;

using namespace std;
int cnt[2020];
char s[maxn];
int sum[maxn],temp,now,x10=1;
ll ans;

int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    cnt[0]=1;
    for(int i=len;i>=1;i--)
    {
        temp=s[i]-'0';
        now=(temp*x10+now)%2019;
        x10=(x10*10)%2019;
        sum[i]=now;
        ans+=cnt[now];
        cnt[now]++;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 4192
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ans = min(B, D) - max(A, C);
	cout << max(ans, 0ll);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,a,b,x[200000];
int main(){
	cin >> n >> a >> b;

	REP(i,n) {
		cin >> x[i];
	}

	ll ans = 0;
	FOR(i,1,n) {
		ans += min((x[i] - x[i - 1]) * a,b);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
n = gets.chomp.split("")
if n[-1] == "2" || n[-1] == "4" || n[-1] == "5" || n[-1] == "7" || n[-1] == "9"
  puts "hon"
elsif n[-1] == "0" || n[-1] == "1" || n[-1] == "6" || n[-1] == "8" 
  puts "pon"
elsif n[-1] == "3"
  puts "bon"
end


Measured memory_bytes: 14264
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        string s;
        cin >> s;
        int sum=0;
        for(int i=0; i<s.size(); i++)
        {
            sum=sum+s[i]-'0';
        }
        if(sum%9==0)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
        return 0;
    }

Measured memory_bytes: 3728
N,A=map(int,input().split())
xlist=list(map(int,input().split()))

dp=[[[0]*(sum(xlist)+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0]=1
for i in range(1,N+1):
  dp[i][0][0]=1
  for j in range(1,N+1):
    for k in range(1,sum(xlist)+1):
      dp[i][j][k]=dp[i-1][j][k]
      if k-xlist[i-1]>=0:
        dp[i][j][k]+=dp[i-1][j-1][k-xlist[i-1]]
#print(dp)

answer=0
for i in range(1,N+1):
  if i*A<=sum(xlist):
    answer+=dp[N][i][i*A]
  
print(answer)

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

int main() {
  // input
  int N, T;
  cin >> N >> T;
  vector<int> c(N);
  vector<int> t(N);
  for (int i = 0; i < N; i++) {
    cin >> c.at(i) >> t.at(i);
  }
  
  // in T
  bool flag = false;
  for (int i = 0; i < N; i++) {
    if (t.at(i) > T) {
      c.at(i) = 9999;
    } else {
      flag = true;
    }
  }
  
  // sort c
  sort(c.begin(), c.end());
  
  // output
  if (flag) {
    cout << c.at(0) << endl;
  } else {
    cout << "TLE" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
bool ok1,ok2;
int main()
{
	cin>>s;
	ok1=(s[0]==s[s.size()-1]);
	ok2=s.size()%2;
	if(ok1!=ok2)
	{
		cout<<"First"<<endl;
	}
	else
	{
		cout<<"Second"<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20180129education
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split('/');

            string S = input[0];
            string b = input[1];
            string c = input[2];

            S = "2018";

            Console.WriteLine("{0}/{1}/{2}",S, b, c);

        }
    }
}


Measured memory_bytes: 11092
//Maximal Value

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    int n;cin>>n;
    vector<int>b(n-1),a(n);
    rep(i,0,n-1)cin>>b[i];
    a[0]=b[0];
    rep(i,1,n-1){
        a[i]=min(b[i],b[i-1]);
    }
    ll ans = accumulate(range(a),0)+b[n-2];
    cout<< ans<< endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = 0;
		final int N = sc.nextInt();
		final String S = sc.next();
		int max = x;
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) == 'I') x++;
			else if(S.charAt(i) == 'D') x--;
			if(max < x) max = x;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x;
  cin>>x;
  int m=x.length(),j=1,k=0,b=1;
  while(j<m){
    while(j<m&&x.at(j)==x.at(k)) j++;
    if(j==m) break;
    b++;
    k=j;
    j++;
  }
  cout<<b-1<<endl;
}

Measured memory_bytes: 3740
#include <stdio.h>

int main(){
  int i0[] = {500,100,50,10,5,1};
  int i1 = 1,i2 = 0;
  int i4[5] = {0};

  for(int j = 0; j < 6; j++){
    i2 = 0;
    scanf("%d",&i1);
    
    if(i1 == 0){   
      for(int n : i4) if(n != 0) printf("%d\n",n);
      return 0;
    }
    
    i1 = 1000 - i1;

    for(int n = 0; n < 6; n++){
      while(i1 >= i0[n]){
        i1 -= i0[n];
        i2++;
      }
    }
    i4[j] = i2;    
  }
  return -1;
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,k;
    int cnt=0;
    vector<int> a(n);
    cin >> n >> k;
    rep(i,n) cin >> a[i];
    n--;
    k--;
    while(n>0){
        n = n-k;
        cnt++;
    }
    cout << cnt << endl;

}

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

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  long long ans = 0;
  if(a+b > 2*c){
    ans += 2*c*min(x,y);
  }
  else{
    ans += (a+b)*min(x,y);
  }
  if(x > y){
    if(a > 2*c) ans += 2*c*(max(x,y)-min(x,y));
    else ans += a*(max(x,y)-min(x,y));
  }
  else{
    if(b > 2*c) ans += 2*c*(max(x,y)-min(x,y));
    else ans += b*(max(x,y)-min(x,y));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1 or m+f<30:
        print('F')
    elif m+f>=80:
        print('A')
    elif m+f>=65 and m+f<80:
        print('B')
    elif m+f>=50 and m+f<65:
        print('C')
    elif m+f>=30 and m+f<50:
        if r>=50:
            print('C')
        else:
            print('D')


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 200100;
int par[MAX_N]; // 親
int rank_[MAX_N]; // 木の深さ

// n要素で初期化
void UFinit(){
    for(int i=0;i<MAX_N;i++){
        par[i] = i;
        rank_[i] = 0;
    }
}

// 木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank_[x] < rank_[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rank_[x] == rank_[y]) rank_[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}

int cnt[MAX_N];
vector<int> G[MAX_N];
vector<int> G2[MAX_N];

int main() {
    UFinit();
    int n, m, k;
    cin >> n >> m >> k;
    int a[m], b[m];
    rep(i,m){
        cin >> a[i] >> b[i];
        unite(a[i], b[i]);
        G2[a[i]].push_back(b[i]);
        G2[b[i]].push_back(a[i]);
    }
    int c[k], d[k];
    rep(i,k){
        cin >> c[i] >> d[i];
        G[c[i]].push_back(d[i]);
        G[d[i]].push_back(c[i]);
    }

    srep(i,1,n+1){
        cnt[find(i)]++;
    }

    srep(i,1,n+1){
        int ans = cnt[find(i)] - G2[i].size() - 1;
        rep(j,G[i].size()){
            if(same(i, G[i][j])){
                ans--;
            }
        } 
        cout << ans << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 20472
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  ll ans = 0;
  REP(i, 0, N) {
    cin >> A[i];
    while (A[i] % 2 == 0) {
      A[i] /= 2;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
 
int main(void){
  int n;
  int a;
  int b;
  int c;
  int d;
  scanf("%d", &n);
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  char road[n];
  scanf("%s", road);
  int i;
  if(c<d){
    for(i=a;i<d;i++){
      if(road[i-1]=='#'&&road[i]=='#'){
        printf("No");
        return 0;
      }
    }
    printf("Yes");
    return 0;
  }else{
    for(i=b-1;i<d;i++){
      //printf("%d", i);
      if(road[i-1]=='.'&&road[i]=='.'&&road[i+1]=='.'){
        printf("Yes");
        return 0;
      }
    }
    printf("No");
    return 0;
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int n; cin >> n;
	cout << 48 - n;


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort()
def arraycount(arr):
  arr_target = [[]]
  cnt = 1
  for i in range(1,len(arr)):
     if arr[i] == arr[i-1]:
         cnt += 1
     else:
         arr_target.append([arr[i-1],cnt])
         cnt = 1
  arr_target.append([arr[len(arr)-1],cnt])
  del arr_target[0]
  return arr_target
B = arraycount(A)
n = len(B)
for i in range(n):
    if B[i][1] >=3:
        if B[i][1] % 2 == 0:
            B[i][1] = 2
        else:
            B[i][1] = 1
    else:
        continue
cnt,ans =0,0
for i in range(n):
    ans += B[i][1]
    if B[i][1] == 2:
        cnt +=1
ans = ans - 2*(-(-cnt//2))
print(ans)


Measured memory_bytes: 64364
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

main(){
    int n,A[1000];
    
    while(1){
        cin>>n;
        if (n==0) break;
        
        for (int i=0;i<n;i++) cin>>A[i];
        int sum=0;
        for (int i=0;i<n;i++) sum+=A[i];
        double avg=1.0*sum/n;
        double dist=0.0;
        for (int i=0;i<n;i++){
            dist += (avg-A[i])*(avg-A[i]);
        }
        
        printf("%lf\n",sqrt(dist/n));
    }
}


Measured memory_bytes: 3220
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    string m[100][100];
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            cin >> m[i][j];
        }
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if(m[i][j] == "snuke") {
                char c = 'A' + j - 1;
                cout << c << i << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vl> vv;
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define endl '\n'
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }

int main(){
    
    fast();
   // #ifndef ONLINE_JUDGE
	//freopen("F:\\Codes\\input.txt", "r", stdin);
	//freopen("F:\\Codes\\output.txt", "w", stdout);
	//#endif
	
	ll n,w,a,b,i,j;
	cin>>n>>w;

	vl dp(w+1),dp1(w+1);
	for(i=0;i<n;i++){
		cin>>a>>b;

		for(j=1;j<=w;j++){
			if(j<a){}
			else{
				//cout<<dp[j]<<" "<<dp[j-a]+b<<endl;
				dp1[j]=max(dp[j],dp[j-a]+b);
			}
		}
		for(j=1;j<=w;j++){dp[j]=dp1[j];}
	}
	cout<<dp[w]<<endl;

    
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// ll dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n);
	map<ll, ll> mp;
	ll M = 0, m = n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		mp[a[i]]++;
		m = min(m, a[i]);
		M = max(M, a[i]);
	}
	if (M == m) {
		dump(M == n - 1 || m * 2 <= n ? "Yes" : "No");
	} else if (m + 1 == M) {
		dump(mp[m] < M && mp[M] >= 2 * (M - mp[m]) ? "Yes" : "No");
	} else {
		dump("No");
	}
}

Measured memory_bytes: 7296
#include<cmath>
#include<cstdio>
using namespace std;
int main() {
	int Q;
	scanf("%d",&Q);
	for(int i=1; i<=Q; i++) {
		long long a,b;
		scanf("%lld %lld",&a,&b);
		long long pr=a*b;
		long long t=sqrt(pr),ans;
		if(t*(t+1)<pr)
			ans=t*2-1;
		else if(t*t==pr) {
			ans=(t-1)*2;
			if(a!=b) ans--;
		} else
			ans=(t-1)*2;
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 128
n = int(input())

a_list = list(map(int, input().split()))
a_list.sort()
a_counter = {}
MOD = 10**9 + 7
for a in a_list:
    if a in a_counter.keys():
        a_counter[a] += 1
    else:
        a_counter[a] = 1

data_error = False

if n % 2 == 0:
    for i in range(1, n, 2):
        if i not in a_counter.keys():
            data_error = True
            break
        if a_counter[i] != 2:
            data_error = True
            break
else:
    for i in range(0, n, 2):
        if i not in a_counter.keys():
            data_error = True
        if a_counter[i] != 2:
            if i == 0 and a_counter[0] == 1:
                continue
            data_error = True
            break

if data_error:
    print(0)
else:
    ans = 2 ** (int(n / 2))
    ans %= MOD
    print(ans)


Measured memory_bytes: 20448
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111111;
int sum[N][26], f[N][26];
string s;
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    n = sz(s);
    rep(i, 1, n) {
        rep(c, 0, 25) {
            sum[i][c] = sum[i - 1][c] + (s[i - 1] == 'a' + c);
            f[i][c] = 2 * sum[i][c] - i;
        }
    }
    rep(c, 0, 25) {
        pair<int, int> maxi(-1e9, -1e9), prev(-1e9, -1e9);
        rrep(i, 0, n) {
            if(f[i][c] < maxi.fi) {
                cout << i + 1 << " " << maxi.se << endl;
                return 0;
            }
            if(prev.fi > maxi.fi) {
                maxi = prev;
            }
            prev = {f[i][c], i};
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}


Measured memory_bytes: 22992
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
typedef long long ll;
using namespace std;
ll a[200010];
#define MOD (1000000007)
int main()
{
	int N;
	cin>>N;
	ll sumA = 0;
	for( int i=0; i<N; i++ )
	{
		cin>>a[i];
		sumA = (sumA+a[i])%MOD;
	}
	ll ot = 0;
	for( int i=0; i<N; i++ )
	{
		ll tmp = (sumA + MOD-a[i])%MOD; 
		ot = ot + (tmp*a[i])%MOD;
		ot %= MOD;
	}
	if( ot%2 == 1 )
		cout << (ot+MOD)/2;
	else
		cout << (ot)/2;
	return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int ans = 0;
    for (int x = 1; x * x <= i; x++) {
      for (int y = 1; x * x + y * y <= i; y++) {
        // for (int z = 1; x * x + y * y + z * z <= i; z++) {
        //     if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
        //       ans++;
        //     }
        //   }
        int D = (x + y) * (x + y) - 4 * (-i + x * x + y * y + x * y);
        if (D == 0) {
          double z = -(x + y) / 2.0;
          ans += floor(z) == ceil(z) && z > 0 ? 1 : 0;
        } else if (D > 0) {
          double z = (-(x + y) + sqrt(D)) / 2.0;
          ans += floor(z) == ceil(z) && z > 0 ? 1 : 0;
          z = (-(x + y) - sqrt(D)) / 2.0;
          ans += floor(z) == ceil(z) && z > 0 ? 1 : 0;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
import math

N, D = map(int, input().split())
xlist = []


for i in range(N):
    xlist.append(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        len = 0
        for k in range(D):
            len += pow(xlist[i][k]-xlist[j][k], 2)

        len = math.sqrt(len)

        # 整数の判定
        b = int(len)
        if len == b:
            ans += 1


print(ans)


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

char array[101][101];
int H,W;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int dfs(int Y, int X,char key){
  int nx,ny;
  array[Y][X]='.';

  for(int i=0;i<4;i++){
    nx=X+dx[i];
    ny=Y+dy[i];
    if(nx>=0 && nx<=W && ny>=0 && ny<=H && array[ny][nx]==key) dfs(ny,nx,key);
  }

}


int main(){


  while(1){
    cin>>H>>W;
    int cnt=0;
    if(H==0 && W==0) break;
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
	cin>>array[i][j];
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
	if(array[i][j]=='#' || array[i][j]=='*' || array[i][j]=='@'){
	  dfs(i,j,array[i][j]);
	  cnt++;
	}
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1636
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  int h, w, k;
  cin >> h;
  cin >> w;
  cin >> k;

  string s[h][w];
  rep(i,h) {
    string ss;
    cin >> ss;
    rep(j,w) {
      s[i][j] = ss[j];
    }
  }

  int ans = 0;
  for (int i = 0; i < (1 << h); i++) {
    for (int j = 0; j < (1 << w); j++) {
      int sum = 0;

      for (int x = 0; x < h; x++) {
        for (int y = 0; y < w; y++) {
          if (i & (1 << x) && j & (1 << y)) {
            if(s[x][y] == "#") sum++;
            //cout << "checking..." << i << " " << j << " " << x << " " << y << " " << s[x][y] << endl;
          }
        }
      }
      if(sum == k) ans++;
    }
  }

  //output
  cout << ans << endl;
}


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

int main(void){

  int N;
  cin >> N;

  vector<int> Y(N);
  for (int i = 0; i < N; i++) cin >> Y.at(i);

  int Ymin = Y.at(0);
  int K = Y.at(1) - Y.at(0);
  for (int i = 1; i < N; i++)
  {
    if ((Y.at(i) - Ymin) > K)
    {
      K = (Y.at(i) - Ymin);
    }
    if (Y.at(i) < Ymin)
    {
      Ymin = Y.at(i);
    }
    
  }
  
  cout << K << endl;
  


  return 0;

}



Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  
  for(int i=1;i<s.size();i++){
  if(s[i]==s[i-1]){
  cout<<"Bad"<<endl;
  return 0;
  }
  }
     cout<<"Good"<<endl;
     

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    if(N >= 1000) cout << "ABD";
    else cout << "ABC";
    cout << endl;
}

Measured memory_bytes: 256
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll a, b, k;
    cin >> a >> b >> k;
    if (k >= a + b)
        cout << "0 0";
    else if (k > a)
        cout << "0 " << a + b - k;
    else
        cout << a - k << " " << b;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] l = new int[m];
		int[] r = new int[m];
		for (int i = 0; i < m; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		sc.close();

		int left = 1;
		int right = n;
		for (int i = 0; i < m; i++) {
			left = Math.max(left, l[i]);
			right = Math.min(right, r[i]);
		}
		if (left > right) {
			System.out.println(0);
		} else {
			System.out.println(right - left + 1);
		}
	}
}


Measured memory_bytes: 77800
#include <iostream>
#include <vector>

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

using namespace std;

int A, B, C;

int nextRnd(int x) {
  return (A * x + B) % C;
}

int main() {
  while (true) {
    int N, X;
    cin >> N >> A >> B >> C >> X;
    if (N + A + B + C + X == 0) break;
    vector<int> Ys(N);
    REP(i, N) {
      cin >> Ys[i];
    }
    
    bool solved = false;
    int t = 0;
    int nrnd = X;
    for (int i = 0; i <= 10000; i++) {
      if (nrnd == Ys[t]) {
        t++;
      }
      if (t == N) {
        cout << i << endl;
        solved = true;
        break;
      }
      nrnd = nextRnd(nrnd);
    }
    if (!solved) cout << -1 << endl;
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    string ans = "No";
    while(n > 0){
        if(n%10 == 7) ans = "Yes";
        n /= 10;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

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

    int x; cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  
  int H, W, K, i, j, cnt=0;
  cin >> H >> W >> K;
  vector<vector<char>> c(H, vector<char>(W));
  
  for(i=0; i<H; i++){
    for(j=0; j<W; j++){
      cin>>c[i][j];
    }
  }
  
  for(int bits=0; bits<(1<<(W+H)); bits++){
    vector<int> km(H+W, 0);
    for(i=0; i<W+H; i++){
      if(bits & (1<<i)) km[i]=1;
    }
    
    int cnt_=0;
    for(i=0; i<H; i++){
      for(j=0; j<W; j++){
		if(c[i][j]=='#' && km[i]==0 && km[j+H]==0)cnt_++;
      }
    }
    cnt+=(K==cnt_);
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int	main()
{
	int a,b,c,d,cnt1,cnt2;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	cnt1=0;
	cnt2=0;
	while(1){
		if(c<=0){	break;}	
		else {
			c=c-b;
			cnt1++;
		}
	}
	while(1){
		if(a<=0){	break;}	
		else {
			a=a-d;
			cnt2++;
		}
	}
	if(cnt2>=cnt1)	printf("Yes\n");
	else	printf("No\n");
	return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	

	int mod = 1000000007;

	void solve(){

		ini(n);
		ini(n1);
		set<int> morty;
		FOR(i,0,n1){
			ini(x);
			morty.insert(x);
		}
		if(!morty.count(n))return out(n);
		int tmp = 0;
		int tmp1 = 0;
		int tmpn = n;
		while(1){
			tmpn--;
			if(!morty.count(tmpn)){
				tmp = tmpn;
				break;
			}
		}
		tmpn = n;
		while(1){
			tmpn++;
			if(!morty.count(tmpn)){
				tmp1 = tmpn;
				break;
			}
		}
			if(n-tmp<=tmp1-n){return out(tmp);}
			else{
				return out(tmp1);
			}


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3660
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    auto s = readln.split;
    writeln(s[0][$-1] == s[1][0] && s[1][$-1] == s[2][0] ? "YES" : "NO");
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double xd = x1 - x2;
    double yd = y1 - y2;
    printf("%lf\n", sqrt(xd * xd + yd * yd));
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64



llong GCD(llong a, llong b){
    llong c;
    if(a<b) swap(a,b);
    while(1){
        if(a%b==0) return b;
        c=b;
        b= a%b;
        a=c;
    }
}

int main(){

    int n;
    cin >> n;
    llong ans=1,tmp;
    cin >> ans;
    REP(i,n-1){
        cin >> tmp;
        tmp=tmp / GCD(ans,tmp);
        ans= ans *tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=2e5+100;
const ll mod=998244353;

ll sum[sz], ara[sz];


int main()
{
    Go_
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;

    cin>>n>>k;

    PII inp[k];
    for(i=0;i<k;i++) cin>>inp[i].first>>inp[i].second;

    for(i=1;i<=n;i++){
        ll p=0;
        if(i==1) p=1;
        for(j=0;j<k;j++){
            ll l=max(0ll,i-inp[j].second);
            ll r=max(0ll,i-inp[j].first);
            ll x;
            
            if(l==0) x=(sum[r] %mod);
            else x=(((sum[r]-sum[l-1])%mod)+mod)%mod;

            p=(p + x)%mod;
        }
        ara[i]=p;
        sum[i]=(sum[i-1] + ara[i]) %mod;
    }

    cout<<ara[n]<<'\n';


     

}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(false);\
				cin.tie(0);\
				cout.tie(0)
#define REP(_i, _a) for(int _i = 0; _i < (int)_a; ++_i)
#define FOR(_i, _a, _b) for(int _i = (int)_a; _i <= (int)_b; ++_i)
#define FORD(_i, _a, _b) for(int _i = (int)_a; _i >= (int)_b; --_i)
#define RESET(_a, _value) fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define ALL(_a) _a.begin(), _a.end()
#define SIZE(_a) _a.size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define newline '\n';

// DEBUG UTIL
#define DEBUG(args...) { cerr << "> "; \
						 string _s = #args; \
						 replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); istream_iterator<string> _it(_ss); \
						 err(_it, args); }

void err(istream_iterator<string> it) { cerr << endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << ": " << a << " ";
	err(++it, args...);
}

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int INF = 2e9;

const int MAX_PRIME = 5 * 50000;

bool is_prime[MAX_PRIME];

vi primes;

void test() {

}

void sieve() {
	memset(is_prime, true, sizeof(is_prime));
	is_prime[1] = false;
	FOR(i, 2, MAX_PRIME) {
		if (!is_prime[i]) continue;
		primes.pb(i);
		for (int j = i + i; j < MAX_PRIME; j += i) {
			is_prime[j] = false;
		}
	}
}

int N;

void read() {
	sieve();
	cin >> N;
}

void solve() {
	int i = 0;
	deque<int> solution;
	while (i < (int)primes.size() && (int)solution.size() < N) {
		
		if (primes[i] % 5 == 1) {
			solution.pb(primes[i]);
		}
		++i;
		
	}

	for (int i = 0; i < (int)solution.size(); ++i) {
		if (i > 0) cout << " ";
		cout << solution[i];
	}
	cout << endl;
}

int main() {
	srand(time(NULL));
	FAST_IO;
	
	test();

	int TC = 1;
	// cin >> TC;
	FOR(tc, 1, TC) {
		read();
		solve();
	}

	return 0;
}


Measured memory_bytes: 768