akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
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;
}
 
int main(){
  COMinit();
  int N,M;
  cin>>N>>M;
  vector<int> A(0,0);
  int cnt=0;
  for(int i=2; i<=M/i; i++){
    int tmp=0;
    while(M%i==0){
      M/=i;
      tmp++;
    }
    if(tmp>0){
      cnt++;
      A.push_back(tmp);
    }
  }
  if(M>1){
    cnt++;
    A.push_back(1);
  }
  ll ans=1;
  for(int i=0; i<cnt; i++){
    ans*=COM(A[i]+N-1, A[i]);
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12160
import math
from functools import reduce

n = int(input())
t = [int(input()) for _ in range(n)]

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(t))


Measured memory_bytes: 9576
/* An ACEASH Source code  */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double

#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>

#define vvi vector< vector < int > >
#define vvl vector< vector < ll > >

#define pii pair< int , int >
#define pll pair< ll , ll >

#define vpl vector< pll >
#define vpi vector< pii >

#define MOD 1000000007

#define mp make_pair
#define pb push_back

#define sare(v) (v).begin(),(v).end()

#define F first
#define S second

#define tez  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ld pie = 3.1415926535897932384626 ;



int main()
{

       ll n;
       cin>>n;
       ll arr[n];
       for(ll i=0;i<n;i++){cin>>arr[i];}
       ll ans=0;
       for(ll i=1;i<n;i++)
       {
           if(arr[i]<arr[i-1])
           {
               ans+=(arr[i-1]-arr[i]);
               arr[i]=arr[i-1];
           }
       }
       cout<<ans;






    return 0;
}




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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> cake(h,vector<int>(w));
    vector<string> berry(h);
    rep(i, h) cin >> berry.at(i);

    int ki = 0;
    rep(i, h) {
        int l = 0;
        rep(j, w) {
            if (berry.at(i).at(j) == '#') {
                ki++;
                for (int a = l; a <= j; ++a) {
                    cake.at(i).at(a) = ki;
                }
                l = j + 1;
            }
            else if (l != 0 && j == w-1) {
                for (int a = l; a <= j; ++a) {
                    cake.at(i).at(a) = ki;
                }
            }
        }
    }

    rep(i, w) {
        rep(j, h) {
            for (int k = j; k < h; ++k) {
                if (cake.at(j).at(i) != 0) break;
                cake.at(j).at(i) = cake.at(k).at(i);
            }
            for (int k = j; 0 <= k; --k) {
                if (cake.at(j).at(i) != 0) break;
                cake.at(j).at(i) = cake.at(k).at(i);
            }
        }
    }

    rep(i, h) {
        rep(j, w) {
            cout << cake.at(i).at(j);
            if (j < w-1) cout << ' ';
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

ll modpow(ll p, ll q) {
	ll ans = 1;
	ll pp = p % MOD;
	while (q) {
		if (q & 1) {
			ans *= pp;
			ans %= MOD;
		}
		q = q >> 1;
		pp *= pp;
		pp %= MOD;
	}
	return ans;
}
V<ll> fac, invfac;
void precom(int n) {
	fac.resize(0);invfac.resize(0);
	rep(i, n + 1) {
		if (i == 0)fac.push_back(1);
		else fac.push_back((fac[i - 1] * i) % MOD);
		invfac.push_back(modpow(fac[i], MOD - 2));
	}
	return;
}
ll com(int n, int r) {
	if (n < r || n < 0 || r < 0)return 0;
	int k = n - r;
	ll ans = fac[n];
	ans *= invfac[r];
	ans %= MOD;
	ans *= invfac[k];
	ans %= MOD;

	return ans;
}

int main() {

	precom(100000);
	int s;
	cin >> s;
	int ss = s / 3;
	ll ans = 0;
	for (int i = ss;i >= 1;i--) {
		int res = s - i * 3;
		ans += com(res + i - 1, res);ans %= MOD;
	}

	cout << ans << endl;

}

Measured memory_bytes: 5016
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	string S;
	cin >> S;
	bool a = S.size() % 2;
	bool b = S[0] == S[S.size() - 1];
	string ans = a ^ b ? "First" : "Second";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
}

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

    COMinit();

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));

    ll ans = 0;
    for (int i = N - 1; i >= K - 1; i--) {
        ans += COM(i, K - 1) * A[i];
        ans %= MOD;
    }

    rep(i, N - K + 1) {
        ans -= COM(N - i - 1, K - 1) * A[i];
        ans %= MOD;
        if (ans < 0) ans += MOD;
    }

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

Measured memory_bytes: 27524
s = input()
q = int(input())
l = []
r = []
c = 0
for _ in range(q):
  t = input().split()
  if t[0] == '1':
    c += 1
    a = l
    l = r
    r = a
  else:
    if t[1] == '1':
      l.append(t[2])
    else:
      r.append(t[2])
l = "".join(l[::-1])
r = "".join(r)
if c%2 ==0:
  print(l + s + r)
else:
  print(l + s[::-1] + r)

Measured memory_bytes: 6252
const Main = input => {
    input = input.trim();
    const kurai1 = parseInt(input.substring(input.length - 1), 10);

    if([2, 4, 5, 7, 9].includes(kurai1)) {
        console.log("hon");
    } else if([0, 1, 6, 8].includes(kurai1)) {
        console.log("pon")
    } else if([3].includes(kurai1)) {
        console.log("bon");
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29632
import math
from functools import reduce


k = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k += 1
ans = 0

for i in range(1,k):
    for j in range(i,k):
        #print(i,j)
        if i == j:
            ans += gcd(i,j)
        else:
            ans += gcd(i,j)*6

for i in range(1,k):
    for j in range((i+1),k):
        for h in range((j+1),k):
            #print(i,j,h)
            ans += gcd(i,j,h)*6


print(ans)


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

int main(){
    int n,m;
    cin >> n >> m;
    //int r=2;
    long ans1 = 1;
    long ans2 = 1;
    for (int i = n; i > n - 2; --i) {
        ans1 = ans1*i;
    }
        ans1 = ans1 / 2;


    for (int i = m; i > m - 2; --i) {
        ans2 = ans2*i;
    }
        ans2 = ans2 / 2;


    long ans = ans1 + ans2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

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

    int N;
    cin >> N;

    vector<int> X;

    // 入力値の取得と平均値算出用の和の計算
    int sum = 0;
    REP(i, N)
    {
        int temp;
        cin >> temp;
        X.push_back(temp);
        sum += temp;
    }

    // 平均値(端数切捨て)
    int ave = sum / X.size();

    int ans1=0;
    REP(i, N)
    {
        ans1 += pow((X.at(i) - ave), 2);
    }

    int ans2=0;
    REP(i, N)
    {
        ans2 += pow(X.at(i) - (ave+1), 2);
    }

    int ans = (ans1 < ans2) ? ans1 : ans2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
typedef long long ll;

using namespace std;
int n,m,q;
int ans[505][505];
vector<int> st[505];
int main() {
  cin >> n >> m >> q;
  int t[505] = {};
  for(int i = 0; i < m; i++) {
    int l,r;
    cin >> l >> r;
    l--;r--;
    st[l].push_back(r);
    t[r]++;
  }
  for(int i = 1; i <= n; i++) {
    t[i] += t[i-1];
    ans[0][i-1] = t[i-1];
  }

  for(int i = 0; i < n; i++) {
    int tmp[505] = {};
    for(int j = 0; j < st[i].size(); j++) {
      tmp[st[i][j]]--;
    }
    for(int j = 1; j <= n; j++) {
      tmp[j] += tmp[j-1];
      ans[i+1][j-1] = ans[i][j-1] + tmp[j-1];
    }
  }

  for(int i = 0; i < q; i++) {
    int p,q;
    cin >> p >> q;
    p--; q--;
    cout << ans[p][q] << endl;
  }
}
    

  
  
 

  


Measured memory_bytes: 3200
ABK=list(map(int,input().split()))

count=1
num=min(ABK[0],ABK[1])+1

while count<=ABK[2]:
 count=count+1
 flag=0
 while flag==0:
  num=num-1
  if ABK[0]%num==0 and ABK[1]%num==0:
    flag=1
  
  
print(num)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
int price,cnt=0,div[6]={500,100,50,10,5,1},i;
while(1){
cin>>price;
if(price==0)break;
price=1000-price;
for(i=0;i<6;i++){
if((price/div[i])!=0){
cnt+=(price/div[i]);
price-=(price/div[i])*div[i];
}
}
cout<<cnt<<endl;
cnt=0;
}
return 0;
}

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

int main(){
    char s[2000],pr[2000];
    int w,k=0,m;
    cin>>s>>w;
    m=strlen(s);
    for(int i=0;i<=m;i+=w)
    {
        pr[k]=s[i];
        k++;
    }
    pr[k]='\0';
    for(int i=0;pr[i]!='\0';i++){
        printf("%c",pr[i]);
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
ans = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(ans[int(input()) - 1])


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)

int a[100];
int N;

void sort(const int *n) {
	int b;
	rep(i, 0, N) {
		rep(j, i + 1, N) {
			if (a[i] < a[j]) {
				b = a[i];
				a[i] = a[j];
				a[j] = b;
			}
		}
	}
}

int main() {
	cin >> N;
	rep(i, 0, N) cin >> a[i];
	sort(a);

	int ans = 0;
	rep(i, 0, N) {
		ans += ((i % 2 == 0) ? a[i] : -a[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
#print(int(s[0:4]),s[5:7])
if int(s[0:4]) < 2019:
    print("Heisei")
elif int(s[0:4]) > 2019:
    print("TBD")
else:
    if int(s[5:7]) <= 4:
        print("Heisei")
    elif int(s[5:7]) > 4:
        print("TBD")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];
    ll maxi=0,mini=0;
    ll a,b;
    rep(i,n)if(chmax(maxi,v[i]))a=i;
    rep(i,n)if(chmin(mini,v[i]))b=i;
    if(maxi>=-mini){
        cout << 2*n-2 <<endl;
        rep(i,n){
            if(a==i)continue;
            cout << a+1 <<" " << i+1 <<endl;
        }
        rep(i,n-1){
            cout << i+1 <<" " <<i+2 <<endl;
        }
    }
    else {
        cout << 2*n-2 <<endl;
        rep(i,n){
            if(b==i)continue;
            cout << b+1 <<" " << i+1 <<endl;
        }
        per(i,n-1){
            cout << i+2 <<" " <<i+1 <<endl;
        }
    }
}

Measured memory_bytes: 256
function main(input) {
  const tmp = input.trim().split('\n')
  const n = parseInt(tmp[0], 10)
  const a = tmp[1].split(' ').map((n) => parseInt(n, 10))

  const m = new Map()

  a.forEach((i) => {
    if (m.has(i)) {
      m.set(i, m.get(i) + 1)
    } else {
      m.set(i, 1)
    }
  })

  let s = 0
  m.forEach((v, _) => {
    s += (v - 1) * v / 2
  })

  a.forEach((i) => {
    console.log(s - m.get(i) + 1)
  })
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 83064
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)    \
    rep(i, n)           \
    {                   \
        ll x;           \
        cin >> x;       \
        v.push_back(x); \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
struct edge
{
    ll to, cost;
};
struct Gragh
{
    vector<vector<edge>> G;
    ll N;
    vl visited;
    vl active;
    ll isloop = 0;
    vl toposo;
    void init(ll n)
    {
        N = n;
        G.resize(N);
        visited = vl(N, 0);
    }

    void add(ll a, ll b, ll c = 1)
    {
        G[a].push_back((edge){b, c});
    }

    void resetv(void)
    {
        visited = vl(N, 0);
    }

    vl TOPOSO(void)
    {
        active.resize(N);
        active = vl(N, 0);
        rep(i, N)
        {
            if (visited[i] == 0)
                dfs(i);
        }
        reverse(all(toposo));
        return toposo;
    }

    void dfs(ll x)
    {
        visited[x] = 1;
        active[x] = 1;
        for (edge i : G[x])
        {
            if (visited[i.to] == 0)
            {
                dfs(i.to);
            }
            else
            {
                if (active[i.to] == 1)
                    isloop = 1;
            }
        }
        active[x] = 0;
        toposo.push_back(x);
    }
};

int main()
{
    cin >> n >> m;
    Gragh g;
    g.init(n);
    rep(i, m)
    {
        cin >> x >> y;
        g.add(x, y);
    }

    vl A = g.TOPOSO();
    rep(i, n)
    {
        cout << A[i] << endl;
    }
}


Measured memory_bytes: 4580
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
int32_t main()
{
	fast;
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n-1);
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n-1;i++)
		cin>>c[i];
	int s=0;
	for(int i=0;i<n;i++)
	{
		if(i!=n)
		{
			if(a[i+1]==a[i]+1)
				s+=c[a[i]-1];
		}
		s+=b[i];
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes";
    else cout<<"No";
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
*/

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W, K;
char S[330][330];
bool isempty[330];
int A[330][330];

int main()
{
	scanf("%d%d%d", &H, &W, &K);
	for (int i = 0; i < H; ++i) scanf("%s", S[i]);

	for (int i = 0; i < H; ++i) {
		isempty[i] = true;
		for (int j = 0; j < W; ++j) if (S[i][j] == '#') isempty[i] = false;
	}
	int cnt = 0;
	for (int i = 0; i < H; ++i) {
		if (isempty[i]) continue;
		for (int j = 0; j < W; ++j) {
			if (S[i][j] == '#') A[i][j] = ++cnt;
		}
		for (int j = 0; j < W; ++j) {
			if (A[i][j] == 0 && (j > 0 && A[i][j - 1] != 0)) A[i][j] = A[i][j - 1];
		}
		for (int j = W - 2; j >= 0; --j) {
			if (A[i][j] == 0 && A[i][j + 1] != 0) A[i][j] = A[i][j + 1];
		}
	}
	for (int i = 1; i < H; ++i) {
		if (isempty[i] && !isempty[i - 1]) {
			isempty[i] = false;
			for (int j = 0; j < W; ++j) A[i][j] = A[i - 1][j];
		}
	}
	for (int i = H - 2; i >= 0; --i) {
		if (isempty[i] && !isempty[i + 1]) {
			isempty[i] = false;
			for (int j = 0; j < W; ++j) A[i][j] = A[i + 1][j];
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			printf("%d%c", A[i][j], j == W - 1 ? '\n' : ' ');
		}
	}
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>

using namespace std;

class stack{
  int topIndex;
  int data[1000];
public:
  stack(){
    topIndex = 0;
  }
  void push(int num){
    data[topIndex++] = num;
  }
  int pop(){
    return data[--topIndex];
  }
  int print(){
    std::cout << "debug stack = ";
    for(int i= 0; i < topIndex; i++){
      std::cout << data[i] << ' ';
    }
    std::cout << '\n';
  }
};

int main(){
  stack st;
  while(!cin.eof()){
    //st.print();
    string s;
    cin >> s;
    if (s == ""){
      break;
    }
    if (s == "*"){
      st.push(st.pop() * st.pop());
    }else if(s == "/"){
      int o1 = st.pop();
      int o2 = st.pop();
      st.push(o2 / o1);
    }else if(s == "+"){
      st.push(st.pop() + st.pop());
    }else if(s == "-"){
      int o1 = st.pop();
      int o2 = st.pop();
      st.push(o2 - o1);
    }else {
      //std::cout << "debug s = " << s << '\n';
      int num = stoi(s);
      st.push(num);
    }
  }
  cout << st.pop() << endl;
}

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

#define int long long

int32_t main() {
    int t = 1;
    while(t--)
    {
    	int n, W, V = 0;
    	cin >> n >> W;
    	int w[n], v[n];
    	for(int i = 0; i < n; i++)
    	    cin >> w[i] >> v[i], V += v[i];
    	int dp[n+1][V+1];
    	for(int i = 0; i <= n; i++)
    	{
    	    for(int j = 0; j <= V; j++)
    	    {
    	        if(j == 0)
    	            dp[i][j] = 0;
    	        else if(i == 0)
    	            dp[i][j] = 1e9;
    	        else
    	        {
    	            int op1 = dp[i-1][j];
    	            int op2 = (j >= v[i-1]) ? (dp[i-1][j-v[i-1]] + w[i-1]) : 1e9;
    	            dp[i][j] = min(op1, op2);
    	        }
    	    }
    	}
    	int ans;
    	for(ans = V; ans >= 0; ans--)
    	    if(dp[n][ans] <= W)
    	        break;
    	cout << ans;
    }
	return 0;
}

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

int main() {
    ll a, b;
    cin >> a >> b;
    
    ll ans = -1;
    ll x;
    rep(i, 1250) {
        x = i + 1;
        if (floor(x * 0.08) == a && floor(x * 0.1)  == b) {
            ans = x;
            break;
        }
    }
    
    cout << ans << endl;
}

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

int main(){
    int n;cin>>n;int b[n-1],sum=0;
    for(int i=0;i<n-1;i++) cin>>b[i];
    for(int i=0;i<n-1;i++){
        if(i>=1) sum+=min(b[i],b[i-1]);
        else if(i==0) sum+=b[i];
        if(i==n-2) sum+=b[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
#$v2 = explode(" ", $stdin[0]);

$a = str_split($stdin[0]);
$b = str_split($stdin[1]);

$count = 0;

if($a[0] == $b[0]){ $count++; }
if($a[1] == $b[1]){ $count++; }
if($a[2] == $b[2]){ $count++; }

$ans = $count;

echo $ans . PHP_EOL;

Measured memory_bytes: 3956
class ModCombination
  attr_reader :fac, :inv, :finv, :mod

  MOD = 10 ** 9 + 7

  def initialize(n, mod: MOD)
    @mod = mod
    @fac = [1, 1]
    @inv = [1, 1]
    @finv = [1, 1]

    (2..n).each do |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
    end
  end

  def combination(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0

    fac[n] * (finv[k] * finv[n - k] % mod) % mod
  end
end

N, M, K = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7

ans = 0

(1...N).each do |d|
  ans += d * (N - d) * M ** 2 % MOD
end

(1...M).each do |d|
  ans += d * (M - d) * N ** 2 % MOD
end

mc = ModCombination.new(N * M)
puts mc.combination(N * M - 2, K - 2) * ans % MOD


Measured memory_bytes: 6552
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort(reverse=True)
c = 0
total = sum(a)
for i in a:
  if i>=((1/(4*m))*total):
    c+=1
if c>=m:
  print("Yes")
else:
  print("No")

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

int main() {
	// 文字入力
	string S;
	cin >> S;

	//setに挿入
	set<char> lowEArray;
	for (int i = 0; i < S.size(); i++) {
		lowEArray.insert(S[i]);
	}

	//初期設定
	string ans = "None";
  
	for (char comp = 'a'; comp <= 'z'; comp++) {
		bool flag = false;
		for (auto x : lowEArray) {
			if (comp == x) {
				flag = true;
				break;
			}
		}
		if (flag == false) {
			ans = comp;
			break;
		}
	}

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

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

long long modpow(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

int inverse(int x) {
	return modpow(x, MOD - 2);
}

int COM(int n, int r) {
	int ans = 1;
	rep(i, 0, r)
	{
		ans *= n;
		ans %= MOD;
		n--;
	}
	rep(i, 0, r)
	{
		ans *= inverse(i + 1);
		ans %= MOD;
	}
	return ans;
}

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

	int N, A, B;
	cin >> N >> A >> B;
	cout << (modpow(2, N)-1 - COM(N, A) - COM(N, B) + 3 * MOD) % MOD << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int main(void)
{

	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        an:[usize;5],
    }
    if an.iter().all(|&x| n <= x) {println!("5");return;} 
    let m_v = an.iter().min().unwrap();
    let ans = if n % m_v  == 0 {
        4 + n / m_v
    } else {
        4 + n / m_v + 1
    };
    println!("{}",ans);
}

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

#define MOD (1000000000+7)

int main()
{
	int N;
	string S;
	cin >> N >> S;
	long long ans = 1;
	if( S[0] == 'W' ) {
		ans = 0;
	}
	else {
		int k = 1;
		for( int i = 1; i < S.size(); i++ ) {
			if( S[i] == 'B' ) {
				if( k % 2 ) {
					ans *= k;
					ans %= MOD;
					k--;
				}
				else {
					k++;
				}
			}
			else {
				if( k == 0 ) {
					ans = 0;
					break;
				}
				if( k % 2 ) {
					k++;
				}
				else {
					ans *= k;
					ans %= MOD;
					k--;
				}
			}
		}
		if( k ) ans = 0;
	}
	for( int i = N; i > 1; i-- ) {
		ans *= i;
		ans %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int n;
int ans;
int par[100010];
int s[100010];
int z[100010];
int h[100010];
vector<int>v[100010];
void solve(int x)
{
	vector<int>t;
	for(int i=0;i<v[x].size();i++)
	{
		solve(v[x][i]);
		t.push_back(h[v[x][i]]);
	}
	sort(t.begin(),t.end());
	int l=t.size();
	for(int i=0;i<l;i++)
	{
		h[x]=max(h[x],t[i]+l-i);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)h[i]=1; 
	for(int i=2;i<=n;i++)
	{
		scanf("%d",par+i);
		v[par[i]].push_back(i);
	}
	solve(1);
	printf("%d",h[1]-1);
	return 0;
}

Measured memory_bytes: 14336
<?php

$nums = explode(' ',trim(fgets(STDIN)));

if ($nums[0]%3==0 || $nums[1]%3==0){
  echo 'Possible';
} else if (($nums[0]+$nums[1])%3==0){
  echo 'Possible';
} else {
  echo 'Impossible';
}

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
//using namespace __gnu_pbds;
//using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
char S[200010],T[200010];
void MAIN() {
	cin>>S>>T;
	int cnt=0;
	for(int i=0;S[i];i++) {
		cnt+=S[i]!=T[i];
	}
	cout<<cnt;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3988
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            String filename = "";
            if (filename.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            }
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    void solve() throws IOException {
        TreeSet<Character> c = new TreeSet<>();
        String s = readString();
        for (char x : s.toCharArray()) {
            c.add(x);
        }
        out.println(s.length() == c.size() ? "yes" : "no");

    }


}

Measured memory_bytes: 23380
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
BC = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(M)]
BC.sort(key=lambda x: x[1], reverse=True)
for i in range(M):
    A.extend([BC[i][1]] * BC[i][0])
    if len(A) >= 2 * N:
        break

A.sort(reverse=True)
print(sum(A[:N]))


Measured memory_bytes: 28608
S = input()
S=list(S)  #1文字ずつリストに格納
ans =0
for i in range(len(S)):
   if i % 2 != 0:
      if S[i] == "L" or S[i] == "U" or S[i] == "D":
         ans +=1
      else:
         ans =0
         break
   else:
      if S[i] == "R" or S[i] == "U" or S[i] == "D":
         ans +=1
      else:
         ans =0
         break
if ans == len(S):
   print("Yes")
else:
   print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

int N;
string c = "abcdefghijklm";

int dfs(int d, string s, int n){
    if(d == N){
        cout << s << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        dfs(d+1, s+c[i], n);
    }
    dfs(d+1, s+c[n], n+1);
    return 0;
}

int main(){
    cin >> N;
    dfs(0,"",0);
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main() {
  int a,b,c,x,cnt=0;
  cin >> a >> b >> c >> x;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        int sum = 500*i + 100*j + 50*k;
        if (sum == x){
	  ++cnt;
	}
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
weight = list(map(int, input().split()))
record = []

for i in range(N):
    left = 0
    right = 0
    sa = 0
    for j in range(i):
        left += weight[j]
    for k in range(i, N):
        right += weight[k]
    if left >= right:
        sa = left - right
    else:
        sa = right - left
    record.append(sa)

newrecord = sorted(record)
ans = newrecord[0]

print("{}".format(ans))


Measured memory_bytes: 3064
import numpy as np
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n = int(input())
tv = av = 1
t = [0]*n; a = [0]*n
for i in range(n):
    t[i], a[i] = imap()
for i in range(n):
    tmp = max(tv//t[i]+(tv%t[i]!=0), av//a[i]+(av%a[i]!=0))
    tv = t[i]*tmp; av=a[i]*tmp
print(tv+av)

Measured memory_bytes: 19872
#入力はn人のx,yに分けないといけない
n = int(input())
a = []
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xx, yy = (int(i) for i in input().split())
        x[i].append(xx)
        y[i].append(yy)

testimony = [[2]*n for i in range(n)]

for i in range(n):
    for j in range(a[i]):
        if (y[i][j] == 1):
            testimony[i][x[i][j] - 1] = 1
        elif(y[i][j] == 0):
            testimony[i][x[i][j]-1] = 0

ans = 0
for i in range(2**n):
    bit_list = []
    for j in range(n):
        if ((i >> j) & 1):
            bit_list.append(1)
        else:
            bit_list.append(0)
    flag = 1
    for k in range(n):
        if(bit_list[k] == 1):
            for l in range(n):
                if(testimony[k][l] != 2):
                    if(testimony[k][l] != bit_list[l]):
                        flag = 0
                        break
    if(flag == 1):
        ans = max(sum(bit_list),ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>

int main(){
	int n,k;
	std::cin >> n >> k;
	std::string in;
	std::cin.ignore();
	std::getline(std::cin,in);
	std::istringstream iss(in);
	
	std::vector<double> arr;
	std::string subs;
	while(iss >> subs){
		arr.push_back(atoi(subs.c_str()));
	}
	std::vector<double> pre;
	pre.push_back(0);
	double m = -1;
	int maxi = -1;
	for(int i = 0; i < n; ++i){
		pre.push_back(pre[i] + (arr[i]+1.0)/2.0);
	}

	for(int i = k; i < n+1; ++i){
		if(pre[i] - pre[i-k] >= m){
			m = pre[i] - pre[i-k];
			maxi = i-k;
		}
	}
	
	//for(auto x : pre){
	//	std::cout << x << " ";
	//}
	//std::cout << "\nmaxi: " << maxi << "\n";

	std::cout << std::fixed << std::setprecision(12) << m;
}



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

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a==5&&((b==5&&c==7)||(c==5&&b==7))){
    cout<<"YES"<<endl;
  }else if(a==7&&(b==5&&c==5)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

const int MAXN = 3005;

const LL MOD = 1000000000LL + 7LL;

LL dp[MAXN][MAXN][2];

int M, N;

LL memo(int blue, int turn, bool reached) {
	if (turn == M)
		return reached;
	LL &ret = dp[blue][turn][reached];
	if (ret != -1)
		return ret;
	int red = N - blue;
	ret = 0;
	if (red)
		ret += memo(blue + 1, turn + 1, reached) + memo(blue, turn + 1, reached || (blue == 0));
	ret %= MOD;
	if (blue)
		ret += memo(blue - 1, turn + 1, reached || (blue - 1 == 0)) + memo(blue, turn + 1, reached || (blue == 1));
	ret %= MOD;
	return ret;
}

int main() {
	cin >> N >> M;
	SET(dp, 255);
	LL ret = 0LL;
	FOR (i, N + 1) {
		ret += memo(i, 0, false || (i == 0));
		ret %= MOD;
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;

int main(void){
	vector<vector<string>> moji{
		{}, 
		{".",",","!","?"," "},
		{"a","b","c"},
		{"d","e","f"},
		{"g","h","i"},
		{"j","k","l"},
		{"m","n","o"},
		{"p","q","r","s"},
		{"t","u","v"},
		{"w","x","y","z"}
	};

	int num;
	cin >> num;
	for(int i = 0; i < num; i++){
		int count = 0;
		string str;
		cin >> str;
		string one = "0";

		for(int j = 0; j < str.size(); j++){
			if(str[j] == '0'){
				if(one != "0"){
					count--;
					cout << moji[stoi(one)][count % moji[stoi(one)].size()];
				}
				one = str[j];
				count = 0;
			}else{
				one = str[j];
				count++;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	w,h,x,y = readline() |> split |> parseMap
	p = w/2
	q = h/2
	print((w*h)/2)
	if p == x*1.0 && q == y*1.0
		println(" 1")
	else
		println(" 0")
	end
end

main()

Measured memory_bytes: 165112
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	int n;
	cin >> n;

	char c[10][5] = {
		{'*', '*', '*', '*', '*'},
		{'.', ',', '!', '?', ' '},
		{'a', 'b', 'c', '*', '*'},
		{'d', 'e', 'f', '*', '*'},
		{'g', 'h', 'i', '*', '*'},
		{'j', 'k', 'l', '*', '*'},
		{'m', 'n', 'o', '*', '*'},
		{'p', 'q', 'r', 's', '*'},
		{'t', 'u', 'v', '*', '*'},
		{'w', 'x', 'y', 'z', '*'}
	};
	int max[] = {
	//  0, 1, 2, 3, 4, 5, 6, 7, 8, 9
		0, 5, 3, 3, 3, 3, 3, 4, 3, 4
	};

	for(int i = 0; i < n; i++) {
		string number;
		string message;
		int num, flg = 0, sel = 0;
		char ch;
		cin >> number;

		for(int j = 0; j < number.length(); j++) {
			num = atoi( number.substr(j, 1).c_str() );
			if(num == 0) {
				if(flg == 0) continue;
				else message += ch;
				flg = 0;
				sel = 0;
			} else {
				flg = 1;
				ch = c[num][sel];
				sel ++;
				if(sel >= max[num]) sel = 0;
			}
		}

		cout << message << endl;

	}

	//while(1){}
	return 0;
}

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

int main(){

    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N;i++)cin >> a[i];
    
    int maxV = *max_element(a.begin(),a.end());
    
    sort(a.begin(),a.end(),[maxV](const int &a, const int &b){
        
        int s = min(a,maxV - a);
        int t = min(b,maxV - b);
        return s < t;
    });

    cout << maxV <<" "<<a.back()<<endl;
}



Measured memory_bytes: 640
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        s: usize,
        c: usize,
    }
    if s * 2 >= c {
        println!("{}", c / 2);
    } else {
        let rest = s + (c - s * 2) / 4;
        println!("{}", rest);
    }
}


Measured memory_bytes: 2172
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll a,b,t;
  cin>>a>>b>>t;

  cout << b * ((ll)((float)t+0.5)/a) << endl;

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(void){
    
    int h1,h2,k1,k2,a,b,c,d,hiroshi=0,kenji=0;
    scanf("%d %d %d %d %d %d %d %d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
    
    if(h1/10>=0){
        hiroshi+=c*(h1/10);
    }
    if(k1%10>=0){
        kenji+=c*(k1/10);
    }
    
    if(h2/20>=0){
        hiroshi+=d*(h2/20);
    }
    if(k2%20>=0){
        kenji+=d*(k2/20);
    }
    
    hiroshi+=h1*a+h2*b;
    
    kenji+=k1*a+k2*b;
    
    if(hiroshi>kenji){
        printf("hiroshi\n");
    }
    if(hiroshi<kenji){
        printf("kenjiro\n");
    }
    if(hiroshi==kenji){
        printf("even\n");
    }
    
    
    
    
}


Measured memory_bytes: 2112
'use strict';

function main(arg) {
    const N     = Number(arg.split("\n")[0]);
    const words = arg.split("\n").slice(1);
    const memo  = new Set();
    
    let lastLetter = words[0].slice(0, 1);

    for(let i=0; i<N; i++) {
        if(lastLetter !== words[i].slice(0, 1)) {
            console.log('No');
            return;
        }
        
        if(memo.has(words[i])) {
            console.log('No');
            return;
        }

        lastLetter = words[i].slice(-1);
        memo.add(words[i]);
    }
    
    console.log('Yes');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main()
{
    int n;
    string s,t;
    string ans;
    cin >> n;
    cin >> s >> t;

    rep(i, n) {
        ans[2*i] = s[i];
        ans[2*i+1] = t[i];
        cout << ans[2*i] << ans[2*i+1];
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256