akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
       fast;
       int n;
       cin>>n;
       int arr[n],cnt=0;
       for(int i=0;i<n;i++)
    	cin>>arr[i];
       for(int i=1;i<n-1;i++)
    		if(arr[i]<arr[i-1]&&arr[i]>arr[i+1])
    			cnt++;
    		else if(arr[i]>arr[i-1]&&arr[i]<arr[i+1])
    			cnt++;
    	cout<<cnt;
       return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
string s;
int len;
int main()
{
	cin >> s;
	len = s.size();
	for (int i = 0; i < len - 1; i++)	if (s[i] == s[i + 1]) { printf("%d %d\n", i + 1, i + 2); return 0; }
	for (int i = 0; i < len - 2; i++)	if (s[i] == s[i + 2]) { printf("%d %d\n", i + 1, i + 3); return 0; }
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 512
/*
  User:- sanyam
*/

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)
#define base(i,val) memset(i, val, sizeof(val))
#define all(x) (x).begin(), (x).end()

const ll inf = 1e18;

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}


/* ---------------------Code--------------------  */
vector<int>tree[100001];
vector<ll>dp1(100001, -1), dp2(100001, -1);
bool vis[100001]={false};


void solve2(ll src, ll m, ll par_ans){
  vis[src] = true;
  dp2[src] = (dp1[src] * (1+par_ans))%m;

  vector<ll>prefix, suffix;

  for(int child : tree[src]) {
    if(!vis[child]){
      suffix.push_back(dp1[child]+1);
      prefix.push_back(dp1[child]+1);
    }
  }

  for(int i=1; i<prefix.size(); i++)
    prefix[i] = (prefix[i] * prefix[i-1])%m;
  
  for(int i=suffix.size()-2; i>=0; i--){
    suffix[i] = (suffix[i+1] * suffix[i])%m;
  }

  int cnt=0;
  for(int child : tree[src]){
    if(!vis[child]){
      ll ways = 1 + par_ans;
      ways = (cnt>0) ? (prefix[cnt-1]*ways)%m : ways;
      ways = (cnt < suffix.size()-1) ? (ways*suffix[cnt+1])%m : ways;
      solve2(child, m, ways);
      cnt++;
    }
  }

  return;
}

void solve1(ll src, ll m){
  vis[src] = true;
  dp1[src] = 1;

  for(int child : tree[src]) {
    if(!vis[child]){
      solve1(child, m);
      dp1[src] = (dp1[src] * (1+dp1[child]))%m;
    }
  }
  return;
} 

void solve(){
  ll n, m;
  cin>>n>>m;
  
  loop(i, 0, n-1) {
    int x, y; cin>>x>>y;
    tree[x].push_back(y);
    tree[y].push_back(x);
  }

  solve1(1, m);
  memset(vis, false, sizeof vis);
  solve2(1, m, 0);

  for(int i=1; i<=n; i++)
    cout<<dp2[i]<<endl;

  return;
}

int main(){

  fastIO;
  //take_fileIO();
  solve();
  return 0;
}

Measured memory_bytes: 24192
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge{
    int to, cost;
};


// dijikstra
/* int V;
vector<edge> G[10];
int d[10];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V + 1, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
*/

bool arr[100010];



void prime(){
    REP(i, 100002){
        arr[i] = true;
    }
    FOR(i, 2, 317){
        if(arr[i]){
            for(int j = 0; i * (j + 2) < 100002; j++){
                arr[i * (j + 2)] = false;
            }
        }
    }
}

int main(){
    int q;
    cin >> q;
    prime();
    int cnt[100000];
    cnt[1] = 0;
    REP(i, 100000){
        if(i == 1) continue;
        if(i % 2 == 0) continue;
        if(arr[i] && arr[(i + 1) / 2]){
            cnt[i] = cnt[i - 2] + 1;
        }else{
            cnt[i] = cnt[i - 2];
        }
    }
    REP(i, q){
        int l, r;
        cin >> l >> r;
        if(l == 1) l = 3;
        cout << cnt[r] - cnt[l - 2] << endl;
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int num[100]={0};
	int n=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	int sum=0;
	for(int i=0;i<n;i++){
		int temp=0;
		scanf("%d",&temp);
		sum+=max(num[i]-temp,0);
	}
	printf("%d\n",sum);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<long>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  int c = 0;
  long a,b;
  for(int i = n-1;i > 0;i--){
    if(data.at(i) == data.at(i-1) && c == 0){
      a = data.at(i);
      i--;
      c++;
    }
    else if(data.at(i) == data.at(i-1) && c == 1){
      b = data.at(i);
      cout << a*b << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

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

Measured memory_bytes: 256
package main

import (
	"strconv"
	"bufio"
	"os"
	"strings"
	"fmt"
)

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_C&lang=jp>
 */

func init() {

}

func main() {
	v,_ := SplitIntStdin(" ")
	fmt.Println(v[0]*v[1],2*(v[0]+v[1]))
}

// ????????????1?????????
func StrStdin() (stringReturned string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput := scanner.Text()

	stringReturned = strings.TrimSpace(stringInput)
	return
}

// ??´??°???1?????????
func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

// ?????????????????????????????????????????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}

	return
}

// ??????????????§??????????????????????????????????????????
func SplitStrStdin(delim string) (stringReturned []string) {
	// ???????????§1?????????
	stringInput := StrStdin()

	// ????????§??????
	// stringSplited := strings.Split(stringInput, delim)
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

// ??????????????§??????????????´??°????????????????????????
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// ??????????????????????????????
	stringSplited := SplitStrStdin(" ")

	// ??´??°?????????????????????
	for i := range stringSplited {
		var iparam int
		iparam, err = strconv.Atoi(stringSplited[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}

Measured memory_bytes: 1060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b) cout << "Yes";
	else cout << "No";
	return 0; 
}

Measured memory_bytes: 256
from collections import*
import sys
input=sys.stdin.readline

h,w=map(int,input().split())
grid=[["#"]*(w+2)]+[list("#"+input()+"#")for x in range(h)]+[["#"]*(w+2)]

stack=deque()
for y in range(1,h+1):
    for x in range(1,w+1):
        if grid[y][x]=="#":
            grid[y][x]=0
            stack.append((y,x))

for i in range(h*w):
    tmp=deque()
    while stack:
        my,mx=stack.pop()
        for y,x in ([0,1],[1,0],[-1,0],[0,-1]):
            if grid[my+y][mx+x]==".":
                grid[my+y][mx+x]=i+1
                tmp.append([my+y,mx+x])
    stack=tmp
    if not tmp:
        print(i)
        break

Measured memory_bytes: 164616
h, w = map(int, input().split())
s = [input() + '#' for _ in range(h)]
s.append('#' * w)

yoko = [[0] * w for _ in range(h)]
for i in range(h):
  si = s[i]
  start = -1
  for j in range(w + 1):
    if si[j] == '#':
      if start != -1:
        for k in range(start, j):
          yoko[i][k] = j - start
        start = -1
    else:
      if start == -1:
        start = j

tate = [[0] * w for _ in range(h)]
for i in range(w):
  start = -1
  for j in range(h + 1):
    if s[j][i] == '#':
      if start != -1:
        for k in range(start, j):
          tate[k][i] = j - start
        start = -1
    else:
      if start == -1:
        start = j

result = 0
for i in range(h):
  yokoi = yoko[i]
  tatei = tate[i]
  for j in range(w):
    t = yokoi[j] + tatei[j] - 1
    if t > result:
      result = t

print(result)


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int n;
  cin>>n;
  int a[n];
  int tmp;
  memset(a,0,sizeof(a));
  REP(i,n-1){
    cin>>tmp;
    a[tmp-1]++;
  }
  REP(i,n){
    cout<<a[i]<<endl;
  }
}


Measured memory_bytes: 4420
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <climits>

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

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

	vector<int> W(N);
	for (int i = 0; i < N; ++i) {
		cin >> W[i];
	}

	int ans = 100000;
	for (int i = 0; i < N; ++i) {
		int S1 = 0;
		for (int j = 0; j <= i; ++j) {
			S1 += W[j];
		}

		int S2 = 0;
		for (int k = i+1; k < N; ++k) {
			S2 += W[k];
		}

		ans = min(ans, abs(S1 - S2));
	}

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


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();

        int x1[] = new int[n];
        int x2[] = new int[n];
        for (int i = 0; i < n; i++) {
            x1[i] = sc.nextInt();
            x2[i] = x1[i];
        }

        Arrays.sort(x2);

        int midl = x2[n / 2 - 1];
        int midr = x2[n / 2];

        for (int i = 0; i < n; i++) {
            System.out.println((x1[i] <= midl) ? midr : midl);
        }
    }

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


Measured memory_bytes: 93592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
int main(){
    string s;
    cin >> s;
    int n(0),w(0),ss(0),e(0);

    for(ll i=0; i<s.length(); i++){
        if(s[i]=='N') n++;
        if(s[i]=='W') w++;
        if(s[i]=='S') ss++;
        if(s[i]=='E') e++;
    }

    bool x(false),y(false);

    if(n==ss) y=true;

    if((n>=1)&&(ss>=1)) y=true;

    if(w==e) x=true;

    if((w>=1)&&(e>=1)) x=true;

    if(x&&y){
        cout <<"Yes"<<endl;
    } 
    else{
        cout <<"No"<<endl;
    }
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< vector<int> > g(n);
  map< pair<int, int>, int> mp;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
    mp[{u, v}] = i;
    mp[{v, u}] = i;
  }
  int k = 0;
  for (int v = 0; v < n; ++v) {
    k = max(k, (int)g[v].size());
  }
  cout << k << '\n';
  vector<int> res(n - 1, -1);
  auto dfs = [&](auto& F, int v, int p, int c) -> void {
    for (int u : g[v]) {
      if (u != p) {
        res[mp[{v, u}]] = c++;
        F(F, u, v, c);
      }
    }
  };
  dfs(dfs, 0, -1, 0);
  for (int e : res) {
    cout << e % k + 1 << '\n';
  }
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int K, S;
    cin >> K >> S;

    int ans = 0;
    rep(i, K + 1) {
        rep(j, K + 1) {
            if (S - i - j <= K && S - i - j >= 0) ans++;
        }
    }

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

Measured memory_bytes: 256
var  
 x,y,z,w:longint;
 s:string;
begin
  readln(s);
  x:=ord(s[1])-ord('0'); y:=ord(s[2])-ord('0');
  z:=ord(s[3])-ord('0'); w:=ord(s[4])-ord('0');
  if  x+y+z+w=7  then 
     begin  writeln(x,'+',y,'+',z,'+',w,'=7');  halt;  end;
  if  x+y+z-w=7  then 
   begin  writeln(x,'+',y,'+',z,'-',w,'=7');  halt;  end;
  if  x+y-z+w=7  then  
   begin  writeln(x,'+',y,'-',z,'+',w,'=7');  halt;  end;
  if  x-y+z+w=7  then 
   begin  writeln(x,'-',y,'+',z,'+',w,'=7');  halt;  end;
  if  x-y-z+w=7  then 
   begin  writeln(x,'-',y,'-',z,'+',w,'=7');  halt;  end;
  if  x-y+z-w=7  then 
   begin  writeln(x,'-',y,'+',z,'-',w,'=7');  halt;  end;
  if  x+y-z-w=7  then 
   begin  writeln(x,'+',y,'-',z,'-',w,'=7');  halt;  end;
  if  x-y-z-w=7  then 
   begin  writeln(x,'-',y,'-',z,'-',w,'=7');  halt;  end;
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int n, x;
  std::cin >> n >> x;
  vector<int> l(n);
  for(int i=0; i<n; i++) std::cin >> l[i];

  int ans = 1;
  int now_dist = 0;
  for(int i=0; i<n; i++){
    now_dist += l[i];  
    if( now_dist <= x ){
      ans += 1;
    }else{
      break;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int A,B;
    cin >> A >> B;
    vector<vector<char>>ans(102,vector<char>(102,'#'));
    for(int i = 50; i <= 100; i++) {
        for(int j = 0; j <= 100; j++) {
            ans[i][j] = '.';
        }
    }
    int nx = 1,ny = 1;
    A--;
    while(A) {
        if(ans[nx+1][ny] == '#' && ans[nx-1][ny] == '#' && ans[nx][ny+1] == '#' && ans[nx][ny-1] == '#') {
            ans[nx][ny] = '.';
            A--;
        }
        if(ny+1 == 101) {
            ny = 1;
            nx+=2;
        }
        else {
            ny++;
        }
    }
    nx = 100;ny = 100;
    B--;
    while(B) {
        if(ans[nx+1][ny] == '.' && ans[nx-1][ny] == '.' && ans[nx][ny+1] == '.' && ans[nx][ny-1] == '.') {
            ans[nx][ny] = '#';
            B--;
        }
        if(ny-1 == 0) {
            ny = 100;
            nx-=2;
        }
        else {
            ny--;
        }
    }
    cout << 100 << " " << 100 << endl;
    for(int i = 1; i <= 100; i++) {
        for(int j = 1; j <= 100; j++) {
            cout << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T>vector<T> inarr(int s,int e, T init){
	vector<T> v;T x;
	for(int i=0;i<s;++i)v.push_back(init);
	for(int i=s;i<e;++i){cin>>x;v.push_back(x);}
	return v;
}

ll N,M;
vl A;

bool check(ll x){ // x以上の和: x<=ai+aj -> x-ai<=aj
	ll total = 0; // count_aj を集計
	for(auto ai:A){
		ll pos_aj = lower_bound(all(A), x-ai) - A.begin();
		ll count_aj = N; // aj に該当するデータの個数
		count_aj -= pos_aj;
		total += count_aj;
	}
	return total < M; // x以上の和 < M個?
}

ll solve(){
	sort(all(A));
	// binary search
	ll ng = 2*A[0], ok = 2*A[N-1]; // [ng,ok]:[l.r]
	while(ng+1<ok){ // l+1 < r
		ll x = (ok+ng)/2; // x:mid
		if(check(x)) ok = x; // (x 以上の和 < M個)? ok=x: ng=x
		else ng = x;
	}
	// ng=x-1, ok=x
	vl csum(N+1); rp(i,0,N) csum[i+1] = csum[i] + A[i]; // 累積和A
	ll ans = 0;
	for(auto ai:A){ // ng<ai+aj -> ng-ai<aj
		ll pos_aj = upper_bound(all(A), ng-ai) - A.begin();
		ll count_aj = N - pos_aj;
		ans += count_aj * ai + (csum[N] - csum[pos_aj]);
		M -= count_aj;
	}
	ans += M * ng;
	return ans;
}

int main(){
	cin>>N>>M;
	A = inarr<ll>(0,N,0);
	cout<< solve() <<endl;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define read(type) readInt<type>() // Fast read
#define ll long long
#define nL "\n"
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set
#define MOD 1000000007
#define imax INT_MAX
#define imin INT_MIN
#define exp 1e9
#define sz(x) (int((x).size()))

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    char board[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> board[i][j];
        }
    }


    int ans = 0;
    for (int maskr = 0; maskr < (1 << h); maskr++)
    {
        for (int maskc = 0; maskc < (1 << w); maskc++)
        {
            int black = 0;
            for (int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++) {
                    if(((maskr>>i) & 1) == 0 and ((maskc>>j) & 1) == 0 and board[i][j] == '#') {
                        black ++;
                    }
                }
            }
            if(black == k) {
                ans ++;
            }
        }
    }
    cout << ans;
    // int maskc = (1<<w) - 1;

    // for ()

        return 0;
}


Measured memory_bytes: 3616
//usr/bin/env picoc $0 - $@;exit
#include <stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d",&a,&b);
  c= a+b;
  if(a-b>c){
    c=a-b;
  }
  if(a*b>c){
   c=a*b;
  }
  printf("%d\n",c);
  return 0;
}

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

int main() {
	// your code goes here
	
	int n;
	cin>>n;
	
	int a[n];
	
	for(int i=0;i<n;i++)
		cin>>a[i];
		
	if(a[0])
		a[0]--;
	
	for(int i=1;i<n;i++){
		
		if(a[i]<a[i-1]){
			cout<<"No";
			return 0;
		}
		else{
			if(a[i]>a[i-1])
				a[i]--;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main() {
  int tes;
  vector<int> s(5);
  for (int i = 0; i < 5; i++) {
    cin >> s[i];
    if (s[i] == 0) {
      tes = i + 1;
    }
  }
  cout << tes << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
	int n,i,j,p,flg,flg2,s,pp;
	int b[11000];
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		for(i=0;i<n;i++)	{
			scanf("%d",&b[i]);
		}
		flg=0;
		p=n;
		for(i=0;i<=10000;i++)	{
			flg2=1;
			for(j=0;j<p;j++)	{
				if(b[j]!=j+1)	{
					flg2=0;
					break;
				}
			}
			if(flg2==1)	{
				flg=1;
				break;
			}
			for(j=0;j<p;j++)	{
				b[j]--;
			}
			b[p]=p;
			p++;
			pp=0;
			for(j=0;j<p;j++)	{
				if(b[j]!=0)	{
					b[pp]=b[j];
					pp++;
				}
			}
			p=pp;
		}
		if(flg==1)	{
			printf("%d\n",i);
		}
		else {
			printf("-1\n");
		}
	}
	return 0;
}


Measured memory_bytes: 624
// noobie_corleone
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
//vector<int> adj[200010];
//vector<int> value(200010),par(200010),vis(200010,0),fi(200010,0),g(200010,0),col(200010,-1);
int myrandom (int i) { return std::rand()%i;}

int main()
{
	ll n,W;
	cin>>n>>W;
	vector<ll> w(n+1),v(n+1);
	fr(i,1,n+1)
	{
		cin>>w[i]>>v[i];
	}
	vector<vector<ll>> dp(n+1, vector<ll> (W+1,0));
	fr(i,1,n+1)
	{
		fr(j,1,W+1)
		{
			if(j < w[i])
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+ v[i]);
		}
	}
/*	fr(i,0,n+1)
	{
		fr(j,0,W+1)
		{
			cout<<dp[i][j]<<" ";
		}
	}*/
	cout<<dp[n][W]<<endl;
	return 0;
}


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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 1

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
//}

int n,ans,m,a,b,c,d,bit,i,j,k;
string s;

int main(){
  cin>>n;
  d=n%10;
  n/=10;
  c=n%10;
  n/=10;
  b=n%10;
  n/=10;
  a=n%10;
  n/=10;
  for(i=0;i<2;i++){
    b*=-1;
    for(j=0;j<2;j++){
      c*=-1;
      for(k=0;k<2;k++){
        d*=-1;
        if(a+b+c+d==7){
          cout<<abs(a);
          (b<0)?cout<<"-":cout<<"+";
          cout<<abs(b);
          (c<0)?cout<<"-":cout<<"+";
          cout<<abs(c);
          (d<0)?cout<<"-":cout<<"+";
          cout<<abs(d)<<"=7"<<endl;
          return 0;
        }
      }
    }
  }
}

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

using namespace std;

#define pb push_back

const int maxi = 1e6+10;
int a[maxi];
string s;
vector<int> v[maxi];
long long l;
int n;
long long cnt[maxi];
long long ans;
int main()
{

   cin>>n;
   for (int i =1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }

    for (int i =1;i<=n;i++)
        ans+=(cnt[i]*(cnt[i]-1)/2);

    for (int i =1;i<=n;i++)
    {
        printf("%lld\n", ans - cnt[a[i]] + 1);
    }
    return 0;
}
//volim tvoje oci tamne kao greh


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

using namespace std;

int main()
{
    int H, W, N, i = 1;

    cin >> H;
    cin >> W;
    cin >> N;

    if(H >= W)
    {
        while(1)
        {
            if(N <= H * i)
            {
                break;
            }
            else
            {
                i++;
            }
        }
    }
    else
    {
        while(1)
        {
            if(N <= W * i)
            {
                break;
            }
            else
            {
                i++;
            }
        }
    }

    cout << i;

    return 0;
}


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

int a,b,c,d,gede;
int main(){
d=0;
cin>>a>>b>>c;
if(c>b){
	d =c-(a+b);
}else{
	d=b-(c+a);
}
if(d<=0){
	cout<<0<<endl;
}else{
	cout<<d<<endl;
}
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int, string>> words(N);
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        reverse(S.begin(), S.end());
        words[i] = {(int)S.size(), S};
    }
    sort(words.begin(), words.end());
    reverse(words.begin(), words.end());
    vector<vector<int>> cnt(1000010, vector<int>(26, 0));
    vector<vector<int>> next(1000010, vector<int>(26, -1));
    int pos = 1;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        string word = words[i].second;
        int K = words[i].first;
        int now = 0;
        int c = 0;
        vector<int> exist(26, 0);
        for (int j = 0; j < K; j++) {
            exist[(int)(word[j]-'a')]++;
        }
        for (int j = 0; j < K-1; j++) {
            c = (int)(word[j] - 'a');
            for (int k = 0; k < 26; k++) {
                if (exist[k] > 0) cnt[now][k]++;
            }
            exist[c]--;
            if (next[now][c] != -1) {
                now = next[now][c];
            }else {
                next[now][c] = pos;
                now = pos;
                pos++;
            }
        }
        c = (int)(word[K-1]-'a');
        ans += cnt[now][c];
        cnt[now][c]++;
        if (next[now][c] == -1) {
            next[now][c] = pos;
            pos++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

int main() {
    vector<int> vec(3);
    for (int i = 0; i < 3; ++i) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    cout << (vec[0] + vec[1] == vec[2] ? "Yes" : "No") << endl;

    return 0;
}

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

int main()
{
	int a,b,c,d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	
	int satu = a*b;
	int dua = c*d;
	if(satu >= dua)
	{
		cout << satu << endl;
	}
	else
	{
		cout << dua << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll N, K;
	cin >> N >> K;

	vector<ll> h(N);
	for (ll i = 0; i < N; ++i) cin >> h[i];

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

	ll ans = INF;
	for (ll i = 0; i + K < N + 1; ++i)
	{
		chmin(ans, h[i + K - 1] - h[i]);
	}

	cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

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

    long long ans = 0;
    for (int i = 1; i < n; i++) {
        ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
  int a,b,c,d;
  int rect1=0,rect2=0;
  std::cin >> a >> b >> c >> d;

  rect1 = a*b;
  rect2 = c*d;

  if(rect1 <= rect2){
    std::cout << rect2 << std::endl;
  }else std::cout << rect1 << std::endl;
  
  return 0;
}


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

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = a * c;
  ans = max(ans, a*d);
  ans = max(ans, b*c);
  ans = max(ans, b*d);
  cout << ans << endl;
}

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

long long mod=2019LL;

template<typename T>
constexpr T modpow(T a,int n){//(a^n)%MOD
    T ret=1;
    while(n>0){
        if((n&1)!=0){//n%2==1
            ret=ret*a%mod;
        }
        a=a*a%mod;
        n=n/2;
    }
    return ret;
}

using namespace std;
using ll = long long;

int main() {
    string s;
    cin>>s;
    int n=s.size();
    reverse(s.rbegin(),s.rend());
    vector<ll> am(s.size());
    am[0]=s[0]-'0';
    map<int,ll> mp;
    mp[am[0]]+=1;
    mp[0]+=1;
    ll ans=0;
    for(int i = 1;i < n;++i) {
        am[i]=am[i-1]+(s[i]-'0')*modpow(10,i);
        am[i]%=mod;
//cerr<<am[i]<<endl;
        ans+=mp[am[i]];
//cerr<<am[i]<<" "<<i<<endl;
        mp[am[i]]+=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N*3);
  for(int i=0; i<N*3; i++) cin >> A.at(i);
  sort(A.begin(),A.end(), greater<int>());
  int64_t res = 0LL; 
  for(int i=1; i<N*2; i+=2) {
    res += A.at(i);
  }
  printf("%lld\n",res);
}


Measured memory_bytes: 1408
#-*-coding:utf-8-*-

def main():
    n, t = map(int, input().split())

    t_list = list(map(int, input().split()))

    not_water = []
    for i in range(1, n):
        if t_list[i] - t_list[i-1] > t:
            not_water.append(t_list[i] - t_list[i-1] - t)
    print(max(t_list) + t - sum(not_water))

if __name__ == '__main__':
    main()

Measured memory_bytes: 25200
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

//#define pb push_back
//#define mp make_pair
//
//#define F first
//#define S second

typedef long long ll;

#define rept(_i,iv,n,type) for(type _i=(type)(iv);_i<(type)(n);++_i)
//#define repi(_i,iv,n) rept(_i,iv,n,int)
//#define repl(_i,iv,n) rept(_i,iv,n,ll)

#define rept0(_i,n,type) rept(_i,0,n,type)
#define repi0(_i,n) rept(_i,0,n,int)
#define repl0(_i,n) rept(_i,0,n,ll)

//#define repst(_i,iv,n,type) for(type _i=iv;_i<=(type)(n);++_i)
//#define repsi1(_i,n) repst(_i,1,n,int)

#define REPT(_i,iv,_l,n,type) for(type _i=(type)(iv),_l=(type)(n);_i<_l;++_i)
//#define REPI(_i,iv,_l,n) REPT(_i,iv,_l,n,int)
//#define REPL(_i,iv,_l,n) REPT(_i,iv,_l,n,ll)
//
#define REPT0(_i,_l,n,type) REPT(_i,0,_l,n,type)
#define REPI0(_i,_l,n) REPT(_i,0,_l,n,int)
#define REPL0(_i,_l,n) REPT(_i,0,_l,n,ll)


//#define rrept(_i,x,e,type) for(type _i=((type)(x)-1);_i>=e;--_i)
//
//#define rrept0(_i,x,type) rrept(_i,x,0,type)
//
//#define RREPT(_i,x,_e,e,type) for(type _i=((type)(x)-1),_e=(type)(e);_i>=_e;--_i)
//
//#define RREPT0(_i,x,_e,type) RREPT(_i,x,_e,0,type)
//
//#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;


//typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
typedef vector<ll> vll;
//typedef vector<vll > vvll;
tdv(string, vs)

#define mod99 998244353

#define SIZE 5
const char STR[SIZE+1]="MARCH";


int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    int nums[SIZE];
    repi0(i, SIZE){
        nums[i]=0;
    }
    
    repi0(i, N){
        char S[11];
        cin>>S;
        repi0(j, SIZE){
            if(S[0]==STR[j]){
                ++nums[j];
                break;
            }
        }
    }
    
    ll sum=0;
    repi0(i, SIZE-2){
        if(nums[i]==0){
            continue;
        }
        for(int j=i+1;j<SIZE-1;++j){
            if(nums[j]==0){
                continue;
            }
            for(int k=j+1;k<SIZE;++k){
                if(nums[k]==0){
                    continue;
                }
                sum+=(ll)nums[i]*nums[j]*nums[k];
            }
        }
    }
    cout<<sum<<endl;
    
    
    return 0;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  int s[110];
  int n, sum = 0;
  int mn0 = -1;
  cin >> n;
  REP(i, n) {
    cin >> s[i];
    sum += s[i];
    if(s[i] % 10 != 0) {
      if(mn0 < 0) {
	mn0 = s[i];
      } else {
	mn0 = mn0 > s[i] ? s[i] : mn0;
      }
    }
  }    

  int ans;
  if(sum % 10 == 0) {
    if(mn0 < 0) {
      ans = 0;
    } else {
      ans = sum - mn0;
    }
  } else {
    ans = sum;
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int H, W;
int main() {
  cin >> H >> W;
  int cnt = 0;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      char c;
      cin >> c;
      if (c == '#') ++cnt;
    }
  }
  cout << (cnt == H + W - 1 ? "P" : "Imp") << "ossible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  char s[100];
  int n;
  scanf("%d", &n);
  scanf("%s", s);
  if(n % 2 == 1){
    printf("No\n");
    return 0;
  }
  for(int i = 0; i < n / 2; i++){
    if(s[i] != s[n / 2 + i]){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  
  return 0;
}

Measured memory_bytes: 128
n=int(input())
c=0
l=['0','3','5','7']
for i1 in l:
 for i2 in l:
  for i3 in l:
   for i4 in l:
    for i5 in l:
     for i6 in l:
      for i7 in l:
       for i8 in l:
        for i9 in l:
         x=str(int(i1+i2+i3+i4+i5+i6+i7+i8+i9))
         if '3' in x and '5' in x and '7' in x and '0' not in x and int(x)<=n:c+=1
print(c)

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

int main(){
    long long n, m;

    cin >> n >> m;

    

    vector <long long> v(m);

    
    for(long long i = 0; i < m; i++){
        cin >> v[i];
    }

    if(m == 1){
        printf("0\n");
        return 0;
    }

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

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

    long long sum = v[m-1] - v[0];

    if(n >= m){
        printf("0");
        return 0;
    }

    //printf("sum %d\n", sum);

    vector <long long> distance(m-1);

    

    for(long long i = 0; i < m-1; i++){
        distance[i] = v[i+1] - v[i];
        //printf("distance[i] %d\n", distance[i]);
    }

    sort(distance.begin(), distance.end());
    reverse(distance.begin(), distance.end());

    /*for(int i = 0; i < m-1; i++){
        //printf("sort distance[i] %d\n", distance[i]);
    }*/

    long long avoid = 0;
    for(long long i = 0; i < n-1; i++){
        avoid += distance[i];
        //printf("avoid %d\n", avoid);
    }

    printf("%lld\n", sum - avoid);

    return 0;


}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！

bool isPalindrome(string s) {
    string t = s;
    reverse(t.begin(),t.end()); //sを反転したtを作る
    return s == t; //sとtが等しければtrue、ダメならfalseを返す
} 

int main() {
    string s;
    cin >> s;
    bool ans = true;
    //A：　Sは回文である。
    //B：　Sの1文字目から(N−1)/2文字目まで(両端含む)からなる文字列は回文である。
    //C：　Sの(N+3)/2文字目からN文字目まで(両端含む)からなる文字列は回文である。
    //どれか2つの条件を判定すればいい。下記は、AとB。
    if (!isPalindrome(s)) ans = false; //文字列全体falseならansもfalse
    if (!isPalindrome(s.substr(0, s.size()/2))) ans = false; //sを半分にした場合
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){
	while(1){
		int n,a=0;
		scanf("%d",&n);
		if(!n)break;
		while(n!=1){
			if(n&1)n=n*3+1;
			else n/=2;
			a++;
		}
		printf("%d\n",a);
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<long long, long long> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    x = -x;
    a[x]++;
  }
  long long ans = 1, cnt = 0;
  for (auto i = a.begin(); i != a.end(); i++) {
    long long tmp = i->second;
    while (true) {
      if (tmp <= 1) {
        break;
      }
      ans = -ans*i->first;
      tmp -= 2;
      cnt++;
      if (cnt == 2) {
        cout << ans << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 6528
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type job struct {
	a, b int
}
type js []job

func (job js) Len() int {
	return len(job)
}
func (job js) Less(i, j int) bool {
	return job[i].b < job[j].b
}
func (job js) Swap(i, j int) {
	job[i], job[j] = job[j], job[i]
}

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	jobs := make([]job, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		jobs[i].a, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		jobs[i].b, _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(js(jobs))
	// fmt.Println("N", N, "jobs", jobs)
	t := 0
	for i := range jobs {
		t += jobs[i].a
		if t > jobs[i].b {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

int main() {
  int N;
  cin >> N;
  vector<pair<pair<string, int>, int> > vec(N);
  for(int i=0;i<N;i++){
    string s;int p;
    cin >> s >> p;
    vec.at(i).first.first=s;vec.at(i).first.second= -1*p;
    vec.at(i).second=i+1;
  }
  sort(vec.begin(),vec.end());
  for(auto f:vec){
    cout << f.second << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = '^' + input().strip() + '$'

dp = [[0 for _ in range(n + 2)] for _ in range(n + 2)]
longest = 0
for i in range(1, n + 2):
    for j in range(i + 1, n + 2):
        if s[i] == s[j]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            val = dp[i - 1][j - 1]
            if j - i < val:
                val = j - i
            if val > longest:
                longest = val

print(longest)

Measured memory_bytes: 247560
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define abs(x) ((x)<0?-1*(x):(x))

int main()
{
  int n;
  int x[105],y[105],h[105];
  int cx,cy,ch;
  int f,s;
  int i;
  scanf("%d",&n);
  
  for(i=0;i<n;++i){
    scanf("%d%d%d",x+i,y+i,h+i);
    if(h[i]) s=i;
  }
  
  for(cx=0;cx<=100;++cx){
    for(cy=0;cy<=100;++cy){
      f=0;
      ch=h[s]+abs(x[s]-cx)+abs(y[s]-cy);
      
      for(i=0;i<n;++i){
        int tmp=max(ch-abs(x[i]-cx)-abs(y[i]-cy),0);
        if(tmp==h[i])++f;
      }
      if(f==n)printf("%d %d %d",cx,cy,ch);
    }
  }
  
  return 0;
}


Measured memory_bytes: 128
h, n = map(int, input().split())
A = []
B = []
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
 
Ama = max(A)
 
dp=[float("inf")]*(h+Ama+1)
dp[0]=0
 
for i in range(h+1):
    for j in range(n):
        dp[i+A[j]]=min(dp[i+A[j]],dp[i]+B[j])
print(min(dp[h:]))

Measured memory_bytes: 42348
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] c = new char[s.length()];
		c = s.toCharArray();
		int sum = 0;
		for(int i = 0; i < s.length(); i++) {
			sum += c[i] - '0';
		}
		int n = Integer.parseInt(s);
		if(n%sum == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21716
w = input()
a = input()
l = [int(x) for x in a.split()]
c = 0
while True:
  for i, v in enumerate(l):
    if v % 2 == 0:
      l[i] = v / 2
    else:
      break
  else:
    c += 1
    continue
  break
print(c)  

Measured memory_bytes: 2940
import math

import math
a, b, h, m = map(int,input().split())

a_kakudo = ((h*60+m)*0.5)
b_kakudo = m * 6

if a_kakudo == b_kakudo:
    print(max(a,b)-min(a,b))
elif a_kakudo + b_kakudo == 180 or a_kakudo + b_kakudo == 360:
    print(a + b)
elif max(a_kakudo,b_kakudo)- min(a_kakudo, b_kakudo) == 90 or max(a_kakudo,b_kakudo)- min(a_kakudo, b_kakudo) == 270:
    print(math.sqrt(a**2 + b**2))
else:
    print(math.sqrt(a**2+b**2-((2*a*b*math.cos(math.radians(max(a_kakudo,b_kakudo)- min(a_kakudo, b_kakudo)))))))

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

const int AMAX = 100000;

int main(){
    ll N, K; cin >> N >> K;
    ll num[AMAX+1] = {0};
    for(int i = 0; i < N; i++){
        ll a, b; cin >> a >> b;
        num[a] += b;
    }
    ll cnt = 0;
    for(int i = 1; i <= AMAX; i++){
        cnt += num[i];
        if(cnt >= K){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 1024
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;




int main()
{
  long a, b, k; //かっている数//最大100
  vector<long> v(2,0);

  cin >> v[0] >> v[1] >> k ;


  for (int i = 0; i < k; ++i) {
    if (i % 2 == 0) {

      if (v[0] % 2 == 1){
        v[0]--;
      }

      v[1] += v[0] / 2;
      v[0] = v[0] / 2;
    } else {

      if (v[1] % 2 == 1){
        v[1]--;
      }
      v[0] += v[1] / 2;
      v[1] = v[1] / 2;
    }

    cerr << v[0] <<" " << v[1] <<endl;

  }




  cout << v[0] << " " << v[1];

  return 0;
}



























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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n,k;
    cin>>n>>k;
    vi p(n);
    rep(i,n)cin>>p[i];

    sort(all(p));

    int sum=0;

    rep(i,k)sum+=p[i];

    cout<<sum<<"\n";

    return 0;

}

Measured memory_bytes: 3628
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

long N, cnt;

bool ask(long n) {
    writeln("? ", n);
    stdout.flush;
    cnt += 1;
    
    debug {
        string sn = n.to!string;
        string sN = N.to!string;
        return (n <= N && sn <= sN) || (n > N && sn > sN);
    } else {
        return readln.chomp == "Y";
    }
}

void main() {
    debug {N = readln.chomp.to!long;}

    long x = 10;
    for (; x <= 10^^9 && ask(x); x *= 10) {}

    if (x == 10L^^10) { // N = 1, 10, 100, ...
        x = 2;
        for (; x <= 2 * 10L^^9 && !ask(x); x *= 10) {}
        writeln("! ", x / 2);
    } else {
        long k = x / 10;
        x = 0;
        for (; k > 0; k /= 10) {
            long hi = 10;
            long lo = 0;
            while (hi - lo > 1) {
                long mid = (hi + lo) / 2;
                if (ask((x * 10 + mid) * 10L^^9)) hi = mid;
                else lo = mid;
            }
            x = x * 10 + lo;
        }
        writeln("! ", x + 1);
    }

    debug {cnt.writeln;}
}


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

int calc(int y,int m,int d){
	y--;m--;d--;
	int res=0;
	res += y/3*(5*(19+20)*2+10*20);
	res += y%3*5*(19+20);
	if((y+1)%3==0){
		res += m*20;
	}else{
		res += m/2*(19+20);
		res += m%2*20;
	}
	res += d;
	return res;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		int y,m,d,ans=0;
		cin>>y>>m>>d;
		cout<<calc(1000,1,1)-calc(y,m,d)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
a,b,c,d = map(int,input().split())
ans = 'No'
if max(a,c)-min(a,c)<=d:
  ans = 'Yes'
if max(a,b)-min(a,b)<=d and max(b,c)-min(b,c)<=d:
  ans = 'Yes'
print(ans)

Measured memory_bytes: 3060