akhauriyash/Code-Regression huggingface dataset:
n, k = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
rps_points = {}
["r", "s", "p"].each_with_index do |a, i|
  rps_points.merge!({"#{a}": arr[i]})
end
rps_points = rps_points.sort_by{|_, v| -v}
t = gets.chomp.split('')
t.each_with_index do |i, index|
  t[index] = 'r' if i=='s'
  t[index] = 's' if i=='p'
  t[index] = 'p' if i=='r'
end

points = Array.new(n, 0)
rps_points.each do |rps_point|  
  t.each_with_index do |i, index|
    if index-k>=0 && t[index-k]==i && points[index-k]!=0
      next
    elsif rps_point[0].to_s==i
      points[index] = rps_point[1]
    end
  end
end
print(points.reduce(:+))

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

template<typename T>
void trace(T *a, int s, int n) {
    for (int i=s; i<n; i++) {
	cout<<a[i]<<" ";
    }
    cout<<endl;
}



typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




ll n,m;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m;
    ll area =n*m;

    if (n==1 || m==1) out(1);

    if (area%2==0) out(area/2);

    ll ans=area/2 + 1;
    out(ans);
  

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        long p = 1000000007;
        long ans = 0;

        int N = ReadInt();
        string S = Read();
        char[] s = new char[N];
        for(int i=0;i<N;i++)
        {
            s[i] = S[i];
        }
        Array.Sort(s);
        char mozi = s[0];
        int cnt = 0;
        ans = 1;
        for (int i = 0; i < N; i++)
        {
            if(s[i] == mozi)
            {
                cnt++;
            }
            else
            {
                mozi = s[i];
                ans = (ans * (cnt+1)) % p;
                cnt = 1;
            }
        }
        ans = (ans * (cnt + 1)) % p;
        ans--;
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

Measured memory_bytes: 3060
import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

T = int(input())


@lru_cache(maxsize=None)
def dfs(n, A, B, C, D):
    # 1
    ans = n * D

    for mul, pt in [(2, A), (3, B), (5, C)]:
        if n % mul == 0:
            n1 = n // mul
            a = dfs(n1, A, B, C, D) + pt
            ans = min(a, ans)
        elif mul <= n:
            md = n % mul
            n1 = (n - md) // mul
            n2 = (n + mul - md) // mul
            a = dfs(n1, A, B, C, D) + (D * md) + pt
            b = dfs(n2, A, B, C, D) + ((mul - md) * D) + pt
            ans = min(a, b, ans)

    return ans


def solve():
    N, A, B, C, D = map(int, input().split())

    ans = dfs(N, A, B, C, D)
    return ans


ans = []
for _ in range(T):
    t = solve()
    ans.append(t)

print("\n".join(map(str, ans)))


Measured memory_bytes: 29684
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
 int mat[22][22];
 int n;
 int dp[(1<<21)+5][22];
 int memo(int mask,int i)
 {
     if(mask==(1<<n)-1)
     return 1;
     if(i==n)
     return 0;
     if(dp[mask][i]!=-1)
     return dp[mask][i];
     int ans=0;
     for(int j=0;j<n;j++)
     {
         if(!(mask&(1<<j)) and mat[j][i])
         {
             ans+=memo(mask|(1<<j),i+1);
             ans=ans%mod;
         }
     }
     return dp[mask][i]=ans;
 }
int32_t main()
{
    c_p_c();
    memset(dp,-1,sizeof(dp));
       cin>>n;
       for(int i=0;i<n;i++)
       {
           for(int j=0;j<n;j++)
           {
               cin>>mat[i][j];
           }
       }
       cout<<memo(0,0);
    return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<int> vb(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> vb[i];
  }

  int ans = vb[0];
  for (int i = 1; i < n - 1; i++) {
    ans += min(vb[i], vb[i - 1]);
  }

  ans += vb.back();

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static long[] ans=new long[100001];
     public static void main (String[] args) throws java.lang.Exception {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
    	int test=1;//c.nextInt();
    	while(test-->0){
    		int n=sc.nextInt();
            if(n%1000==0)
             pw.println(0);
            else pw.println((n/1000 + 1)*1000 -n);
        }
        pw.close();
  }
}

  

Measured memory_bytes: 33676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N, M, a, b, r, x, tmp, cnt = 0, cnt_tmp = 0;
  cin >> N >> M;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    tmp = vec.at(i);
    while (tmp > 1) {
      if (tmp % 2 == 0) {
        tmp /= 2;
        cnt_tmp++;
      }
      else break;
    }
    if (i > 1 && cnt != cnt_tmp) {
      cout << 0 << endl;
      return 0;
    }
    else cnt = cnt_tmp;
    cnt_tmp = 0;
    vec.at(i) /= 2;
  }

  a = vec.at(0);
  
  for (int i = 1; i < N; i++) {
    b = vec.at(i);
    
    x = a * b;
    if (a < b) swap(a, b);
    r = a % b;
    while (r != 0) {
      a = b;
      b = r;
      r = a % b;
    }
    
    a = x / b;
    if (a > M) {
      cout << 0 << endl;
      return 0;
    }
  }
  
  cout << (M / a + 1) / 2 << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  string S;
  cin >> S;
  int siz=S.size();
  if(S[siz-1]=='s') cout << S+"es" << endl;
  else cout << S+"s" << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<vector<int>> a(3,vector<int>(3));
    for(int i = 0;i<3;i++)
        for(int k = 0;k<3;k++)
            cin >> a[i][k];
    int n;
    cin >> n;
    for(int i = 0;i<n;i++)
    {
        int t;
        cin >> t;
        for(int i = 0;i<3;i++){
            for(int k = 0;k<3;k++)
            {
                if (a[i][k]==t)
                    a[i][k]=-1;
            }
        }
    }
    if(a[0][0] == -1 && a[0][1]==a[0][0] && a[0][2]==a[0][0])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a[1][0] == -1 && a[1][1]==a[1][0] && a[1][2]==a[1][0])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a[2][0] == -1 && a[2][1]==a[2][0] && a[2][2]==a[2][0])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0][0] == -1 && a[0][0]==a[1][0] && a[0][0]==a[2][0])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0][1] == -1 && a[0][1]==a[1][1] && a[0][0]==a[2][1])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0][2] == -1 && a[0][2]==a[1][2] && a[0][2]==a[2][2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0][0] == -1 && a[0][0]==a[1][1] && a[0][0]==a[2][2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a[2][0] == -1 && a[2][0]==a[1][1] && a[2][0]==a[0][2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <stdio.h>
#include <memory.h>
#include <sstream>
#include <iterator>

int main ()
{
	std::string t, s;
	std::cin >> t;
	std::unique_copy (t.begin(), t.end(), std::back_inserter(s));
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] == 'W') cnt1++;
		else cnt2++;
	}
	std::cout << cnt1 + cnt2 - 1;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    vector<ll> acc(N + 1, 0);
    rep(i, N) {
        acc[i + 1] += acc[i] + A[i];
    }
    ll ans = 1;
    rrep(i, N - 1, 1) {
        ll m = acc[i + 1] - acc[i];
        if (acc[i] * 2 >= m) {
            ans++;
        } else {
            break;
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = -n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>
#include<queue>

using lli = long long int;
using namespace std;
int inf = 1000000007;

int N, M;

int main() {
	cin >> N >> M;
	vector<tuple<int, int, int>> d;
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		d.push_back(tie(a, b, c));
	}
	//負辺を含むのでBellmanFord
	vector<lli> cost(N + 1);
	fill(cost.begin(), cost.end(), 1e15);
	cost[1] = 0;
	for (int i = 0; i < N; i++)
		for (auto e : d) {
			int s, g, c;
			tie(s, g, c) = e;
			cost[g] = min(cost[g], cost[s] - c);
		}
	lli _cost = cost[N];
	for (int i = 0; i < N; i++)
		for (auto e : d) {
			int s, g, c;
			tie(s, g, c) = e;
			cost[g] = min(cost[g], cost[s] - c);
		}
	cout << (_cost == cost[N] ? to_string(-cost[N]) : "inf") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	string S;
	cin >> N >> S;
	int  ans = 0;
	for (int i = 0; i < N - 2; i++) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	_, v, c := nextLine(), nextLine(), nextLine()

	vL := strings.Split(v, " ")
	cL := strings.Split(c, " ")

	var max int
	for i, u := range vL {
		intU, _ := strconv.Atoi(u)
		intC, _ := strconv.Atoi(cL[i])
		xy := intU - intC

		if xy > 0 {
			max += xy
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 640
import numpy as np
N = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans_arr = np.zeros(29,int)
for k in range(29):
    a = np.sort(A%(2**(k+1)))
    b = B%(2**(k+1))
    ans_arr[k] += np.sum(np.searchsorted(a,2**(k+1)-1-b,side='right')-np.searchsorted(a,2**k-b))
    ans_arr[k] += np.sum(N-np.searchsorted(a,3*2**k-b))
    ans_arr[k] %= 2

ans = 0
for k in range(29):
    ans += ans_arr[k]*2**k

print(ans)

Measured memory_bytes: 35952
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    lint N;
    cin >> N;
    string S[N];
    rep(i,N) cin >> S[i];
    lint count[5]={};
    lint ans=0;
    rep(i,N){
        if(S[i][0]=='M') count[0]++;
        if(S[i][0]=='A') count[1]++;
        if(S[i][0]=='R') count[2]++;
        if(S[i][0]=='C') count[3]++;
        if(S[i][0]=='H') count[4]++;
    }
    rep(i,3) for(int j=i+1;j<5;j++) for(int k=j+1;k<5;k++) ans+=count[i]*count[j]*count[k];
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;


//----------------------------------------------------------------
signed main(){

	ll n;
	cin >> n;
	
	if(n == 1){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 0;
	for(int i = 1;i <= n-1;i++)ans += i;
	cout << ans << endl;

	return 0;
}

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

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc139.contest.atcoder.jp/tasks/abc139_b

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = 0;
  // bool ok = false;
  if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') ans = 3;
  else if((s[0]=='R'||s[2]=='R')&&s[1]=='R') ans = 2;
  else if(s[0]=='R'||s[1]=='R'||s[2]=='R') ans = 1;
  else ans = 0;
  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <string>
#include <unordered_map>
// #include <queue>
#include <set>

using namespace std;
int X, Y, Z,K;
vector<long> a, b, c;

struct Mat {
    long sum;
    int x, y, z;
    Mat(long sum, int x, int y, int z) {
        this->sum=sum;
        this->x=x;
        this->y=y;
        this->z=z;
    }
};

struct Cmp {
    bool operator()(const Mat* a, const Mat* b) const {
        return a->sum < b->sum;
    }
};

int main() {
    int i, j, k, cnt;
    long t;
    cin >> X >> Y >> Z >> K;
    for (i = 0; i < X; i++) {cin >> t; a.push_back(t);}
    for (i = 0; i < Y; i++) {cin >> t; b.push_back(t);}
    for (i = 0; i < Z; i++) {cin >> t; c.push_back(t);}

    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    sort(c.rbegin(),c.rend());
    priority_queue<Mat*, vector<Mat*>, Cmp> q;
    unordered_map<string,int> mp;
    Mat *m = new Mat(a[0]+b[0]+c[0],0,0,0);
    q.push(m);
    for(k=0;k<K;k++) {
        Mat *now = q.top();
        q.pop();
        cout << now->sum<< endl;
        if (now->x<X-1){
            string s = to_string(now->x+1)+","+to_string(now->y)+","+to_string(now->z);
            if(mp.find(s) == mp.end()){
                mp[s]=1;
                q.push(new Mat(a[now->x+1]+b[now->y]+c[now->z],now->x+1,now->y,now->z));
            }
        }
        if (now->y<Y-1){
            string s = to_string(now->x)+","+to_string(now->y+1)+","+to_string(now->z);
            if(mp.find(s) == mp.end()){
                mp[s]=1;
                q.push(new Mat(a[now->x]+b[now->y+1]+c[now->z],now->x,now->y+1,now->z));
            }
        }
        if (now->z<Z-1){
            string s = to_string(now->x)+","+to_string(now->y)+","+to_string(now->z+1);
            if(mp.find(s) == mp.end()){
                mp[s]=1;
                q.push(new Mat(a[now->x]+b[now->y]+c[now->z+1],now->x,now->y,now->z+1));
            }
        }
    }

    return 0;
}

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

using namespace std;
typedef long long ll;


int main(){
    int a, b;
    int k;
    int x[100] = {0};
    int count = 0;

    cin >> a >> b;
    cin >> k;

    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            x[count++] = i;
        }
    }

    cout << x[k - 1];

    return 0;
}

Measured memory_bytes: 888
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int X, Y;
  cin >> X >> Y;

  bool ok = false;
  rep(a, 101) {
    rep(b, 101) {
      if (a + b == X && a * 2 + b * 4 == Y)
        ok = true;
    }
  }

  if (ok)
    cout << "Yes\n";
  else
    cout << "No\n";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define mp make_pair
#define db long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define mod 1000000007
#define MAX 100005
using namespace std;

typedef long double ld;
const ld inf = 2e18;

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

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);

    ll n;
    cin >> n;
    if(n%2==0) cout << (n/2) - 1;
    else cout << (n/2);

    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static int LCS (char [] X, char[] Y, int a, int b) {
		int[][] result = new int[a+1][b+1];
		for (int k = 0; k <= a; k++) {
			result[k][0] = 0;
		}
		for (int j = 0; j <=b; j++) {
			result[0][j]= 0;
		}
		if (a==0 || b==0 ) {
			return 0;
		}
		for (int n = 1; n <= a; n++) {
			for(int m = 1; m <=b; m++) {
				if (X[n-1] == Y[m-1]) {
					//return 1 + LCS(X, Y, a-1, b-1);
					result[n][m] = 1 + result[n-1][m-1]; 
				}
				else {
					//return max(LCS(X,Y, a, b-1), LCS(X,Y, a-1,b));
					result[n][m] = max(result[n-1][m], result[n][m-1]);
				}			
			}
		}
		return result[a][b];
	}
	static int max(int i, int j) {
		if (i >= j) {
			return i;
		}
		else {
			return j;
		}
	}
	public static void main(String[] args) {
		Main LCS = new Main();
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for (int m = 0; m < n; m++) {
			String S1 = scan.next();
			String S2 = scan.next();
			
			char[] X = S1.toCharArray();
			char[] Y = S2.toCharArray();
			int a = X.length;
			int b = Y.length;
			
			System.out.println(LCS(X,Y,a,b));
		}
		
	}
}	


Measured memory_bytes: 64972
#include <iostream>

using namespace std;

int A[31];

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

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int a;
      cin >> a;
      A[a - 1] += 1;
    }
  }

  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (A[i] == N)
      ans += 1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	status := make([][]rune, h)
	for i := 0; i < h; i++ {
		var s string
		fmt.Scan(&s)
		status[i] = make([]rune, w)
		for j, c := range s {
			status[i][j] = c
		}
	}

	count := make([][]int, h)
	for i := 0; i < h; i++ {
		count[i] = make([]int, w)
	}
	x := []int{-1, 0, 1}
	y := []int{-1, 0, 1}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			cnt := 0
			for _, dx := range x {
				for _, dy := range y {
					if dx == 0 && dy == 0 {
						continue
					}
					if i+dx >= 0 && i+dx < h &&
						j+dy >= 0 && j+dy < w &&
						status[i+dx][j+dy] == '#' {
						cnt++
					}
				}
			}
			count[i][j] = cnt
		}
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if status[i][j] == '#' {
				fmt.Printf("#")
			} else {
				fmt.Printf("%d", count[i][j])
			}
		}
		fmt.Println()
	}
}


Measured memory_bytes: 512
package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(in io.Reader, out io.Writer) {
	var n int
	Fscan(in, &n)
	n %= 1000
	if n > 0 {
		n = 1000 - n
	}
	Fprint(out, n)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 1776
#include<cstdio>
int f[2][3],n,a,b,c;
int ma(int a,int b){return a>b?a:b;}
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d%d%d",&a,&b,&c);
		f[n%2][0]=ma(f[(n+1)%2][1]+b,f[(n+1)%2][2]+c);
		f[n%2][1]=ma(f[(n+1)%2][0]+a,f[(n+1)%2][2]+c);
		f[n%2][2]=ma(f[(n+1)%2][0]+a,f[(n+1)%2][1]+b);
	}
	printf("%d",ma(f[0][0],ma(f[0][1],f[0][2])));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
 
using namespace std;
 
/* template */
 
using ll = long long;
 
void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;
 
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;
}
 
template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}
 
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;
 
 
vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};
 
/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k,c; cin >> n >> k >>c;
    string s; cin >> s;
    vector<int> a(n,-1),b(n,-2);
    int flag = -c-1;
    int point = 0;
    rep(i,0,n){
        if(i-flag>c && s[i]=='o'){
            point++;
            a[i] = point;
            flag = i;
        }
    }
    flag = c+n;
    point = k;
    rrep(i,0,n){
        if(flag-i>c && s[i]=='o'){
            b[i] = point;
            point--;
            flag = i;
        }
    }
    rep(i,0,n){
        if(a[i]==b[i]){
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
PII th[102]; ///0 --> weight/1 --> value
const int MAX = 1e5;
long long dp[MAX + 7];
int main()
{
    int n, w;
    cin >> n >> w;
    for(int i = 0; i < n; i++)
        cin >> th[i].first >> th[i].second;
    for(int i = 1; i <= 1e5; i++)
        dp[i] = 1e16;
    for(int i = 0; i < n; i++)
        for(int j = 1e5; j >= th[i].second; j--)
            dp[j] = min(dp[j], dp[j - th[i].second] + th[i].first);
    int res = -1;
    for(int i = 0; i <= 1e5; i++)
        if(dp[i] <= w)
            res = i;
    cout << res << '\n';
    return 0;
}


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

int main() {
  int n;

  cin >> n;

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

  long long dp[n + 1];

  rep(i,0,n + 1) dp[i] = 100100100100;

  dp[1] = 0;
  rep(i,1,n + 1){
    dp[i + 1] = min(dp[i + 1],dp[i] + abs(h[i + 1] - h[i]));
    dp[i + 2] = min(dp[i + 2],dp[i] + abs(h[i + 2] - h[i]));
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	int l;l = 0;
	cout << 0 << endl;
	string sl;cin>>sl;
	if (sl == "Vacant"){	
		return 0;
	}
	int r;r = n - 1;
	cout << n - 1 << endl;
	string sr;cin>>sr;
	if (sr == "Vacant"){
		return 0;
	}
	while(1){
		int mid = (l + r) / 2;
		cout << mid << endl;
		string sm;cin>>sm;
		if (sm == "Vacant"){
			return 0;
		}
		if (((mid - l) % 2 == 0 && sl != sm) || ((mid - l) % 2 == 1 && sl == sm)){
			sr = sm;
			r = mid;
		}
		else{
			sl = sm;
			l =mid;
		}
	}
	return 0;
}

Measured memory_bytes: 852
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInts >>= print . uncurry (+) . ( ( ^ 3 ) *** ( ^ 3 ) ) . ( uncurry solveHalf &&& uncurry solveFull ) . mp

solveHalf n k
	| k `mod` 2 == 0 = ( n `div` ( k `div` 2 ) + 1 ) `div` 2
	| otherwise = 0

solveFull = div

Measured memory_bytes: 380
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long

#define bitToYen 380000.0


signed main(void) {
  int N;
  cin >> N;
  float x[N];
  string u[N];
  float sum = 0;
  rep(i, N) {
    cin >> x[i] >> u[i];
    if (u[i] == "JPY") {
      sum += x[i];
    } else {
      sum += x[i] * bitToYen;
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[1000000],b[1000000],ans=1000000;
  string s;
  cin>>n>>s;
  a[0]=0;
  b[0]=0;
  for(int i=0;i<n;i++){
    a[i+1]=a[i];
    if(s[i]=='W')a[i+1]++;
  }
  reverse(s.begin(),s.end());
  for(int i=0;i<n;i++){
    b[i+1]=b[i];
    if(s[i]=='E')b[i+1]++;
  }
  for(int i=1;i<=n;i++){
    int temp=0;
    if(i!=1){
      temp+=a[i-1];
    }
    if(i!=n){
      temp+=b[n-i+1];
    }
    ans=min(ans,temp);
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 7428
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}
ll prime[1000000];bool visprime[10000000];
void sieve(){ll k=0;for(ll i=2;i*i<=1000000;i++){for(ll j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(ll i=2;i<=1000000;i++){if(visprime[i]==false) prime[k++]=i;}}


int main()
{
    string x;
    cin>>x;
    bool flag=true;
    for(int  i=0;i<x.size();i++)
    {
        if(x[i]=='R' && (i+1)%2==0 )
        {flag=false;
         break;
        }
        if(x[i]=='L' && (i+1)%2)
        {
            flag=false;
            break;
        }

    }
    if(flag==false) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}
























Measured memory_bytes: 256
package main

import (
  "bufio"
  "strconv"
  "os"
)

import (
  "fmt"
  "sort"
)

var sc = bufio.NewScanner(os.Stdin)

func Init() {
  sc.Split(bufio.ScanWords)
}

func NextLine() (string, bool) {
  nonstop := sc.Scan()
  return sc.Text(), nonstop
}

func NextWord() (string, bool) {
  nonstop := sc.Scan()
  return sc.Text(), nonstop
}

func NextInt() (int, bool) {
  nonstop := sc.Scan()
  res, _ := strconv.ParseInt(sc.Text(), 10, 32)
  return int(res), nonstop
}

func NextLong() (int64, bool) {
  nonstop := sc.Scan()
  res, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return int64(res), nonstop
}

func NextFloat() (float32, bool) {
  nonstop := sc.Scan()
  res, _ := strconv.ParseFloat(sc.Text(), 32)
  return float32(res), nonstop
}

func NextDouble() (float64, bool) {
  nonstop := sc.Scan()
  res, _ := strconv.ParseFloat(sc.Text(), 64)
  return float64(res), nonstop
}

func main(){
  Init()
  N, _ := NextInt()
  d := make([]int, N)
  for i:= 0; i < N; i++ {
    d[i], _ = NextInt()
  }

  sort.Ints(d)
  fmt.Printf("%v\n", d[N/2]-d[N/2-1])
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

int main()
{
    int n, res = 0;
    int p[21], box[3];

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }

    for (int i = 1; i < n - 1; i++)
    {
        box[0] = p[i - 1];
        box[1] = p[i];
        box[2] = p[i + 1];

        sort(box, box + 3);

        if (p[i] == box[1])
        {
            res++;
        }
    }

    cout << res;
}


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

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

	long long mod = 1000000007;
	long long m = 1;
	for (long i = 1; i <= N; i++)
	{
		m = (m * i) % mod;
	}
	cout << m  << endl;

	return 0;
}

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




int main(){
      //memset( par, -1, sizeof par );
    ll n,m;
    cin>>n>>m;
    ll v=2*m;
    if(v>=n)cout<<"0";
    else cout<<n-v;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF -1e18
signed main(){
  int n,m;
  cin>>n>>m;
  int x[1000],y[1000],z[1000];
  for(int i=0;i<n;i++)
    cin>>x[i]>>y[i]>>z[i];
  int ans=0;
  for(int a=0;a<2;a++)
    for(int b=0;b<2;b++)
      for(int c=0;c<2;c++){
	int dp[1010][1010]={};
	for(int i=0;i<1010;i++)
	  for(int j=0;j<1010;j++)dp[i][j]=INF;
	dp[0][0]=0;
	for(int i=0;i<n;i++)
	  for(int j=0;j<m;j++){
	    if(dp[i][j]==INF)continue;
	    int cost=x[i]*(a?-1:1);
	    cost+=y[i]*(b?-1:1);
	    cost+=z[i]*(c?-1:1);
	    dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
	    dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+cost);
	  }
	for(int i=0;i<=n;i++)ans=max(ans,dp[i][m]);
      }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define REP(i,n) for(i=0; i<n; ++i)
#define ALL(x) begin(x), end(x)
#define GETS(s) fgets(s,size(s),stdin)

using namespace std;
typedef long long ll;
typedef string str;
template<typename T>
using vec=vector<T>;
template<typename T>
using uset=unordered_set<T>;
template<typename T,typename S>
using umap=unordered_map<T,S>;
const size_t mbs = sizeof(bitset<1>)*8;
template<size_t N>
using bit=bitset<mbs*((N+mbs-1)/mbs)>;
 
#define MOD 1000000007
#define PI 3.14159265358979323846
#define MAXN 1000001
size_t i,j,k;

int main(void) {
	int a,b,h,m;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	double ang=PI*2*((double)h/12.0 + ((double)m/60.0)/12.0 - (double)m/60.0);
	double ans=sqrt((double)(a*a+b*b) - (double)(2*a*b)*cos(ang));
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, X, T;

int main()
{
    cin >> N >> X >> T;
    ll x = N / X;
    if (N % X == 0)
    {
        cout << x * T << endl;
    }
    else
    {
        cout << (x + 1) * T << endl;
    }
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int x, a, b, n;
signed main() {
	cin >> x >> a >> b >> n;
	for1(i, n) {
		string s; cin >> s;
		if (s[0] == 'n')x += a;
		else if (s[0] == 't')x += b;
		else x = 0;
		if (x < 0)x = 0;
	}cout << x << endl;
}


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

using namespace std;

int a, b;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &a, &b);
if (a <= 0 && 0 <= b)
{
    printf ("Zero\n");
    return 0;
}
if (a > 0 || (b - a + 1) % 2 == 0)
{
    printf ("Positive\n");
    return 0;
}
printf ("Negative\n");

return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <bitset>
#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 <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
/*
int R,C;
int search(int i, vector< vector<int> > moti){
  if(i==R){
    int ret = 0;
    REP(j,C){
      int c=0;
      REP(k,R){
        if(moti[k][j]==1) c++;
      }
      ret+=max(c,R-c);
    }
    return ret;
  }else{
    vector< vector<int> > moti2;
    moti2=moti;
    REP(j,C){
      if(moti2[i][j]==1)moti2[i][j]=0;
      else moti2[i][j]=1;
    }
    return max(search(i+1,moti),search(i+1,moti2));
  }
}

int main(void){
  while(cin>>R>>C){
    if(R==0) break;
    vector< vector<int> > moti;    
    REP(i,R){
      vector<int> tmp;
      REP(j,C){
        int tmp2;
        cin>>tmp2;
        tmp.push_back(tmp2);
      }
      moti.push_back(tmp);
    }
    cout<<search(0,moti)<<endl;
  }
  return 0;
}
*/
int R,C;
bool moti[11][10001];
int main(){
  while(cin>>R>>C){
    if(R==0) break;
    REP(i,R)REP(j,C) cin>>moti[i][j];
    bitset<10> test;
    int ans = 0;
    for(int i=0; i<pow(2,(double)R)-1; i++){
      int ka = 0;
      test = i;
      REP(i,C){
        int c=0;
        REP(j,R){
          if(moti[j][i]==test[j]) c++;
        }
        ka += max(c,R-c);
      }
      ans = max(ans, ka);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(void){
    int N;

    cin>>N;
    string str[N];

    for(int i=0;i<N;i++) cin>>str[i];

    for(int i=0;i<N-1;i++){
      string now = str[i];
      string next = str[i+1];
      for(int j=0;j<N;j++){
        if( (i!=j) && (now ==str[j])){
          cout<<"No"<<endl;
          return 0;
        }
      }
      if(now.substr((int)now.size()-1, 1)!= next.substr(0, 1)){
        cout<<"No"<<endl;
        return 0;
      }
    }

    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	ans := 0
	for i := 0; i < N; i++ {
		ans += a[i] - 1
	}
	out(ans)
}


Measured memory_bytes: 640
n,a,b = map(int,input().split())
mod = 10**9+7
def pow(n, p,mod=10**9+7): #繰り返し二乗法(nのp乗)
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod

def large_conbination(n,k,mod=10**9+7): #needs pow method. return nCk.
    res1 = 1
    for i in range(n,n-k,-1):
        res1*=i
        res1%=mod
    res2 = 1
    for i in range(1,k+1):
        res2*= i
        res2%=mod
    return res1*pow(res2,mod-2)%mod

ans = pow(2,n) -1 

ans -= large_conbination(n,a)
ans -= large_conbination(n,b)

while ans<0:
    ans += mod
print(ans%mod)

Measured memory_bytes: 38640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int gcd(int x,int y)
{
	while(1)
	{
		x %= y;
		if(x == 0)
			return y;
		y %= x;
		if(y == 0)
			return x;
	}
}

typedef struct mb
{
	struct mb* red;
	struct mb* blue;
	struct mb* parent;
	long long int weight_r;
	long long int weight_b;
	int ratio_r;
	int ratio_b;
	int flug;
} mobile;

int main()
{
	int n;
	int i,j;
	mobile* list;
	while(scanf("%d",&n),n)
	{
		list = (mobile*)malloc(sizeof(mobile)*n);
		for(i = 0;i < n;i++)
		{
			list[i].parent = NULL;
			list[i].flug = 1;
		}
		for(i = 0;i < n;i++)
		{
			int p,q,r,b;
			scanf("%d %d %d %d",&p,&q,&r,&b);
			list[i].ratio_r = p;
			list[i].ratio_b = q;
			list[i].weight_r = 0;
			list[i].weight_b = 0;
			if(r)
			{
				list[i].red = &list[r-1];
				list[r-1].parent = &list[i];
			}
			else
				list[i].red = NULL;
			if(b)
			{
				list[i].blue = &list[b-1];
				list[b-1].parent = &list[i];
			}
			else
				list[i].blue = NULL;
		}
		while(1)
		{
			for(j = 0;j < n;j++)
			{
				if(list[j].red == NULL && list[j].blue == NULL && list[j].flug)
				{
					if(list[j].weight_r == 0 && list[j].weight_b == 0)
					{
						list[j].weight_r = list[j].ratio_b/gcd(list[j].ratio_r,list[j].ratio_b);
						list[j].weight_b = list[j].ratio_r/gcd(list[j].ratio_r,list[j].ratio_b);
					}
					else if(list[j].weight_r == 0)
					{
						list[j].weight_r = list[j].ratio_b*list[j].weight_b/gcd(list[j].ratio_r,list[j].ratio_b*list[j].weight_b);
						list[j].weight_b = list[j].ratio_r*list[j].weight_b/gcd(list[j].ratio_r,list[j].ratio_b*list[j].weight_b);
					}
					else if(list[j].weight_b == 0)
					{
						list[j].weight_r = list[j].ratio_b*list[j].weight_r/gcd(list[j].ratio_r*list[j].weight_r,list[j].ratio_b);
						list[j].weight_b = list[j].ratio_r*list[j].weight_r/gcd(list[j].ratio_r*list[j].weight_r,list[j].ratio_b);
					}
					else
					{
						list[j].weight_r = list[j].weight_r*list[j].weight_b*list[j].ratio_b/gcd(list[j].ratio_r*list[j].weight_r,list[j].ratio_b*list[j].weight_b);
						list[j].weight_b = list[j].weight_b*list[j].weight_r*list[j].ratio_r/gcd(list[j].ratio_r*list[j].weight_r,list[j].ratio_b*list[j].weight_b);
					}
					if(list[j].parent == NULL)
					{
						printf("%lld\n",list[j].weight_r+list[j].weight_b);
						goto hell;
					}
					else if(list[j].parent->red == &list[j])
					{
						list[j].parent->red = NULL;
						list[j].parent->weight_r = list[j].weight_r+list[j].weight_b;
					}
					else
					{
						list[j].parent->blue = NULL;
						list[j].parent->weight_b = list[j].weight_r+list[j].weight_b;
					}
					list[j].flug = 0;
				}
			}
		}
		hell:;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26328