akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)

const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n), y(n), a(n);
    for(int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> a[i];

    pair<int, int> mn = {0, 0};
    pair<int, int> mx = {w, h};

    // cout << "(" << mn.first << ", " << mn.second << ") : (" << mx.first << ", " << mx.second << ")" << endl;


    rep(n) {
        if(a[i] == 1) {
            mn.first = max(mn.first, x[i]);
        }else if(a[i] == 2) {
            mx.first = min(mx.first, x[i]);
        }else if(a[i] == 3) {
            mn.second = max(mn.second, y[i]);
        }else {
            mx.second = min(mx.second, y[i]);
        }
        // cout << "(" << mn.first << ", " << mn.second << ") : (" << mx.first << ", " << mx.second << ")" << endl;
    }

    // cout << "(" << mn.first << ", " << mn.second << ") : (" << mx.first << ", " << mx.second << ")" << endl;

    // int ans = (mx.first - mn.first) * (mx.second - mn.second);

    // cout << ((ans > 0) ? ans : 0 );
    cout << max(0, (mx.first - mn.first)) * max(0, (mx.second - mn.second));
}

Measured memory_bytes: 256
import math

n = int(input(""))
blue = []
red = []
for i in range(0,n):
    blue.append(input(""))
m = int(input(""))
for i in range(0,m):
    red.append(input(""))
ans = 0
for i in range(0,n):
    temp = 0
    for str in blue:
        temp += 1 if blue[i] == str else 0
    for str in red:
        temp -= 1 if blue[i] == str else 0
    ans = max(ans,temp)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt

  val x = (1 to n).map(_ => sc.nextInt)
  val y = (1 to n).map(_ => sc.nextInt)

  val ans = x.zip(y)
    .filter(t => t._1 > t._2)
    .map(t => t._1 - t._2)
    .sum

  println(ans)

}


Measured memory_bytes: 27204
# https://atcoder.jp/contests/abc149/tasks/abc149_b



A, B, K = gets.split.map(&:to_i)

if A > K
  puts "#{A - K} #{B}"
else
  B = (A + B - K > 0) ? A + B - K : 0
  puts "0 #{B}"
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S ;
  cin >> S ;
    if (S == "Sunny"){
      cout << "Cloudy" << endl;
    }
    else if (S == "Cloudy") {
      cout << "Rainy" << endl;
    }
    else if (S == "Rainy"){
      cout << "Sunny" << endl;
    }
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    ll a = 1,b;
    rep(n){
        cin >> b;
        a = a * b / gcd(a,b);
    }
    cout << a << endl;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 610, mod = 1e9 + 7;
int f[N][N][N];
void upd(int &x, ll y) {
    x = (x + y) % mod;
}

ll getfac(ll n) {
    ll r = 1;
    for(int i = 1 ; i <= n ; ++ i) {
        r = r * i % mod;
    }
    return r;
}

int n, a[N], m, cnt;
int use[N], c[N];

int main() {
    scanf("%d", &n);
    for(int i = 1 ; i <= 2 * n ; ++ i) {
        scanf("%d", &a[i]);
    }
    for(int i = 1 ; i <= 2 * n ; i += 2) {
        if(a[i] == -1 && a[i + 1] == -1) {
            ++ cnt;
        } else if(a[i] != -1 && a[i + 1] != -1) {
            use[a[i]] = use[a[i + 1]] = -1; // 不使用
        } else if(a[i] != -1) {
            use[a[i]] = 1;
        } else if(a[i + 1] != -1) {
            use[a[i + 1]] = 1;
        }
    }
    for(int i = 1 ; i <= 2 * n ; ++ i) {
        if(use[i] == 1) {
            c[++ m] = 1;
        } else if(use[i] == 0) {
            c[++ m] = 0;
        }
    }
    f[m][0][0] = 1;
    for(int i = m ; i ; -- i) {
        for(int j = 0 ; j <= min(n, m) ; ++ j) {
            for(int k = 0 ; k <= min(n, m) ; ++ k) {
                if(c[i] == 1) {
                    upd(f[i - 1][j + 1][k], f[i][j][k]);
                    if(k) upd(f[i - 1][j][k - 1], f[i][j][k]);
                } else if(c[i] == 0) {
                    upd(f[i - 1][j][k + 1], f[i][j][k]);
                    if(k) upd(f[i - 1][j][k - 1], f[i][j][k]);
                    if(j) upd(f[i - 1][j - 1][k], (ll) f[i][j][k] * j % mod);
                }
            }
        }
    }
    printf("%lld\n", (f[0][0][0] * getfac(cnt) % mod + mod) % mod);
}


Measured memory_bytes: 825344
#include<stdio.h>

int main(){
  int a[524288],i,n,r=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
    r+=(a[i]%2)*(i%2);
  }
  printf("%d\n",r);
  return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b;
  cin>>a>>b;
  cout<<max(a+b,max(a-b,a*b))<<endl;


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] arr = s.split("");
		if (arr[2].equals(arr[3]) && arr[4].equals(arr[5])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35732
#include <vector>
#include <iostream>
#include <string>
using namespace std;
using ll=long long;
int main(){
  string S;
  cin>>S;
  string k("keyence");
  int i=0;
  for(auto s:S){
    if(k[i]==s){
      i++;
    }else{break;}
    if(i==k.size())break;
  }
  int j=k.size()-1;
  for(int a=S.size()-1;a>=0;--a){
    if(k[j]==S[a]){
      j--;
    }else{break;}
    if(j==-1)break;
  }
  if(i-(j-(k.size()-1))>=k.size()){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
d,g = map(int,input().split(" "))

pros = []

for i in range(d):
    pros.append(list(map(int,input().split(" "))))
    pros[i].append(100*(i+1)*pros[i][0]+pros[i][1])

min_p = 1000
for i in range(2**d):
    sum_i,pro_num = 0,0
    i_2 = str(bin(i)[2:])
    for k,j in enumerate(i_2[::-1]):
        if sum_i > g or min_p <=pro_num:
            break
        if j == "1":
            sum_i += pros[k][2]
            pro_num += pros[k][0]
    else:
        if sum_i >= g:
            min_p = min(pro_num,min_p)
        else:
            if pro_num < min_p:
                remain = g - sum_i
                i_3 = i_2.zfill(d)
                for k,j in enumerate(i_3):
                    if j == "0":
                        add = 0
                        while remain > 0 and add < pros[d-1-k][0]:
                            remain -= 100*(d-k)
                            add += 1
                            if remain <= 0:
                                pro_num += add
                                min_p = min(pro_num,min_p)
                                break
                        break
print(min_p)




Measured memory_bytes: 3188
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;


void solveCase() {
   int n, k;
   cin >> n >> k;
   vector <int> v(n);
   for(int i = 0; i < n; i++) {
      cin >> v[i];
   }
   int g = 0;
   for(int i = 0; i < n; i++) {
      g = std::gcd(g, v[i]);
   }

   if(k % g == 0 && k <= *max_element(v.begin(), v.end())) {
      cout << "POSSIBLE" << endl;
   } else {
      cout << "IMPOSSIBLE" << endl;
   }
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}



Measured memory_bytes: 3644
function Main(input) {
    const lines = input.split("\n");
    const H = +lines[0];
    const attack = (h, count) => {
        count++;
        h = Math.floor(h / 2);
        return h == 0 ? count : attack(h, count*2);
    };
    
    console.log(attack(H, 0));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
def solve(items, n, w):
    dp = [0] * (w+1)
    for i in range(n):
        wi, vi = items[i]
        for j in range(w, wi-1, -1):
            dp[j] = max(dp[j], dp[j-wi] + vi)

    return dp[w]


def main():
    inp = lambda: [int(x) for x in input().split()]
    n, w = inp()
    items = [inp() for _ in range(n)]
    print(solve(items, n, w))


if __name__ == '__main__':
    main()


Measured memory_bytes: 40432
import java.util.Scanner;
import java.util.TreeSet;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			TreeSet<Integer> set=new TreeSet<Integer>();
			for(int i=0;i<3;i++) set.add(sc.nextInt());
			System.out.println(set.size());
		}
	}
}

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

using namespace std;

int main(){
    int n,maximum=0,x=0;
    string s;
    char car;
    cin >> n >> s;

    for(int i=0;i<n;i++){
        car=s[i];
        if(car=='I') x++;
        else x--;

        if(x>maximum) maximum=x;
    }
    cout << maximum << endl;
}


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

char list1[4]={'m','c','x','i'};
int list2[4]={1000,100,10,1};

string tomcxi(int a){
     string tmp;
     for(int i=0;i<4;i++){
	  if(a/list2[i]>1)tmp+=(a/list2[i])+'0';
	  if(a/list2[i]>0)tmp+=list1[i];
	  a-=list2[i]*(a/list2[i]);
     }
     return tmp;
}

int toint(string a){
     int t=1;
     int sum=0;
     for(int i=0;i<a.size();i++){
	  switch(a[i]){
	  case 'm':
	       sum+=t*1000;
	       t=1;
	       break;
	  case 'c':
	       sum+=t*100;
	       t=1;
	       break;
	  case 'x':
	       sum+=t*10;
	       t=1;
	       break;
	  case 'i':
	       sum+=t;
	       t=1;
	       break;
	  default:
	       t=a[i]-'0';
	       break;
	  }
     }
     return sum;
}

int main(){
     int N;
     cin>>N;
     for(int i=0;i<N;i++){
	  string a,b;
	  cin>>a>>b;
	  //cout<<toint(a)+toint(b)<<endl;
	  cout<<tomcxi(toint(a)+toint(b))<<endl;
     }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define sortV(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
// DSU
/*
const int maxn=100009;
int arr[maxn];
int sz[maxn];
void init(){rep(i,maxn){arr[i]=i;sz[i]=1;}}
int root(int a){while(a!=arr[a]){arr[a]=arr[arr[a]];a=arr[a];}return a;}
int check(int a,int b){if(root(a)==root(b))return 1;return 0;}
int un(int a,int b)
{
  int roota=root(a);int rootb=root(b);
  if(sz[roota]>=sz[rootb]){sz[roota]+=sz[rootb];arr[rootb]=roota;}
  else {sz[rootb]+=sz[roota];arr[roota]=rootb;}
}
*/

//Dijkstra
/*
const int maxn=0x3f3f3f3f;
void dijkstra(int n,int dist[],vector<pi >adj[],int s)
{
  int visited[n+1];
  repre(i,0,n)
  {
    visited[i]=0;
    dist[i]=maxn;
  }
  dist[s]=0;
  priority_queue<pi ,vector<pi>,greater<pi> >p;
  p.push(mkp(0,s));
  while(p.empty()==false)
  {
    pi temp=p.top();
    p.pop();
    if(visited[temp.ss])continue;
    visited[temp.ss]=1;
    int u=temp.ss;
    rep(i,adj[u].size())
    {
      if(dist[u]+adj[u][i].ss<dist[adj[u][i].ff])
      {
        dist[adj[u][i].ff]=dist[u]+adj[u][i].ss;
        p.push(mkp(dist[adj[u][i].ff],adj[u][i].ff));
      }
    }
  }
}*/
int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int a,b,c,d;
  cin>>a>>b;
  cout<<max(a+b,max(a-b,a*b))<<endl;

  return 0;
}


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

int main() {
	int X;
	cin >> X;
	if(X!=2){
		while(true){
			bool tmp =true;
			for(int i=2;i*i<=X;i++){
				if(X%i==0){
					tmp=false;
					break;
				}
			}
			if(tmp)break;
			else X++;
		}
	}
	
	cout<<X<<endl;
}
	
	

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int N, cur=0, In;
    cin>>N;
    rep(i, N){
        cin>>In;
        if(In==cur+1) cur++;
    }
    if(cur==0) cout<<-1<<endl;
    else cout<<(N-cur)<<endl;
    return 0;
}


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

int days(int Y) {
    return Y % 3 ? 195 : 200;
}
int days(int Y, int M) {
    return (Y % 3 && M % 2 == 0) ? 19 : 20;
}
int f(int Y, int M, int D) {
    if (1 < D) return f(Y, M, D-1) - 1;
    if (1 < M) return f(Y, M-1, D) - days(Y, M-1);
    if (Y == 1000) return 0;
    return f(Y+1, M, D) + days(Y);
}
int main() {
    int n, Y, M, D;
    cin >> n;
    while (n--) {
        cin >> Y >> M >> D;
        cout << f(Y, M, D) << endl;
    }
    return 0;
}

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

int ceil(int x,int y){
    if(x%y==0) return x/y;
    else return x/y+1;
}
int main(){
    int a,b,c,d,e;
    cin >> a >> b>> c >> d >> e;
    int ans=0;
    ans+=(ceil(a,10)+ceil(b,10)+ceil(c,10)+ceil(d,10)+ceil(e,10))*10;
    a%=10; b%=10; c%=10; d%=10; e%=10;
    if(a==0) a+=10;
    if(b==0) b+=10;
    if(c==0) c+=10;
    if(d==0) d+=10;
    if(e==0) e+=10;
    int m=min(a,min(b,min(c,min(d,e))));
    ans-=(10-m);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
//  int a, b, c, d, e, X, Y;
  int a, b;
  //  double  c;
//  long long  A[1000001]={};
 int  A[1000001][2]={};
  int  ans[100003]={};
  int  sum[100003]={};
  int  cnt_flag[100003]={};

  int  L[1003]={};


//  long long  a, b, c, d, X, Y;
  long long  c, d, X, Y;
  long long JPY;
  double BTC;
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  int flag=0;
//  int flag[10000003]={};
  int tmp=0;
//  int min=1000000;
  long long min=10000000001;
  int len=0;
  int cnt=0;
  int cnt0=0;
  int cnt1=0;
  int num=0;
//  double ans=0.0;
//  long long ans=0;
  int max=0;
//  int sum=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d%d", &a,&b);
  scanf("%s", &s);
  for(i=0;i<b;i++){
    scanf("%d%d", &A[i][0],&A[i][1]);
//    printf("%d%d\n", A[i][0],A[i][1]);
  }
  for(i=0;i<a;i++){
    if((s[i-1]=='A') && (s[i]=='C')) sum[i+1] =sum[i]+1;
    else  sum[i+1] =sum[i];
//    printf("i=%d sum= %d\n",i, sum[i]);
/*    
    for(j=0;j<b;j++){
      if( i==A[j][0])
        ans[j]=-sum[i];
      else if(i==A[j][1])
        ans[j]=ans[j]+sum[i];
      printf("%d\n",ans[j]);
    }
    */
  }
  for(j=0;j<b;j++){
    printf("%d\n",sum[A[j][1]]-sum[A[j][0]]);
  }

//  printf("%s\n",s);
//    else  
  
return 0;
}


Measured memory_bytes: 9088
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,K = map(int,input().split())
c = [0] * N
for i in range(1,N+1):
    j = i
    d = 0
    while j < K:
        j *= 2
        d += 1
    c[i-1] = d
s = 0
for k in c:
    s += (0.5) ** k
print(s/N)

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long double n,x=0,y=0;
    cin>>n;
    x=n/3.0;
    //cout<<x<<endl;
    y=x*x*x;
    cout<<setprecision(12)<<fixed;
    cout<<y<<endl;
    return 0;
}


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

int main() {
  std::string x(1, ' ');
  std::string y(1, ' ');
  scanf("%s", &x[0], x.size());
  scanf("%s", &y[0], y.size());
  if (x[0] == 'H' && y[0] == 'H' || x[0] == 'D' && y[0] == 'D')
    printf("H");
  else
    printf("D");
}


Measured memory_bytes: 256
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

int main(){
	fastio;
	int n; cin>>n;
	int x = n/1000 + (n%1000? 1:0);
	cout << x*1000-n << endl;
	return 0;
}



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

int main(){
    long long int k, a, b;
    cin >> k >> a >> b;

    long long int ans = 0;
    if(b - a <= 2) ans = k+1;
    else{
        if(k >= a-1){
            ans = a + (k-(a-1)) / 2 * (b-a);
            if((k-(a-1)) % 2 == 1) ans += 1;
        }
        else ans = k+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#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,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int h,w;
vector<vector<char>> vec;
int sy,sx,gy,gx;

int bfs() {
    vector<vector<int>> d(h,vector<int>(w,INF));
    queue <pair<int,int>> q;
    
    q.push(make_pair(sy,sx));
    d[sy][sx]=0;
    
    while(!(q.empty())) {
        pair<int,int> now=q.front(); q.pop();
        
        rep(i,4) {
            int ny = now.first + dy[i];
            int nx = now.second + dx[i];
            
            if(0<=ny && ny<h && 0<=nx && nx<w && vec[ny][nx]!='#' && d[ny][nx]==INF) {
                q.push(pair<int,int> (ny,nx));
                d[ny][nx] = d[now.first][now.second] + 1;
            }
        }
    }
    
    return d[gy][gx];
}

int main(){
    cin>>h>>w;
    
    int cnt=0;
    
    vec.resize(h);
    rep(i,h){
        vec[i].resize(w);
        rep(j,w){
            cin>>vec[i][j];
            if(vec[i][j]=='.') cnt++;
        }
    }
    
    sy=0;sx=0;gy=h-1;gx=w-1;
    cout<<(bfs()==INF ? -1 : cnt-(bfs()+1))<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

const int mod = 998244353;

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int inv(int a) {
  return pw(a, mod - 2);
}

const int N = 3'009;

int f[N];
int rf[N];
int c[N][N];

int main() {
  f[0] = 1;
  rf[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    rf[i] = inv(f[i]);
  }
  memset(c, 0, sizeof c);
  for (int i = 0; i < N; ++i) {
    c[i][0] = 1;
    c[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      c[i][j] = c[i - 1][j - 1];
      add(c[i][j], c[i - 1][j]);
    }
  }
  int n, m;
  scanf("%d%d", &n, &m);
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; i + j <= n; ++j) {
      if (i + j * 2 < m - 1) {
        add(ans, mul(mul(f[i + j], mul(rf[i], rf[j])), c[n][i + j]));
      }
    }
  }
  for (int i = 0; i <= n; ++i) {
    int rem = (m - 1) - i * 2;
    if (rem < 0) {
      break;
    }
    for (int j = 0; j <= n; ++j) {
      int k = rem - j * 2;
      if (k < 0) {
        break;
      }
      if (i * 2 + j + k <= n) {
        add(ans, mul(mul(f[j + k], mul(rf[j], rf[k])), c[n][i * 2 + j + k]));
      }
    }
  }
  if ((m - 1) % 2 == 0) {
    int q = (m - 1) / 2;
    for (int i = 1; 2 * q + i <= n; ++i) {
      add(ans, c[n][2 * q + i]);
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define mp make_pair
 
using namespace std;


int main(){
	string s,t;cin>>s>>t;
	int n=s.size(),m=t.size();
	int mn=10001;
	for(int i=0;i<n-m+1;i++){
		string p="";
		for(int j=i;j<=i+m-1;j++)
		p+=s[j];
		int cnt=0;
		for(int i=0;i<m;i++){
			if(p[i]!=t[i])cnt++;
		}
		mn=min(mn,cnt);
	}
	cout<<mn;
	return 0;
}
	

	



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a,b,c,k;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if(a>=k) printf("%d\n",k);
	else if(a+b>=k) printf("%d\n",a);
	else printf("%d\n",a-(k-(a+b)));
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    cout << (a + b < c ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	for (int i = 1; i < 10;  i++){
		for (int j = 1; j < 10;  j++){
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3072
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define po pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 1000000000000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }

int main()
{
    jaldi
    #ifndef ONLINE_JUDGE
    //TakeInput
    #endif
    double n,m,i;
    cin>>n>>m;
    ll sum=0;
    in(i,m){
        ll a;
        cin>>a;
        sum+=a;
    }
    if(sum>=n){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}








 




Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x=0;
		int x1=0;
		String str = sc.next();
		for(int i=0;i<n;i++) {
			if(str.charAt(i)=='I') {
				x++;
			}else if(str.charAt(i)=='D') {
				x--;
			}
			if(x1<x) {
				x1=x;
			}
		}
		System.out.println(x1);
	}

}


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



int main(){
    string S;
    cin >> S;
    ll x;
    cin >> x;
    ll y;
    cin >> y;
    S+='T';
    ll n=S.size();
    ll F=0;
    ll T=0;
    vector<ll> vecx(0);
    vector<ll> vecy(0);
    for(ll i=0;i<n;i++){
        if(S[i]=='F')F++;
        else {
            if(T%2)vecy.emplace_back(F);
            else vecx.emplace_back(F);
            T++;
            F=0;
        }
    }

    //dpx[i][j]はvecx[i-1]まででj-9000に到達できるか
    vector<vector<bool>> dpx(9000, vector<bool>(18000, 0));
    vector<vector<bool>> dpy(9000, vector<bool>(18000, 0));
    
    dpx[0][9000]=1;
    dpy[0][9000]=1;

    if(vecx.size())dpx[1][vecx[0]+9000]=1;
    if(vecy.size()){
    dpy[1][vecy[0]+9000]=1;
    dpy[1][-vecy[0]+9000]=1;}
    for(ll i=1;i<vecx.size();i++)
        for(ll j=0;j<18000;j++){
            if(dpx[i][j]){
                dpx[i+1][j+vecx[i]]=1;
                dpx[i+1][j-vecx[i]]=1;
            }
        }
    for(ll i=1;i<vecy.size();i++)
        for(ll j=0;j<18000;j++){
            if(dpy[i][j]){
                dpy[i+1][j+vecy[i]]=1;
                dpy[i+1][j-vecy[i]]=1;
            }
        }
    if(dpx[vecx.size()][x+9000]&&dpy[vecy.size()][y+9000]){
        cout<<"Yes"<<endl;return 0;
    }
    print("No")

    return 0;
}


Measured memory_bytes: 40960
#include "bits/stdc++.h"
using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

int RepeatSquaring(int n,int x) {
	if (x == 0) return 1;
	else if (x % 2 == 0) {
		int div = RepeatSquaring(n, x / 2);
		return div*div%mod;
	}
	return n*RepeatSquaring(n,x-1)%mod;
}

signed main(void) {
	int n;
	cin >> n;
	vector<int>p;
	p.resize(n);
	rep(i, n) {
		cin >> p[i];
	}
	int ans = 0;
	int min = p[0];
	rep(i, n) {
		if (min >= p[i]) {
			ans++;
			min = p[i];
		}
	}
	print(ans);
}

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

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(long, "val", long, "cnt");

void main() {
    int X, Y, Z, K;
    scan(X, Y, Z, K);
    auto a = readArr!(long).sort!"a > b"();
    auto b = readArr!(long).sort!"a > b"();
    auto c = readArr!(long).sort!"a > b"();

    int cnt;
    long[] ans;

    foreach (i ; 0 .. X) {
        foreach (j ; 0 .. Y) {
            if ((i + 1) * (j + 1) > K) break;
            foreach (s ; 0 .. Z) {
                if ((i + 1) * (j + 1) * (s + 1) > K) break;
                cnt++;
                ans ~= a[i] + b[j] + c[s];
            }
        }
    }

    ans.sort!"a > b"();

    foreach (i ; 0 .. K) {
        ans[i].writeln;
    }
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 3324
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[210000][2];
vector<int> a1,a2;
vector<int> vma,vmi;
vector<pair<int,int> > all;

int main()
{
  int i,j,k,n,ma,mai,maj,mi,mii,mij;
  _int64 ans,tmp;
  scanf("%d",&n);
  ma=0;mi=2000000000;
  vma.clear();
  vmi.clear();
  for (i=0;i<n;i++)
  {
    scanf("%d%d",&a[i][0],&a[i][1]);
    for (j=0;j<2;j++)
    {
      if (a[i][j]>ma)
      {
        ma=a[i][j];
        mai=i;maj=j;
      }
      if (a[i][j]<mi)
      {
        mi=a[i][j];
        mii=i;
        mij=j;
      }
    }
  }
  a1.clear();
  a2.clear();
  for (i=0;i<n;i++)
    if (a[i][0]>a[i][1])
    {
      a1.push_back(a[i][0]);
      a2.push_back(a[i][1]);
    }
    else
    {
      a1.push_back(a[i][1]);
      a2.push_back(a[i][0]);
    }
  sort(a1.begin(),a1.end());
  sort(a2.begin(),a2.end());
  ans=((_int64)a1[a1.size()-1]-a1[0])*((_int64)a2[a2.size()-1]-a2[0]);
  tmp=2000000000;
  all.clear();
  for (i=0;i<n;i++)
    for (j=0;j<2;j++)
    {
      all.push_back(make_pair(a[i][j],i));
    }
  sort(all.begin(),all.end());
  map<int,int> mp;
  mp.clear();
  j=0;
  for (i=0;i<all.size();i++)
  {
    while ((j<all.size())&&(mp.size()<n))
    {
      mp[all[j].second]++;
      j++;
    }
    if (mp.size()==n)
    {
      if (all[j-1].first-all[i].first<tmp) tmp=all[j-1].first-all[i].first;
    }
    mp[all[i].second]--;
    if (mp[all[i].second]==0) mp.erase(all[i].second);
  }
  tmp*=(ma-mi);
  if (tmp<ans) ans=tmp;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 17892
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i,odd;
    cin>>n;
    odd=n/2;
    if(n%2) odd++;
    cout.setf(ios::fixed);
    cout.precision(7);
    cout<<(odd*1.0)/n<<endl;

    return 0;
}





Measured memory_bytes: 3744
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double inv = 0;
        for (int i = 0, lim = sc.nextInt(); i < lim; i++) {
            inv += (1.0 / sc.nextInt());
        }
        System.out.println(1.0 / inv);
    }
}

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

bool is_prime(int n){ //流石に2以上で
    bool flag =true;
    for(int i=2; i<n-1; i++){
        if(n%i==0) flag =false;
    }
    return flag;
}

int fact[100];

void pr_fact(int n){ //n!の素因数列挙
    for(int i=2; i<=n; i++){
        int l = i;
        int j=2;
        while(l>1){
            if(l%j !=0) {j++; continue;}
            l = l/j;
            fact[j]++;
        }
    }
}

int over_75, over_25, over_15, over_5, over_3;


int main(){
    int N;
    cin >> N;
    pr_fact(N);
//    for(int i=0; i<100; i++){
//        cout << fact[i] << endl;
//    }
//    sort(fact,fact+100,greater<int>());

    int ans =0;
    for(int i=0; i<100; i++){
        if(fact[i]>=74) over_75++;
        if(fact[i]>=24) over_25++;
        if(fact[i]>=14) over_15++;
        if(fact[i]>=4) over_5++;
        if(fact[i]>=2) over_3++; 
    }

//    cout << over_75 << endl 
//    << over_25 << endl 
//    << over_15 << endl 
//    << over_5 << endl 
//    << over_3 <<endl;


    ans += over_75;
    ans += over_25*(over_3-1);
    ans += over_15*(over_5-1);
    ans += (over_5*(over_5-1)*(over_3-2) )/2;

    cout << ans <<endl;

}


Measured memory_bytes: 256
N = int(input())

def dfs(s):
    if int(s)>N: 
        return 0
    for c in list("753"):
        if s.count(c) < 1:
            ret = 0
            break
    else:
        ret = 1
    for c in list("753"):
        ret += dfs(s+c)
    return ret

print(dfs("0"))

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
vector<int>g[200000];
int dist[200000];
void dfs(int s, int p){
    for(int x :g[s]){
        if(x == p)continue;
        dist[x] = dist[s] + 1;
        dfs(x, s);
    }
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0, -1);
    int cnt = 0;
    rep(i,n)cnt += dist[i]&1;
    vector<int>a[3];
    rep(i,n)a[(i+1)%3].push_back(i+1);
    vector<int>res(n);
    if(cnt <= a[0].size()){
        rep(i,n){
            if(dist[i]&1){
                res[i] = a[0].back();
                a[0].pop_back();
            }else{
                rep(ii,3){
                    int iii = (ii + 1) % 3;
                    if(a[iii].size()){
                        res[i] = a[iii].back();
                        a[iii].pop_back();
                        break;
                    }
                }
            }
        }
    }else if(n - cnt <= a[0].size()){
        rep(i,n){
            if(!(dist[i]&1)){
                res[i] = a[0].back();
                a[0].pop_back();
            }else{
                rep(ii,3){
                    int iii = (ii + 1) % 3;
                    if(a[iii].size()){
                        res[i] = a[iii].back();
                        a[iii].pop_back();
                        break;
                    }
                }
            }
        }
    }else{
        rep(i,n){
            int k;
            if(dist[i]&1){
                if(a[1].size())k = 1;
                else k = 0;
            }else{
                if(a[2].size())k = 2;
                else k = 0;
            }
            res[i] = a[k].back();
            a[k].pop_back();
        }
    }
    rep(i,n)assert(res[i] != 0);
    rep(i,n)cout << res[i] << " \n"[i == n - 1];
}


Measured memory_bytes: 19832
toBool :: String -> Bool
toBool "H" = True
toBool _ = False

main :: IO ()
main = do
    [a,b] <- map toBool . words <$> getLine
    if a == b then
        putStrLn "H"
    else
        putStrLn "D"
{-    
a b c
H H H
H D D
D H D
D D H
-}

Measured memory_bytes: 380
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int cnt[] = new int[5];
		int n=sc.nextInt();
		for(int i=0; i<n; i++) {
			switch(sc.next().charAt(0)) {
			case 'M':
				cnt[0]++;
				break;
			case 'A':
				cnt[1]++;
				break;
			case 'R':
				cnt[2]++;
				break;
			case 'C':
				cnt[3]++;
				break;
			case 'H':
				cnt[4]++;
				break;
			}
		}
		long ans = 0;
		for(int i=0; i<(1<<5); i++) {
			int c=0;
			long tmp=0;
			for(int j=0; j<5; j++) {
				if(((i>>j)&1)==1) {
					if(c==0) {
						tmp = cnt[j];
					} else {
						tmp = tmp * cnt[j];
					}
					c++;
				}
			}
			if(c==3){
				ans += tmp;
			}
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 44752
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));


void solve()
{
	int n;
	cin>>n;
	if(n==1)
		cout<<0;
	else
		cout<<1;
}

int main()
{	
	fast;
	int t=1;
	//cin>>t;
	while(t--)
		solve();
}	


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

int main() {
  int xs[3];
  std::cin >> xs[0] >> xs[1] >> xs[2];
  std::sort(std::begin(xs), std::end(xs));
  std::cout << xs[0] << " " << xs[1] << " " << xs[2] << std::endl;
}

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main() {
    int cnt = 0;

    char S[256];
    scanf("%s", S);
    int s = strlen(S);

    for (int i = 0; i < s / 2; i++) {
        if (S[i] != S[s-i-1]) {
            cnt++;
        }
    }

    printf("%d\n", cnt);
    return 0;
}

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

int main(void){
  int x, y, s;
  int ans;
  int max, i, j, t;

  while(1){
    scanf("%d %d %d", &x, &y, &s);
    if(x+y+s == 0){ break; }
    max = 0;
    
    for(i = 1; i <= s; i++){
      for(j = 1; i + j <= s; j++){
	t = (int)(i*(100+x)/(double)100.0) + (int)(j*(100+x)/(double)100.0);
	//printf("i:%d j:%d: ", i, j);
	//printf("%d + %d = %d\t", (int)(i*(100+x)/(double)100.0), (int)(j*(100+x)/(double)100.0), t);
	if(t == s){
	  ans = (int)(i*(100+y)/(double)100.0) + (int)(j*(100+y)/(double)100.0);
	  //printf("%d + %d = %d", (int)(i*(100+y)/(double)100.0), (int)(j*(100+y)/(double)100.0), ans);
	  if(max < ans){
	    max = ans;
	  }
 	}
	//printf("\n");
      }
    }

    printf("%d\n", max);
  }

  return 0;
}

Measured memory_bytes: 1028
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m,x=LI()
  l=[LI() for _ in range(n)]

  ans=inf
  for i in range(1<<n):
    ans_l=[0]*m
    sm=0
    for j in range(n):
      if i&(1<<j):
        for _i,y in enumerate(l[j]):
          if _i>0:
            ans_l[_i-1]+=y
        sm+=l[j][0]
    # print(ans_l)
    f=True
    for _x in ans_l:
      if _x<x:
        f=False
    if f:
      ans=min(ans,sm)

  if ans==inf:
    return -1

  return ans

# main()
print(main())


Measured memory_bytes: 10796
line1=input().split()
n=int(line1[0])
a=int(line1[1])
nums=input().split()
for i in range(n):
    nums[i]=int(nums[i])-a

works={}

works[0]=1
s=0
for x in nums:

    if x>=0:
        for i in range(50*(n+1),-50*(n+1), -1):
            try:
                works[i]+=works[i-x]
            except:
                try:
                    works[i]=works[i-x]
                except:
                    pass
    else:
        for i in range (-50*(n+1),50*(n+1)):
            try:
                works[i+x]+=works[i]
            except:
                try:
                    works[i+x]=works[i]
                except:
                    pass

print (works[0]-1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  
  for(int i =0;i<s.size()-1;i++){
    if( s.at(i) == 'A'&&s.at(i+1)=='C'){
      cout << "Yes"<<endl;
      return 0;
    }
  }
  cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a,b;
  int c=0;
    cin >> a >> b;
  if(b%a==0){
    c=a+b;
  }
  else{
    c=b-a;
  }
    // 出力
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
def calc(n, ls):
    if n == 1 and ls[0]%2==0:
        return 1
    cnt = 1
    for item in ls:
        if item%2 == 0:
            cnt *= 2
        else:
            cnt *= 1
    return 3 ** n - cnt

n = int(input())
ls = list(map(int, input().split()))
print(calc(n, ls))

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    if ((A+B) % 2) cout << "IMPOSSIBLE" << endl;
    else cout << (A+B) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 51

int main(){
  int n, cnt=0;
  char s[N];
  scanf("%d %s", &n, s);
  
  for(int i=0;i<n;i++){
    if(s[i]=='A'){
      if(s[i+1]=='B'){
        if(s[i+2]=='C'){
          cnt++;
        }
      }
    }
  }
  
  printf("%d",cnt);
  return 0;
}

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

using namespace std;

int main(){

  int a,b,c,i = 0;
  cin >> a >> b >> c;

  if(a == 5)
    i++;
  if(b == 5)
    i++;
  if(c == 5){
    i++;
  }

  if(i == 2)
    cout << "YES" << endl;
  else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  vector <string> table = {"Sunny", "Cloudy", "Rainy", "Sunny"};
  string s;
  cin >> s;

  cout << * ++ find (ALL(table),s) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int ans;
struct node
{
    int v,n;
}a[6];
bool cmp(node a,node b)
{
    return a.n<b.n;
}
int main()
{
    for(int i=1;i<=5;i++)cin>>a[i].v;
    for(int i=1;i<=5;i++)
    	for(int j=1;j<=9;j++)
    		if((a[i].v+j)%10==0)
    		{
    			a[i].n=j;
    			break;
			}
    sort(a+1,a+6,cmp);
    for(int i=1;i<=4;i++)
    {
        ans+=a[i].v+a[i].n;
    }
    cout<<ans+a[5].v;
    return 0;
}

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

const int MAX_N = 100100;
const int MOD = 1e9+7;
int inv[MAX_N]; 

int p(int a, int n ){ 
  if( n == 0 ){ return 1LL;}
  else if( n == 1 ){ return a;}
  else{
    if( n % 2 == 0 ){ return ( p(a,n/2)*p(a,n/2) )%MOD;}
    else{ return ( ( ( p(a,(n-1)/2 ) * p(a,(n-1)/2) )%MOD ) *a )%MOD;}
  }
}

void init(){
  inv[1] = 1;
  for(int i = 2; i < MAX_N; i++){
    inv[i] = (inv[i-1]+p(i,MOD-2))%MOD;
  }
}

signed main(void){ 
  
  int N; cin >> N; init();
  vector<int> X(N);
  for(int i = 0; i < N; i++){ cin >> X[i];}
  int ans = 0;
  for(int i = 1; i < N; i++){
    int d = (X[i]-X[i-1])%MOD;
    ans += d*inv[i];
    ans %= MOD;
  }
  
  for(int i = 1; i < N; i++){ 
    ans *= i;
    ans %= MOD;
  }
  
  cout << ans << endl;
  
  return 0;
}
   

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

int main(void) {
	int i,j;
	while(1){
		scanf("%d",&i);
		scanf("%d",&j);
		if(i==0 && j==0)break;
		if(i>j)printf("%d %d\n",j,i);
		if(i<=j)printf("%d %d\n",i,j);
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 600