akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int c[n];
    int a[n][m];
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    
    ll ans=LINF;
    for(int bit=0;bit<(1<<n);bit++){
        vector<ll> tot(m,0);
        ll ans_t=0;
        for(int i=0;i<n;i++){
            if((bit>>i) & 1){
                rep(j,m) tot[j] += a[i][j];
                ans_t += c[i];
            }
        }
        bool flag=true;
        rep(k,m){
            if(tot[k]<x){
                flag=false;
                break;
            }
        }
        if(flag){
            ans = min(ans,ans_t);
        }
    }

    if(ans==LINF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3632
package main

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

func main() {
	c := getString()

	ans := "consonant"
	if c == "a" || c == "i" || c == "u" || c == "e" || c == "o" {
		ans = "vowel"
	}

	fmt.Println(ans)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
vector <long> p;
long i;
long n,m;
long a;
long f;
long ice[100002],tim[100002];
int main()
{
	cin >> n >> m;
	ice[0]=ice[n+1]=0;
	cin >> ice[1];
	for(i=2;i<=n;i++)
	{
		cin >> ice[i];
		if(ice[i-2]<ice[i-1] && ice[i-1]>ice[i])
		{
			p.push_back(i-1);
		}
	}
	//cout <<"AA";
	if(ice[n-1]<ice[n] && ice[n]>ice[n+1])
	{
		p.push_back(n);
	}
	while(!p.empty())
	{
		//cout << "BB" ;
		a=p[p.size()-1];
		p.pop_back();
		if(ice[a-1]<ice[a] && ice[a]>ice[a+1])
		{
			tim[a]=m-ice[a];
			if(ice[a-1]!=0) p.push_back(a-1);
			if(ice[a+1]!=0)p.push_back(a+1);
		}
		else if(ice[a-1]<ice[a] || ice[a]>ice[a+1])
		{
			if(ice[a-1]>ice[a])
			{
				f=tim[a-1];
				if(ice[a+1]!=0) p.push_back(a+1);
			}
			if(ice[a+1]>ice[a])
			{
				f=tim[a+1];
				if(ice[a-1]) p.push_back(a-1);
			}
			tim[a]=m-ice[a]+f;
		}
		else
		{
			if(tim[a-1]>tim[a+1])
			{
				tim[a]=m-ice[a]+tim[a-1];
			}
			if(tim[a-1]<tim[a+1])
			{
				tim[a]=m-ice[a]+tim[a+1];
			}
		}
	}
	//cout << "CC";
	long mx=0;
	for(i=1;i<=n;i++)
	{
		if(mx<tim[i]) mx=tim[i];
	}
	cout << mx <<endl;
	return 0;
}

Measured memory_bytes: 4916
import Data.List

main :: IO ()
main = do
  [h,w] <- map read . words <$> getLine :: IO [Int]
  l <- lines <$> getContents 
  let bs = concat $ map (\g -> boms (fst g) (snd g)) $ zip [1..h] l 
  let grid =  [((i,j),v) | i <- [1..h], j <- [1..w], let v = (l !! (i-1)) !! (j-1)]
  putStr $ split (makeLine grid bs)  w
 
boms :: Int -> String -> [(Int, Int)]
boms h l = map (\i -> (h,i+1)) $ elemIndices '#' l

around :: (Int, Int) -> [(Int,Int)]
around (i,j) = [(i-1,j-1), (i-1,j), (i-1,j+1), (i,j-1), (i,j+1), (i+1,j-1), (i+1,j), (i+1,j+1)]

makeLine :: [((Int,Int),Char)] -> [(Int,Int)]-> String
makeLine [] _ = ""
makeLine (x:xs) bs
  |snd x == '#'= ['#'] ++ (makeLine xs bs)
  |otherwise =
    let number = length $ filter (`elem` bs) $ around (fst x) 
      in show number ++ makeLine xs bs

  
split :: String -> Int -> String
split "" _ = ""
split xs w = take w xs ++ "\n" ++ split (drop w xs) w

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	// cin>>t;
	string s;
	cin>>s;
	for(int i = 0; i < s.size(); i++)
	{
		if(i%2==0)
		{
			if(!(s[i]=='R' or s[i]=='D' or s[i]=='U'))
			{
				cout<<"No"<<endl;
				return 0;
			}

		}
		else
		{
			if(!(s[i]=='L' or s[i]=='D' or s[i]=='U'))
			{
				cout<<"No"<<endl;
				return 0;
			}

		}
	}
	cout<<"Yes"<<endl;

}

Measured memory_bytes: 256
MOD = 2019
l, r = map(int, input().split())
if r - l > MOD:
    print(0)
else:
    mods = sorted([item % MOD for item in range(l, r+1)])
    n = len(mods)
    ans = MOD
    for i in range(n):
        for j in range(i+1, n):
            if mods[i] * mods[j] % MOD < ans:
                ans = mods[i] * mods[j] % MOD
    print(ans)


Measured memory_bytes: 40812
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int N;
    cin>>N;
    vector<int>A(N-1);
    vector<int>a(N);
    rep(i,N-1){
        cin>>A[i];
        a[A[i]-1]+=1;
    }
    rep(i,N){
        cout<<a[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4832
#include <stdio.h>
int main(){
  int x,y;
  for(int i = 0; i < 3000;i++){
    scanf("%d %d",&x, &y);
    if(x == 0 && y == 0)break;
    else if(y < x)printf("%d %d\n",y,x);
    else printf("%d %d\n",x,y);
  }
  return 0;
}

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

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
		int k = reader.nextInt();
        if (k%2!=0){
			int r=(k/2)*(k+1)/2;
      	System.out.printf("%d\n",r);}
        else{
			int r=(k/2)*(k/2);
        System.out.printf("%d\n",r);
        }
    }

}

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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < M; i++) cin >> B.at(i);
    for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) cin >> A.at(i).at(j);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int sum = C;
        for (int j = 0l; j < M; j++) sum += A.at(i).at(j) * B.at(j);
        if (sum > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> d(a);
  rep(i,a)
    cin>>d[i];
  int e=0,f=0,g=0;
  rep(i,a){
  if(d[i]<=b)
    e++;
    else if(d[i]<=c)
      f++;
      else
        g++;
  }
  cout<<min(e,min(f,g))<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> A(N+1,0); // A[i]:= i 文字目まで見たときのAC の数の合計
    rep(i,N){
        A[i+1] = A[i];
        if(S[i]=='C' && S[i-1]=='A' && i-1>=0){
            A[i+1]++;
        }
    }
    rep(i,Q){
        int l,r;
        cin >> l >> r;
        cout << A[r] - A[l] << endl;
    }
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U;
    // int x;
    cin>>n>>m;
    map<int,int> AC,WA;
    while(m--)
    {
        cin>>t>>S;
        if(S=="AC")
        {
            if(!AC[t]) count++;
            AC[t]++;
        }
        else
        {
            if(!AC[t]) WA[t]++;
        }
    }
    for(auto x:AC)
    {
        if(x.S)flag+=WA[x.F];
        // cout<<x.F<<" "<<x.S<<"\n";
    }
    cout<<count<<" "<<flag;
}


signed main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


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


void solve(long long X, long long A){
    if(X < A) cout << 0 << endl;
    else cout << 10 << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
    return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
d = map(int, input().split())
d_l = list(d)

d_com = list(itertools.combinations(d_l, 2))

d_sum = 0
for x in range(len(d_com)):
    d_sum += d_com[x][0] * d_com[x][1]
print(d_sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int h, w, m = 1;
  cin >> h >> w;
  vector<string> v(h);
  v2i l(h, v1i(w)), r(h, v1i(w)), u(h, v1i(w)), d(h, v1i(w));
  rep(i, h) cin >> v[i];
  rep(i, h){
    int t = 0;
    rep(j, w){
      if(v[i][j] == '#') t = 0;
      else ++t;
      l[i][j] = t;
    }
  }
  rep(i, h){
    int t = 0;
    rrep(j, w){
      if(v[i][j] == '#') t = 0;
      else ++t;
      r[i][j] = t;
    }
  }
  rep(i, w){
    int t = 0;
    rep(j, h){
      if(v[j][i] == '#') t = 0;
      else ++t;
      u[j][i] = t;
    }
  }
  rep(i, w){
    int t = 0;
    rrep(j, h){
      if(v[j][i] == '#') t = 0;
      else ++t;
      d[j][i] = t;
    }
  }
  rep(i, h) rep(j, w) m = max(m, l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 67200
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    val e = sc.nextInt()
    val f = sc.nextInt()

    var max = -0.1
    var ans = 0 to 0

    for (w1 in 0..f step 100 * a) {
        for (w2 in 0..(f - w1) step 100 * b) {
            val water = w1 + w2

            for (s1 in 0..(f - water) step c) {
                for (s2 in 0..(f - water - s1) step d) {
                    val sugar = s1 + s2

                    if (sugar / water.toDouble() > e / 100.0) {
                        continue
                    }

                    val x = sugar / (water + sugar).toDouble()
                    if (x > max) {
                        max = x
                        ans = water + sugar to sugar
                    }
                }
            }
        }
    }

    println("${ans.first} ${ans.second}")
}


Measured memory_bytes: 31272
#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++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s,t;
    cin>>s>>t;
    map<char,int> mci1,mci2;
    rep(i,s.size()){
        mci1[s[i]]++;
        mci2[t[i]]++;
    }
    if(mci1.size()!=mci2.size()){
        cout<<"No"<<endl;
        return 0;
    }
    vector<int> v1(s.size(),0),v2(t.size(),0);
    rep(i,s.size()){
        v1[i]=mci1[s[i]];
        v2[i]=mci2[t[i]];
    }
    rep(i,s.size()){
        if(v1[i]!=v2[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 2312
#include <bits/stdc++.h>
#include <climits>
using namespace std;
long long gcd(long long a, long long b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b)
{
    return a * b / gcd(a, b);
}
int main() {
    long long N,M;
    string S,T;
    cin >> N >> M;
    cin >> S;
    cin >> T;
    long long g = gcd(N,M);
    long long n = N/g;
    long long m = M/g;
    bool flag = true;
    for(long long i = 0; i < g;i++){
        if(S[i*n]!=T[i*m])flag = false;
    }
    if(flag)cout << lcm(N,M)<<endl;
    else cout << -1 << endl;
    
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 1e5 + 5;

lint dp[3005][3005];

int main () {
	make(n);
	makev(v, n);
	FOR(i,0,n) dp[i][i] = v[i];
	FOR(d,1,n) {
		FOR(i,0,n) {
			if (i+d>n) break;
			dp[i][i+d] = max(v[i]-dp[i+1][i+d], v[i+d]-dp[i][i+d-1]);
		}
	}
	printf("%lld\n", dp[0][n-1]);
}	





Measured memory_bytes: 70016
#include <iostream>
#include "string.h"
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;
#define output(member) cout << member << endl;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W,a,b;
	cin >> W >> a >> b;
	int answer = abs(b - a) - W;
	if(answer > 0){
		output(answer);
	}else{
		output(0);
	}
	return 0;
}

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

int solve(long long X, long long N, std::vector<long long> p)
{
    long long index = 0;
    long long q_index = 0;
    long long absx;
    long long mina = 9999999999;
    long long ans;
    vector<long long> q;
    sort(p.begin(), p.end());

    if (N == 0)
    {
        cout << X << endl;
        return 0;
    }

    for (int i = -100; i <= 200; i++)
    {
        if (p[index] != i)
        {

            q.push_back(i);
            q_index++;
        }
        else
        {
            index++;
        }
    }

    for (int i = 0; i < q_index; i++)
    {
        absx = abs(X - q[i]);
        if (mina > absx)
        {
            mina = min(mina, absx);
            ans = q[i];
        }
    }
    cout << ans << endl;
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


Measured memory_bytes: 3604
s = input()
N = len(s)

g = 0
p = 0
score = 0

for i in range(N):
    if(g > p):
        if(s[i] == "g"):
            p += 1
            score += 1
        else:
            p += 1
    elif(g == p):
        if(s[i] == "g"):
            g += 1
        else:
            g += 1
            score -= 1
print(score) 

Measured memory_bytes: 3316
N=int(input())
X=list(map(int,input().split()))
def tairyoku(n):
    return (n-i)**2
i=1
XT=list(map(tairyoku,X))
ans=sum(XT)
for i in range(2,101):
    XT=list(map(tairyoku,X))
    ans=min(ans,sum(XT))
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
int n,p,a[52],m0=0,m1=0;
long long ans;
int main()
{
    scanf("%d%d",&n,&p);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%2==0)
            m0++;
        else
            m1++;
    }
    if(m1!=0)
        printf("%lld",1ll<<(n-1));
    else
    {
        if(p%2==1)
            printf("0");
        else
            printf("%lld",1ll<<n);
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

main(){
  char data[3];
  int i;

  while(1){
    if(scanf("%c", &data[0])==EOF) break;

    if(data[0]=='@'){
      scanf("%c%c", &data[1], &data[2]);

      for(i=0;i<(data[1]-'0');i++){
	printf("%c", data[2]);
      }
    }
    else printf("%c", data[0]);
  }
  return 0;
}

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

using namespace std;

double P,E,T;

double solve(double L,double R,int K){
  double H = (L + R) / 2.0;
  if(K == 0){
    if(T-E <= H && H <= T+E){
      return 1;
    }else{
      return 0;
    }
  }

  if(T-E <= L && L <= T+E &&
     T-E <= R && R <= T+E){
    return 1;
  }

  if(T-E > L || T+E < R){
    return 0;
  }

  double res = 0;
  if(H < T){
    res += solve(L,H,K-1)*(1-P);
    res += solve(H,R,K-1)*P;
  }else{
    res += solve(H,R,K-1)*(1-P);
    res += solve(L,H,K-1)*P;
  }
  return res;
}

int main(){
  int K;
  double R,L;
  cin >> K >> R >> L >> P >> E >> T;
  printf("%.8f\n",solve(L,R,K));
  return 0;
}

Measured memory_bytes: 1248
//@sakshjha
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979
const ll MOD =1000000007;
const ll N=1000005;
ll pow (ll x, ll y, ll m);
int main()
{
    IOS
    ll t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
       ll a,b,c,k;
       cin>>a>>b>>c>>k;
       if(k<=a)
       {
           cout<<k;
           return 0;
       }
       else if(k<=a+b)
       {
           cout<<a;
           return 0;
       }
       else
       {
           k-=(a+b);
           a-=k;
           cout<<a;
       }
    }
    return 0;
}


/*ll pow (ll x, ll y, ll m)
{
    ll res=1;
    x=x%m;
    if(x==0)
        return 0;
    while(y>0)
    {
        if(y&1)
        {
            res*=x;
            res%=m;
        }
        y=y/2;
        x=(x*x)%m;
    }
    return res;
}*/


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> ship(n);
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;a--;b--;
        ship[a].push_back(b);
        ship[b].push_back(a);
    }
    for(int i=0;i<ship[0].size();i++){
        int x = ship[0][i];
        for(int j=0;j<ship[x].size();j++){
            int y = ship[x][j];
            if(y==n-1){
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 12016
#include<stdio.h>

int main()
{
  int n,m,l;
  int i,j,k;
  int a[101][101];
  int b[101][101];
  long long int c[101][101];
  scanf("%d %d %d",&n,&m,&l);
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i = 0; i < m; i++){
    for(j = 0; j < l; j++){
      scanf("%d",&b[i][j]);
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < l; j++){
      c[i][j] = 0;
      for(k=0; k < m; k++){
      c[i][j] += a[i][k] * b[k][j];
      }
      if(j!=l-1)
         printf("%lld ",c[i][j]);
      else printf("%lld\n",c[i][j]);
      }
   
  }
  
  return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int ans = A + B > 23 ? A + B - 24 : A + B;
        System.out.println(ans);
    }
}


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

int main() {
  int N, K, X, D;
  D = 0;
  cin >> N >> K;
  
  for ( int i = 0 ; i < N ; i++ ) {
    cin >> X;
    if ( K > 2 *X ) {
      D += X;
    } else {
      D += K - X;
    }
  }
  cout << 2 * D << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
int main()
{
	int i = 0, ans, j = 0;
	char s[3];
	for (i = 0; i < 3; i++)
		scanf("%c", &s[i]);
	for (i = 0; i < 3; i++)
	{
		if (s[i] == 'o')
			j++;
    }
	ans = 700 + 100 * j;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define piii pair<pii, int>
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R){int val=rng()%R;assert(val >= 0);return val;}

const long double PI = atan(1.0) * 4;
const int64_t INF64 = 3e18;
const int32_t INF32 = 2e9 + 7;
const int32_t LOG = 21;
const int32_t MOD = MOD1;

using namespace std;


//-------------------DEBUGGING-------------------------
void my_debugger(string s,int LINE_NUM){cerr<<endl;}
template<typename start,typename... end>
void my_debugger(string s,int LINE_NUM,start x,end... y) 
{
    if(s.back()!=',') {s+=',';cerr<<"LINE("<<LINE_NUM<<"): ";}
    int i=s.find(',');
    cerr<<s.substr(0,i)<<" = "<<x;
    s=s.substr(i+1);
    if(!s.empty()) cerr<<", ";
    my_debugger(s,LINE_NUM,y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__,__LINE__,__VA_ARGS__);
#else
#define debug(...) ;
#endif

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



int32_t main()
{
      getFaster;
      //files_init();
      int tests = 1;
      //cin >> tests;
      rep(ii, 0, tests)
      {
              string s;
              cin>>s;
              if(s.back()=='s')s+="es";
              else s+="s";
              cout<<s<<endl;
      }
      return 0;
}


Measured memory_bytes: 3660
res = 0
p = 0
R, G, B, N = map(int, input().split())
for i in range (N // R + 1):
    for j in range(N // G + 1):
        P =N - i*R - j*G
        if P < 0:
            break
        else:
            if(P % B == 0):
                res += 1


print(res)

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

int main(void){
    string s;
    cin >> s;
    int cnt = 0, cns=0;
    for(int i=0;i<s.size();++i){
        if(s[i]=='S'){
            ++cnt;
            ++cns;
        }else{
            if(cns>0){
                --cnt;
                --cns;
            }else ++cnt;
        }
    }
    cout << cnt << endl;
}

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

const int MOD = 1e9 + 7;

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

    vector<int> dp(n + 1);
    dp[0] = 1;
    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        if (i - 3 >= 0) {
            sum += dp[i - 3];
            sum %= MOD;
        }
        dp[i] = sum;
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 3496
class Heap
  attr_reader :size
  def initialize
    @heap = []
    @size = 0
  end
  def sum
    @heap.inject(:+)
  end
  def push(n)
    i = @size
    while i > 0
      pid = (i - 1) / 2
      break if n >= @heap[pid]
      @heap[i] = @heap[pid]
      i = pid
    end
    @heap[i] = n
    @size += 1
  end
  def pop
    top = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size
      cid1 = i * 2 + 1
      cid2 = cid1 + 1
      if cid2 < @size && @heap[cid2] < @heap[cid1]
        cid1 = cid2
      end
      break if @heap[cid1] >= n
      @heap[i] = @heap[cid1]
      i = cid1
    end
    @heap[i] = n
    top
  end
end

def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m = input_a
a = input_a

q = Heap.new

a.each do |num|
  q.push(-num)
end

m.times do
  max = q.pop
  q.push(-(-max / 2))
end

sum = 0
while q.size != 0
  sum += -q.pop
end
puts sum

Measured memory_bytes: 11476
#include<stdio.h>

int main(){
    int A,B,C,X,Y;
    scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);                                                    
    int a,b,c;
    a = A*X+B*Y;
    b = 2*C*X;
    if(X<Y)     b+=B*(Y-X);
    c = 2*C*Y;
    if(Y<X)     c+=A*(X-Y);
    if(a>b)     a=b;
    if(a>c)     a=c;
    printf("%d",a);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  cin >> S;
  int C = 0, ans = 0;
  for(int i = 0; i < S.length(); ++i){
    if(S[i] == 'g'){
      if(C){
	--C;
	++ans;
      }else{
	++C;
      }
    }else{//S[i] == 'p'
      if(C){
	--C;
      }else{
	++C;
	--ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define NMAX 50

int main(){

    int N,K;
    int m,bunny;
    vector<int> vm[NMAX+1];
    int R,p,q;
    bool f[NMAX+1];
    int cnt;

    cin>>N>>K;

    for(int i=0;i<NMAX+1;i++){
        f[i]=false;
    }

    for(int i=0;i<K;i++){
        cin>>m;
        while(m--){
            cin>>bunny;
            vm[i].push_back(bunny);
        }
    }

    cin>>R;

    for(int i=0;i<R;i++){
        cin>>p>>q;
        bool pf,qf;
        for(int j=0;j<K;j++){
            pf=false,qf=false;
            for(int k=0;k<vm[j].size();k++){
                if(p==vm[j][k]) pf=true;
                if(q==vm[j][k]) qf=true;
            }
            if(pf&&qf) f[p]=true,f[q]=true;
        }
    }

    cnt=0;
    for(int i=1;i<=50;i++){
        if(f[i]) cnt++;
    }

    cout<<cnt<<endl;

    return 0;

}

Measured memory_bytes: 1220
A, B, C, X = 4.times.map { gets.to_i }
count = 0

(0..A).each do |i|
  (0..B).each do |j|
    (0..C).each do |k|
      count += 1 if i * 500 + j * 100 + k * 50 == X
    end
  end
end
puts count

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

int N;
int A[200010];
int zyoushi[200010] = { 0 };

int main(){
  cin >> N;

  for(int i = 0; i < N; i++){ cin >> A[i]; zyoushi[A[i]] += 1; }

  for(int i = 1; i <= N; i++) cout << zyoushi[i] << endl;
  return 0;
  
}
    

Measured memory_bytes: 5124
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>>A(H, vector<char>(W));
	rep(i, H) {
		rep(j, W) {
			cin >> A[i][j];
		}
	}
	int cnt = 0;
	rep(i, H) {
		rep(j, W) {
			if (A[i][j] == '#') {
				cnt++;
			}
		}
		if (cnt == 0) {
			rep(j, W) {
				A[i][j] = '*';
			}
		}
		cnt = 0;
	}

	rep(j, W) {
		rep(i, H) {
			if (A[i][j] == '#') {
				cnt++;
			}
		}
		if (cnt == 0) {
			rep(i, H) {
				A[i][j] = '*';
			}
		}
		cnt = 0;
	}

	rep(i, H) {
		rep(j, W) {
			if (A[i][j] != '*') {
				cout << A[i][j];
				cnt++;
			}
		}
		if (cnt != 0) {
			cout << endl;
		}
		cnt = 0;
	}
}

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

# input
A, B, C, D = map(int, input().split())

# solve
if (A + B) > (C + D):
    ans = 'Left'
elif (A + B) < (C + D):
    ans = 'Right'
else:
    ans = 'Balanced'

# output
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int n, q, i, t = 0;
	cin >> n >> q;

	vector<string> vs(n);
	vector<int> vq(n);
	queue<int> vi;
	
	for(i = 0; i < n; ++i){
		cin >> vs[i] >> vq[i];
		vi.push(i);
	}

	while( !vi.empty() )
	{
		i = vi.front();
		vi.pop();
		if( vq[i] <= q ){
			t += vq[i];
			cout << vs[i] << " " <<  t << "\n";
		} else {
			t += q;
			vq[i] -= q;
			vi.push(i);
		}
	}

	return 0;
}

Measured memory_bytes: 4184
n=int(input())
arr=[[str(i) for i in input().split()] for _ in range(n) ]

jpy=0.0
btc=0.0
for l in arr:
    if l[1]=="JPY":
        jpy+=float(l[0])
    else:
        btc+=float(l[0])
        
print(jpy+(btc*380000.0))

Measured memory_bytes: 3060
#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++)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
	int n, k, sum = 0, a[110] = {};

	cin >> n>>k;

	int d,dn;
	rep(i, k) {
		cin >> d;
		rep(j, d) {
			cin >> dn;
			a[dn]=1;
		}
	}

	For(i,1,n+1)if (a[i] == 0)sum++;

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long; //using lll=__int128;
using pii=pair<int,int>;
#define repeat(i,a,b) for(int i=(a),iE=(b);i<iE;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,iE=(a);i>=iE;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define N (100*101-100-101+1)
#define inf 1e9
#define qwq {cout<<"qwq"<<endl;}
//#define int ll
const int mod=1000000007;
string s;
set<string> s1,s2,s3;
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	cin>>s;
	repeat(i,0,n){
		for(auto p:s2)
			s3.insert(p+s[i]);
		for(auto p:s1)
			s2.insert(p+s[i]);
		s1.insert(string()+s[i]);
	}
	cout<<s3.size()<<endl;
	return 0;
}

Measured memory_bytes: 384
k,s=map(int,input().split())
ans=0
x=min(k+1,s+1)
y=max(0,s-k-k)
for i in range(y,x):
    for j in range(y,x):
        if i+j>s: break
        if 0<=s-i-j<=k:
            ans+=1
print(ans)

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

int main(){
    double A,B,H,M;
    cin>>A>>B>>H>>M;
    double Ans=abs((H*30+M*0.5)-6*M);
    Ans=min(360-Ans,Ans);
    double c=sqrt(A*A+B*B-2*A*B*cos(M_PI*(Ans/180)));
    cout<<fixed<<setprecision(10)<<c<<endl;
}

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

int main()
{
    string S;
    cin >> S;
    if (S.size() == 26)
    {
        for (int i=25; i>=0; i--)
        {
            int tmp=-1;
            for (int j=i+1; j<26; j++)
            {
                if (S[j] > S[i] && (S[j] < S[tmp] || tmp<0))
                {
                    tmp = j;
                }
            }
            if (tmp>0)
            {
                char c = S[i];
                S[i] = S[tmp];
                S[tmp] = c;
                S.erase(S.begin()+i+1, S.end());
                cout << S << endl;
                return 0;
            }
        }
        cout << -1 << endl;
        return 0;
    }
    else
    {
        set<char> a;
        for (int i=0; i<26; i++) a.insert('a' + i);

        for (int i=0; i<S.size(); i++) a.erase(S[i]);
        cout << S << *a.begin() << endl;
        return 0;
    }
}

Measured memory_bytes: 256
const main = (input) => {
  const ip = input.trim().split('\n')
  const arr = ip[1].split(' ').map(v => parseInt(v, 10))
  const n_q = parseInt(ip[2])
  const q = ip.slice(3)

  const nums = {}
  let currentSum = BigInt(0)

  for (let v of arr) {
    currentSum += BigInt(v)
    nums[v] = ~~nums[v] + 1
  }

  for (let i = 0; i < n_q; i++) {
    const [pre, v] = q[i].split(' ').map(v => parseInt(v, 10))
    const dif = v - pre
    const count = ~~nums[pre]

    if (!count) {
      console.log(`${currentSum}`)
      continue
    }

    nums[v] = ~~nums[v] + count
    delete nums[pre]

    currentSum += BigInt(dif * count)
    console.log(`${currentSum}`)
  }
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 61664
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll modpow(ll m, ll p) {
    if (p == 0) return 1;
    ll tmp = modpow(m, p / 2);
    if (p & 1) return (tmp * tmp % MOD) * m % MOD;
    else return tmp * tmp % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    
    // insert or delete
    vvll dp(2, vll(n + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        dp[1] = vll(n + 1, 0);
        for (int j = 0; j < n; j++) {
            if (j > 0) (dp[1][j - 1] += dp[0][j]) %= MOD;
            else (dp[1][j] += dp[0][j]) %= MOD;
            (dp[1][j + 1] += 2 * dp[0][j] % MOD) %= MOD;
        }
        swap(dp[0], dp[1]);
    }
    cout << (dp[0][s.size()] * modpow(modpow(2, s.size()), MOD - 2)) % MOD << '\n';
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;

	cout << (n+1)/2 << '\n';
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int, C: int, D: int, E: int, F: int):

    mwater = 0
    msugar = 0
    mnoudo = 0

    # ope1
    for i in range(-(-F//100)*A+1):
        # ope2
        for j in range(-(-F//100)*B + 1):
            water = 100*A*i+100*B*j
            if water > F:
                break
            # ope3
            for k in range(-(-water*E//100)//C + 1):
                if water+C*k > F:
                    break
                for l in range(-(-water*E//100)//D + 1):
                    sugar = C*k + D*l
                    if water + sugar > F:
                        break
                    if (water*E/100) < sugar:
                        break
                    if water+sugar == 0:
                        break
                    noudo = 100*sugar/(water+sugar)
                    # print(water, sugar, noudo)
                    if mnoudo <= noudo:
                        mnoudo = noudo
                        mwater = water
                        msugar = sugar
    print(mwater+msugar, msugar)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string ss;
    cin>>ss;
    int mat[27];
    for(int i=0;i<=26;i++)
        mat[i]=0;
        for(int i=0;i<ss.size();i++)
        {
            mat[ss[i]-'a']++;
        }
        for(int i=0;i<=26;i++)
        {
            if(mat[i]%2!=0)
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int i, a[4];
char s[4];
 
int main(void)
{
    scanf("%s", s);
    for (i = 0; i < 4; i++)
    {
        a[i] = s[i];
        //printf("%d\n",a[i]);
    }
    if(a[0]*4 == a[0]+a[1]+a[2]+a[3])
        {
            printf("No");
        }
        else if(a[0] != a[1]&&a[1] != a[2]&&a[2] != a[3]&&a[0] !=a[2]&&a[0] != a[3]&&a[1] != a[3]){
            printf("No");
        }else if (a[0] - a[1] == 0 && a[2] - a[3] == 0)
        {
            printf("Yes");
        }
        else if ((a[0] + a[1]) - (a[2] + a[3]) == 0)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
        return 0;    
}

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

int n,f[10005];

int main(){

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

    cin>>n;
    for(int x=1;x*x<=n;x++){
        for(int y=1;x*x+y*y+x*y<=n;y++){
            for(int z=1;x*x+y*y+z*z+x*y+y*z+x*z<=n;z++){
                f[x*x+y*y+z*z+x*y+y*z+x*z]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<f[i]<<'\n';
    }

    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	int n;
  	cin >> n;
  	vector<int> h(n);	
  	rep(i, n) cin >> h[i];
  
  	vector<int> dp(n+1, 1e9);
  	dp[0] = 0;
  	dp[1] = abs(h[1]-h[0]);
  	for(int i = 2; i <= n; i++){
    	dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
  
  	cout << dp[n-1] << endl;
}	

Measured memory_bytes: 3884
#include <iostream>
#include <vector>
#include <limits>

int main()
{
  int N,M,X;
  std::cin>>N>>M>>X;
  
  std::vector<int> cVec;
  cVec.reserve(N*N);
  std::vector<std::vector<int>> aVec;
  aVec.reserve(N*N);
  
  for(size_t i=0;i!=N;i++)
  {
    int C;
    std::cin>>C;
    std::vector<int> A(M);
    for(auto &e:A)
      std::cin>>e;
    
    for(size_t j=cVec.size()-1;j!=-1;j--)
    {
      int cTemp=C+cVec[j];      
      std::vector<int> aTemp(M);
      for(size_t k=0;k!=M;k++)
        aTemp[k]=A[k]+aVec[j][k];
      
      cVec.push_back(cTemp);
      aVec.push_back(move(aTemp));
    }
    
    cVec.push_back(C);
    aVec.push_back(move(A));
  }
  
  int result=std::numeric_limits<int>::max();
  for(size_t i=0;i!=cVec.size();i++)
  {
    bool understood=true;
    for(auto &e:aVec[i])
    {
      if(e<X)
      {
        understood=false;
        break;
      }
    }
    if(understood)
    {
      if(cVec[i]<result)
        result=cVec[i];
    }
  }
  
  if(result==std::numeric_limits<int>::max())
    result=-1;
  
  std::cout<<result<<std::endl;
  
  return 0;
}

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

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

    auto vec = vector<pair<int, int>>(m);
    auto q = set<int>();
    for (int i = 1; i <= n; i++)
        q.insert(i);

    auto left = 1;
    auto right = m;
    for (int i = 0; i < m / 2; i++) {
        vec[i].first = left++;
        vec[i].second = right--;
    }

    left = m + 1;
    right = m + m + 1;
    for (int i = m / 2; i < m; i++) {
        vec[i].first = left++;
        vec[i].second = right--;
    }

    for (int i = 0; i < m; i++)
        cout << vec[i].first << " " << vec[i].second << "\n";
    return 0;
}


Measured memory_bytes: 12336
#include <iostream>

using namespace std;

main(){

int n;
int a[100];

cin >> n;

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

 cout << a[n-1];

for(int i=n-2;i>=0;i--){
 cout << " " << a[i]; 
}

cout << endl;

}

Measured memory_bytes: 1160
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]
ans = 9
n = 0
j = 0
for i in [i % 10 for i in l]:
    if i != 0 and i < ans:
        ans = i
        n = j
    j += 1
m = l.pop(n)
r = 0
for i in l:
    r += math.ceil(i / 10) * 10
print(r + m)


Measured memory_bytes: 38384
from bisect import bisect_left
a, b, q = map(int, input().split())
inf = 10**18
shrine = [-inf] + [int(input()) for _ in range(a)] + [inf]
temple = [-inf] + [int(input()) for _ in range(b)] + [inf]

for _ in range(q):
    ans = inf
    x = int(input())
    index_s = bisect_left(shrine, x)
    index_t = bisect_left(temple, x)

    for s in [shrine[index_s-1], shrine[index_s]]:
        for t in [temple[index_t-1], temple[index_t]]:
            ans = min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            )

    print(ans)


Measured memory_bytes: 14168
#include<iostream>
#include<cstdio>
#include<queue>

using namespace std;

int main(){
    string s;
    int num;
    priority_queue<int> fila;
    while(cin >> s, s!="end"){
        if(s=="extract"){
            if(!fila.empty()){
                cout << fila.top() << endl;
                fila.pop();
            }
        }
        else{
            cin >> num;
            fila.push(num);
        }
    }
}


Measured memory_bytes: 7024
S = input()
Sum = 0
N = 2 ** (len(S) - 1)
for i in range(N):
  A = []
  for j in range(len(S) - 1):
    A.append(i % 2)
    i //= 2
  T = S[0]
  T2 = 0
  for j in range(len(S) - 1):
    if A[j] == 0:
      T = T[:] + S[j+1]
    else:
      T2 += int(T)
      T = S[j+1]
  T2 += int(T)
  Sum += T2
print(Sum)

Measured memory_bytes: 3064