akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll N, X;
vector<ll> B, P, A;

ll p(ll n, ll x) {
  if (n == 0)
    return 1;

  if (x == 0) {
    return 0;
  } else if (x <= A[n - 1]) {
    return p(n - 1, x - 1);
  } else if (x == A[n - 1] + 1) {
    return P[n - 1] + 1;
  } else if (x <= 2 * A[n - 1] + 1) {
    return P[n - 1] + 1 + p(n - 1, x - (A[n - 1] + 2));
  } else {
    return 2 * P[n - 1] + 1;
  }
}

int main() {
  cin >> N >> X;
  X--;  // 0-origin

  B = vector<ll>(N + 1);
  P = vector<ll>(N + 1);
  A = vector<ll>(N + 1);

  B[0] = 0;
  P[0] = 1;
  A[0] = 1;
  rep(i, N) {
    B[i + 1] = B[i] * 2 + 2;
    P[i + 1] = P[i] * 2 + 1;
    A[i + 1] = A[i] * 2 + 3;
  }

  cout << p(N, X) << endl;
}

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


Measured memory_bytes: 5592
N,L = map(int,input().split())
sum_list=[]
l2=[]
l3=[]
for i in range(1,N+1):
  sum_list.append(L+i-1)
  
if 0 in sum_list:
  print(sum(sum_list))
else:
  for j in sum_list:
    l3.append(abs(j))

l2=[k for k in sum_list if not 0 in sum_list and abs(k) == min(l3)]

if not 0 in sum_list:
  print(sum(sum_list)-l2[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int d;
	cin >>d;
	Vi ans(d,0);
	Vi c(26,0);
	ll sum=0LL;
	rep(i,26){
		cin>>c[i];
		sum+=c[i];
	}
	VVi s(d,Vi(26,0));
	rep(i,d){
		rep(j,26){
			cin>>s[i][j];
		}
	}
	int up=1;
	int val=-INF;
	int now=0;
	Vi last(26,0);
	rep(i,d){
		val=-INF;
		rep(j,26){
			now=0;
			now=s[i][j];
			rep(k,26){
				if(j==k)continue;
				now-=c[k]*last[k];
			}
			if(chmax(val,now)){
				up=j;
			}
		}
		ans[i]=up;
		last[ans[i]]=i+1;
	}
	rep(i,d){
		cout<<ans[i]+1<<endl;
	}
	
}

Measured memory_bytes: 3684
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N,M;
int num[100001];

int main() {
	ios::sync_with_stdio(false);
	cin >> N>>M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		num[a]++;
		num[b]++;
	}
	for (int i = 1; i <= N; i++) {
		if (num[i] % 2) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

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

    int64_t a, b, c;
    cin >> a >> b >> c;

    int res;
    if (a + b + 1 >= c) {
        cout << b + c << endl;
    } else {
        cout << a + b + 1 + b << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

const int AMAX=50,HMAX=100,MOITIE=50;
int terrain[HMAX][HMAX],a,b;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin >> a >> b;
	
	a--;
	b--;
	for(int i=50;i<HMAX;i++){
		for(int j=0;j<HMAX;j++){
			terrain[i][j]=1;
		}
	}
	
	for(int lig=0;lig<MOITIE;lig++){
		for(int col=0;col<HMAX;col++){
			if(lig%2==0 && col%2==0 && b>0){
				terrain[lig][col]=1;
				b--;
			}
		}
	}
	
	for(int lig=HMAX-1;lig>=MOITIE;lig--){
		for(int col=0;col<HMAX;col++){
			if(lig%2==0 && col%2==0 && a>0){
				terrain[lig][col]=0;
				a--;
			}
		}
	}
	
	cout << HMAX << ' ' << HMAX << '\n';
	
	for(int i=0;i<HMAX;i++){
		for(int j=0;j<HMAX;j++){
			if(terrain[i][j]==0){
				cout << '.';
			}
			else{
				cout << '#';
			}
		}
		cout << '\n';
	}
	cout << '\n';
	
    return 0;
}


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

ll paw( ll x, ll n ){
	if( n == 0 ) return 1;
	ll t = pow(x,n/2);
	if( n%2 == 0 ){
		return t*t;
	}else{
		return t*t*x;
	}
}

int main() {
	ll n,p;cin >> n >> p;
	ll even = 0;
	ll odd = 0;
	rep(i,n){
		ll num;cin >> num;
		if( num%2 == 0 ) even++;
		else odd++;
	}
	if( p == 0 ){
		ll ans = paw(2,even)*paw(2,odd);
		if( ans == 1 ) cout << 1 << endl;
		else if( odd == 0 ){
			cout << ans << endl;
		}else{
			cout << ans/2 << endl;
		}
	}else{
		if( odd == 0 ){
			cout << 0 << endl;
		}else{
			cout << paw(2,even)*paw(2,odd)/2 << endl;
		}
	}
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	string S;
	cin >>N >>S;
	int SS=0;
	for (int i=2; i<N; i++) {
		int SSS=0;
		for(int j=0; i+j<N; j++)
			if (S.at(j)==S.at(j+i))
				SS=max(SS, min(i, ++SSS));
			else
				SSS=0;
	}
	cout <<SS <<endl;
	return 0;
}



Measured memory_bytes: 256
given = $<.readlines.map {|l| l.chomp.chars.map(&:to_i)}
yoko = 0.step(8, 2).map {|i| given[i]}
tate = 1.step(8, 2).map {|i| given[i]}.transpose
dirs = "LRUD"
go = nil
route = ""
f = false

get_yoko = ->(x, y, dir) {
  if dir == 0
    if tate[x][y] == 1
      go.(x, y, 3)
    elsif x > 0 and yoko[y][x - 1] == 1
      go.(x, y, 0)
    elsif y > 0 and tate[x][y - 1] == 1
      go.(x, y, 2)
    else
     go.(x, y, 1)
    end
  else
    if y > 0 and tate[x][y - 1] == 1
      go.(x, y, 2)
    elsif x <= 3 and yoko[y][x] == 1
      go.(x, y, 1)
    elsif tate[x][y] == 1
      go.(x, y, 3)
    else
      go.(x, y, 0)
    end
  end
}

get_tate = ->(x, y, dir) {
  if dir == 2
    if x > 0 and yoko[y][x - 1] == 1
      go.(x, y, 0)
    elsif y > 0 and tate[x][y - 1] == 1
      go.(x, y, 2)
    elsif yoko[y][x] == 1
      go.(x, y, 1)
    else
      go.(x, y, 3)
    end
  else
    if x <= 3 and yoko[y][x] == 1
      go.(x, y, 1)
    elsif y <= 3 and tate[x][y] == 1
      go.(x, y, 3)
    elsif x > 0 and yoko[y][x - 1] == 1
      go.(x, y, 0)
    else
      go.(x, y, 2)
    end
  end
}

go = ->(x, y, dir) {
  return if x.zero? and y.zero? and f
  f = true
  route += dirs[dir]
  if dir <= 1
    get_yoko.(x + dir * 2 - 1, y, dir)
  else
    get_tate.(x, y + dir * 2 - 5, dir)
  end
}

go.(0, 0, 1)
puts route


Measured memory_bytes: 6984
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<int> d(n);
    rep(i, n) {
        cin >> d[i];
    }

    if(24 <= n) {
        cout << 0 << endl;
        return 0;
    }

    if(n == 23) {

        sort(d.begin(), d.end());

        int flag = 0;
        for(int i = 0; i <= 20; i += 2) {
            int k = i/2 + 1;
            if(d[i] != k || d[i+1] != k) {
                flag = 1;
            }
        }
        if(d[22] != 12) {
            flag = 1;
        }

        if(flag) {
            cout << 0;
        }
        else {
            cout << 1;
        }

        cout << endl;
        return 0;
    }

    int ans = 0;
    for(int b = 0; b < (1<<n); b++) {

        vector<int> t(n+1);
        rep(i, n) {
            if(b & 1<<i) {
                t[i] = 24-d[i];
            }
            else {
                t[i] = d[i];
            }
        }

        int u = 30;
        rep(i, n) {
            for(int j = i+1; j <= n; j++) {
                int x = abs(t[i] - t[j]);
                int y = min(x, 24-x);
                u = min(u, y);
            }
        }

        ans = max(ans, u);
    }

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

Measured memory_bytes: 256
K, N = map(int, input().split())
house = list(map(int,input().split()))
house = house + house
min = house[N - 1] - house[0]
 
for i in range(N - 1):
  if K - (house[N + 1 + i] - house[i]) < min:
    min = K - (house[N + 1 + i] - house[i])
 
print(min)

Measured memory_bytes: 26060
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF=1e18;

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

    unsigned long long N, K;
    cin >> N >> K;

    unsigned long long left = N % K;
    unsigned long long lastSubstraction = 0;
    if (left >= K) {
        lastSubstraction = left - K;
    } else {
        lastSubstraction = K - left;
    }

    if (left <= lastSubstraction) {
        cout << left << '\n';
    } else {
        cout << lastSubstraction << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
N, K = [int(v) for v in input().split(' ')]
S = input()

A = []
for s in S:
    if s == 'L':
        A.append(0)
    else:
        A.append(1)

def count(S):

    s = -1
    next_s = A[0]

    c = 0
    i = 1
    while i <= N:
        prev_s = s
        s = next_s
        if i < N:
            next_s = A[i]
        else:
            next_s = -1

        if s == 0: # L
            if s != prev_s:
                c += 1
        else: # R
            if s != next_s:
                c += 1
        i += 1
    return c

unhappy = count(S)
unhappy -= K * 2
if unhappy <= 0:
    unhappy = 1
print(N - unhappy)


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

ll beki(ll a, ll b) {
  if (b == 0) return 1;
  ll ret = beki(a, b / 2);
  ret = ret * ret % MOD;
  if (b & 1) ret = ret * a % MOD;
  return ret;
}

int main() {
  int N;
  cin >> N;
  map<P, int> mp;
  int abzero = 0;
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      abzero++;
      continue;
    }
    if (b < 0) {
      b = -b;
      a = -a;
    } else if (b == 0) {
      mp[make_pair(1, 0)]++;
      continue;
    }
    ll g = gcd(a, b);
    mp[make_pair(a / g, b / g)]++;
  }
  ll ans = 1;
  for (const auto& [k, v] : mp) {
    ll tmp = 1;
    P chokkou;
    if (k.first > 0) {
      chokkou = make_pair(-k.second, k.first);
    } else {
      chokkou = make_pair(k.second, -k.first);
    }
    tmp = (tmp + beki(2, v) - 1) % MOD;
    tmp = (tmp + beki(2, mp[chokkou]) - 1) % MOD;
    mp[k] = 0;
    mp[chokkou] = 0;
    ans = (ans * tmp) % MOD;
  }
  ans = (ans + abzero + MOD - 1) % MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 28592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
ll a,b,c,d,i,l,j;
int main(){
  cin >> a >> b >> c >> d;
  i = b/c-roundup(a,c)+1; l = b/d-roundup(a,d)+1; j=b/(lcm(c,d))-roundup(a,(lcm(c,d)))+1;
  cout << (b-a+1)-(i+l-j) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,i,j;
int main(){
	while(scanf("%d",&n)!=EOF){
		if(n==-1)break;i=4;
		while(n>=i)i*=4;
		while(i>0){
			i/=4;
			if(i>0){
				printf("%d",n/i);
				n=n%i;
			}
		}
		printf("\n");
	}
	return 0;
}

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

#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define mi                map<int,int>
#define pqb               priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mod               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //fir defining the precision int the decimal upto y places. 
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)     type *a=new type[n];
#define test(t)            int t; cin>>t; while(t--)


void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);


}



int32_t main()
{
	

	//int te = 1;

	// test(t)
	// {
	// int r, g, b;
	int n;
	cin >> n;

	int a[n] = {0};

	for (int i = 0; i < n; i++)
		cin >> a[i];

	sort(a, a + n, greater<int>());

	int x = 0;
	int y = 1;
	int z = 2;

	if (n < 3)
		cout << 0 << "\n";
	else
	{
		int ctr = 0;

		for (int i = 0; i < n; i++)
		{
			for (int j = i + 1; j < n; j++)
			{
				for (int k = j + 1; k < n; k++)
				{
					if ((a[i] != a[j] and a[j] != a[k] and a[i] != a[k]) and a[k] + a[j] > a[i])
						ctr++;
				}
			}
		}

		cout << ctr << "\n";
	}







	// cout << concat(4, 1) << "\n";
	//te++;
// double c_time = (double) (clock() - begin) / CLOCKS_PER_SEC;
// cout << ps(c_time, 4) << " seconds\n";
	//}

	return 0;
}






Measured memory_bytes: 3636
while 1:
    n = int(input())
    if n == 0:
        break

    data = list(map(int, input().split()))
    data.sort()

    ans = 10**9
    for i in range(1, n):
        if data[i] - data[i-1] < ans:
            ans = data[i] - data[i-1]

    print(ans)



Measured memory_bytes: 5628
#include<stdio.h>
int n,m,t[102],n_d,t_d;
int main(){
	scanf("%d",&n);

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

	scanf("%d",&m);

	int sum;
	for(int i=1;i<=m;i++){
		scanf("%d %d",&n_d,&t_d);
			sum=0;
			for(int j=1;j<=n;j++){
			if(j==n_d)
				sum=sum+t_d;
						else
				sum=sum+t[j];
						}
		printf("%d\n",sum);
			}	
}

Measured memory_bytes: 128
#include<stdio.h>

int saiki(int n[30], int limit, int len){
	int i;
	int m;
	if(limit==0){
		printf("%d",n[0]);
		for(i=1;i<len;i++){
			printf(" %d",n[i]);
		}
		printf("\n");
	}else{
		if(len!=0 && n[len-1] < limit){
			m = n[len-1];
		}else{
			m = limit;
		}
		for(i=m;i>=1;i--){
			n[len] = i;
			saiki(n,limit-i,len+1);
		}
	}
}
int main(){
	int n;
	int a[30];
	scanf("%d",&n);
	while(n){
		saiki(a,n,0);
		scanf("%d",&n);
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int a[10];

bool dfs(int i, vector<int>& l, vector<int>& r) {
  if (i == 10) return true;
  bool res = false;
  if (l.empty() || l.back() < a[i]) {
    l.emplace_back(a[i]);
    res |= dfs(i + 1, l, r);
    l.pop_back();
  }
  if (r.empty() || r.back() < a[i]) {
    r.emplace_back(a[i]);
    res |= dfs(i + 1, l, r);
    r.pop_back();
  }
  return res;
}

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

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> a[j];
    }
    vector<int> l, r;
    cout << (dfs(0, l, r) ? "YES" : "NO") << endl;
  }

  return 0;
}


Measured memory_bytes: 3152
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


a, b = LI()

if a == 1:
    a *= 100
if b == 1:
    b *= 100

if a == b:
    print('Draw')
else:
    print('Alice' if a > b else 'Bob')


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
/* Kadai2_2
   key_tree */
 
#include <stdio.h>
 
int main(void) {
    int N, A;
 
    //入力受け取り
    scanf("%d", &N);
    scanf("%d", &A);
    printf("%d\n",  N*N - A);
    return 0;
  
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int s[15], n;
int ans = 0;
void dfs(int i, int sum, int now) {
	if (i == n - 1) {
		ans += sum + now;
	}
	else {
		dfs(i + 1, sum + now, s[i + 1]);
		dfs(i + 1, sum, now * 10 + s[i + 1]);
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string str; cin >> str;
	n = str.size();
	rep(i, n)s[i] = str.at(i) - '0';
	dfs(0, 0, s[0]);
	cout << ans << endl;
	return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


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

	if (n % 1000 == 0)
		cout << 0 << endl;
	else
		cout << 1000 - (n % 1000) << endl;



}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
odd=[]
even=[]
if n%2==0:
  m=n//2
  for i in range(m):
    odd.append(a[n-1-2*i])
    even.append(a[2*i])
  print(*(odd+even))
else:
  m=n//2
  for i in range(m):
    odd.append(a[n-1-2*i])
    even.append(a[n-2-2*i])
  even.reverse()
  odd=odd+[a[0]]
  print(*(odd+even))

Measured memory_bytes: 30912
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let n: i64 = read();
    let s: String = read();
    let mut maxv = 0;
    let mut cv = 0;

    for i in s.chars() {
        if i == 'I' {
            cv += 1;
        } else {
            cv -= 1;
        }
        maxv = max(maxv, cv);
    }

    println!("{}", maxv);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(2020,0);
  a[0] = 1;
  int b = 1;
  int sum = 0;
  ll ans = 0;
  for(int i=n-1; i>=0; i--){
    int d = s[i]-'0';
    sum = (sum + b*d) % 2019;
    ans += a[sum];
    a[sum]++;
    b = b*10%2019;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 550;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
int a, b, c;
cin>>a>>b>>c;
if((a+b+c) >= 22) puts("bust");
else puts("win");
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int x;

int main()
{
    _FastIO;
    cin >> x;
    if(x == 3 || x == 5 || x == 7){
        cout << "YES" << endl;
    }
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7;

int main(){
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s, t; int n, m; cin >> s >> t >> n >> m;
	string str; cin >> str; if(str == s) -- n; else -- m;
	cout << n << ' ' << m << '\n';
	return 0;
}

Measured memory_bytes: 256
use itertools::interleave;
use itertools::join;
use num_bigint;
use num_complex;
use num_integer;
use num_traits;
use proconio::input;
use proconio::marker::Chars;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::Write;

pub trait Echo {
    fn echo(&self);
    fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error>;
}

macro_rules! impl_echo {
    ($($t:ty),*) => {
        $(
            impl Echo for $t {
                fn echo(&self){
                    self.echo_b(&mut std::io::stdout()).unwrap();
                }

                fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error>{
                    writeln!(out,"{}", &self)?;
                    Ok(())
                }
            }
        )*
    };
}

macro_rules! impl_echo_f {
    ($($t:ty),*) => {
        $(
            impl Echo for $t {
                fn echo(&self){
                    self.echo_b(&mut std::io::stdout()).unwrap();
                }

                fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error>{
                    writeln!(out,"{:.12}", &self)?;
                    Ok(())
                }
            }
        )*
    };
}

impl_echo!(u8, u16, u32, u64, u128, usize);
impl_echo!(i8, i16, i32, i64, i128, isize);
impl_echo!(&str, String, char);
impl_echo_f!(f32, f64);

impl<T: Echo> Echo for Vec<T> {
    fn echo(&self) {
        self.echo_b(&mut std::io::stdout()).unwrap();
    }
    fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error> {
        for i in self {
            i.echo_b(out).unwrap();
        }
        Ok(())
    }
}

fn main() {
    input! {
        n: usize,
    };
    let res = if n % 1000 == 0 { 0 } else { 1000 - n % 1000 };
    res.echo();
}

#[allow(dead_code)]
fn yn(i: bool) {
    if i {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

signed main(){
  int N,K,testB=0;
  cin>>N>>K;
  vector<int> A(N);
  rep(i,N){
    cin>>A[i];
    if(i<=K-1)testB+=A[i];
  }
  int co=0;
  for(int i=K;i<N;i++){
    int testA=testB-A[co]+A[i];
    if(testA>testB)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    testB=testA;
    co+=1;
  }
  return 0;
}

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

using namespace std;

int main(){
 
  int n,m,c;
  cin >> n >> m >> c;
  
  int b[m],a[n][m],result=0,count=0;
  
  for(int i=0;i<m;i++)
    cin >> b[i];
  
  for(int i=0;i<n;i++){
  	for(int j=0;j<m;j++){
    	cin >> a[i][j];
      	result = result + (a[i][j]*b[j]);
    }
    if(result+c>0)
      count++;
    result = 0;
  }

 cout << count;
  
  return 0;
}

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

using namespace std;

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

  sort(b.begin(), b.end(), greater<int>());
  int first = b[0];
  int second = b[1];

  for (int i = 0; i < n; ++i) {
    if (a[i] == first) cout << second << endl;
    else cout << first << endl;
  }
  return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    int n,d,x;
    int i,j,k;
    cin >>n>>d>>x;
    vector<int> a(n);
    REP(i,n) {
        cin >> a.at(i);
        for(j=0;((j*a.at(i)+1)<=d);j++){
            x++;
        }
    }
    cout << x << endl;
    return 0;
}

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

#define MAX 200000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];

long long merge(int A[], int n, int l, int m, int r) {
    int i, j, k;
    long long cnt = 0;
    int n1 = m - l;
    int n2 = r - m;
    for ( i = 0; i < n1; i++) {
        L[i] = A[l + i];
    }
    for ( i = 0; i < n2; i++) {
        R[i] = A[m + i];
    }
    L[n1] = R[n2] = SENTINEL;
    i = j = 0;
    for ( k = l; k < r; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        }else {
            A[k] = R[j++];
            cnt += n1 - i; // = mid + j - k -1
        }
    }
    return cnt;
}

long long mergeSort(int A[], int n, int left, int right) {
    int mid;
    long long v1, v2, v3;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    } else return 0;
}

int main(int argc, char const* argv[])
{
    int A[MAX], n, i;

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

    long long ans = mergeSort(A, n, 0, n);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4668
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  while(n%111!=0){n++;}
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	string S;
	cin >> S;

	if (S[3] == S[2] && S[5] == S[4])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


	return 0;
}

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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	u32 n;

	std::cin >> n;

	std::vector<u32> v;
	v.reserve(n);

	for(u32 i=0; i<n;i++)
	{
		u32 x;
		std::cin >> x;
		v.push_back(x);
	}

	bool ok = true;

	for(i32 i=n-1; i!=-1; i--)
	{
		if(v[i-1] > v[i])
		{
			i32 diff = v[i-1] - v[i];
			if (diff > 1)
			{
				ok = false;
				break;
			}
			else
			{
				v[i-1]--;
			}
			
		}
	}

	if (ok)
	{
		std::cout << "Yes\n";
	}
	else
	{
		std::cout << "No\n";
	}
	
	
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    int H = Integer.parseInt(sc.next());
    int W = Integer.parseInt(sc.next());
    
    int c[][] = new int[10][10];
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c[i][j] = Integer.parseInt(sc.next());
      }
    }
    
    int min[] = new int[10];
    for (int i = 0; i < 10; i++) {
      min[i] = c[i][1];
    }
    
    boolean flag = true;
    while (flag) {
      flag = false;
      for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
          int tmp = c[i][j] + min[j];
          if (tmp < min[i]) {
            min[i] = tmp;
            flag = true;
          }
        }
      }
    }
    
    int cost = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int input = Integer.parseInt(sc.next());
        if (input != -1) {
          cost += min[input];
        }
      }
    }
    System.out.println(cost);
  }
}

Measured memory_bytes: 38020
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;
	string s; cin >> s;

	map<char, int> m;
	for (int i = 0; i < n; i++) {
		m[s[i]]++;
	}

	LL ans = 1;

	for (auto i : m) {
		ans = (ans*(i.second +1))%MOD;
	}

	ans = (ans - 1 + MOD) % MOD;

	cout << ans<< endl;
	

	return 0;
}


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

using namespace std;

int main()
{
    int h, w;
    char mp[55][55];
    int f = 1;
    int dy[] = {1, 0, -1, 0};
    int dx[] = {0, 1, 0, -1};

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

    for ( int i = 0; i < h; i++) {
        for ( int j = 0; j < w; j++) {
            
            if ( mp[i][j] == '#') {
                int ff = 0;
                for ( int k = 0; k < 4; k++) {
                    int ny = i + dy[k];
                    int nx = j + dx[k];
                    if ( ny >= 0 && ny < h && nx >= 0 && nx < w && mp[ny][nx] == '#' ) {
                        ff = 1;
                    }
                }
                if ( ff == 0 ) {
                    f = 0;
                }
            }
            
        }
    }
    

    if ( f == 1 ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
s = int(input())
lst = []
lst.append(s)
cnt = 1
while (True):
  cnt += 1
  if (s % 2 == 0):
    s = int(s / 2)
  else:
    s = int(3*s + 1)
  if (s not in lst):
    lst.append(s)
  else:
    break
print(cnt)


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		char[]s = stdIn.next().toCharArray();
		int zero = 0;
		int one = 0;
		
		for(int i = 0; i < s.length; i++) {
			if(s[i]=='0') {
				zero++;
			}else {
				one++;
			}
		}
		
		System.out.println(Math.min(zero, one)*2);
		
		
	}

}


Measured memory_bytes: 27092
#include <stdio.h>
#include <math.h>

int main(void)
{
	int h, w;
	int i, j;

	for (;scanf("%d%d", &h, &w),h+w;){
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++) putchar('#');
			puts("");
		}
		puts("");
	}
	return (0);
}

Measured memory_bytes: 588
local n = io.read("*n")
local t = {}
for i = 1, n do
  local a = io.read("*n")
  if t[a] then
    t[a] = t[a] + 1
    if t[a] == 3 then t[a] = 1 end
  else
    t[a] = 1
  end
end
local num2 = 0
local rem = 0
for k, v in pairs(t) do
  if v == 2 then num2 = num2 + 1 end
  rem = rem + 1
end
if num2 % 2 == 0 then
  print(rem)
else
  print(rem - 1)
end


Measured memory_bytes: 2424
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#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 all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s; cin >> s;
    int ans = 0;
    int now = 0;
    rep(i,s.size()) {
        if (s[i] == 'A'
            || s[i] == 'C'
            || s[i] == 'G'
            || s[i] == 'T') {
            ++now;
            ans = max(ans, now);
        }
        else {
            now = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NMAX 100000

int len, part, rank[NMAX+1];
int compare_sa(const void *a, const void *b);
void construct_sa(char *string, int n, int *sa);
int main(void)
{
  int i, n, k, l, lo, hi, sa[NMAX+1];
  char s[NMAX+1];
  scanf("%d%*c", &k);
  scanf("%s%*c", s);
  n = strlen(s);
  l = (n + k) / (k + 1);
  lo = 1;
  hi = n;
  construct_sa(s, n, sa);
  if (n % (k + 1) == 0) {
    int res = 0;
    for (i = 0; i < k; i++) {
      if (rank[n/(k+1)*(i+1)] > rank[res]) res = n / (k + 1) * (i + 1);
    }
    s[res+n/(k+1)] = '\0';
    printf("%s\n", s + res);
  } else {
    while (hi >= lo) {
      int mid = (lo + hi) / 2, pos = 0, res = 0;
      while (pos < n) {
        pos += rank[pos] <= mid ? l : l - 1;
        res++;
      }
      if (res <= k + 1) hi = mid - 1;
      else lo = mid + 1;
    }
    s[sa[lo]+l] = '\0';
    printf("%s\n", s + sa[lo]);
  }
}

int compare_sa(const void *a, const void *b)
{
  int i = *(int*)a, j = *(int*)b;
  if (rank[i] != rank[j]) return rank[i] - rank[j];
  else {
    int ri = (i + part <= len ? rank[i+part] : -1), rj = (j + part <= len ? rank[j+part] : -1);
    return ri - rj;
  }
}

void construct_sa(char *string, int n, int *sa)
{
  int i, tmp[NMAX+1];
  len = n;
  for (i = 0; i <= len; i++) {
    sa[i] = i;
    rank[i] = i < n ? string[i] : -1;
  }
  for (part = 1; part <= len; part *= 2) {
    qsort(sa, len + 1, sizeof(int), compare_sa);
    tmp[sa[0]] = 0;
    for (i = 1; i <= len; i++) {
      tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(&sa[i-1], &sa[i]) ? 1 : 0);
    }
    for (i = 0; i <= len; i++) rank[i] = tmp[i];
  }
}


Measured memory_bytes: 1780
a=sorted(list(map(int, input().split())))
b=0
while(True):
    if a[0]==a[1] and a[1]==a[2]:
        print(b)
        exit()
    elif a[0]==a[1]:
        a[0]+=1
        a[1]+=1
    else:
        a[0]+=2
    b+=1
    a=sorted(a)





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

using namespace std;
const int maxn = 10;
char mp[maxn][maxn];
int h,w,k;
int sum = 0;
int cnt = 0;
int row[maxn]={0};
int col[maxn]={0};
void dfs(int r,int c)
{
     //判断行
    if(r<=h)
    {
        row[r] = 1;
        dfs(r+1,c);
        row[r] = 0;
        dfs(r+1,c);
    }
    //判断列
    else if(c<=w)
    {
        col[c] = 1;
        dfs(r,c+1);
        col[c] = 0;
        dfs(r,c+1);
    }
   else
    {
        char s[maxn][maxn];
        //赋值
        for(int i=1;i<=h;i++)
        {
            for(int j=1;j<=w;j++)
            {
                s[i][j] = mp[i][j];
            }
        }
        //处理行
        for(int i =1;i<=h;i++)
        {
            if(row[i])
            {
                //这一行全部赋值为'.'
                   for(int j=1;j<=w;j++)
                   {
                       s[i][j]='.';
                   }
            }
        }
        //处理列
        for(int j =1;j<=w;j++)
        {
            if(col[j])
            {
                   for(int i=1;i<=h;i++)
                   {
                       s[i][j]='.';
                   }
            }
        }
        //统计
        int  n= 0;
        for(int i=1;i<=h;i++)
        {
            for(int j=1;j<=w;j++)
            {
               if(s[i][j]=='#') n++;
            }
        }
        if(n==k) cnt++;
       // return ;
    }

}
int main()
{

    cin>>h>>w>>k;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>mp[i][j];
            //if(mp[i][j]=='#') sum++;
        }
    }
    dfs(1,1);
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3632
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
import string
def main():  #startline-------------------------------------------
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    bc = [list(map(int, input().split())) for i in range(q)]
    b = [bc[i][0] for i in range(q)]
    c = [bc[i][1] for i in range(q)]
    dic = Counter(a)
    base = sum(a)
    for i in range(q):
        celb = deepcopy(dic[b[i]])
        celc = deepcopy(dic[c[i]])
        dic[c[i]] += dic[b[i]]
        dic[b[i]] = 0
        base += (c[i]-b[i])*(celb)
        print(base)
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 54520
#include <bits/stdc++.h>
using namespace std;
#define max 200009
map<long,long>mp;

int main()
{
    long i,j,t,a,b,n,c,temp,m;
    t=1;
    // cin>>t;
    while(t--)
    {
       cin>>n;
       long sum=0,sl=0,mini=LONG_MAX;
      long arr[n+1];
      for(i=1;i<=n;i++)
      {
          cin>>arr[i];
          sum+=arr[i];
      }
      for(i=1;i<n;i++)
      {
          sl+=arr[i];
          if(abs(sl-(sum-sl))<mini)
          mini=abs(sl-(sum-sl));
      }
      cout<<mini;
    }
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(void){
int a,b,c,d=0,e=0;
char ch;
  while(cin >> a >> ch >> b >> ch >> c){
    if(a*a+b*b == c*c)d++;
    if(a == b)e++;
  }
  cout << d << endl << e << endl;
  return 0;
}


Measured memory_bytes: 3016
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if v <= w:
    print('NO')
    exit()

if a < b:
    d1 = a + v * t
    d2 = b + w * t
    if d1 < d2:
        print('NO')
        exit()
else:
    d1 = a - v * t
    d2 = b - w * t
    if d1 > d2:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    cout << (B % A ? B - A : B + A) << endl;
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  vi a(3);
  rep (i, 3) {
    cin >> a[i];
  }
  sort(all(a));
  cout << a[0] * a[1] / 2 << endl;
}


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

class Problem
{
private:
	// Variables
	long long a, b, x;
	
public:
	// Methods
	void input ()
	{
		cin >> a >> b >> x;
	}
	
	void process ()
	{
		
	}
	
	void output ()
	{
		cout << ((b+x)/x) - ((a-1+x)/x) << endl;
	}
};

int main ()
{
	Problem problem;
	problem.input();
	problem.process();
	problem.output();
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long int
#define N (ll)(1e9+7)
#define T int
#define P pair<T,T>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define rep(i,n) for(i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<< " "
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    int c=2*b;
    int ans=a-c;
    if(ans>0)
        cout<<ans<<endl;
    else
        cout<<"0"<<endl;

    return 0;
}



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

string s;

bool is_palindrome(string txt);
int main() {
  cin >> s;

  int n = s.length();

  if (n == 3) {
    if (is_palindrome(s)) {
      printf("Yes");
    } else {
      printf("No");
    }

    return 0;
  }

  string sub_1 = s.substr(0, (n - 1) / 2);
  string sub_2 = s.substr((n + 1) / 2, (n - 1) / 2);

  if (is_palindrome(s) & is_palindrome(sub_1) & is_palindrome(sub_2)) {
    printf("Yes");
  } else {
    printf("No");
  }

  return 0;
}

bool is_palindrome(string txt) {
  // 回文かチェック
  string r_txt;
  r_txt = txt;
  reverse(r_txt.begin(), r_txt.end());
  if (txt == r_txt) {
    return true;
  } else {
    false;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int c0,c1;
    char c;
    c0=0;
    c1=0;
    while(scanf("%c",&c)!=EOF){
        if(c=='0'){
            c0++;
        }else if(c=='1'){
            c1++;
        }
    }
    if(c0>c1){
        printf("%d\n",c1*2);
    }else{
        printf("%d\n",c0*2);
    }
    return 0;
}

Measured memory_bytes: 128