akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

typedef pair<ll, pair<string, int>> S;

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

	int n;
	cin >> n;
	vector<string> s(n); vector<ll> c(n);
	vector<string> revs(n);
	rep(i, n) cin >> s[i] >> c[i];
	map<pair<string, ll>, ll> mp;
	priority_queue<S, vector<S>, greater<S>> que;
	que.push({ 0,{"",0} });
	que.push({ 0,{"",1} });
	int f = 0;
	while (!que.empty()) {
		S p = que.top(); que.pop();
		ll cost = p.first; string now = p.second.first; int mode = p.second.second;
		int len = now.size();
		if (cost != 0) {
			bool ok = true;
			rep(i, len) if (now[i] != now[len - 1 - i]) ok = false;
			if (ok) {
				cout << cost << '\n';
				return 0;
			}
		}
		if (cost > mp[{now, mode}]) continue;
		rep(i, n) {
			int sz = s[i].size();
			string tmp = s[i];
			if (mode == 0) reverse(all(tmp));
			if (now.size() >= sz && now.substr(0, sz) == tmp) {
				string rem = now.substr(sz);
				if (mp[{ rem, mode }] == 0 || mp[{rem, mode}] > mp[{now, mode}] + c[i]) {
					mp[{rem, mode}] = cost + c[i];
					que.push({ cost + c[i],{rem,mode} });
				}
			}
			if (tmp.substr(0, len) == now) {
				string rem = tmp.substr(len);
				if (mp[{ rem, mode ^ 1 }] == 0 || mp[{rem, mode ^ 1}] > mp[{now, mode}] + c[i]) {
					mp[{rem, mode ^ 1}] = cost + c[i];
					que.push({ cost + c[i],{rem,mode ^ 1} });
				}
			}
		}
	}
	cout << "-1\n";
}

Measured memory_bytes: 3748
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()

def main():
    dishes = [int(input()) for _ in range(5)]
    ans = float('inf')
    for dish in itertools.permutations(dishes, 5):
        time = 0
        for i in range(5):
            time += dish[i]
            if time%10 != 0 and i < 4:
                time += 10 - time%10
        ans = min(ans, time)
    print(ans)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long k;
    cin >>k;
    long long res=7;
    for(long long i=1;i<=k;i++){
        if(res%k==0){
            cout<<i;
            return 0;
        }
        res=(res*10+7)%k;
    }
    
    cout<<"-1";
    
}


Measured memory_bytes: 3588
n,y=map(int,input().split())
for i in range(y//5000+1):
    for j in range(y//10000+1):
        if n-i-j<0:
            break
        if 10000*j+5000*i+1000*(n-i-j)==y:
            print("{} {} {}".format(j,i,n-i-j))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 40684
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	long long a[10];
	for (int i=0;i<3;i++)
		cin>>a[i];
	for (int i=0;i<3;i++)
	{
		if (a[i]%2==0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	sort(a,a+3);
	long long ans=a[0]*a[1]; 
	cout<<ans<<endl;
	
	return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define ll long long int
using namespace std;


int main() {
	ll N,K;
	cin >> N >> K;
	ll sum = 0;
	for (ll a = 1; a <= N; ++a) {
		ll d = K - (a%K);
		if((d*2)%K==0){
			ll n;
			n = (N - d) / K + 1;
			sum += n*n;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
# from bisect import *
# from collections import *
# from heapq import *
# import itertools
import math
# INF = 10**9
# MOD = 10**9+7

a, b, x = map(int, input().split())
l, r = 0.0, 90.0
ep = 10**(-7)
for i in range(100):
    m = (l+r)/2
    t = math.radians(m)
    if a*math.sin(t) >= b*math.sin(math.pi/2-t):
        y = b*a*b*math.tan(math.pi/2-t)/2
    else:
        y = a*a*(b+b-a*math.tan(t))/2
    if abs(x-y) < ep:
        break
    if y < x:
        r = m
    else:
        l = m
print(m)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n;
    cin >> n;
    double ans = ((n + 1) / 2) / (db) n;
    printf("%.14lf\n", ans);
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

void solve() {
	int a, b; cin >> a >> b;
	if (a <= 0 && b >= 0) {
		cout << "Zero" << endl;
	}
	else if (a > 0) {
		cout << "Positive" << endl;
	}
	else {
		int c = b - a + 1;
		if (c % 2 == 1)cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
    string s;ll n,p;cin>>n;
    map<string,vector<pair<ll,ll>>> m;
    for(ll i=0;i<n;i++)
    {
    	cin>>s>>p;
    	m[s].pb(make_pair(p,i));
	}
	for(auto x:m)
	{
		vector<pair<ll,ll>> v =x.second;
		sort(v.rbegin(),v.rend());
		for(ll i=0;i<v.size();i++)
		   cout<<(v[i].second+1)<<endl;
	}
	
    
	
	
	
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
using Int = long long;
int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> M(N);
    for (int i = 0; i < N; i++) cin >> M[i];
    sort(M.begin(), M.end());
    int sum = accumulate(M.begin(), M.end(), 0);
    cout << M.size() + (X-sum)/M[0] << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
//const ll MOD = 1000000007;

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<int>> a(H, vector<int>(W, 0));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin>>a[i][j];
    }
  }
  int cnt = 0;
  vector< pair<int, int> > pairs1;
  vector< pair<int, int> > pairs2;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a[i][j] % 2 != 0) {
        if (j < W - 1) {
          pairs1.emplace_back(i,j), pairs2.emplace_back(i,j+1);
          a[i][j+1]++;
        } else if (i < H - 1) {
          pairs1.emplace_back(i,j), pairs2.emplace_back(i+1,j);
          a[i+1][j]++;
        }
      }
    }
  }
  cout<<pairs1.size()<<endl;
  for (int i = 0; i < pairs1.size(); i++) {
    cout<<pairs1[i].first+1<<" "<<pairs1[i].second+1<<" "<<pairs2[i].first+1<<" "<<pairs2[i].second+1;
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 5228
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  sort(all(a));
  bool ok = true;
  if(n % 2 == 0){
    int cnt = -1;
    rep(i,n){
      if(i % 2 == 0) cnt += 2;
      if(a[i] != cnt) ok = false;
    }
  }else{
    int cnt = 0;
    for(int i = 1; i < n; i++){
      if(i % 2 == 1) cnt += 2;
      if(a[i] != cnt) ok = false;
    }
    if(a[0] != 0) ok = false;
  }
  if(!ok){
    cout << 0;
    return 0;
  }
  ll ans = 1;
  rep(i,n/2){
    ans *= 2;
    ans %= 1000000007;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,A[200];
double anss;
ll i, j, k, ans;
int main(){
    scanf("%lld", &N);
    anss = 0;
    fornum(i,0,N){
        scanf("%lld", &A[i]);
        anss += (double)1 / A[i];
    }
    printf("%.12lf", 1 / anss);
    return 0;
}

Measured memory_bytes: 256
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    S=input().strip()
    T=input().strip()
    cnt=0
    for i in range(len(S)):
        if S[i]==T[i]:
            cnt+=1
    print(cnt)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 65260
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
  int W;
  int N;
  int num[30];

  
  cin >> W;
  cin >> N;
  for (int i = 0; i < W; i++) {
    num[i] = i+1;
  }
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a;
    cin.ignore();
    cin >> b;
    swap(num[a-1], num[b-1]);
  }
  for (int i = 0; i < W; i++) {
    cout << num[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

int main() {
    int t[5];
    for (int i = 0; i < 5; ++i) {
        scanf("%d", &t[i]);
    }

    int min_time = INT_MAX;
    vector<int> idx = { 0, 1, 2, 3, 4 };
    do {
        int cur = 0;
        for (int i = 0; i < 5; ++i) {
            int k = idx[i];
            if (cur % 10 != 0) {
                cur = (cur + 10) / 10 * 10;
            }
            cur += t[idx[i]];
        }
        min_time = min(min_time, cur);
    } while (next_permutation(idx.begin(), idx.end()));
    printf("%d\n", min_time);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;

int a[N];

int main()
{
	LL a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int maxHeapify(int);
int XXX[500010];
int T,M,i,l,r,k=0;
 
int main(void){
  scanf("%d",&T);
  for(i=1;i<=T;i++){
    scanf("%d",&XXX[i]);
  }
  for(i=T/2;i>0;i--){
    maxHeapify(i);
  }
  for(i=1;i<=T;i++){
    printf(" %d",XXX[i]);
  }
  printf("\n");
  return 0;
}
 
int maxHeapify(i){
  l=2*i;
  r=2*i+1;
  if(l<=T && XXX[l]>XXX[i])M=l;
  else M=i;
  if(r<=T && XXX[r]>XXX[M])M=r;
  if(M!=i){
    k=XXX[i];
    XXX[i]=XXX[M];
    XXX[M]=k;
    return maxHeapify(M);
  }
  return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    cout << "ABC" << N << endl;
    return 0;
}

Measured memory_bytes: 256
//object D {
object Main {
  import InOut._
  def main(args: Array[String]): Unit = {

    val n = nextInt

    val divisorCount = Array.fill(n + 1)(2)
    divisorCount(1) = 1

    var i = 2
    while (i <= n) {
      var j = 2 * i// * i
      //if (divisorCount(j)) {
        while (j <= n) {
          //if (j == 16) println(if (i == j * j) 1 else 2)
          divisorCount(j) += 1//(if (i == j * j) 1 else 2)
          j += i
        }
//      if (n % i == 0) {
//        divisorCount(n / i) += 1
//      }
      //}
      i += 1
    }
//println(divisorCount.zipWithIndex.mkString(" "))
    var res = 0L
    i = 1
    while (i <= n) {
      res += i.toLong * divisorCount(i)
      i += 1
    }

    out.println(res)

    out.flush()
  }
 
  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}


Measured memory_bytes: 95440
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
  
    long long int n,k;
    cin>>n>>k;
    long long int a[n],i,j=0;
    for(i=0;i<n;++i)
        cin>>a[i];
        
    for(i=k;i<n;++i)
     {
         if(a[i]>a[j])
          {
              cout<<"Yes"<<endl;
          }
          
         else
          {
              cout<<"No"<<endl;
          }
          
          j++;
     }
    
      
   
   
     return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;cin>>S;
  if(S.length()==3)reverse(S.begin(),S.end());
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

n = int(raw_input())
x = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    seq = map(int,raw_input().split())
    tmp = seq[0]-1
    n2 = seq[1]
    if n2!=0:
        for e in seq[2:]:
            x[tmp][e-1]=1
        
for i in range(n):
    print " ".join(map(str,x[i]))

Measured memory_bytes: 4300
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1,b-1)
maxn = 0
for i in range(n):
    maxn = max(maxn, uf.size(i))
print(maxn)

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

int main() {
    int age;
    cin >> age;
    if( age == 1 ) {
        cout << "Hello World" << endl;
    }
    else {
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
#define BUF_SIZE 1024
#define ARRAY_SIZE 100
 
int main(){
 
    char buf[BUF_SIZE] = {0};
    int n = atoi(fgets(buf,BUF_SIZE,stdin));
 
    int array[ARRAY_SIZE] = {0};
 
    for(int i = 0; i < n; i++){
        cin >> array[i];
    }
 
    for(int k = 0;k < n; k++){
        if(k != n-1){
            printf("%d ",array[k]);
        }else{
            printf("%d\n",array[k]);
        }
    }
 
    int v = 0;
    int j = 0;
    for(int i = 1; i < n; i++){
        v = array[i];
        j = i-1;
        while(j >= 0 && array[j] > v){
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = v;
        for(int k = 0;k < n; k++){
            if(k != n-1){
                printf("%d ",array[k]);
            }else{
                printf("%d\n",array[k]);
            }
        }
    }
 
}


Measured memory_bytes: 3188
integer a,b,c,d,e,f,n_a,i,j,k,l,S,T
double precision youeki, yousitu,noudo,Li

read*, a,b,c,d,e,f
noudo=0
Li=0;n=int(f/(100*a))

do i=0, 5+n_a
  do j=0, 5+int((f-100*i*a)/(100*b))
    do k=0, 5+int((f-100*i*a-100*j*b-k*c)/d)
      do l=0, 5+int((f-100*i*a-100*j*b-k*c)/d)
        S=100*a*i+100*b*j+c*k+d*l
        T=c*k+d*l
        if(S==0)cycle
        Li=100.0*T/S
        if (S<=f .and. Li<=100.0*e/(100.0+e) .and. Li>=noudo) then
          noudo=Li
          youeki=S
          yousitu=T
        endif
     end do
   end do
  end do
end do
print"(i0,A,i0)", int(youeki)," ",int(yousitu)
end

Measured memory_bytes: 256
while True:
    x=int(input())
    if x==0:
        break
    a=1000-x
    b=a//500
    c=a%500
    d=c//100
    e=c%100
    f=e//50
    g=e%50
    h=g//10
    i=g%10
    j=i//5
    k=i%5
    print(b+d+f+h+j+k)



Measured memory_bytes: 5588
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main() {
    char n, m;
    cin >> n >> m;
    int a, b;
    a = n - '0';
    b = m - '0';
    string s, t;
    s = "";
    t = "";
    for(int i = 0; i < a; i++) {
        s += (m);
    }
    for(int i = 0; i < b; i++) {
        t += n;
    }
    if(s < t) {
        cout << s << endl;
    }
    else {
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cstring>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int W, H, N;
    cin >> W >> H >> N;
    int x[N], y[N], a[N];
    rep(i,N) cin >> x[i] >> y[i] >> a[i];
    int wh[W][H];
    memset(wh, 0, sizeof(wh));
    for(int i=0; i<N; i++){
        if(a[i]==1){
            for(int j=0; j<x[i]; j++){
                for(int k=0; k<H; k++){
                    wh[j][k]=1;
                }
            }
        }else if(a[i]==2){
            for(int j=x[i]; j<W; j++){
                for(int k=0; k<H; k++){
                    wh[j][k]=1;
                }
            }
        }else if(a[i]==3){
            for(int j=0; j<W; j++){
                for(int k=0; k<y[i]; k++){
                    wh[j][k]=1;
                }
            }
        }else if(a[i]==4){
            for(int j=0; j<W; j++){
                for(int k=y[i]; k<H; k++){
                    wh[j][k]=1;
                }
            }
        }
    }
    int ans = 0;
    rep(i,W){
        rep(j,H){
            if(wh[i][j]==0){
                ans++;
            }
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    //偶奇、どの場合が最適がに注目
    int n; cin >> n;
    map<int, int> ma;
    rep(i,n) {
        int a; cin >> a;
        ma[a]++;
    }
    int res = ma.size();
    if((n-res)%2!=0) res--;
    cout << res << endl;
}

Measured memory_bytes: 4992
k, n = input().split()
k, n = int(k), int(n)
a = list(map(int, input().split()))

max = 0

for i in range(n - 1):
  if a[i + 1] - a[i] > max:
    max = a[i + 1] - a[i]

if (k - a[n - 1]) + a[0] >= max:
  max = (k - a[n - 1]) + a[0]

print(k - max)


Measured memory_bytes: 26444
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{



    class Program
    {

        const int Gray = 1;
        const int Brown = 2;
        const int Green = 3;
        const int LightBlue = 4;
        const int Blue = 5;
        const int Yellow = 6;
        const int Orange = 7;
        const int Red = 8;
        const int Brack = 9;

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] data = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var dic = new Dictionary<int, bool>();

            for (int i = 1; i <= 9; i++)
            {
                dic[i] = false;
            }

            int color = 0;
            int cnt_brack = 0;
            for (int i = 0; i < N; i++)
            {
                color = data[i];
                
                if (1 <= color && color <= 399)
                {
                    color = Gray;
                }
                else if (color <= 799)
                {
                    color = Brown;
                }
                else if (color <= 1199)
                {
                    color = Green;
                }
                else if (color <= 1599)
                {
                    color = LightBlue;
                }
                else if (color <= 1999)
                {
                    color = Blue;
                }
                else if (color <= 2399)
                {
                    color = Yellow;
                }
                else if (color <= 2799)
                {
                    color = Orange;
                }
                else if (color <= 3199)
                {
                    color = Red;
                }
                else if (color >= 3200)
                {
                    dic[color] = true;
                    color = Brack;
                    cnt_brack++;
                }
                
                dic[color] = true;

            }

            
            int min = 0;
            int max = 0;

            for (int i = 1; i < 9; i++)
            {
                if (dic[i])
                {
                    min++;
                }
            }

            max = min;

            if (min == 0 && cnt_brack >= 1)
            {
                min++;
            }

            max += cnt_brack;

            Console.WriteLine($"{min} {max}");

        }
    }
}


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

using namespace std;

int main() {

    int n;
    cin >> n;

    pair<int, int> data[n];

    for(int i = 0; i < n; i++) {
        cin >> data[i].first >> data[i].second;
    }
    

    double sol = 0;
    for(int r = 0; r < 100000; r++) {
        random_shuffle(data, data + n);
        double x = data[0].first, y = data[0].second, c = sqrt(pow(x, 2) + pow(y, 2));
        for(int j = 1; j < n; j++) {
            x += data[j].first;
            y += data[j].second;
            double length = sqrt(pow(x, 2) + pow(y, 2));
            if(length > c) c = length;
            else {
                x -= data[j].first;
                y -= data[j].second;
            }
        }
        sol = max(c, sol);
    }

    cout << fixed << setprecision(20) << sol << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  vi a(3);
  rep(i,3){
    cin >> a[i];
  }
  sort(all(a));
  ll ans = a[2] * 10 + a[0] + a[1];
  print(ans);
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/*
 * n = 3
 * A = 6 7 3    get 1b using 3 acorns
 * B = 4 7 7    get 7 acorns using 1b, get 1g using 4 acorns (3 left)
 * A = 6 7 3    get 6 acorns using 1g
 * ans = 6+3 = 9
 */

const int maxn = 5050;
LL dp[maxn*maxn]; int ga,sa,ba, gb,sb,bb;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while (cin >> n) {
        memset(dp,0,sizeof(dp));
        cin >> ga >> sa >> ba >> gb >> sb >> bb;
        FOR(i,0,n+1) {
            if (i+ga <= n && ga < gb)
                dp[i+ga] = max(dp[i+ga], dp[i]+gb);
            if (i+sa <= n && sa < sb)
                dp[i+sa] = max(dp[i+sa], dp[i]+sb);
            if (i+ba <= n && ba < bb)
                dp[i+ba] = max(dp[i+ba], dp[i]+bb);
        }
        LL gain = 0;
        FOR(i,0,n+1)
            gain = max(gain,dp[i]-i);
        n += gain;
        memset(dp,0,sizeof(dp));
        FOR(i,0,n+1) {
            if (i+gb <= n && gb < ga)
                dp[i+gb] = max(dp[i+gb], dp[i]+ga);
            if (i+sb <= n && sb < sa)
                dp[i+sb] = max(dp[i+sb], dp[i]+sa);
            if (i+bb <= n && bb < ba)
                dp[i+bb] = max(dp[i+bb], dp[i]+ba);
        }
        gain = 0;
        FOR(i,0,n+1)
            gain = max(gain, dp[i]-i);
        cout << n+gain << endl;
    }
    return 0;
}


Measured memory_bytes: 199552
from collections import defaultdict
import itertools

N=input()
l=["M","A","R","C","H"]
C=defaultdict(lambda: 0)

for i in range(N):
	S=raw_input()
	if S[0] in l:
		C[S[0]]+=1

P=list(itertools.combinations(C.keys(),3))

ans=0
for x,y,z in P:
	ans+=C[x]*C[y]*C[z]

print ans

Measured memory_bytes: 8056
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int ans[n+1];
    fill(ans, 0);
    for(int i=1;i<100;i++)
    {
        for(int j=1;j<100;j++)
        {
            for(int k=1;k<100;k++)
            {
                int res=(i*i)+(j*j)+(k*k)+(k*j)+(i*k)+(i*j);
                if(res<=n)
                ans[res]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    cout<<ans[i]<<"\n";
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int a,b;
	char c;
	while(cin>>a>>c>>b)
	{
		if(c=='?')break;
		else if(c=='+')cout<<a+b<<endl;
		else if(c=='-')cout<<a-b<<endl;
		else if(c=='*')cout<<a*b<<endl;
		else cout<<a/b<<endl;
	}
	return 0;	
}


Measured memory_bytes: 3060
import sys
d={' ':'101',"'":'000000',',':'000011','-':'10010001','.':'010001','?':'000001','A':'100101','B':'10011010','C':'0101','D':'0001','E':'110',
'F':'01001','G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100','M':'10011001','N':'10011110','O':'00101','P':'111',
'Q':'10011111','R':'1000','S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010','Y':'10010011','Z':'10010000'}
for e in sys.stdin:
 a=''.join(d[c]for c in e[:-1])
 a+='0'*(-len(a)%5)
 print(''.join("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i*5:i*5+5],2)]for i in range(len(a)//5)))


Measured memory_bytes: 5612
<?php
	fscanf(STDIN, "%d", $train_A);
	fscanf(STDIN, "%d", $train_B);
	fscanf(STDIN, "%d", $bus_A);
	fscanf(STDIN, "%d", $bus_B);

	$train_min = min($train_A, $train_B);
	$bus_min = min($bus_A, $bus_B);
	
	echo $train_min + $bus_min;
?>

Measured memory_bytes: 4728
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();

    if(A<=5){
    System.out.println(0);
    }else if(A<=12){
    System.out.println(B/2);
    }else{
    System.out.println(B);
    }

  }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int partition(int a[], int p, int r)
{
	int pivot = a[r];
	int i = p - 1;
	for(int j = p; j < r; j++){
		if(a[j] <= pivot){
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i + 1], a[r]);
	return i + 1;
}

int main()
{
	int n;
	int a[100000];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int ans = partition(a, 0, n - 1);
	for(int i = 0; i < n; i++){
		if(i == ans) cout << "[" << a[i] << "] ";
		else if(i == n - 1) cout << a[i] << endl;
		else cout << a[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 1548
n, k = map(int, input().split())
mod = 10 ** 9 + 7
a = [0] * (2 * 10 ** 6)
for i in range(1, n + 1):
    a[i] = a[i - 1] + i
ans = 0
for i in range(k, n + 2):
    ans += (i * n - 2 * a[i - 1] + 1) % mod
print(ans % mod)


Measured memory_bytes: 33308
#include <iostream>

using namespace std;

int main(){

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

    int G = 0;
    for(int l=0; l<10; l++){
        G = (G + S[l]);
    }

    cout << G << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;
vector<vector<pair<int,int>>> z(100010);

int main()
{
    int H1,H2,M1,M2,K;
    cin >> H1>>M1>>H2>>M2>>K;
    int T;
    if(M2>=M1){
         T=60*(H2-H1)+(M2-M1);
         T-=K;
    }else{
        T=60*(H2-H1-1)+(60+M2-M1);
         T-=K;
    }
   
    
    cout << T <<endl;
    return 0;
}

Measured memory_bytes: 5488
N = int(input())
A,B = map(int, input().split())
p_list =  list(map(int,input().split()))
p_list.sort()
count_one = 0
count_two = 0
count_three = 0
for i in p_list:
    if i <= A:
        count_one += 1
    elif B < i:
        count_three += 1
    else:
        count_two += 1
print(min(count_one,count_two,count_three))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
int main(){
    std::string s;
    std::cin >> s;
    long long ans = 0;
    long long count = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != 'A' && s[i] != 'T' && s[i] != 'C' && s[i] != 'G'){
            ans = std::max(ans, count);
            count = 0;
        }
        else count++;
    }
    ans = std::max(ans, count);
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define int long long
using namespace std;
const int mod = 1000000007;
signed main() {
	int n, m; cin >> n >> m;
	int ans = 1;
	for (int i = 2; i <= sqrt(m); i++) {
		if (m%i == 0) {
			int cnt = 0;
			while (m%i == 0) {
				m /= i; cnt++;
			}
			int p = 1;
			//m+n-1Cm
			for (int i = 1; i <= cnt; i++) {
				p *= cnt + n - i;
				p %= mod;
			}
			for (int i = 2; i <= cnt; i++) {
				while (p%i != 0)p += mod;
				p /= i;
				p %= mod;
			}
			ans *= p;
			ans %= mod;
		}
	}
	if (m != 1) {
		ans *= n;
		ans %= mod;
	}
	cout << ans << endl;
}

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

int main(){
    ll a,b;
    cin >> a >> b;
    if (a * b <= 0){
        cout << "Zero" << endl;
    }
    else if (b < 0 && (b - a) % 2 == 0){
        cout << "Negative" << endl;
    }
    else{
        cout << "Positive" << endl;
    }
}


Measured memory_bytes: 3600
n,m=map(int,input().split())

l=[[int(x) for x in input().split()] for _ in range(m)]
p=[int(x) for x in input().split()]

t=0
for i in range(2**n):
  f = True
  for j in range(m):
     c=0
     for k in range(1,l[j][0]+1):
       if (i>>(l[j][k]-1)) & 1:
         c+=1
     if (c&1)!=p[j]:
        f = False
        break
  if f==True:
    t+=1

print(t)


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

int main(){
    int N;
    cin >> N ;
    int M=N%10;
    
    if(M==2||M==4||M==5||M==7||M==9){
        cout << "hon" << endl;
    }
    else if(M==0||M==1||M==6||M==8){
        cout << "pon" << endl;
    }
    else   cout << "bon" << endl;
    
    
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n, k;
	cin>>n>>k;
	if(n==1)
		cout<<1<<endl;
	for(int i=1;i<n;i++){
		if(pow(k, i)>n){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    len_diff = len(set([A[i], B[i], C[i]]))
    if len_diff == 3:
        ans += 2
    elif len_diff == 2:
        ans += 1
print(ans)




Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)
ll num[110] = { 0 };
bool prime[110];
void furui() {
	prime[2] = false;
	int i = 2;
	while (i <= 100) {
		int j = 2;
		while (!prime[i]&&j<=sqrt(i)) {
			if (i%j == 0) {
				prime[i] = true;
				break;
			}
			else j++;
		}
		if (!prime[i]) {
			int num = 2;
			while (i*num <= 100) {
				prime[i*num] = true;
				num++;
			}
		}
		i++;
	}
	return;
}
int main(void) {
	furui();
	int n, ans = 0;
	cin >> n;
	if (n < 10) {
		cout << 0 << endl;
	}
	else {
		ll p = 2;
		while (p <= n) {
			if (!prime[p]) {
				ll x = p;
				while (x <= n) {
					num[p] += n / x;
					x = x*p;
				}
				p++;
			}
			else p++;
		}
		p = 2;
		//指数部74
		while (p <= n) {
			if (!prime[p]) {
				if (num[p] >= 74)ans++;
				p++;
			}
			else p++;
		}
		p = 2;
		int kind1 = 0, kind2 = 0;
		while (p <= n) {
			if (!prime[p]) {
				if (( 2<= num[p]) && (num[p] < 24))kind1++;
				else {
					if (num[p] >= 24)kind2++;
				}
				p++;
			}
			else p++;
		}
		ans += kind2*(kind2 - 1)+ kind1*kind2;
		p = 2;kind1 = 0, kind2 = 0;
		while (p <= n) {
			if (!prime[p]) {
				if ((4 <= num[p]) && (num[p] < 14))kind1++;
				else {
					if (num[p] >= 14)kind2++;
				}
				p++;
			}
			else p++;
		}
		ans += kind2*(kind2 - 1) + kind1*kind2;
		p = 2;kind1 = 0, kind2 = 0;
		while (p <= n) {
			if (!prime[p]) {
				if ((2 <= num[p]) && (num[p] < 4))kind1++;
				else {
					if (num[p] >= 4)kind2++;
				}
				p++;
			}
			else p++;
		}
		ans += kind1*kind2*(kind2 - 1) / 2 + kind2*(kind2 - 1)*(kind2 - 2) / 2;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] s = new int[5];
        int[] c = new int[5];
        for(int i=0;i<M;i++){
            s[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
        }
        int[] result = new int[3];
        for(int i=0;i<M;i++){
            if(s[i] == 1 && c[i] == 0 && N != 1){
                result[0] = -1;
                break;
            }else{
                if(result[s[i] - 1] != 0 && result[s[i] - 1] != c[i]){
                    result[0] = -1;
                    break;
                }else{
                    result[s[i] - 1] = c[i];
                }
            }
        }
        if(result[0] == -1){
            System.out.println(result[0]);
        }else{
            switch(N){
                case 1:
                    System.out.println(result[0]);
                    break;
                case 2:
                    result[0] = result[0] == 0 ? 1 : result[0];
                    System.out.println(result[0] * 10 + result[1]);
                    break;
                case 3:
                    result[0] = result[0] == 0 ? 1 : result[0];
                    System.out.println(result[0] * 100 + result[1] * 10 + result[2]);
                    break;
            }
        }
    }
}


Measured memory_bytes: 23764
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        String exStr = sc.next();
        String plStr = sc.next();
		
        int count = 0;
        for(int i = 0; i < 3; i++){
          if(exStr.charAt(i) == plStr.charAt(i)){
            count++;
          }
        }
      
		// 出力
		System.out.println(count);
	}
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll H, W, K, ans=0, tmp=0;
vector<string> A;

void dfs(vector<ll> v, ll id) {
    if(id>=W+H) {
        ll ct=0;
        for(int i=0;i<H;i++) {
            for(int j=0;j<W;j++) {
                if(v[i]==1&&v[H+j]==1&&A[i][j]=='#') {
                    ct++;
                }
            }
        }
        if(ct==K) {
            ans++;
            for(int i=0;i<v.size();i++) {
                //cout << " " << v[i];
            }
        }
        return;
    }
    dfs(v, id+1);
    v[id] = 1;
    dfs(v, id+1);
}

signed main(){
    cin >> H >> W >> K;
    for(int i=0;i<H;i++) {
        string a;
        cin >> a;
        A.push_back(a);        
    }
    vector<ll> vemp(W+H,0);
    dfs(vemp,0);
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,m[100],sum,ans,min,x;
  cin >> n >> x;
  ans = n;
  min =10000;
  sum=0;
  for(int i=0;i<n;i++){
    cin >> m[i];
    sum+=m[i];
    if(m[i]<min)min=m[i];
  }
  x -=sum;
  while(x - min>=0){
    x -= min;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
	scanf("%*d");
	char data[4][3][10];
	memset(data, 0, sizeof(data));
	int b, f, r, v;
	while (~scanf("%d%d%d%d", &b, &f, &r, &v)) {
		data[b - 1][f - 1][r - 1] += v;
	}
	for (b = 0; b < 4; b++) {
		b && puts("####################");
		for (f = 0; f < 3; f++) {
			for (r = 0; r < 10; r++) {
				printf("%2d", data[b][f][r]);
			}
			puts("");
		}
	}
	return 0;
}

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

int arr[100000];

int main()
{
	int D, N, M;
	while (scanf("%d", &D), D){
		scanf("%d %d", &N, &M);
		
		memset(arr, 0, sizeof(arr));
		for (int i = 1; i < N; i++){
			scanf("%d", &arr[i]);
		}
		sort(arr, arr + N);
		arr[N] = D;
		
		//for (int i = 0; i <= N; i++){
		//	printf("%d ", arr[i]);
		//}
		//puts("");
		
		long long sum = 0;
		for (int i = 0; i < M; i++){
			int k;
			scanf("%d", &k);
			
			int l = 0, r = N, m;
			while (true){
				m = (l + r) / 2;
				
				if (l > r) break;
				if (arr[m] < k) l = m + 1;
				else if (arr[m] > k) r = m - 1;
				else break;
			}
			
			if (l > r) sum += min(arr[l] - k, k - arr[r]);
		}
		printf("%lld\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 1596
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}


int main(){ 
  int h, w;
  cin >> h >> w;
  char s[h+2][w+2];
  char mat[h][w];
  rep(i,h+2){
    rep(j,w+2){
      if(i == 0 || i == h+1 || j == 0 || j == w+1){
        s[i][j] = ' ';
      }
      else{
        cin >> s[i][j];
        mat[i][j] = ' ';
      }

    }
  }
  for(int i = 1;i < h+1;i++){
    for(int j = 1;j < w+1;j++){
      int temp = 0;
      if(s[i][j] == '#')mat[i-1][j-1] = '#';
      else {
        for(int k = -1;k < 2;k++){
          for(int l = -1;l < 2;l++){
            if(s[i+k][j+l] == '#')temp++;
          }
        }
        mat[i-1][j-1] = to_string(temp)[0];
      }
    }
  }
  rep(i,h){
    rep(j,w)cout << mat[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 3728
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  cin>>N;
  vector<int> goal(7 * 4);
  REP(y, 4)REP(x, 7){
    int idx = 7 * y + x;
    if(x + 2 <= 7) goal[idx] = (y + 1) * 10 + x + 2;
    else goal[idx] = 0;
  }
  while(N--){
    vector<int> v(7 * 4);
    REP(i, 7 * 4) cin>>v[i];
    REP(i, 7 * 4) if(v[i] % 10 == 1) v[i] = 0;
    map< vector<int>, int > d;
    queue< vector<int> > que;
    que.push(v); d[v] = 0;
    while(!que.empty()){
      vector<int> v = que.front(); que.pop();
      if(v == goal) break;
      int t = d[v];
      REP(y, 4)REP(x, 7){
        int idx = 7 * y + x;
        if(v[idx] == 0){
          vector<int> v2 = v;
          int target;
          if(x == 0) target = (2 + x) + (y + 1) * 10;
          else target = v[y * 7 + x - 1] + 1;
          if(target % 10 == 8) continue;
          v2[idx] = target;
          REP(idx2, 7 * 4) if(v[idx2] == target){
            v2[idx2] = 0;
            break;
          }
          if(!d.count(v2)){
            d[v2] = t + 1;
            que.push(v2);
          }
        }
      }
    }
    if(d.count(goal)) cout<<d[goal]<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 14616