akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Light[] lights = new Light[m];
        for(int i=0; i<m; i++) {
            Light l = new Light();
            int k = in.nextInt();
            int[] s = new int[k];
            for(int j=0; j<k; j++) {
                s[j] = in.nextInt();
            }
            l.s = s;
            lights[i] = l;
        }
        for(int i=0; i<m; i++) {
            lights[i].p = in.nextInt();
        }

        int attempts = 1 << n;
        int result = 0;
        for(int i=0; i<attempts; i++) {
            boolean isAllOn = true;
            for(int j=0; j<m; j++) {
                if(!lights[j].isOn(i)) {
                    isAllOn = false;
                    break;
                }
            }
            if(isAllOn) {
                result++;
            }
        }
        System.out.println(result);
    }
}
class Light {
    int[] s;
    int p;
    public boolean isOn(int switches) {
        int c = 0;
        for(int i=0; i<this.s.length; i++) {
            if((switches & (1<<(this.s[i]-1))) > 0) {
                c++;
            }
        }
        return (c%2 == this.p);
    }
}


Measured memory_bytes: 23252
//nani?
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
using namespace __gnu_pbds;
const int inf=1e7;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 2e5+5;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll bp(ll b,ll e){
	if(e==0) return 1LL;
  	ll aux=bp(b,e/2);
  	if(e%2==1){
    	return (((b*aux)%MOD)*aux)%MOD;
    }
  	else{
      return (aux*aux)%MOD;
    }
}
int main(){
    fastio;
    ll n,k;
  	cin>>n>>k;
  	ll ans=0;
  	ll val = n*(n+1)/2;
  	for(ll i=k;i<=n+1;i++){
      	ll val1 = (n-i)*(n-i+1)/2;
      	ll val2 = (i-1)*i/2;
      	//trace(i,val,val1,val2);
    	ans += ((val-val1)-val2+1);
      	ans%=MOD;
    }
  	cout<<ans<<endl;
  
    
    
} 

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

int nakamayukie(const void* x, const void* y) {
	uint64_t a = *(const uint64_t*)x, b = *(const uint64_t*)y;
	return a > b ? -1 : a < b;
}

int N;
uint64_t a[333333];

int main(void) {
	int i;
	uint64_t hayasibaramegumi = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < 3 * N; i++) {
		if (scanf("%" SCNu64, &a[i]) != 1) return 1;
	}
	qsort(a, 3 * N, sizeof(*a), nakamayukie);
	for (i = 0; i < N; i++) {
		hayasibaramegumi += a[i * 2 + 1];
	}
	printf("%" PRIu64 "\n", hayasibaramegumi);
	return 0;
}


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

public class Main {

	public static void main (String[] args) {
	   Scanner sc = new Scanner(System.in) ;
	   char s[] = sc.nextLine().toCharArray();
	   long k = sc.nextLong();
	   for(int i = 0; i<Math.min(s.length, k); i++) {
		   if(s[i] != '1' ) {
			   System.out.println(s[i]);
			   return; 
		   }
	   }
	   System.out.println('1'); 
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(),a.end()
#define IN(a,x,b) (a<=x && x<b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

double EPS = 1e-10;

double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}


struct P{
	double x,y;
	P(){}
	P(double x,double y):x(x),y(y){}
	P operator +(P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator *(double d){
		return P(x*d,y*d);
	}
	double dot(P p){//内積
		return add(x*p.x,y*p.y);
	}
	double det(P p){//外積
		return add(x*p.y,-y*p.x);
	}
};

//交差判定
bool on_seg(P p1,P p2,P q){
	return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<=0;
}

//交差座標
P intersection(P p1,P p2,P q1,P q2){
	return p1 + (p2-p1) * ((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));
}

int solve(){
	int xa,ya,xb,yb;
	int N;
	cin>>xa>>ya>>xb>>yb>>N;
	auto st = P(xa,ya);
	auto en = P(xb,yb);
	vector<pair<double,pair<int,int>>>kousa;
	int XS,YS,XT,YT,O,L;
	REP(i,N){
		cin>>XS>>YS>>XT>>YT>>O>>L;
		auto S = P(XS,YS);
		auto T = P(XT,YT);
		if((st-en).det(S-T)==0)continue;
		P r = intersection(st,en,S,T);
		if(on_seg(S,T,r)&&on_seg(st,en,r))kousa.push_back({r.x,{O,L}});
	}
	sort(ALL(kousa));
	vector<int>now;
	for(auto e:kousa){
		now.push_back(e.second.first==e.second.second);
		if(now.size()>=2&&now[now.size()-1]==now[now.size()-2])now.pop_back();
	}
	return max(0ll,(int)now.size()-1ll);
}

signed main(){
	int N;
	cin>>N;
	vector<int>ans;
	REP(i,N)ans.push_back(solve());
	for(auto e:ans)cout<<e<<endl;
}


Measured memory_bytes: 3128
from sys import stdin
xs = [int(x) for x in stdin.readline().rstrip().split()]
a = xs[0] * 10 + xs[1] + xs[2]
b = xs[0] + xs[1] * 10 + xs[2]
c = xs[0] + xs[1] + xs[2] * 10
print(max(max(a, b),c))


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mp1(a,b,c) P1(a,P(b,c))

vector<P1> ret;
void solve(int n,int L){
	if(n==0)return;
	int x=L/2;
	solve(n-1,x);
	ret.push_back(mp1(n-1,n,0));
	if(x!=0){
		ret.push_back(mp1(n-1,n,x));
		if(L&1){
			ret.push_back(mp1(0,n,L-1));
		}
	}
}

int main(){
	int L;
	cin>>L;
	solve(19,L);
	printf("%d %d\n",20,(int)ret.size());
	for(int i=0;i<ret.size();i++){
		printf("%lld %lld %lld\n",ret[i].fr+1,ret[i].sc.fr+1,ret[i].sc.sc);
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <algorithm>

using namespace std;

#define N 205
#define R 1005
#define INF INT_MAX

int hl[N][N], sl[N][N];
int pack[R];

int dp[R][N];

int n, m, r;

void warshall_floyd(){
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				if (hl[i][k] != INF && hl[k][j] != INF){
					hl[i][j] = min(hl[i][j], hl[i][k] + hl[k][j]);
				}
				if (sl[i][k] != INF && sl[k][j] != INF){
					sl[i][j] = min(sl[i][j], sl[i][k] + sl[k][j]);
				}
			}
		}
	}
}

int solve(){
	warshall_floyd();
	for (int i = 0; i < r; i++){
		for (int j = 0; j < n; j++) dp[i][j] = INF;
	}
	for (int i = 0; i < n; i++){
		if (sl[pack[0]][i] != INF && hl[i][pack[0]] != INF)
			dp[0][i] = sl[pack[0]][i] + hl[i][pack[0]];
	}
	for (int i = 1; i < r; i++){
		for (int j = 0; j < n; j++){
			for (int k = 0; k < n; k++){
				if (k == j){
					if (dp[i - 1][j] != INF && hl[pack[i - 1]][pack[i]] != INF)
						dp[i][k] = min(dp[i][k], dp[i - 1][j] + hl[pack[i - 1]][pack[i]]);
				}else{
					if (dp[i - 1][j] != INF && hl[pack[i - 1]][j] != INF && sl[j][k] != INF && hl[k][pack[i]] != INF)
						dp[i][k] = min(dp[i][k], dp[i - 1][j] + hl[pack[i - 1]][j] + sl[j][k] + hl[k][pack[i]]);
				}
			}
		}
	}
	int rst = INF;
	for (int i = 0; i < n; i++){
		rst = min(rst, dp[r - 1][i]);
	}
	return rst;
}

int main(){
	while (~scanf("%d %d", &n, &m)){
		if (n == 0 && m == 0) break;
		int from, to, t;
		char type;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				if (i == j){
					hl[i][j] = sl[i][j] = 0;
				}else{
					hl[i][j] = sl[i][j] = INF;
				}
			}
		}
		for (int i = 0; i < m; i++){
			scanf("%d %d %d %c", &from, &to, &t, &type);
			from--, to--;
			if (type == 'L'){
				hl[from][to] = min(t, hl[from][to]);
				hl[to][from] = hl[from][to];
			}else{
				sl[from][to] = min(t, sl[from][to]);
				sl[to][from] = sl[from][to];
			}
		}
		scanf("%d", &r);
		for (int i = 0; i < r; i++){
			scanf("%d", &pack[i]);
			pack[i]--;
		}
		int ans = solve();
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
  std::string s;
  std::cin >> s;
  
  if ((s[2] == s[3]) && (s[4] == s[5])) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(111111);
  ll ans = 0;
  while(n--){
    ll a,b;cin>>a>>b;
    ans += b-a+1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int dp[1005][5000];

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> di(m);
  vector<int> a(m);
  rep(i, m){
    int b;
    cin >> a[i] >> b;
    rep(j, b){
      int c;
      cin >> c;
      c--;
      di[i]+=(1<<c);
    }
  }
  rep(i, m+1)rep(j, (1<<n)){
    dp[i][j]=INF;
  }
  rep(i, m+1){
    dp[i][0]=0;
  }

    rep(j, (1<<n)){
      rep(i, m){
      /*
      if(i+1==3 && (di[i]|j)==3){
        cout << di[i] << endl;
        cout << j << endl;
        cout << (di[i]|j) << endl;
        cout << dp[i+1][(di[i]|j)] << " " << dp[i][j]+a[i] << endl;
      }
      */
      dp[i+1][(int)(di[i]|j)]=min(dp[i+1][(int)(di[i]|j)], dp[i][j]+a[i]);
      dp[i+1][j]=min(dp[i][j], dp[i+1][j]);
      //dp[i+1][di[i]|j]=min(dp[i+1][di[i]|j], dp[i][di[i]|j]);
    }
  }
  if(dp[m][(int)((1<<n)-1)]==INF){
    cout << "-1" << endl;
  } else {
      cout << dp[m][(int)((1<<n)-1)] << endl;
  }

  return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string str;
    cin >> str;
    int n = str.size();
    int s[n];
    for (int i = 0; i < n; i++) {
        s[i] = str[i] - '0';
    }
    long long res = 0;
    for (int i = 0; i < 1 << n - 1; i++) {
        long long t = 0;
        for (int j = 0; j < n; j++) {
            t = 10 * t + s[j];
            if ((i >> j) % 2 || j == n - 1) {
                res += t;
                t = 0;
            }
        }
    }
    cout << res << "\n";
    return 0;
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

#define mygc(c) (c)=getchar_unlocked()

int ri() {
	int c,s=0,r=0;
	for(;;){ mygc(c); if(c=='-'){s=1;break;} if(c<='9'&&c>='0'){r=c-'0';break;}}
	for(;;){ mygc(c); if(c>'9'||c<'0')break; r= r* 10 + c-'0';}
	if(s)r=-r;
	return r;
}

int main() {
    int n = ri();
	int a[n];
	FOR(i,n) a[i] = ri();
	
	// to +
	s64 cur = 0;
	s64 r0 = 0;
	FOR(i,n) {
		cur += a[i];
		if (i%2) { // -
			if (cur >= 0) {
				r0 += cur+1;
				cur = -1;
			}
		} else {
			if (cur <= 0) {
				r0 += 1-cur;
				cur = 1;
			}
		}
	}
	
	cur = 0;
	s64 r1 = 0;
	FOR(i,n) {
		cur += a[i];
		if (i%2) { // -
			if (cur <= 0) {
				r1 += 1-cur;
				cur = 1;
			}
		} else {
			if (cur >= 0) {
				r1 += cur+1;
				cur = -1;
			}
		}
	}
	
	cout << min(r0,r1) << endl;
	
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <queue>
#define int long long
using namespace std;
queue<pair<string,int>> que;
int n,q;
void round_robin(){
    int t = 0;
    while(!que.empty()){
        auto nt = que.front(); que.pop();
        if(nt.second > q){
            nt.second -= q;
            t += q;
            que.push(nt);
        }else{
            t += nt.second;
            cout << nt.first << " " << t << endl;
        }
    }
}
signed main(){    
    while(cin >> n >> q){
        for(int i=0; i<n; i++){
            pair<string,int> nt;
            cin >> nt.first >> nt.second;
            que.push(nt);
        }
        round_robin();
    }
}


Measured memory_bytes: 6316
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    
    int N;
    scanf("%d", &N);

    char si1mojime[N];
    char dammy;
    scanf("%c", &dammy);
    int i;
    char buff[100];

    for (i = 0; i < N; i++){
        gets(buff);
        si1mojime[i] = buff[0];
        }

    /*
    for (i = 0; i < N; i++)
    {
        printf("%c\n", si1mojime[i]);
    }
    */

    unsigned long long int m, a, r, c, h;
    m = a = r = c = h = 0;
    for (i = 0; i < N; i++){
        if(si1mojime[i] == 'M'){
            m += 1;
        }else if(si1mojime[i] =='A'){
            a += 1;
        }else if(si1mojime[i]=='R'){
            r += 1;
        }else if(si1mojime[i]=='C'){
            c += 1;
        }else if(si1mojime[i] =='H'){
            h += 1;
        }

    }

    unsigned long long ans = 0;
    ans 
    = m * a * r 
    + m * a * c 
    + m * a * h 
    + m * r * c 
    + m * r * h 
    + m * c * h 
    + a * r * c 
    + a * r * h 
    + a * c * h 
    + r * c * h;

    // printf("%d %d %d %d %d", m, a, r, c, h);
    printf("%llu", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
const int N = 100007;
const int K = 107;

int dp[N][K][2];
char s[N];
int a[N];
int n,m;

int dfs(int k,int now,int lim)
{
    if(dp[k][now][lim]>=0) return dp[k][now][lim];
    if(k==m) return dp[k][now][lim] = (now==0);
    int sum = 0;
    int up = lim?a[k]:9;
    for(int i=0;i<=up;i++)
    {
        sum += dfs(k+1,(now+i)%n,lim&&i==up);
        sum%=mod;
    }
    return dp[k][now][lim] = sum;
}


int main()
{
    scanf("%s%d",s,&n);
    m = strlen(s);
    for(int i=0;i<m;i++)
    {
        a[i] = s[i]-'0';
    }
    memset(dp,-1,sizeof(dp));
    printf("%d\n",(dfs(0,0,1)+mod-1)%mod);
    return 0;

}


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

int main() {
	long long int t;
	cin>>t;

	long long int x = t / 500;
	t = t - x * 500;
	long long int ans = 0;
	ans = x * 1000;
	x = t / 5;
	ans += x * 5;

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

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, a[100];
    cin >> n >> m;
    int total = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        total += a[i];
    }
    sort(a, a + n, greater<int>());
    if (a[m - 1] * 4 * m < total) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<array>
using namespace std;

int main(){

    long long int n;
    cin >> n;

    array<long long int, 5> way;

    for(int i = 0;i < 5; ++i){

        cin >> way[i];

    }

    long long int out = 4;
    long long int going = n;

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

    out += (going+way[0]-1) / way[0];


    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int d[1<<26];
char s[200001];
int main() {
	fill(d,d+(1<<26),INF);
	d[0]=1;
	int now=0,n;
	scanf("%s",s);
	n=strlen(s);
	fup(i,0,n-1,1)
	{
		s[i]-='a';
		now^=(1<<s[i]);
		bitset<26> bs=now;
		if(bs.count()<=1)d[now]=1;
		fup(k,0,25,1)
		{
			int kk=now^(1<<k);
			if(d[kk]!=INF)
				d[now]=min(d[now],d[kk]+1);
		}
	}
	printf("%d",d[now]);
}

Measured memory_bytes: 262528
#include <iostream>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void cMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}

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

    cout << (thermal>=30? "Yes" : "No");   
    return 0;
}
/*

*/


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

bool is_prime(int x)
{
    if (x <= 1)
        return false;
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0)
            return false;
    return true;
}
int main()
{

    int x;
    cin >> x;

    int p = x;
    while (!is_prime(p))
        p++;
    cout << p << endl;

    return 0;
}


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

using namespace std;
const int N = 1e4 + 5;

int main()
{
	int n;
	cin >> n;
	int height[n+1], dp[n+1];
	for (int i = 0; i < n; i++)
		cin >> height[i];
	//memset(dp, 0, sizeof(dp));
	dp[0] = 0;
	dp[1] = abs(height[1] - height[0]);
	for (int i = 2; i < n; i++)
	{
		long long a, b;
		a = abs(height[i] - height[i - 1]) + dp[i - 1];
		b = abs(height[i] - height[i - 2]) + dp[i - 2];
		dp[i] = min(a, b);
	}
	cout << dp[n - 1] << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	ll n,m;
	cin >> n>>m;
	ll ans=0;
	if (n < m/2) {
		ans = n;
	}
	else {
		ans = m/2;
		cout << ans << endl;
		return 0;
	}

	ans += (m-2*n)/4;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int cnt=0;
	while(1){
		cnt++;
		if (n>=k) n/=k;
		else{cnt--;break;}
	}
	cout<<cnt+1;
	return 0;
}

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

int main() {
	long long n = 0, a = 0, b = 0, c = 0, x = 0, y = 0;
	
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		long long in;
		cin >> in;
		a = max(in, a);
		b += in;
	}
	cout << b - (a / 2) << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
	int n, k;
	std::vector<int> aList;

	std::cin>>n>>k;
	aList.resize(n);
	
	for(int i=0; i<n; i++)
		std::cin>>aList[i];



	for(int i=0; i<n-k; i++){
		if(aList[i]<aList[i+k])
			std::cout<<"Yes"<<std::endl;
		else
			std::cout<<"No"<<std::endl;
	}


	return 0;
}

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

#define ll long long
#define ppi pair<int, int>
#define vi vector<int>
#define fi first
#define se second
#define forn(n) for(ll i = 0; i < n; i++)
#define forx(x,n) for(ll i = x; i < n; i++)

using namespace std;
int DP[3001][3001];
string LCA(int n, int m, string c, string a, string b)
{
	if(n == 0 || m == 0)
	{
		reverse(c.begin(), c.end());
		return c;
	}
	if(a[n-1] == b[m-1])
	{
		c+=a[n-1];
	 	return	LCA(n - 1, m - 1, c, a, b);
	}
	else
	{
		if(DP[n][m-1] > DP[n-1][m]) return LCA(n, m - 1, c, a, b);
		else return LCA(n - 1, m, c, a, b);
	}
	
}
int main()
{
 	string s,t;
 	cin>>s>>t; 
 	DP[(int)s.size()-1][0] = 0;
 	DP[0][(int)t.size()-1] = 0;
 	
  
  	for(int i = 1; i <= s.size(); i++) 
  	  for(int j = 1; j <= t.size(); j++)
  	  {
  	  	 if(s[i-1] == t[j-1])
		 {
		 	 DP[i][j] = DP[max(i-1,0)][max(j-1,0)] + 1;
				
		 }	 
		 else if (i>0 && j>0) DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
		 else DP[i][j] = 0 ;
		 //cout<<DP[i][j]<<" "<<s[i-1]<<" "<<t[j-1]<<" ";
	  } 
	int i = s.size(), j = t.size();
    cout<<LCA(s.size(), t.size(), "", s, t);
}

Measured memory_bytes: 66432
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n;
    int l[2000];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }
    sort(l,l+n);
    int ans=0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if(l[i]<l[j]+l[k] && l[j]<l[i]+l[k] && l[k]<l[i]+l[j]){
                    ans++;
                }else{
                    break;
                }
            }
        }
    }
    std::cout << ans << std::endl;
}


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

using namespace std;

int main()
{
	long long n, x, a;
	long long r = 0;
	cin >> n >> x >> a;
	for (int i = 0; i < n-1; i++)
	{
		long long b;
		cin >> b;
		if (a + b > x)
		{
			r += (a + b) - x;
			b -= (a + b) - x;
			a = max(0ll, b);
		}
		else a = b;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, M := ReadInt(), ReadInt()
	t := 1900*M + 100*(N-M)
	invp := 1 << M
	fmt.Println(invp * t)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef vector<int> vi;
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;

   int flag;
   int i;

   for(i=0;;i++)
   {
       if(i%2==0)
       {
           c-=b;
           if(c<=0)
           {   flag=1;
               break;
           }
       }
       else
       {
           a-=d;
           if(a<=0)
           {
               flag=0;
               break;
           }
       }
   }
   if(flag)
    cout<<"Yes\n";
   else
    cout<<"No\n";
   return 0;
}


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

int main(){
	char b;
	cin >> b;
	switch(b) {
		case 'A':
			cout << 'T' << endl;
			break;
		case 'T':
			cout << 'A' << endl;
			break;
		case 'G':
			cout << 'C' << endl;
			break;
		case 'C':
			cout << 'G' << endl;
			break;
		default:	
			break;	
	}
}


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

int main() {
    int N;
    cin >> N;
    int a[N], b[N], c[N];
    for (int i = 0; i < N; ++i) cin >> a[i] >> b[i] >> c[i];

    int dp[N + 1][3];
    for (int j = 0; j < 3; ++j) dp[0][j] = 0;

    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j < 3; ++j) {
            switch (j) {
                case 0:
                    dp[i][j] = max(dp[i - 1][1] + b[i - 1], dp[i - 1][2] + c[i - 1]);
                    break;
                case 1:
                    dp[i][j] = max(dp[i - 1][2] + c[i - 1], dp[i - 1][0] + a[i - 1]);
                    break;
                case 2:
                    dp[i][j] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][1] + b[i - 1]);
                    break;
            }
        }
    }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        System.out.println(squareArea(x,y) + " " + squarePerimeter(x,y));
    }
    public static int squareArea(int x, int y){
        return x * y;
    }
    public static int squarePerimeter(int x, int y){
        return (x + y) * 2;
    }
}


Measured memory_bytes: 25944
import java.util.Scanner;

public class Main {



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

		Long n = Long.parseLong(sc.next());
		Long a = Long.parseLong(sc.next());
		Long b = Long.parseLong(sc.next());
		Long c = a + b;

		Long ans = 0l;

		ans = (n/c)*a;
		
		long cnt = n%c;
		
		if(cnt > a) {
			cnt = a;
		}
		ans += cnt;

		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 21844
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct S {
    int x, y;
    int opCmp(const ref S s) const {
        if (x == s.x) {
            return y - s.y;
        }
        return x - s.x;
    }
}

int f(S[] a) {
    if (a.length <= 32) return h(a);
    int ret = min(f(a[0 .. $ / 2]), f(a[$ / 2 .. $]));
    int border = a[$ / 2].x;
    foreach (i; 0 .. a.length) {
        if (!(border - ret < a[i].x && a[i].x < border)) continue;
        int lb = 0, ub = cast(int)a.length;
        while (lb + 1 < ub) {
            int mid = (lb + ub) / 2;
            if (border  - ret <= a[mid].x && a[mid].x <= border) {
                lb = mid;
            } else {
                ub = mid;
            }
        }
        foreach (p; a[lb .. ub]) {
            if (p.y - a[i].y >= ret) continue;
            ret = min(ret, d(a[i], p));
        }
    }
    return ret;
}

int h(S[] a) {
    int ret = int.max;
    foreach (i; 0 .. a.length) {
        foreach (j; i + 1 .. a.length) {
            ret = min(ret, d(a[i], a[j]));
        }
    }
    return ret;
}

int d (const ref S a, const ref S b) {
    return square(a.x - b.x) + square(a.y - b.y);
}

int square(int x) {
    return x * x;
}

void main() {
    int n; readf("%d\n", &n);
    S[] ps = new S[n];
    foreach (i; 0 .. n) {
        readf("%d %d\n", &ps[i].x, &ps[i].y);
    }
    ps = ps.sort.array;
    f(ps).writeln;
}

Measured memory_bytes: 10736
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long
#define L size


void solve()
{
    int n,ans = 0;
    double d;
    cin >> n >> d;
    while(n--)
    {
        double a,b;
        cin >> a >> b;
        if(sqrt(a*a+b*b)<=d)
            ans++;
    }
    cout << ans;

}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
/*  int t;
    read(t);
    while(t--)*/
        solve();
    
}


Measured memory_bytes: 3824
#include<stdio.h>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for ( int i = g; i < n; i++ ) {
    int v = A[i];
    int j = i - g;
    while ( j >= 0 && A[j] > v ) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  for ( int h = 1; ; ) {
    if ( h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i-- )
    insertionSort(A, n, G[i]);
}

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  printf("%d\n", G.size());
  for ( int i = G.size() - 1; i >= 0; i-- ) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

  return 0;
}


Measured memory_bytes: 6700
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
 
#define N  100005

signed main()
{
      int n,k;
      cin>>n>>k;
      cout<<ceil(float(n)/k);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();

		switch (str) {
		case "Sunny":
			System.out.println("Cloudy");
			break;
		case "Cloudy":
			System.out.println("Rainy");
			break;
		default:
			System.out.println("Sunny");
			break;
		}
	}
}


Measured memory_bytes: 21076
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main () {
	int x, p;
	vector<int> scores;
	map<int, int> teams;
	while (scanf("%d,%d", &x, &p), x || p) {
		teams[x] = p;
		scores.push_back(p);
	}
	sort(scores.begin(), scores.end());
	scores.erase(unique(scores.begin(), scores.end()), scores.end());
	while (scanf("%d", &x) != EOF) {
		printf("%d\n", static_cast<int>(scores.size() - static_cast<int>(lower_bound(scores.begin(), scores.end(), teams[x]) - scores.begin())));
	}
	return 0;
}

Measured memory_bytes: 1056
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        long numC = b / c - (a - 1) / c;
        long numD = b / d - (a - 1) / d;

        long l = lcm(c, d);
        long numL = b / l - (a - 1) / l;

        System.out.print(b - a - (numC + numD - numL) + 1);
    }


    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return c/b;
    }
}

Measured memory_bytes: 21844
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 200003
#define M 2003
#define inf 1e18
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    Arena
    
    int n,l;
    cin>>n>>l;
    int i,mi=inf,s=0,f=0;
    for(i=1;i<=n;++i)
    {
        if(abs(l+i-1)<mi)
        {
            mi=abs(l+i-1);
            if(l+i-1ll>0ll)
                f=1ll;
        }
        s+=(l+i-1ll);
    }
    
    cout<<(f? s-mi:s+mi);
    
    
    return 0;
}


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

int H, W;
const int maxn = 1005;
char grid[maxn][maxn];
int dist[maxn][maxn];

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> H >> W;
    queue<pair<int,int>> q;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == '#') {
                q.push({i,j});
                dist[i][j] = 0;
            }
            else dist[i][j] = 999999;
        }
    }
    while (!q.empty()) {
        auto p = q.front(); q.pop();
        int x = p.first;
        int y = p.second;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (1 <= nx && nx <= H && 1 <= ny && ny <= W) {
                if (dist[nx][ny] > dist[x][y] + 1) {
                    dist[nx][ny] = dist[x][y] + 1;
                    q.push({nx,ny});
                }
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            ans = max(ans,dist[i][j]);
        }
    }
    cout << ans << '\n';
}



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

using namespace std;

typedef long long int ll;

const ll MOD = 1000000007;

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

  int N, K;
  cin >> N >> K;

  int b = K + 1;
  ll cnt = 0;
  for (int i = b; i <= N; i++) {
    int a = 0;
    while (a + i <= N) {
      cnt += i - K;
      a += i;
    }
    if (K == 0) cnt--;
    int remaining = N - a + 1;
    cnt += max(0, remaining - K);
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
n,c=map(int,input().split())

C0={i:0 for i in range(1,c+1)}
C1={i:0 for i in range(1,c+1)}
C2={i:0 for i in range(1,c+1)}

CH=[-1]
for i in range(c):
    new=[-1]+[int(i) for i in input().split()]
    CH.append(new[:])

for i in range(n):
    D=[int(i) for i in input().split()]
    for q in range(n):
        now=(i+q)%3
        if now==0:
            C0[D[q]]+=1
        elif now==1:
            C1[D[q]]+=1
        else:
            C2[D[q]]+=1



def calc(dic,col):
    res=0
    for ele in dic:
        res+=dic[ele]*CH[ele][col]
    return res

ans=10**10
for i in range(1,c+1):
    for q in range(1,c+1):
        for r in range(1,c+1):
            if i==q or q==r or r==i:
                continue
            sub=0
            sub+=calc(C0,i)
            sub+=calc(C1,q)
            sub+=calc(C2,r)
            ans=min(ans,sub)

print(ans)
            

Measured memory_bytes: 69244
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {

        int[] input = Array.ConvertAll(Console.ReadLine().Split(" "), int.Parse);
        int h = input[0],
            w = input[1],
            k = input[2];
        int ans = 0;
        char[,] array = new char[h, w];
        for (int i = 0; i < h; i++)
        {
            char[] tmp = Console.ReadLine().ToCharArray();
            for (int j = 0; j < w; j++)
            {
                array[i, j] = tmp[j];
            }
        }
        for (int maskH = 0; maskH < Math.Pow(2, h); maskH++)
        {
            for (int maskW = 0; maskW < Math.Pow(2, w); maskW++)
            {
                int black = 0;
                for (int i = 0; i < h; i++)
                {
                    if (((maskH >> i) & 1) == 0)
                        continue;

                    for (int j = 0; j < w; j++)
                    {
                        if (((maskW >> j) & 1) == 0)
                        {
                            if (array[i, j] == '#')
                                black++;
                        }
                    }
                }
                if (black == k)
                    ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    if (s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 764
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


S = str(input())
P = str(input())

is_ok = False

for i in range(len(S)):
    FLG = True
    for k in range(len(P)):
        if S[(i+k)%(len(S))] != P[k]:
            FLG = False
            break

    if FLG == True:
        is_ok = True
        break

if is_ok == True:
    print("Yes")
else:
    print("No")







Measured memory_bytes: 5580
def increment_decrement(N: int, S: str)->int:
    x, max_x = 0, 0
    for c in S:
        if c == 'I':
            x += 1
            max_x = max(max_x, x)
        else:
            x -= 1
    return max_x


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = increment_decrement(N, S)
    print(ans)


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

using namespace std;

int main(){
  int N;
  int A[100001];
  int B;
  long long unsigned int ans = 0;

  cin >> N;
  for (int i=0; i<=N; i++) {
    cin >> A[i];
  }
  for (int i=0; i<N; i++) {
    cin >> B;
    if (B >= A[i]) {
      ans += A[i];
      B -= A[i];
      ans += min(B, A[i+1]);
      A[i+1] -= B;
      A[i+1] = max(A[i+1], 0);
    } else {
      ans += B;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


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

    vector<int>p(n);

    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    long long int a = 0, b = -1;;
    for (int i = 0; i < k; i++) {
        a += p[i];
    }
    b = a;
    int r = k - 1;
    for (int i = k; i < n; i++) {
        a += p[i];
        a -= p[i - k];
        if (b < a) {
            b = a;
            r = i;
        }
    }
    double ans = 0;
    cout << setprecision(20);
    for (int i = r; i > r - k; i--) {
        ans += (double)(1 + p[i]) / 2;
    }
    cout << ans << endl;

    return 0;

}

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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

ll calc()
{
	ll X, K, D;
	cin >> X >> K >> D;

	ll t1 = floor(abs(X) / D);
	ll t2 = ceil(abs(X) / D);

	if (t1 == t2 && t2 < K) {
		++t2;
	}

	if (abs(t1) >= K) {
		ll r = (abs(X) - D * K);
		return r;
	}

	ll r1 = abs(abs(X) - D * t1);
	ll r2 = abs(abs(X) - D * t2);

	if (r1 <= r2) {
		ll s = K - t1;
		if (s % 2 == 0) {
			return r1;
		}
		else{
			return r2;
		}
	}
	else {
		ll s = K - t2;
		if (s % 2 == 0) {
			return r2;
		}
		else {
			return r1;
		}
	}
}

void Main()
{
	cout << calc();
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int c;
  int sum=0;
  cin>>n;
  vector<int>a;
  for(int i=0;i<n;i++){
    cin>>c;
    a.push_back(c);
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      sum+=a[i]*a[j];
    }
  }
  cout<<sum;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#define MAX 100
#define INFTY -1

using namespace std;
queue<int> Q;
int d[MAX];
int A[MAX][MAX]={0};
int n;

void bfs(int u)
{
	Q.push(u);
	d[u] = 0;

	while(!Q.empty())
	{
		int v = Q.front();
		Q.pop();
		for(int i=0; i<n; i++)
		{
			if(A[v][i] == 1)
			{
				if(d[i] == INFTY)
				{
					Q.push(i);
					d[i] = d[v] + 1;
					//printf("%d %d\n",v+1,d[v]);
				}
			}
		}
	}
}

int main()
{
	int u,k,v;
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		scanf("%d%d", &u, &k);
		u -= 1;
		for(int j=0; j<k; j++)
		{
			scanf("%d", &v);
			v -= 1;
			A[u][v] = 1;
		}
		d[u] = -1;
	}
	
	bfs(0);

	for(int i=0; i<n; i++)
	{
		printf("%d %d\n", i+1, d[i]);
	}

	return 0;
}


Measured memory_bytes: 2720
h, w = map(int, input().split())
S = [input() for i in range(h)]
A = []
for s in S:
	if '#' in s:
		A.append(s)
nh = len(A)
B = [''] * nh
for x in range(w):
	if any(a[x] == '#' for a in A):
		for y in range(nh):
			B[y] += A[y][x]
for b in B:
	print(b)

Measured memory_bytes: 38896
import sys

input = sys.stdin.readline

bingo = []
for _ in range(3):
    bingo.append(list(map(int, input().split())))

N = int(input())
nums = []
for _ in range(N):
    nums.append(int(input()))

for num in nums:
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == num:
                bingo[i][j] = -1

for i in range(3):
    if sum(bingo[i]) == -3:
        print("Yes")
        sys.exit()
    tmp = 0
    for j in range(3):
        tmp += bingo[j][i]
    if tmp == -3:
        print("Yes")
        sys.exit()
if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
    print("Yes")
    sys.exit()
if bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[0][2] == -1:
    print("Yes")
    sys.exit()

print("No")

Measured memory_bytes: 9084
#include <stdio.h>


int main(){

int a[10000], min, max, n, i;

long sum;

scanf("%d", &n);

for(i = 0; i < n; i++){
scanf("%d", &a[i]);
sum += a[i];

}

max = min = a[0];
for(i = 1; i < n; i++){
    if(a[i] > max)
    max = a[i];
    
    if(a[i] < min)
    min = a[i];
}

printf("%d %d %ld\n", min, max, sum);


return 0;

}

Measured memory_bytes: 636
r , c = map( int,input().split())

spread_list=[ [0]*c ] * (r+1) 

for i in range( r ):# スプレッドシート入力
    spread_list[i] = list ( map( int,input().split()) )
    spread_list[i].append( sum (spread_list[i]) )

spread_list[r].append( 0 )

for ci in range( c+1 ):
    sumer = 0
    for ri in range(r):
        sumer += spread_list[ri][ci]
    spread_list[r][ci] = sumer

for a in spread_list:
    print(*a, sep=' ')


Measured memory_bytes: 6224