akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,v,c,ans;
  ans = 0;
  cin >> n;
  vector<int> vv;
  vector<int> vc;

  for(int i=0;i<n;i++){
    cin >> v;
    vv.push_back(v);
  }
  for(int i=0;i<n;i++){
    cin >> c;
    vc.push_back(c);
  }

  for(int i=0;i<n;i++){
    if(vv[i]-vc[i]>0){
      ans += vv[i]-vc[i];
    }
  }


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

Measured memory_bytes: 256
N=input()
K=input()
x=input().split()
N=int(N)
K=int(K)
for i in range(N):
    x[i]=int(x[i])

ans=0 #答え（初期化）

#ここから判定
for y in range(N):
    #Aの動線
    lenA=abs((x[y]-0))*2 #ボールの位置とロボAの待機位置の差*2
    #Bの動線
    lenB=abs((x[y]-K))*2 #ボールの位置とロボBの待機位置の差*2
    #小さい方を答えとする
    if lenA<=lenB:
        ans+=lenA
    else:
        ans+=lenB

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    string a,b; cin >> a >> b;
    int f = 0;
    if(a.size()>b.size()){
        cout << "GREATER" << endl;
    }else if(a.size()<b.size()){
        cout << "LESS" << endl;
    }else{
        if(a>b)cout << "GREATER" << endl;
        else if (a<b) cout << "LESS" << endl;
        else cout << "EQUAL" << endl;
    }
    return 0;
}

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

int a[4];

int main()
{
	int x,y;
	for(int i=1; i<=3; i++)
	{
		scanf("%d%d",&x,&y);
		a[x]++; a[y]++;
	}
	if(a[1]==3 || a[1]==0 || a[2]==3 || a[2]==0 || a[3]==3 || a[3]==0 || a[4]==3 || a[4]==0) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
#define ll long long
#define fi first
#define se second
#define inf (999999999)
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
ll n, a, b, c, d;
int main() {
	cin >> n >> a >> b >> c >> d;
	for (int i = n - 1; i >= 0; i--) {
		ll from = a + i*c - (n - 1 - i)*d;
		ll to = a + i*d - (n - 1 - i)*c;
		//cout << "from=" << from <<" "<< "to=" << to << endl;
		if (from <= b && b <= to) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
  	
  	int a, b;
	cin >> a >> b;
	cout << max(0, a - (2 * b)) << "\n";    
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<int,Pil>Piil;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
ll a[200002];

int main() {

	ll n,k;
	cin>>n>>k;

	rep(i,n)cin>>a[i+1];

	for(int i=k+1; i<n+1; i++){
		if(a[i-k]<a[i])cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 5156
import sys

s_args = sys.stdin.read().splitlines()

s_args = s_args[0].split(' ')

a = int(s_args[0])
b = int(s_args[1])
k = int(s_args[2])

if k*2 >= b-a+1:
    for i in range(a, b+1):
        print(i)
    sys.exit()

for i in range(k):
    print(a+i)

for i in range(k):
    print(b-k+i+1)
    


Measured memory_bytes: 3064
import sys
import math

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K = int(input())

    amari = 7 % K
    if amari == 0:
        print(1)
        return
    for i in range(2, 10 ** 6 + 1):
        amari = 7 + amari * 10
        amari %= K
        if amari == 0:
            print(i)
            return

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63100
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ll n,k,x,ans;
    cin>>n>>k;
    x=n%k;
    ans=abs(x-k);
    if(x>ans)
    cout<<ans;
    else
     	cout<<x;

}

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

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x,a;
    cin>>x>>a;
    if(x<a)
    cout<<0;
    else
    cout<<"10";
    
    
	

}


Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let a:Vec<i32> = st.trim().split(' ').map(|x| x.parse().unwrap()).collect();
    let mut r = -1;
    for i in 1..1001 {
        if i*8/100 == a[0] && i/10 == a[1] {
            r = i;
            break;
        }; 
    };
    println!("{}", r);
}

Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
    long long N, k;
    long long a, b;
    long long i, j;

    scanf("%lld %lld", &N, &k);

    a = 0; b = 0;
    for(i = 0; i < N - 1; i++){
        j = b/(k-1);
        while(1){
            if(k == 2){
                if(++j == b+2) break;
            }else{
                if(++j > b/(k-1)+k/(k-1)) break;
            }
        }
        a = --j;
        b += a;
    }

    printf("%lld\n", b);

    return 0;
}



Measured memory_bytes: 2100
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  cin >> n;
  ll cnt[10][10];
  rep(i, 10) rep(j, 10) {
    cnt[i][j] = 0;
  }
  rep(i, n + 1) {
    if(!(i % 10))
      continue;
    int k = 1;
    int p = 0;
    while(i / k >= 10) {
      ++p;
      k *= 10;
    }
    int rd = i % 10;
    int ld = i / k;
    ++cnt[rd][ld];
  }
  ll ans = 0;
  rep(i, 10) rep(j, 10) ans += cnt[i][j] * cnt[j][i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

S = input()

# pattern that S start 0
v1 = 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s != "0":
            v1 += 1
    else:
        if s != "1":
            v1 += 1

# pattern that S start 1
v2 = 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s != "1":
            v2 += 1
    else:
        if s != "0":
            v2 += 1
            
print(min(v1, v2))

Measured memory_bytes: 3188
//
#include <iostream>
#include <string>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

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

void op(string &str){
	while(1){
		auto pos = str.find("BBB");
		if(pos != -1)	str.replace(pos,2,"B");
		pos = str.find("BB");
		if(pos != -1)	str.replace(pos,2,"B");
		else break;
	}
	while(1){
		auto pos = str.find("WWW");
		if(pos != -1)	str.replace(pos,2,"W");
		pos = str.find("WW");
		if(pos != -1)	str.replace(pos,2,"W");
		else break;
	}
	return;
}

int main(){
	string str;
	cin >> str;
	// op(str);
	// printf("%lu\n", str.size()-1);
	int counter = 0;
	char before = str[0], after;
	REP(i,1,str.size()){
		after = str[i];
		if(after != before) counter++;
		before = after;
	}
	printf("%d\n", counter);

	return 0;
}


Measured memory_bytes: 512
X = int(input())
divisions_100 = X//100
residuals = X%100
n_100 = 0
for i in range(1,6)[::-1]:
    n_100 += residuals // i
    residuals -= (residuals // i)*i
    if residuals % i == 0:
        break
if n_100 <= divisions_100:
    print(1)
else:
    print(0)

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	char prev = '$';
	int answer = 0;
	for(char c : s) {
		if(c != prev) {
			prev = c;
			++answer;
		}
	}
	cout << answer;
}


Measured memory_bytes: 3740
n = int(input())
from collections import Counter
c = Counter()
for i in range(n):
  a = input()
  c.update({a:1})
  
m = int(input())
for i in range(m):
  s = input()
  if c[s] >= 1:
    c.update({s:-1})
    
print(c.most_common()[0][1])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050 * 2;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n;
int a[N];
int pri[N], tot, vis[N];
void shaipri(int up)
{
    for (int i = 2; i <= up; ++i)
    {
        if (!vis[i])
            vis[i] = i, pri[++tot] = i;
        for (int j = 1; j <= tot && i * pri[j] <= up; ++j)
        {
            vis[i * pri[j]] = pri[j];
            if (i % pri[j] == 0)
                break;
        }
    }
}
int cnt[N];

inline void solve()
{
    shaipri(1000000);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; ++i)
    {
        int x = a[i];
        while (x > 1)
        {
            int nowpri = vis[x];
            cnt[nowpri]++;
            while (x % nowpri == 0)
                x /= nowpri;
        }
    }
    bool pairwise = true;
    for (int i = 1; i <= 1000000; ++i)
    {
        if (cnt[i] >= n)
        {
            return puts("not coprime"), void();
        }
        else if (cnt[i] > 1)
            pairwise = false;
    }
    if (pairwise)
        puts("pairwise coprime");
    else
        puts("setwise coprime");
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 15680
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int k[32] = {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};
    int N;
    cin >> N;
    cout <<k[N-1]<<endl;
}


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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

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

int main() {
	int k;
	string s;
	cin >> k >> s;

	string ans = s;
	if (s.size() > k) {
		ans = ans.substr(0, k);
		ans += "...";
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 3632
def solve(string):
    x, k, d = map(int, string.split())
    x = abs(x)
    if k % 2:
        x = min(x - d, x + d, key=abs)
        k -= 1
    k, d = k // 2, d * 2
    return str(min(x % d, abs((x % d) - d))) if x < k * d else str(x - k * d)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9004
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  long int n;
  long long int k;
  long int q;
  long int a[100001];
  long long int point[100001] = {0};

  scanf("%ld%lld%ld", &n, &k, &q);


  /*
  // 初期化
  for(long int i = 0; i < n; i++){
    point[i] = k;
  }
  */
  /*
  if(q < k){
    for(long int i = 0; i < n; i++){
      printf("Yes\n");
      return 0;
    }
    }*/
  //  一人ずつはしない。問題ずつそれぞれのポイントを考える
  for(long int i = 0; i < q; i++){
    scanf("%ld", &a[i]);
    point[a[i] - 1]++;
    /*
    for(long int j = 0; j < n; j++){
      if(a[i] != (j + 1) && point[j] < k){
	point[j]++;
      }
      //      printf("i = %ld  point = %lld\n", i, point[j]);
    }
    */
  }

  // 求め方を変えた
  for(long int i = 0; i < n; i++){
    if(k - (q - point[i]) > 0){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }

  return 0;
}


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

int32_t main(){
	int n; cin>>n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	double ans = 0;
	for(int x: a){
		ans += 1.0 / x;
	}
	cout<<fixed<<setprecision(9)<<1.0/ans<<endl;
}


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

int main()
{
	long long N, X, ans = 0;
	cin >> N >> X;
	
	while(N >= 0 && X > 0)
	{
		long long half = ((long long)1 << N + 1) - 2; 
		if (X > half)
		{
			ans += (half >> 1) + 1;
			X -= half + 1;
		}
		else
		{
			X--;
		}
		N--;
	}
	
	cout << ans;
}

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

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int X, Y, Z;
    cin >> X >> Y >> Z;

    REP(i, X) {
        if (((i + 1) * Z + i * Y) > X) {
            cout << i - 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int main(void)
{
	ll a = 100;
	ll x; cin >> x;
	ll cnt = 0;
	while(a < x) {
		cnt++;
		a += a / 100;
	}
	cout << cnt << endl;



	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int x[1010][110];

int main(void)
{
    const int H=1000;
    int n, m, a;
    while (scanf("%d%d%d", &n, &m, &a), n) {
        int i, j;
        for(i=0;i<=n;++i) for(j=0;j<=H;++j) x[j][i]=i;
        for(i=0;i<m;++i) {
            int h, p, q;
            scanf("%d%d%d", &h, &p, &q);
            h=H-h;
            x[h][p]=q;
            x[h][q]=p;
        }

        for(i=0;i<=H;++i) a=x[i][a];
        printf("%d\n", a);
    }
    return 0;
}

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

using namespace std;

const int MX = 100000;

int l[MX], r[MX], pL[MX], pR[MX], sL[MX], sR[MX];

int main() {
	int n;
	ignore = scanf("%d", &n);
	for (int i = 0; i < n; i++) ignore = scanf("%d %d", l + i, r + i);
	
	pL[0] = l[0];
	pR[0] = r[0];
	for (int i = 1; i < n; i++) {
		pL[i] = max(pL[i - 1], l[i]);
		pR[i] = min(pR[i - 1], r[i]);
	}
	
	sL[n - 1] = l[n - 1];
	sR[n - 1] = r[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		sL[i] = max(sL[i + 1], l[i]);
		sR[i] = min(sR[i + 1], r[i]);
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int ll = -1, rr = 2e9;
		if (i > 0) {
			ll = max(pL[i - 1], ll);
			rr = min(pR[i - 1], rr);
		}
		if (i + 1 < n) {
			ll = max(sL[i + 1], ll);
			rr = min(sR[i + 1], rr);
		}
		
		ans = max(r[i] - l[i] + 1 + max(rr - ll + 1, 0), ans);
	}
	
	int k = min_element(r, r + n) - r;
	int L = l[k], R = r[k];
	
	vector<pair<int, int>> vec;
	for (int i = 0; i < n; i++) {
		if (i != k) vec.emplace_back(l[i], r[i]);
	}
	
	sort(vec.begin(), vec.end());
	
	l[n - 2] = vec.back().first;
	r[n - 2] = vec.back().second;
	for (int i = n - 3; i >= 0; i--) {
		l[i] = max(l[i + 1], vec[i].first);
		r[i] = min(r[i + 1], vec[i].second);
	}
	
	for (int i = 0; i < n - 1; i++) {
		ans = max(ans, max(R - L + 1, 0) + max(r[i] - l[i] + 1, 0));
		L = max(vec[i].first, L);
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<vector<ll>> a(N, vector<ll>(N, 0));
    for(ll i=0;i<N;++i)
        for(ll j=0;j<N;++j)cin>>a[i][j];
    //dp[x][S]は男xまでを女の集合S内でマッチングさせる方法の数
    vector<vector<ll>> dp(N, vector<ll>(1LL<<N, -1));
    function<ll(ll,ll)> F=[&](ll x, ll S){
        if(x==-1)return 1LL;
        if(dp[x][S]!=-1)return dp[x][S];
        ll ret=0;
        for(ll i=0;i<N;++i){
            if((S&(1LL<<i))&&a[x][i]){
                ret+=F(x-1,S-(1LL<<i));
                ret%=MOD;
            }
        }
        return dp[x][S]=ret;
    };
    prt(F(N-1,(1LL<<N)-1))


    return 0;
}


Measured memory_bytes: 360832
import java.io.*;
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		ArrayList<String> list = new ArrayList<String>();
		for(int i=0; i<num;i++)
			list.add(scan.next());
		scan.close();
		BubbleSort bs = new BubbleSort(num);
		SelectionSort ss = new SelectionSort(num);
		bs.loadSequence((String[])list.toArray(new String[0]));
		ss.loadSequence((String[])list.toArray(new String[0]));
		bs.sort();
		ss.sort();
		System.out.println(bs);
		System.out.println("Stable");
		System.out.println(ss);
		if(bs.isStable(ss))
			System.out.println("Stable");
		else
			System.out.println("Not stable");
	//	System.out.println(sort.swapTimes);
	}

}

class BubbleSort extends SortingCards{
	public BubbleSort(int n){
		super(n);
	}

	@Override
	public void sort(){
		for(int i=0; i<this.length;i++)
			for(int j=this.length-1; i<j ;j--)
				if(sortList.get(j).compValue()<sortList.get(j-1).compValue())
					swap(j,j-1);
	}
	boolean isStable(Sorting sort){
		for(int i=0; i<this.length;i++){
			String tmp01 = this.sortList.get(i).toString();
			String tmp02 = sort.sortList.get(i).toString();
			if(!tmp01.equals(tmp02))
				return false;
		}
		return true;
	}	
}

class SelectionSort extends SortingCards{
	public SelectionSort(int n){
		super(n);
	}
	@Override
	public void sort(){
		for(int i=0; i<this.length;i++){
			int minIndex=i;
			for(int j=i; j<this.length;j++){
				if(sortList.get(j).compValue()<sortList.get(minIndex).compValue())
					minIndex = j;
			}
			if(i!=minIndex)
				swap(i,minIndex);
		}
	}	
}


interface comparable{
	int compValue();
}
class SortingCards extends Sorting{
	public SortingCards(int n){
		super(n);
	}
	@Override
	public void loadSequence(String[] str){
		for(int i=0; i<this.length;i++)
			sortList.add(new cards(str[i]));
	}
	@Override
	public void sort(){};
}
class cards implements comparable{
	char type;
	Integer number;
	public cards(String str){
		type = str.charAt(0);
		number = Integer.parseInt(str.substring(1,str.length()));		
	}
	public int compValue(){
		return number;
	}
	@Override
	public String toString(){
		return type + number.toString();
	}
}
abstract class Sorting{
	int swapTimes;
	int length;
	ArrayList<comparable> sortList;
	public Sorting(int n){
		swapTimes=0;
		length=n;
		sortList = new ArrayList<comparable>();
	}
	
	@Override
	public String toString(){
		String tmp = "";
		for(int i=0; i<length; i++)
			tmp = tmp + " " + sortList.get(i);
		return tmp.trim();
	}
	void swap(int i, int j){
		swapTimes++;
		comparable tmp = sortList.set(i,sortList.get(j));
		sortList.set(j,tmp);
	}
	abstract public void loadSequence(String[] str);
	//abstract public void loadSequence(Scanner scan);
	abstract public void sort();
}

Measured memory_bytes: 17280
import java.io.*;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String s = fs.next();
        char before = s.charAt(0);
        for( int i = 1 ; i < s.length() ; i++ ){
            if( before == s.charAt(i) ){
                System.out.println( "Bad" );
                return;
            }
            before = s.charAt(i);
        }
        System.out.println( "Good" );
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) {
                return buffer[ptr++];
            } else {
                return -1;
            }
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
                throw new NumberFormatException();
            }
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<LL> a(n);
    rep(i, n) cin >> a[i];
    vector<LL> absa(n);
    rep(i, n) absa[i] = abs(a[i]);

    int ct = 0;
    rep(i, n)if(a[i] < 0) ct++;
    LL ans = accumulate(all(absa), 0LL);
    if(ct%2 == 1){
        LL tmp = INF;
        rep(i, n) tmp = min(tmp, absa[i]);
        ans -= 2*tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n,w;
    cin >> n >> w;
    auto dp=make_v<ll>(n+1,100100);
    fill_v<ll>(dp,LLINF);
    vector<ll> W(n),v(n);
    rep(i,n){
      cin >> W[i] >> v[i];
    }
    dp[0][0] = 0;
    rep(i,n){
      rep(j,100100){
        chmin(dp[i+1][j], dp[i][j]);
        if(v[i] > j) continue;
        chmin(dp[i+1][j], dp[i][j - v[i]] + W[i]);
      }
    }
    ll ans = 0;
    rep(i,100100){
      if(dp[n][i] > w) continue;
      ans = i;
    }
    print(ans);
}

Measured memory_bytes: 80384
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();

		int t = N%500;
		if(t<=A) System.out.println("Yes");
		else System.out.println("No");
	}
}

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

int main() {
	int r, c;
	while (cin >> r >> c, r || c) {
		vector<vector<int>> osenbei(r);
		for (auto& vb : osenbei) {
			vb.resize(c);
			for (auto& x : vb) {
				cin >> x;
			}
		}
		int ans = 0;
		for (int rptn = 0; rptn < (1 << r); rptn++) {
			int sum = 0;
			for (int i = 0; i < c; i++) {
				int rsum = 0;
				for (int j = 0; j < r; j++) {
					int b = (rptn >> j) & 1;
					rsum += b ^ osenbei[j][i];
				}
				sum += max(rsum, r - rsum);
			}
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
h,w=map(int,input().split())
a=[]
b=[]
f=0
for i in range(h):
  b=input()
  if b!='.'*w:
    a.append(b)
ans=['' for j in range(len(a))]
for i in range(len(a[0])):
  f=0
  for j in range(len(a)):
    if a[j][i]=='#':
      f=1
      break
  if f==1:
    for k in range(len(a)):
      ans[k]+=a[k][i]
for i in range(len(a)):
  print(ans[i])

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 1e15;
	int lim = max(x, y) * 2;
	REPN(i, 0, lim) {
		ll cur = i * c + max(0ll, x - i / 2) * a + max(0ll, y - i / 2) * b;
		ans = min(ans, cur);
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main ()
{
    int a,b,m,n;
    cin>>a>>b;
    if (a>=13)
        cout<<b<<endl;
    else if (a>=6 && a<=12)
        cout<<b/2<<endl;
    else
        cout<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

struct edge{int to, cost;};

class Graph
{
public:
    int V;
    vector<vector<edge>> G;

    vec gen, par;
    mat chi, genlist;
    int depth;

    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
    }

    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    void dfs(int v, int d){
        gen[v] = d;
        depth = max(depth, d + 1);
        REP(k, G[v].size()){
            if(G[v][k].to == par[v]) continue;
            par[G[v][k].to] = v;
            chi[v].push_back(G[v][k].to);
            dfs(G[v][k].to, d + 1);
        }
    }

    mat makegenlist(){
        REP(v, V) genlist[gen[v]].push_back(v);
        return genlist;
    }

    void analyzeTree(int root){
        gen = vec(V); par = vec(V);
        chi = mat(V, vec(0));
        depth = 0;
        par[root] = -1;
        dfs(root, 0);

        genlist = mat(depth, vec(0));
        makegenlist();
    }

};

signed main(){

    int N; cin >> N;
    Graph T(N);
    int x, y;
    REP(i, N - 1){
        cin >> x >> y;
        T.add_edge2(x - 1, y - 1, 0);
    }
    T.analyzeTree(0);
    int mod = 1000000007;

    mat dp(N, vec(2, 0));
    IREP(d, T.depth){
        for(int v: T.genlist[d]){
            int v0 = 1;
            REP(i, T.chi[v].size()){
                v0 *= (dp[T.chi[v][i]][0] + dp[T.chi[v][i]][1]);
                v0 %= mod;
            }
            dp[v][0] = v0;
            int v1 = 1;
            REP(i, T.chi[v].size()){
                v1 *= dp[T.chi[v][i]][0];
                v1 %= mod;
            }
            dp[v][1] = v1;
        }
    }
    cout << (dp[0][0] + dp[0][1]) % mod;
    
    return 0;
}

Measured memory_bytes: 28760
# -*- coding: utf-8 -*-
from collections import Counter
from itertools import product
def inpl(): return tuple(map(int, input().split()))
   

S = input()
x, y = inpl()
M = []

d = 0
for s in S:
    if s == "F":
        d += 1
    else:
        M.append(d)
        d = 0
M.append(d)

Cx = Counter(M[2::2])
Cy = Counter(M[1::2])

Lx = []
Ly = []

for k, v in Cx.items():
    if k == 0:
        pass
    else:
        Lx.append(list(range(-k*v, k*v+1, 2*k)))
        
for k, v in Cy.items():
    if k == 0:
        pass
    else:
        Ly.append(list(range(-k*v, k*v+1, 2*k)))

def bfss(Ls, t, f):
    N = set([f])
    for L in Ls:
        nN = set()
        nN.update([n+l for n, l in product(N, L)])
        N = nN
    if t in N:
        return True
    else:
        return False

if bfss(Lx, x, M[0]) and bfss(Ly, y, 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 8576
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    R = sorted([i_list() for _ in range(n)])
    B = sorted([i_list() for _ in range(n)])

    ans = 0
    for bx, by in B:
        C = [(y,x) for x,y in R if x<bx and y < by]
        if len(C) == 0:
            continue
        ans += 1
        C.sort(reverse=True)
        R.remove([C[0][1],C[0][0]])
    print(ans)


if __name__=="__main__":
    main()


Measured memory_bytes: 83712
s = input()
n = len(s)

s_ok = True  # sが回文か
for i in range(n):
  if s[i] != s[-1 - i]:
    s_ok = False

s_left = s[:(n - 1) // 2]  # Pythonのスライスは末尾の要素を含まないので、+1
s_left_ok = True
for i in range(len(s_left)):
  if s_left[i] != s_left[-1 - i]:
    s_left_ok = False

s_right = s[(n - 1) // 2 + 1:]
s_right_ok = True
for i in range(len(s_right)):
  if s_right[i] != s_right[-1 - i]:
    s_right_ok = False

if s_ok and s_left_ok and s_right_ok:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
#define PAIR pair<int,int>
using namespace std;
class road {
public:
	int from, to;
	bool use;
	road() :use(true) {

	}
};
class town {
public:
	int fast;
	bool used, said;
	vector<class road*> road;
	int num;
	town():used(false),num(0),said(false) {

	}
};
int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	town *map;
	map = new town[N + 1];
	road *train;
	train = new road[M * 2 + 1];
	int a, b;
	for (int i = 1; i <= M; ++i) {
		cin >> a >> b;
		train[i].from = a;
		train[i].to = b;
		train[i + M].from = b;
		train[i + M].to = a;
		map[a].road.push_back(&train[i]);
		map[b].road.push_back(&train[i + M]);
	}
	priority_queue<PAIR, vector<PAIR>, greater<PAIR> > que;
	PAIR dummy;
	que.push(PAIR(0, 1));
	while (!que.empty()) {
		dummy = que.top(); que.pop();
		if (map[dummy.second].used) {
			continue;
		}
		map[dummy.second].used = true;
		map[dummy.second].fast = dummy.first;
		for (int i = 0, nmax = map[dummy.second].road.size(); i < nmax; ++i) {
			if (map[map[dummy.second].road[i]->to].used == false) {
				que.push(PAIR(dummy.first + 1, map[dummy.second].road[i]->to));
			}
		}
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 0, nmax = map[i].road.size(); j < nmax; ++j) {
			if (map[map[i].road[j]->to].fast - map[i].fast == 0) {
				map[i].road[j]->use = false;
				swap(map[i].road[j], map[i].road[nmax - 1]);
				map[i].road.pop_back();
				--nmax;
				--j;
			}
			else if (map[map[i].road[j]->to].fast - map[i].fast == -1) {
				++map[i].num;
				map[i].road[j]->use = false;
				swap(map[i].road[j], map[i].road[nmax - 1]);
				map[i].road.pop_back();
				--nmax;
				--j;
			}
		}
	}
	int answer = 0;
	int up;
	queue<int> say;
	for (int i = 0; i < Q; ++i) {
		cin >> up;
		if (train[up].use) {
			say.push(train[up].to);
			train[up].use = false;
		}
		else if (train[up + M].use) {
			say.push(train[up + M].to);
			train[up + M].use = false;
		}
		while (!say.empty()) {
			int mati = say.front(); say.pop();
			if (map[mati].said) {
				continue;
			}
			else if (--map[mati].num != 0) {
				continue;
			}
			++answer;
			map[mati].said = true;
			for (int i = 0, nmax = map[mati].road.size(); i < nmax; ++i) {
				if (map[mati].road[i]->use) {
					say.push(map[mati].road[i]->to);
					map[mati].road[i]->use = false;
				}
				swap(map[mati].road[i], map[mati].road[nmax - 1]);
				--i;
				--nmax;
				map[mati].road.pop_back();
			}
		}
		cout << answer << endl;
	}
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  bool b_flag=0, w_flag=0;
  ll w_cnt=0;
  ll ans=0;
  rep(i,s.size()){
    if(s[i]=='B') b_flag=1;
    if(s[i]=='W'){
      w_flag=1;
      ans+=i;
      w_cnt++;
    }
  }
  if(b_flag==0||w_flag==0){
    ans=0;
  }else{
    ans=ans-(w_cnt*(w_cnt-1)/2);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
vector<int64_t>A(26,1);
  for(int i=0;i<N;i++){
  char x=s.at(i);
    int y=x-'a';
    A.at(y)++;
  
  }int64_t ans=1;
  for(int i=0;i<26;i++){
  ans=(ans*A.at(i))%1000000007;
  } ans--; cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std; 
#define endl "\n"
int main() 
{
//	ios::sync_with_stdio(0);
//	cin.tie(0);
    long long int i,j,l,inc,dec,t,r,mod=1000000007;
   	long long int c,d,q,e,ans=0,n,temp,m,p,w,h,k,x,y;
//	cin>>t;
	t=1;
	while(t--)
	{
		cin>>n;
		double dp[n+1][n+1],a[n],an=0;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		if(n==1)
		{
			cout<<a[0];
			continue;
		}
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=n;j++)
			{
				dp[i][j]=0;
			}
		}
		dp[0][0]=1;
		for(i=1;i<=n;i++)
		{
			for(j=0;j<=i;j++)
			{
				if(j==0)
				{
					dp[i][j]=dp[i-1][j]*(1-a[i-1]);
				}
				else
				{
					dp[i][j]=dp[i-1][j-1]*a[i-1] + dp[i-1][j]*(1-a[i-1]);			
				}
				//cout<<dp[i][j]<<" ";
			}
			//cout<<endl;
		}
		for(i=n/2+1;i<=n;i++)
		{
			an=an+dp[n][i];
		}
		printf("%.12f",an);
		
	}

   return 0;
}
/*
1
5
1 1 6 1 6

*/



Measured memory_bytes: 70528
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S;

int main()
{
	in >> S;

	if (S.length() < 4) { out << "No" << std::endl; }
	else
	{
		auto c = S.substr(0, 4);
		if (c == "YAKI") { out << "Yes" << std::endl; }
		else { out << "No" << std::endl; }
	}
	return 0;
}

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

int count(char** c, int l, int v, int h, int w){
	int sum = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(!(l & (1 << i)) && !(v & (1 << j)) && c[i][j] == '#')sum++;
		}
	}
	return sum;
}


int main(void){
	int h, w, k;
	scanf("%d %d %d", &h, &w, &k);
	char **c = malloc(sizeof(char*) * h);
	for(int i = 0; i < h; i++){
		c[i] = malloc(sizeof(char) * w);
		scanf("%s", c[i]);
	}

	int sum = 0;
	for(int l = 0; l < (1 << h); l++){
		for(int v = 0; v < (1 << w); v++){
			if(count(c, l, v, h, w) == k)sum++;
		}
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 2100
S = list(input())
ans = 0

for i in range(2**(len(S)-1)):
    tmp = S
    p = list(bin(i))
    flag = ['0' for _ in range(len(S) - len(p) + 1)] + p[2:]
    nums = []
    l = 0
    for j in range(len(S)-1):
        if flag[j] == '1':
            nums.append("".join(tmp[l:j+1]))
            l = j+1
    nums.append("".join(tmp[l:]))
    for n in nums:
        ans += int(n)

print(ans)


Measured memory_bytes: 8920
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int ans = 0;
        for(int i = 1; i <= n; i++) {
            int sum = 0;
            int num = i;
            while(num != 0){
                sum += num % 10;
                num /= 10;
            }
            System.err.printf("num: %d, sum: %d\n", i, sum);
            if(sum >= a && sum <= b)
                ans += i;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 41476
#include <iostream>

using namespace std;

int main(void){
	int n; cin >> n;
	char str[10];
	bool ans = true;
	int count = 0;
	for(int i=0; i<n; i++){
		cin >> str;
		if(str[0] == 'A') count++;
		else count--;
		if(count < 0) ans = false;
	}
	if(count != 0) ans = false;
	if(ans) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  char S[H][W];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> S[i][j];
    }
  }
  int counter = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      counter = 0;
      if(S[i][j] == '.'){
        if(i>0&&j>0){if(S[i-1][j-1] == '#'){counter++;}}
        if(i>0){if(S[i-1][j] == '#'){counter++;}}
        if(i>0&&j<W-1){if(S[i-1][j+1] == '#'){counter++;}}
        if(j>0){if(S[i][j-1] == '#'){counter++;}}
        if(j<W-1){if(S[i][j+1] == '#'){counter++;}}
        if(i<H-1&&j>0){if(S[i+1][j-1] == '#'){counter++;}}
        if(i<H-1){if(S[i+1][j] == '#'){counter++;}}
        if(i<H-1&&j<W-1){if(S[i+1][j+1] == '#'){counter++;}}
        if(counter == 0){S[i][j] = '0';}
        if(counter == 1){S[i][j] = '1';}
        if(counter == 2){S[i][j] = '2';}
        if(counter == 3){S[i][j] = '3';}
        if(counter == 4){S[i][j] = '4';}
        if(counter == 5){S[i][j] = '5';}
        if(counter == 6){S[i][j] = '6';}
        if(counter == 7){S[i][j] = '7';}
        if(counter == 8){S[i][j] = '8';}
      }
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout << S[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string w;
    cin >> w;
    map<char, int> m;
    for (auto c : w) {
        m[c]++;
    }
    for (auto p : m) {
        if (p.second % 2 == 1) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int h1, m1, h2, m2;
	cin >> h1 >> m1 >> h2 >> m2;
	int t1 = 60 * h1 + m1;
	int t2 = 60 * h2 + m2;
	int k;
	cin >> k;
	cout << (t2 - t1 - k) << endl;
}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll x,y,z;cin>>x>>y>>z;
    x-=z;
    cout<<x/(y+z)<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
using namespace std;

using ll = long long;

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

int main()
{
	int N;
	cin >> N;
	vector<int> x(N), y(N), h(N);

	int index_HNotZ;
	rep(i, N)
	{
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] != 0)
		{
			index_HNotZ = i;
		}
	}

	ll ansX, ansY, ansH;
	bool isAns = false;
	rep(i, 101)
	{
		rep(j, 101)
		{
			isAns = true;
			ll cand_h = h[index_HNotZ] + abs(x[index_HNotZ] - i) + abs(y[index_HNotZ] - j);
			rep(k, N)
			{
				auto a = abs(x[k] - i) + abs(y[k] - j);
				if (cand_h != h[k] + abs(x[k] - i) + abs(y[k] - j))
				{
					if (h[k] != 0 || cand_h > abs(x[k] - i) + abs(y[k] - j))
					{
						isAns = false;
						break;
					}
				}
			}

			if (isAns)
			{
				ansX = i;
				ansY = j;
				ansH = cand_h;

				break;
			}
		}

		if (isAns) break;
	}

	cout << ansX << " " << ansY << " " << ansH << endl;
	
	return 0;
}

Measured memory_bytes: 3544
#include<stdio.h>
#include<string.h>
#include<ctype.h>

void str_tolower(char s[])
{
	int i= 0;
	while (s[i]){
		s[i] = tolower(s[i]);
		i++;
	}
}

int main()
{
	char W[11];
	char T[32];
	int count=0;
	
	scanf("%s",W);
	
	while(1){
		scanf("%s",T);
		
		if(strcmp(T,  "END_OF_TEXT")==0) break;
		
		str_tolower(T);
		
		if(strcmp(T, W)==0)
			count++;
	}
	
	printf("%d\n",count);
	
	return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
string str[maxn];
ll n;
int main()
{
	scanf("%lld",&n);
	ll ans=0;
	map <string,ll> m;
	map <string,ll> :: iterator to;
	for(int i=0;i<n;i++)
	{
		cin>>str[i];
		sort(str[i].begin(),str[i].end());
		m[str[i]]++;
	}
	for(to=m.begin();to!=m.end();to++)
	{
		ans+=(to->second)*(to->second-1)/2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18176
#include<stdio.h>
int main()
{
    int a,b,c;

    scanf("%d %d",&a,&b);
    c=a*b;
    if(a<=9 && b<=9)
    {
        printf("%d\n",c);
    }
    else
    {
        printf(" -1\n");
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<pair<pair<string, int>, int>> data(n);

  for (int i = 0; i < n; i++) {
      string s;
      int k;
      cin >> s >> k;
      k *= -1;
      data.at(i) = make_pair(make_pair(s,k),i+1);
  }

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

  for (int i = 0; i < n; i++) {
      cout << data.at(i).second << endl;
  }
}


Measured memory_bytes: 3600