akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	ll m1,m2,d1,d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if(m1!=m2){
		cout << 1;
	}
	else{
		cout << 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define ll long long
#define MOD 1000000007
#define INF (int)1e9
#define EPS 1e-9
/*
	C.Low Elements
*/
int main(){
	ll n; cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	ll an=0;
	/*for(ll i=0;i<n;i++){
		for(ll j=0;j<=i;j++){
			if(arr[j]>=arr[i]){
				continue;
			}
			else{
				an++;
				break;
			}
		}
	}
	cout<<n-an;*/
	ll x=0;
	for(ll i=0;i<n;i++){
		if(arr[i]==1){
			x=i;
			break;
		}
	}
	an+=n-(x+1);
	ll k=0,t=0;
	while(k!=x){
		//cout<<k<<endl;
		ll j=k+1;
		for(;j<x;j++){
			if(arr[k]<arr[j]){
				t++;
			}
			else{
				break;
			}
		}
		k=j;
	}
	an+=t;
	cout<<n-an;
    return 0;
}



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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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

const int inf=100000000;



llong func(int n){
    if(n == 0) return 1;
    return n*func(n-1)%MOD;
}

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

    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;

}

Measured memory_bytes: 256
n, q = map(int, input().split())
a = list(map(int, input().split()))
s = [0] 
#i~jの和: s[j+1]-s[i]
for p in a:
	s.append(s[-1] + p)
oe = [a[0], a[1]]
#oe[i]: range(i, -1, -2)の和
for i in range(2, n):
	oe.append(oe[-2]+a[i])

for _ in range(q):
	x = int(input())
	if 2*x > a[n-2] + a[n-1]:
		print(oe[n-1])
	elif abs(x - a[0]) <= abs(x - a[n//2]):
		print(s[n] - s[n//2])
	else:
		ok = 0
		ng = n + 1
		while abs(ng-ok) > 1:
			mi = (ng+ok) // 2
			if abs(x - a[n - mi]) <= abs(x - a[n - (mi+1)//2]):
				ok = mi
			else:
				ng = mi
		ans = s[n] - s[n-(ok+1)//2]
		if n - (ok+1)//2 * 2 - 1 >= 0:
			ans += oe[n - (ok+1)//2 * 2 - 1]
		print(ans)

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

typedef long long Long;
int arr[200];
int main(){
	cin.tie(0);ios::sync_with_stdio(0);
	int N;
	
	cin >> N;
	for( int i = 0; i < N; i++ )
		cin >> arr[i];
	
	int maximo = 0;
	for( int i = 0; i < N; i++ ){
		for( int j = 0; j < N; j++ ){
			if( i == j ) continue;
			maximo = max(maximo, abs(arr[i]-arr[j]));
		}
	}
	
	cout << maximo << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const ll MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modinv(ll a) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

ll modpow(ll x, ll n) {
  ll ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= MOD;
    (x *= x) %= MOD;
    n >>= 1;
  }
  return ret;
}

struct Eratos {
    vector<int> primes;
    vector<bool> isprime;
    vector<int> min_factor;

    Eratos(int MAX) : primes(),
                      isprime(MAX+1, true),
                      min_factor(MAX+1, -1) {
        isprime[0] = isprime[1] = false;
        min_factor[0] = 0, min_factor[1] = 1;
        for (int i = 2; i <= MAX; ++i) {
            if (!isprime[i]) continue;
            primes.push_back(i);
            min_factor[i] = i;
            for (int j = i*2; j <= MAX; j += i) {
                isprime[j] = false;
                if (min_factor[j] == -1) min_factor[j] = i;
            }
        }
    }

    // prime factorization
    vector<pair<int,int>> prime_factorize(int n) {
        vector<pair<int,int> > res;
        while (n != 1) {
            int prime = min_factor[n];
            int exp = 0;
            while (min_factor[n] == prime) {
                ++exp;
                n /= prime;
            }
            res.push_back(make_pair(prime, exp));
        }
        return res;
    }
};

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

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

  

struct UnionFind {
    vector<int> par; 

    UnionFind(int N) : par(N) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y); 
        if (rx == ry) return; 
        par[rx] = ry; 
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    cin >> N >> K;
    if(N < 2*(K-1) + 1) cout << "NO";
    else cout << "YES";
     
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    int N, A;
    cin >> N;
    int num[N] = {};
    for(int i = 0; i < N - 1; i++){
        cin >> A;
        num[A - 1]++;
    }
    for(int i = 0; i < N; i++)cout << num[i] << endl;
    return 0;
}


Measured memory_bytes: 4436
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))


(let* ((n (read))
	   (m (read))
	   (ans (make-array (1+ n) :initial-element 0)))
  (dotimes (i m)
	(let ((a (read))
		  (b (read)))
	  (incf (aref ans a))
	  (incf (aref ans b))))
  (loop for i from 1 to n do
		(progn
		  (princ (aref ans i))
		  (fresh-line))))


Measured memory_bytes: 12084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;
signed main(){
  cout << setprecision(10) << fixed;
  double a,b,x;
  cin >> a >> b >> x;
  double s = x / a;
  double deg = 0;
  if(s > a * b /2){
    double m = (a*b-s)*2/a;
    deg = atan2(m,a);
  }
  else{
    double n = s*2/b;
    deg = atan2(b,n);
  }
  double PI = acos(-1);
  cout << deg/(PI*2)*360 << endl;
}

Measured memory_bytes: 512
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int n,q;
lint ar[100005];
lint sum[100005][2];
lint sumA[100005];
int main(){
  cin>>n>>q;
  const lint M=1e10;
  REP(i,n){
    cin>>ar[i];
    ar[i]*=4;
  }
  REP(i,n){
    sum[i+1][0]=sum[i][0];
    sum[i+1][1]=sum[i][1];
    sum[i+1][i&1]+=ar[i];

    sumA[i+1]=sumA[i]+ar[i];
  }
  REP(hoge,q){
    lint v;cin>>v;
    v=v*4-1;

    lint lb=-1,ub=M;
    while(ub-lb>1){
      lint md=(lb+ub)>>1;
      lint L=v-md,R=v+md;
      int L1=lower_bound(ar,ar+n,L)-ar,R1=lower_bound(ar,ar+n,R)-ar;
      int cntA=R1-L1,cntT=n-R1;
      if(cntA<=cntT){
        lb=md;
      }else{
        ub=md;
      }
    }
    int L1=lower_bound(ar,ar+n,v-lb)-ar,R1=lower_bound(ar,ar+n,v+lb)-ar;

    lint res=sum[L1][((n-L1)&1)^(L1&1)^1]+(sumA[n]-sumA[R1]);
    printf("%lld\n",res/4);
  }
  return 0;
}





Measured memory_bytes: 4864
#include<stdio.h>
int ta[10010],to[60010],nt[60010],id[10010],cmp[100010],r=0,f[10010]={0};
void sdfs(int e,int s,int k){
  int i;
  f[s]++;
  for(i=ta[s];i+1;i=nt[i]){
    if(i<e&&k<0&&f[to[i]]==0||i>=e&&k>=0&&f[to[i]]==1)sdfs(e,to[i],k);
  }
  k<0?(id[r++]=s):(cmp[s]=k);
}
void scc(int v,int e,int *a,int *b){
  int i,k;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    ta[a[i]]=i;
    ta[b[i]]=i+e;
  }
  for(i=k=0;i<v;i++){
    if(f[i]==0)sdfs(e,i,-1);
  }
  for(i=r;i;i--){
    if(f[id[i-1]]==1)sdfs(e,id[i-1],id[i-1]);
  }
}
int main(){
  int v,e,a[100010],b[100010],s,t,i;
  scanf("%d %d",&v,&e);
  for(i=0;i<e;i++)scanf("%d %d",&a[i],&b[i]);
  scc(v,e,a,b);
  scanf("%d",&v);
  while(v--){
    scanf("%d %d",&s,&t);
    printf("%d\n",cmp[s]-cmp[t]?0:1);
  }
  return 0;
}

Measured memory_bytes: 2032
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
H = LIST()

tmp = 0
ans = 0
for i in range(1, N):
	if H[i-1] >= H[i]:
		tmp += 1
	else:
		ans = max(ans, tmp)
		tmp = 0
ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 15044
#include<stdio.h>
#include <iostream>
#include <cmath>
using namespace std;

int main ()
{
    double x1,y1,x2,y2,x3,y3; 
    cin>>x1>>y1>>x2>>y2;
    x3=pow(x1-x2,2);
    y3=pow(y1-y2,2);
    printf("%f",sqrt(x3+y3));
    return 0;
}



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

int abs(int a,int b){
  if(a>b){
    return a-b;
  }else{
    return b-a;
  }
}

int main(){
  int n;
  cin>>n;
  int a[n+2];
  a[0]=0;
  a[n+1]=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  int pre;
  int sum=0;
  int ans;
  for(int i=1;i<=n+1;i++){
    sum+=abs(a[i]-a[i-1]);
  }
  for(int i=1;i<=n;i++){
    ans=sum+abs(a[i+1]-a[i-1])-abs(a[i]-a[i-1])-abs(a[i+1]-a[i]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1664
V, E, root = map(int, input().split())
visited = [False] * V
nodes = [[] for i in range(V)]
cost = [[] for i in range(V)]
for i in range(E):
    s, t, d = map(int, input().split())
    nodes[s].append(t)
    cost[s].append(d)

dist = [float('inf')] * V
dist[root] = 0

negative_cycle = False

for k in range(V):
    for i in range(V):
        for j in range(len(nodes[i])):
            if dist[nodes[i][j]] > dist[i] + cost[i][j]:
                dist[nodes[i][j]] = dist[i] + cost[i][j]
                if k == V - 1:
                    dist[nodes[i][j]] = -float('inf')
                    negative_cycle = True
if negative_cycle:
    print('NEGATIVE CYCLE')
else:
    for i in range(V):
        if dist[i] == float('inf'):
            print('INF')
        else:
            print(dist[i])

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

int main() {

 int n;
 cin >> n;
  
 while (n != 0){
    
  vector<int>N(n);
  for (int i = 0; i < n; i++) {
    cin >> N.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += N.at(i);
  }
  
  double ave = 1.0 * sum / n;
  double sum2 = 0;
  for (int i = 0; i < n; i++) {
    sum2 += (N.at(i) - ave)*(N.at(i) - ave);
  }
  double b = sqrt(sum2 / n);
  
  printf("%.8lf\n",b);
  cin >> n;
 }
}




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

bool debug = 0;	

void solve() {
    int n, k;
    cin >> n >> k;
    ll ans;
    if (k % 2) {
        ll num = n / k;
        ans = num * num * num;
    } else {
        ll num = n / k;
        ll num1 = n / (k / 2) - num;
        ans = num * num * num + num1 * num1 * num1;
    }
    cout << ans << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}

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

int main(){

    int N, M, X;
    cin >> N >> M >> X;
    int C[N];
    int A[N][M];
    rep (i, N){
        cin >> C[i];
        rep (j, M){
            cin >> A[i][j];
        }
    }

    int mi = INT_MAX;
    rep (bit, 1<<N){
        vector<int> cnt(M);
        int sumC = 0;
        rep (i, N){
            if (bit & (1<<i)){
                sumC += C[i];
                rep (j, M){
                    cnt[j] += A[i][j];
                }
            }
        }
        bool frag = 1;
        rep (i, M){
            if (cnt[i] < X) frag = 0;
        }
        if (frag) mi = min(mi,sumC);
    }

    if (mi == INT_MAX) cout << -1 << endl;
    else cout << mi << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int findSumOfDigits(int n) {

    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main() {

    int n, a, b;
    cin >> n >> a >> b;

    int sum = 0;
    int res = 0;

    for (int i = 1; i <= n; i++) {

        sum = findSumOfDigits(i);
        if (a <= sum && sum <= b)
            res += i;
    }

    cout << res << endl;
    
    return 0;

}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
int calc(int N){
  if(N==0){
    return 0;

  }
  else{
    return N*calc(N-1);
  }
}

int main() {
  ll N;
cin>>N;
string S[N];
ll alp_num[5];
ll count=0;
rep(i,5){
  alp_num[i]=0;
}
rep(i,N){
  
  cin>>S[i];
  if(S[i][0]=='M'){
    count++;
    alp_num[0]++;


  }
  else if(S[i][0]=='A'){
    count++;
    alp_num[1]++;
  }
  else if(S[i][0]=='R'){
    count++;
    alp_num[2]++;
  }
  else if(S[i][0]=='C'){
    count++;
    alp_num[3]++;
  }
  else if(S[i][0]=='H'){
    count++;
    alp_num[4]++;
  }
  
}
ll ans=0;
rep(i,5){
  rep2(j,i+1,5){
    rep2(k,j+1,5){
      ans+=alp_num[i]*alp_num[j]*alp_num[k];
    }
  }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 6144
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
const int N=3010,size=1<<20,mod=998244353;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,m;
ll f[N],ans;

int main() {
	qr(n); qr(m); 
	for(int i=1,x;i<=n;i++) {
		qr(x); f[0]++; if(x>m) continue;
		ans+=1LL*(n-i+1)*f[m-x]%mod;
		for(int j=m-x;j>=0;j--) (f[j+x]+=f[j])%=mod;
	}
	pr2(ans%mod);
	return 0;
}


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

using namespace std;

using ll = long long;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int X;
    cin >> X;

    set<ll> s{0};

    ll i5_prev = 0;
    for (ll i = 1; ; ++i) {
        ll i5 = i * i * i * i * i;
        if (i5 - i5_prev > X) {
            break;
        }
        s.insert(i5);
        i5_prev = i5;
    }

    for (ll A = 0; ; ++A) {
        ll A5 = A * A * A * A * A;
        ll abs_B5 = abs(A5 - X);
        if (s.count(abs_B5)) {
            for (ll abs_B = 0; ; ++abs_B) {
                if (abs_B * abs_B * abs_B * abs_B * abs_B == abs_B5) {
                    ll B;
                    if (A5 - X >= 0) {
                        B = abs_B;
                    } else {
                        B = -abs_B;
                    }
                    cout << A << " " << B << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
      	int y = x / 100;
        int z = x % 100;
        int i;
        if(z == 0){
          System.out.println(1);  
          System.exit(0);
        }
      	for(i = 1;i <= y; i++){
          if(z >= 5){
            z -= 5;
          }else if(z >= 4){
            z -= 4;
          }else if(z >= 3){
            z -= 3;
          }else if(z >= 2){
            z -= 2;
          }else if(z >= 1){
            z -= 1;
          }
        }
    	if(z == 0){
           System.out.println(1);  
        }else{
           System.out.println(0);  
        }
    }
}

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

using namespace std;

int N, M, cnt[200005][2], vis[200005];
char ch[200005];
vector<int> G[200005];
queue<int> que;

int main() {
  scanf("%d%d", &N, &M);
  scanf("%s", ch + 1);
  for (int i = 1, u, v; i <= M; i++) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v), cnt[u][ch[v] - 'A']++;
    G[v].push_back(u), cnt[v][ch[u] - 'A']++;
  }
  for (int i = 1; i <= N; i++)
    if (!cnt[i][0] || !cnt[i][1]) vis[i] = true, que.push(i);
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    for (auto to : G[now]) {
      if (vis[to]) continue;
      cnt[to][ch[now] - 'A']--;
      if (!cnt[to][0] || !cnt[to][1]) vis[to] = true, que.push(to);
    }
  }
  bool flag = false;
  for (int i = 1; i <= N && !flag; i++)
    if (!vis[i]) flag = true;
  puts(flag ? "Yes" : "No");
  return 0;
}


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

struct edge
{
    int to;
    int cost;
};
 
// 色を0か1で塗る
void dfs(vector<vector<edge>> &graph, vector<int> &color, int v, int p, int c)
{
    color[v] = c; //塗る
    for (int i = 0; i < (int)graph[v].size(); i++)
    {
        edge e = graph[v][i];
        if (e.to == p)
        {
            continue;
        }
        if (e.cost % 2)
        {
            dfs(graph, color, e.to, v, 1 - c);
        }
        else
        {
            dfs(graph, color, e.to, v, c);
        }
    }
}
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<edge>> graph(n);
    vector<int> color(n, 0);
    for (int i = 0; i < n - 1; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        graph[u].push_back(edge{v, w});
        graph[v].push_back(edge{u, w});
    }
    dfs(graph, color, 0, -1, 0);
    for (int i = 0; i < n; i++)
    {
        cout << color[i] << endl;
    }
}

Measured memory_bytes: 9728
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


long long check(long long current)
{
    if(current == 1){
        return 1;
    }else{
        long long r = check(current/2);
        return r * 2 +1;
    }
}


int main(void)
{
    long long h;
    cin >>h;

    printf("%lld\n", check(h));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;

	int ans;

	ans = (H - h) * (W - w);

	printf("%d",ans);


	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int x,n,i,a[105];
    int sum=0,j=0;
    scanf("%d%d",&n,&x);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    int min=a[0];
    for(i=1;i<n;i++)
    {
        if(a[i]<min)
            min=a[i];
    }
    if((x-sum)>=min)
    {
        j=(x-sum)/min;
    }
    printf("%d",n+j);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,k;
	cin >> n >> k;
	map<long long,long long> cnt;
	for ( int i =0; i< n;  i ++)
	{
		int x, y;
		cin >> x >> y;
		cnt[x] += y;
	}
	long long sum = 0;
	for ( auto it : cnt)
	{

		if ( it.second + sum >= k )
		{
			cout << it.first ;
			return 0;
		}
		sum += it.second;
	}

	return 0;
}

Measured memory_bytes: 4224
N = int(input())
A = list(map(int,input().split(' ')))

flag = True
for a in A:
    if (a%2)!=0:
        continue
    else:
        if(a%3)==0:
            continue
        elif(a%5)==0:
            continue
        else:
            flag=False
            break

if flag:
    print('APPROVED')
else:
    print('DENIED')

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

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int dx4[4]={1,-1,0,0};
int dy4[4]={0,0,1,-1};

int cti(char c){
  if(c=='i'){return 1;}
  if(c=='x'){return 10;}
  if(c=='c'){return 100;}
  if(c=='m'){return 1000;}
  return 0;
}

int sti(char s[]){
  int i=0,l=strlen(s),r=0,k=1;
  while(i<l){
    if(cti(s[i])!=0){
      //printf("%c %d\n",s[i],k);
      r+=cti(s[i])*k;
      k=1;
    }
    else{k=s[i]-'0';}
    i++;
  }
  return r;
}

char de[8]="mcxi";
void its(int a){
  //printf("<%d>",a);
  int k=1000,i=0,v;
  for(i=0;i<4;i++){
    v=a/k;
    if(v>=2){printf("%d",v);}
    if(v!=0){printf("%c",de[i]);}
    a%=k;k/=10;
  }
  printf("\n");
}

int main(){
  int i,j,n;
  char a[16],b[16];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%s",a,b);
    its(sti(a)+sti(b));
  }
  return 0;
}



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

int main() {
	int n,k,count=0;
  	cin>>n>>k;
  	
  	int arr[n];
  	for(int i=0;i<n;i++)
    {
      cin>>arr[i];
      if(arr[i]>=k)
        count++;
    }
  
  	cout<<count<<endl;
}


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

#define ROOT 0
#define INTERNAL 1
#define LEAF 2

typedef struct{
  int id;//ノードID
  int p;//ノードの親のID
  int d;//ノードの深さ
  int h;//ノードの深さ
  char kind[13];//ノードの種類
  int lc;
  int rc;//ノードの子供のID
  int k;
  int sib;
  int deg;
}node;

node *t;
int n;//要素数

//高さの決定
void getHeight(int id, int k){
  if(t[id].deg==0){
    t[id].h = 0;
  }
  if(t[id].h < k){
    t[id].h = k;
  }
  if(t[id].p!=-1){
    getHeight(t[id].p, ++k);
  }
}
//兄弟の検索
void getSib(){
  int i,j;
  for(i=0; i<n; i++){
    if(strcmp(t[i].kind,"root")==0)t[i].sib=-1;
    for(j=i+1; j<n; j++){
      if(t[i].d==t[j].d){
        if(t[i].p==t[j].p){
          t[i].sib=t[j].id;
          t[j].sib=t[i].id;
        }
      }
    }
  }
}
//深さの決定
int getDepth(int id){
  if(t[id].p!=-1){
    return getDepth(t[id].p) + 1;
  }
  return 0;
}
//表示
void print(){
  int i;
  //printf("print now\n");
  for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",t[i].id,t[i].p,t[i].sib,t[i].deg,t[i].d,t[i].h,t[i].kind);
  }
}
//----------------------------------------------------------
int main() {
  int i,j;
  int count;
  int id;
  int left, right;

  //全体の要素数の入力
  scanf("%d",&n);
  t = (node*)malloc(sizeof(node) * n);
  //ID[i]のノードの情報を入力
  for(i=0; i<n; i++){
    //printf("In ID: ");
    scanf("%d",&id);//ID入力
    t[id].id = id;
    scanf("%d%d",&t[id].lc,&t[id].rc);
    t[id].p = -1;
    t[id].d = 0;
    t[id].h = 0;
    t[id].sib = -1;
    t[id].deg = 0;
  }
  //  printf("end input\n");
  for (i = 0; i < n; i++) {
    if(t[i].lc!=-1){
      t[t[i].lc].p=t[i].id;
      t[i].deg++;
      //printf("%d:%d\n",t[left].id,t[left].p);
    }
    if(t[i].rc!=-1){
      t[t[i].rc].p=t[i].id;
      t[i].deg++;
      //printf("%d\n",t[right].id,t[right].p);
    }
  }
  //print();
  //ノードの種類の決定
  for(i=0; i<n; i++){
    if(t[i].p==-1){
      strcpy(t[i].kind,"root");
    }else if((t[i].lc==-1)&&(t[i].rc==-1)){
      strcpy(t[i].kind,"leaf");
    }else strcpy(t[i].kind,"internal node");
    //階層の決定
    t[i].d = getDepth(t[i].id);
    getHeight(i, 0);
    //兄弟の決定
    getSib();
  }
  //printf("kink fin\n" );
  print();

  return 0;
}



Measured memory_bytes: 2104
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static final boolean[] pc = createPrimeChecker();
    private static final int MAX = 1000000;
    
    public static void main(String[] args) {
        while(scn.hasNextInt()) {
            System.out.println(countPrime(scn.nextInt()));
        }
    }
    
    private static boolean[] createPrimeChecker() {
        boolean[] ary = new boolean[MAX];
        ary[2] = true;
        for(int i = 3; i < MAX; i += 2) {
            ary[i] = !ary[i];
        }
        for(int i = 3; i <= Math.sqrt(MAX); i += 2) {
            if(ary[i]) {
                for(int j = i * 2; j < MAX; j += i) {
                    ary[j] = false;
                }
            }
        }
        return ary;
    }
    
    private static int countPrime(int n) {
        int cnt = n > 1 ? 1 : 0;
        for(int i = 3; i <= n; i += 2) {
            cnt += pc[i] ? 1 : 0;
        }
        return cnt;
    }
}

Measured memory_bytes: 27716
#include<cstdio>

using namespace std;

int main(void){
	double work,data=0;
	int mon,num,cnt=0,sum=0,ave;

	while((scanf("%d,%d",&mon,&num))!=EOF){
		sum+=mon*num;
		cnt++;
		data+=num;
	}
	work=data/cnt;
	ave=work+0.5;
	printf("%d\n%d\n",sum,ave);

	return 0;
}

Measured memory_bytes: 0
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())
ans_a = 0
ans_b = 0

for i in range(n):
    a, b = input().split()
    if a > b:
        ans_a += 3
    elif b > a:
        ans_b += 3
    else:
        ans_a += 1
        ans_b += 1

print(ans_a, ans_b)




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

namespace ConsoleApplication51
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                double a = int.Parse(Console.ReadLine());
                double b = int.Parse(Console.ReadLine());
                if (a == 0 && b == 0)
                    break;
                double c = a * a;
                double d = (a / 2) * (a / 2) + b * b;
                d = Math.Sqrt(d);
                c += d * a * 2;
                Console.WriteLine(c);

            }
        }
    }
}

Measured memory_bytes: 9188
#include<cstdio>
int a[5];
int main()
{
    for(int i=1;i<=4;i++)
    {
    	char c=getchar();
    	a[i]=c-'0';
	}
	for(int i=0;i<8;i++)
	{
		int ans=a[1];
		for(int j=0;j<3;j++)
		if(i&(1<<j)) ans+=a[j+2];
		else ans-=a[j+2];
		if(ans!=7) continue;
		printf("%d",a[1]);
		for(int j=0;j<3;j++)
		{
			if(i&(1<<j)) printf("+");
			else printf("-");
			printf("%d",a[j+2]);
		}
		return printf("=7"),0;
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();

    int[] num = new int[26];
    for(int i = 0 ;i < S.length() ; i ++){
      num[ ( (int) S.charAt(i) )- 97 ] ++ ;
    }
    boolean notFoundFlag = true;
    for(int i = 0 ; i< num.length ; i++){
      if( num[i] == 0 ){
        System.out.println( (char) (i + 97) );
        notFoundFlag = false;
        break;
      }
    }
    if(notFoundFlag){
      System.out.println("None");
    }
  }
}


Measured memory_bytes: 23132
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
#include <set>
#include <iostream>
using namespace std;

inline int getInt(){ int s; scanf("%d", &s); return s; }
inline string getStr(){ char buff[256]; scanf("%s", buff); return buff; }

int main(){
  const int n = getInt();
  set<string> u;

  REP(i,n) u.insert(getStr());

  bool lock = true;

  const int m = getInt();

  REP(i,m){
    const string s = getStr();
    if(u.count(s)){
        if(lock){
          printf("Opened by ");
        }else{
          printf("Closed by ");
        }
        lock = !lock;
    }else{
        printf("Unknown ");
    }
    puts(s.c_str());
  }

  return 0;
}

Measured memory_bytes: 1248
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define ll long long int
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};
int main() {
	int a,b,c,ans=0;
	cin>>a>>b>>c;
	if(a+b<c){
		ans=a+b+1+b;
	}else ans=b+c;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#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<ll> a(n), b(n), c;
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }

    ll x = 0;
    ll ans = 0;
    rep(i, n) {
        if(a[i] < b[i]) {
            x += b[i] - a[i];
            ans++;
        }
        else if(b[i] < a[i]) {
            c.push_back(a[i] - b[i]);
        }
    }
    sort(c.rbegin(), c.rend());

    rep(i, c.size()) {
        if(x <= 0) {
            break;
        }
        x -= c[i];
        ans++;
    }

    if(0 < x) {
        cout << -1;
    }
    else {
        cout << ans;
    }

    cout << endl;
    return 0;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetLongNumArray();
            var count = 0;
            foreach (var item in input)
            {
                count++;
                if (item == 0)
                {
                    Console.WriteLine(count);
                }
            }
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 28020
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int N;
    cin >>N;
    ll a=2,b=1,tmp=0;
    int i;
    for(i=1;i<N;i++){
      tmp=b;
      b=a+b;
      a=tmp;
    }
    cout << b;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans_index = 0;
  int sum = 0;
  for (int i = 1; i <= n; i++){
    sum += i;
    if(sum >= n){
      ans_index = i;
      break;
    }
  }
  int non_num = sum - n;
  for (int i = 1; i <= ans_index; i++){
    if(i != non_num){
      cout << i << (i == ans_index ? "\n" : " ");
    }
  }
}

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

int A[300010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 0;i < 3 * n;i++){
		scanf("%d",&A[i]);
	}
	sort(A,A + 3 * n);
	long long ans = 0;
	int flag = 1;
	for(int i = n;i < 3 * n;i++){
		if(flag) {
			ans += A[i];	
			flag = 0;
		}
		else{
			flag = 1;
		}
	}
	printf("%lld",ans);
	return 0;
} 

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

int main(){

    int W,H,x,y,r;
    cin >> W >>H>>x>>y>>r;

    if (x < r || W-x < r ||y < r || H-y < r) cout << "No" <<endl;
    else cout << "Yes" <<endl;

}




Measured memory_bytes: 3096
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    h, w = ns()
    mat = [list(sys.stdin.readline()) for _ in range(h)]

    total = h + w - 1
    cnt = 0
    for i in range(h):
        for j in range(w):
            if mat[i][j] == "#":
                cnt += 1

    if cnt != total:
        print("Impossible")
        exit(0)

    def dfs(x, y):
        if x == w-1 and y == h-1:
            print("Possible")
            exit(0)

        if x + 1 < w:
            if mat[y][x + 1] == "#":
                dfs(x + 1, y)
        if y + 1 < h:
            if mat[y + 1][x] == "#":
                dfs(x, y + 1)

    dfs(0, 0)
    print("Impossible")


if __name__ == '__main__':
    main()


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

const int MAX_N=41;

int n,sum,t,ok; string w;
vector<int> words(MAX_N);
vector<int> each={5,7,5,7,7};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n,n){
        for (int i=0;i<n;++i){
            cin >> w; words[i]=(int)w.size();
        }
        for (int i=0;i<n;++i){
            t=i,ok=1;
            for (int j=0;j<5;++j){
                sum=0;
                for (int k=t;k<n;++k){
                    sum+=words[k];
                    if (sum==each[j]){t=k+1; break;}
                    if (sum>each[j]){ok=0; break;}
                }
            }
            if (ok){
                cout << i+1 << '\n';
                break;
            }
        }
    }
}


Measured memory_bytes: 3160
import java.util.Arrays;
import java.util.*;
class Main
{
	static ArrayList<Integer> adj[];
	static int dpi[],dpo[],vis[];
	static int ans;
	public static void main (String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt(); int m=sc.nextInt();
		dpi=new int[n]; dpo=new int[n];
		adj=new ArrayList[n]; ans=0;
		for(i=0;i<n;i++)
			adj[i]=new ArrayList();
		for(i=0;i<m;i++) 
		{
			int u=sc.nextInt()-1; int v=sc.nextInt()-1;
			adj[u].add(v); 
		}
		vis=new int[n];
		for(i=0;i<n;i++)
		{
			if(vis[i]==0)
				dfs(i,-1,0);
		}
		for(i=0;i<n;i++)
			if(dpi[i]+dpo[i]>ans)
				ans=dpi[i]+dpo[i];
		System.out.println(ans);
	}
	public static void dfs(int v,int p,int l)
	{
		vis[v]=1;
		dpi[v]=Math.max(dpi[v], l);
	/*	if(p!=-1)
		{
			dpo[p]=Math.max(dpo[p], 1+dpo[v]);
			dpi[v]=Math.max(dpi[v], dpi[p]+1);
		} */
		for(int node:adj[v])
		{
			if(vis[node]==0)
			{
				dfs(node,v,l+1);
				dpo[v]=Math.max(dpo[v], 1+dpo[node]);
			}
			else
			{
				dpi[node]=Math.max(dpi[node], dpi[v]+1);
				dpo[v]=Math.max(dpo[node]+1, dpo[v]);
			}
		}	
	}
} 

Measured memory_bytes: 75856
#include <stdio.h>

int main(void) {
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);

	int grid[6][6] = {0};
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			scanf(" %c", &c);
			if (c == '#')
				grid[i][j] = 1;
		}
	}

	int ans = 0;
	for (unsigned int b = 0; b < (1u<<(h+w)); b++) {
		int cnt = 0;
		for (int i = 0; i < h; i++) {
			if (b & (1u<<i))
				continue;
			for (int j = 0; j < w; j++) {
				if (b & (1u<<(h+j)))
					continue;
				if (grid[i][j])
					cnt++;
			}
		}

		if (cnt == k)
			ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define MAX_DATA 100001
typedef long long ll;

/*データ構造queueを実装*/
struct queue
{
    ll arr[MAX_DATA];
    int first; //次にpopする配列の添え字
    int last;  //次にpushする配列の添え字
};

ll push(struct queue *que, ll input)
{
    if (que->arr[que->last] <= MAX_DATA)
    {
        que->arr[que->last] = input;

        // 添え字の更新
        que->last++;

        //printf("push:%lld\n", input);
        return 0;
    }
    else
    {
        //printf("これ以上データを追加できません。\n");
        return -1;
    }
}

ll pop(struct queue *que)
{
    ll output = que->arr[que->first];

    if (output != -1)
    {
        que->arr[que->first] = -1;

        // 添え字の更新
        que->first++;

        //printf("pop:%lld\n", output);
        return output;
    }
    else
    {
        //printf("データがありません。\n");
        return -1;
    }
}

/*queue初期化*/
void init_queue(struct queue *que)
{
    int i;

    for (i = 0; i < MAX_DATA; i++)
        que->arr[i] = -1;

    que->first = 0;
    que->last = 0;
}

/*queueの確認*/
void show_queue(struct queue *que)
{
    int i;
    for (i = 0; i < MAX_DATA; i++)
    {
        if (que->arr[i] != -1)
            printf("%lld ", que->arr[i]);
    }

    printf("\nfirst:%d last%d\n\n", que->first, que->last);
}

/*メイン関数*/
int main(void)
{
    int k;
    ll lunlun[100001]; // ルンルン数保存用配列
    int lunlunCnt; // ルンルン数配列の添え字
    struct queue que;

    scanf("%d", &k);
    if (k < 10) // kが9以下ならそのまま出力
    {
        printf("%d\n", k);
        return 0;
    }

    /*1から9をあらかじめpushしておく*/
    init_queue(&que);
    for (int i = 1; i <= 9; i++)
        push(&que, (ll)i);

    /*1から9はあらかじめ代入しておく*/
    for (lunlunCnt = 0; lunlunCnt < 9; lunlunCnt++)
        lunlun[lunlunCnt] = lunlunCnt + 1;

    /*queueが空になるまでループ*/
    while (que.first != que.last)
    {
        /*popした数値の末尾に数をくっつけて新たなルンルン数を生成*/
        ll source = pop(&que); // もとになる数
        for (int i = -1; i <= 1; i++) // 絶対値が1以下
        {
            ll tmp = source % 10 + i; // 末尾の値

            if (tmp < 0 || tmp > 9) // 条件を満たさないならスキップ
                continue;

            /*sourceを10倍して末尾にtmpをくっつける*/
            ll num = source * 10 + (ll)tmp;

            /*保存用配列とqueueに新たなルンルン数を代入*/
            lunlun[lunlunCnt++] = num;
            push(&que, num);
        }
        if (lunlunCnt > k)
            break;
    }

    printf("%lld\n", lunlun[k - 1]);

    return 0;
}

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

int main() {
  int a,b,sum=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    int x,y,z,w;
    x=i%10;//1桁目
    y=i/10000;//５桁目
    z=i%100;
    z/=10;//２桁目
    w=i/1000;
    w%=10;//４桁目
    if(x==y && z==w)
      sum++;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.root = [-1] * (n + 1)
            self.rnk = [0] * (n + 1)

        def find_root(self, x):
            while self.root[x] >= 0:
                x = self.root[x]
            return x

        def unite(self, x, y):
            x = self.find_root(x)
            y = self.find_root(y)
            if x == y:
                return
            elif self.rnk[x] > self.rnk[y]:
                self.root[x] += self.root[y]
                self.root[y] = x
            else:
                self.root[y] += self.root[x]
                self.root[x] = y
                if self.rnk[x] == self.rnk[y]:
                    self.rnk[y] += 1

        def isSameGroup(self, x, y):
            return self.find_root(x) == self.find_root(y)

        def size(self, x):
            return -self.root[self.find_root(x)]

    class Bit:
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

        def lower_bound(self, w):
            if w <= 0:
                return 0
            x = 0
            k = 1 << (self.size.bit_length() - 1)
            while k:
                if x + k <= self.size and self.tree[x + k] < w:
                    w -= self.tree[x + k]
                    x += k
                k >>= 1
            return x + 1

    N = int(input())
    XY = []
    x2i = [0] * (N+1)
    y2i = [0] * (N+1)
    for i in range(1, N+1):
        x, y = map(int, input().split())
        XY.append((x, y))
        x2i[x] = i
        y2i[y] = i
    bit = Bit(N)
    UF = UnionFind(N)

    XY.sort(key=lambda z: z[1])
    r = N+1
    for i in range(N):
        x, y = XY[i]
        bit.add(x, 1)
        #print(x, r)
        if x < r:
            for xx in range(x, r-1):
                UF.unite(x2i[xx], x2i[xx+1])
            if bit.sum(N) - bit.sum(r-1) != N - r + 1:
                UF.unite(x2i[r-1], x2i[r])
            r = x
            if r == 1:
                break
    for i in range(1, N+1):
        print(UF.size(i))


if __name__ == '__main__':
    main()


Measured memory_bytes: 106424
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    IN(a, b);
    if (a != b)
    {
        rep(i, max(a, b))
        {
            cout << min(a, b);
        }
        cout << endl;
    }
    else
    {
        rep(i, min(a,b))
        {
            cout << a;
        }
        cout << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

int main(void) {
	string S;
	
	cin >> S;
	int len = S.length();
	bool res = (len % 2 == 0) ^ (S[0] == S[len - 1]);

	string ans = "First";
	if (res)
		ans = "Second";

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


Measured memory_bytes: 512