akhauriyash/Code-Regression huggingface dataset:
/*
  -------------
  Prateek Celly
  DA-IICT
  -------------
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b);
  return 0;
}


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

int store[200007];
ll csum[200007];


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

    for (int i = 1; i <= n; i++) scanf("%d", &store[i]);
    //sort(store+1, store+n+1);
    for (int i = 1; i <= n; i++) csum[i] = csum[i-1] + store[i];

    ll ans = INT_MAX;

    for (int i = 2; i <= n; i++) {
        ll a = csum[i-1];
        ll b = csum[n] - csum[i-1];

        ans = min(ans, abs(a-b));
    }

    cout << ans << "\n";
}


Measured memory_bytes: 2560
#include<stdio.h>
int main()
{ int A,B,C,D;
 scanf("%d%d%d%d",&A,&B,&C,&D);
       while(1)
       {
         C=C-B;
         if(C<=0)
         {
           printf("Yes");
           break;
         }
         A=A-D;
         if(A<=0)
         {
           printf("No");
           break;
         }
       }  
return 0;
       }    


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

class Main {

    static int n;
    static int[] A;

    public static boolean solve(int p, int t){
        if (t == 0) return true;
        if (p >= n) return false;
        return solve(p+1, t) || solve(p+1, t - A[p]) ;
    }

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

        n = Integer.parseInt(br.readLine());

        A = new int[n];

        String[] nums = br.readLine().trim().split("\\s+");
        for (int i = 0; i < n; i++)
            A[i] = Integer.parseInt(nums[i]);

        int q = Integer.parseInt(br.readLine());
        nums = br.readLine().trim().split("\\s+");
        br.close();

        for (int i = 0; i < q; i++) {
            int m = Integer.parseInt(nums[i]);
            String ans = solve(0, m) ? "yes" : "no";
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 25120
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, int) {
	return scanInt(sc), scanInt(sc)
}

func operation(n, k int) int {
	var v int
	if n > k {
		v = n % k
	} else {
		v = k - n
	}
	if v < n {
		return v
	}
	return n
}

func resolve(n int, k int) int {
	c := n
	tmp := operation(c, k)
	for c != tmp {
		c = tmp
		tmp = operation(c, k)
	}
	return c
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

using namespace std;

int main(void)
{
    int N, L, base = 0, tmp, tmpIndex, answer = 20000;
    cin >> N >> L;
    vector<int> aji(N);
    for (int count = 0; count < N; count++)
    {
        aji.at(count) = L + count;
    }
    for (int count = 0; count < N; count++)
    {
        if (aji.at(count) < 0)
        {
            tmp = aji.at(count) * (-1);
            if (answer > tmp)
            {
                answer = tmp;
                tmpIndex = count;
            }
        }
        else
        {
            if (answer > aji.at(count))
            {
                answer = aji.at(count);
                tmpIndex = count;
            }
        }
    }
    aji.at(tmpIndex) = 0;
    for (int x : aji)
    {
        base += x;
    }
    cout << base << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    string s;
    cin >> s;
    if(s.back() != 's') cout << s << "s" << endl;
    else cout << s << "es" << endl;
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

D.sort()
T.sort()
j = 0
for i in range(M):
    if j==N:
        print('NO')
        break
    if T[i]>=D[j]:
        while T[i]>D[j]:
            j += 1
        if T[i]==D[j]:
            j += 1
        else:
            print('NO')
            break
    else:
        print('NO')
        break
else:
    print('YES')

Measured memory_bytes: 127828
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

int inv_mod(int a, int m){
	assert(0<a);
	assert(a<m);
	return a==1 ? 1 : m-m*int64_t(inv_mod(m%a, a))/a;
}

const int mod = 1e9+7 ;
struct mint {
	int x;
	mint(): x(0) {}
	mint(const auto &val): x(val%mod) { if(x<0) x+=mod; }
};

void operator+=(mint &a, const mint &b){ a.x+=b.x; if(a.x>=mod) a.x-=mod; }
mint operator+(mint a, const mint &b){ a+=b; return a; }
void operator-=(mint &a, const mint &b){ a.x-=b.x; if(a.x<0) a.x+=mod; }
mint operator-(mint a, const mint &b){ a-=b; return a; }
void operator*=(mint &a, mint b){ a.x = int64_t(a.x)*b.x %mod; }
mint operator*(mint a, const mint &b){ a*=b; return a; }
void operator/=(mint &a, const mint &b){ a.x = int64_t(a.x)*inv_mod(b.x,mod) %mod; }
mint operator/(mint a, const mint &b){ a/=b; return a; }
mint operator-(mint a){ if(a.x) a.x = mod - a.x; return a; }
mint operator""m(unsigned long long x){ return mint(x); }
ostream& operator<<(ostream &o, const mint &m){ return o<<m.x; }



int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int S;
	
	cin>>S;
	
	
	int D = max(3, S);
	//sum, last
	vector<vector<mint>> dp(D+1, vector<mint>(D+1));
	
	dp[3][3] = 1;
	
	for(int sum=3;sum<S;++sum)
	for(int x=3;x<=S;++x){
		if(sum+1<=S && x+1<=S) dp[sum+1][x+1]+=dp[sum][x];
		if(sum+3<=S) dp[sum+3][3]+=dp[sum][x];
	}
	
	auto ans = 0m;
	for(int x=3;x<=S;++x) ans+=dp[S][x];
	
	cout<<ans<<endl;
	
	return 0;
}


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

int main (void) {
    char    s[100001];
    int     s_len;
    int     even_n, odd_n;
    int     even_white=0, odd_white=0;
    int     i;

    scanf("%s", s);
    s_len = strlen(s);
    even_n = s_len/2;
    odd_n = s_len-even_n;
    for ( i=0; i<s_len; i++ ) {
        if ( i%2 )
            even_white += s[i]-'0';
        else
            odd_white += s[i]-'0';
    }
    //printf("even_white: %d, odd_white: %d\n", even_white, odd_white);

    if ( (odd_n-odd_white)+even_white > (even_n-even_white)+odd_white ) {
        /* even->white, odd->black */
        printf("%d\n", (even_n-even_white)+odd_white);
    } else {
        /* even->black, odd->white */
        printf("%d\n", (odd_n-odd_white)+even_white);
    }
    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = input()
max_length = 0
tmp_length = 0
match_char = ["A", "C", "G", "T"]
for si in s:
    if si in match_char:
        tmp_length += 1
        max_length = max(max_length, tmp_length)
    else:
        tmp_length = 0
print(max_length)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 45, maxs = 405;
int n, ma, mb, a[maxn], b[maxn], c[maxn];
int dp[maxn][maxs][maxs];

int main(){
	scanf("%d %d %d", &n, &ma, &mb);
	for(int i = 1; i<=n; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]);

	memset(dp, 63, sizeof(dp));
	int ans = dp[0][0][0];
	dp[0][0][0] = 0;
	for(int i = 1; i<=n; i++){
		for(int s = 0; s<maxs; s++){
			for(int k = 0; k<maxs; k++){
				dp[i][s][k] = dp[i-1][s][k];
				if (s>=a[i] && k>=b[i])
					dp[i][s][k] = min(dp[i][s][k], dp[i-1][s-a[i]][k-b[i]]+c[i]);
			}
		}
	}
	for(int mul = 1; ma*mul<=400 && mb*mul<=400; mul++) ans = min(ans, dp[n][ma*mul][mb*mul]);
	if (ans == dp[0][404][404]) puts("-1");
	else printf("%d\n", ans);
	return 0;
}


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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;


int n, m, q, pre[3][2100][2100];
char s[2100][2100];

int get(int xa, int ya, int xb, int yb, int k){
	if(xa > xb || ya > yb)
		return 0;
	int res = pre[k][xb][yb];     
	if(xa)
		res -= pre[k][xa - 1][yb];
	if(ya)
		res -= pre[k][xb][ya - 1];
	if(xa && ya)
		res += pre[k][xa - 1][ya - 1];
	return res;
}
int main()
{                         
	scanf("%d%d%d", &n, &m, &q);
	for(int i = 0; i < n; i++)
		scanf("%s", &s[i]);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(s[i][j] == '1')	
				pre[0][i][j]++;               
			if(i)
				pre[0][i][j] += pre[0][i - 1][j];   
			if(j)
				pre[0][i][j] += pre[0][i][j - 1];
			if(i && j)
				pre[0][i][j] -= pre[0][i - 1][j - 1];
		}
	}	

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(j > 0 && s[i][j] == '1' && s[i][j - 1] == '1')	
				pre[1][i][j]++;               
			if(i)
				pre[1][i][j] += pre[1][i - 1][j];   
			if(j)
				pre[1][i][j] += pre[1][i][j - 1];
			if(i && j)
				pre[1][i][j] -= pre[1][i - 1][j - 1];
		}
	}	

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(i > 0 && s[i][j] == '1' && s[i - 1][j] == '1')	
				pre[2][i][j]++;               
			if(i)
				pre[2][i][j] += pre[2][i - 1][j];   
			if(j)
				pre[2][i][j] += pre[2][i][j - 1];
			if(i && j)
				pre[2][i][j] -= pre[2][i - 1][j - 1];
		}
	}	


	while(q--){
		int xa, ya, xb, yb;
		scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
		xa--, xb--;
		ya--, yb--;
		printf("%d\n", get(xa, ya, xb, yb, 0) - get(xa, ya + 1, xb, yb, 1) - get(xa + 1, ya, xb, yb, 2));
	}
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  string s;
  cin>>s;
  string r;

  rep(i,s.size()){
    if(s.at(i)=='B'){
      if(r.size()!=0)r.erase(r.size()-1);
    }else{
      r+=s.substr(i,1);
    }
  }

  cout<<r;

  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    K = readint()
    if not K % 2:
        print(-1)
    elif not 7 % K:
        print(1)
    else:
        d = 7 % K
        s = set()
        for i in range(1, 10 ** 6 + 1):
            s.add(d)
            d = (d * 10 + 7) % K
            if not d:
                print(i + 1)
                sys.exit()
            elif d in s:
                print(-1)
                sys.exit()
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 77940
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    int N;
    cin >> N;
    int Time[N];
    long sum = 0;
    REP(i, N)
    {
        cin >> Time[i];
        sum += Time[i];
    }
    int M;
    cin >> M;
    int Problem[M], xTime[M];
    REP(i, M)
    {
        cin >> Problem[i] >> xTime[i];
        cout << sum - Time[Problem[i]-1] + xTime[i] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5;
const int maxn = 3e5 + 5;
ll mod = 1e9 + 7;

int n, x, y, a[maxn];
int main()
{
	scanf("%d%d%d", &n, &x, &y);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	if (n == 1) printf("%d", abs(a[1] - y));
	else printf("%d", max(abs(a[n] - y), abs(a[n] - a[n - 1])));
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	ans := 0
	for i := 0; i <= 999; i++ {
		x := fmt.Sprintf("%03d", i)
		p := 0
		for xi := range x {
			found := false
			for si := p; si < n; si++ {
				if x[xi] == s[si] {
					found = true
					p = si + 1
					break
				}
			}
			if !found {
				break
			} else if xi == 2 && found {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int N, K, m;
  bool rabbit[51];
  vector<int> boat[51];
  int tmp;
  memset(rabbit, 0, sizeof(rabbit));
  cin >> N >> K;
  for(int i = 0 ; i < K ; i++){
    cin >> m;
    for(int j = 0 ; j < m ; j++){
      cin >> tmp;
      boat[i].push_back(tmp);
    }
    sort(boat[i].begin(), boat[i].end());
  }
  int ans = 0;
  int p;
  int a, b;
  cin >> p;
  while(p--){
    cin >> a >> b;
    for(int i = 0 ; i < K ; i++){
      if(binary_search(boat[i].begin(), boat[i].end(), a) &&
	 binary_search(boat[i].begin(), boat[i].end(), b)){
	rabbit[a] = 1;
	rabbit[b] = 1;
      }
    }
  }
  for(int i = 0 ; i < 51 ; i++){
    if(rabbit[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 0
#include <utility>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <numeric>
#include <limits>
#include <queue>
#include <cstdint>
#include<iomanip>
#define ll long long int
#define rep(i,rept) for (int (i) = 0; (i) < rept; (i)++)
#define rept(i,n,rept) for (int (i) = n; (i) < rept; (i)++)
#define Yes(b) std::cout<< (b ? "Yes" : "No")<<std::endl
#define YES(b) std::cout<< (b ? "YES" : "NO")<<std::endl
#define fr first
#define se second
#define lolo 92233720368547757
#define susu 1000000007
typedef std::pair<int, int> pp;
typedef std::pair<ll, ll> llpp;
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c;
	d = a + b;
	if(d+1>=c){
		cout << c + b;
		return 0;
	}
	else {
		cout << d + 1 + b;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

int main() {
    long n = 0;
    string s;
    cin >> n;
    cin >> s;
    long long fans = 0;
    set<long> r, b, g;
    for (long i = 0; i < n; i++)
    {

        if (s[i] == 'R')
            r.insert(i);
        else if (s[i] == 'B')
            b.insert(i);
        else
            g.insert(i);
    }
    for (long i: r)
        for (long j: b)
        {
            long x, y;
            x = i;
            y = j;
            if (x > y)
                swap(x, y);
            long c = g.size();
            long d = y-x;

            // left
            if (g.find(x - (d))!= g.end())
                c -= 1;
            // right
            if (g.find(y + d)!= g.end())
                c -= 1;
            // mid
            long xx = y - x;
            if ((y - x) % 2 == 0)
            {
                long in = x + ((y-x)/2);
                if (g.find(in)!= g.end())
                    c -= 1;
            }
            fans += c;
        }
    cout << fans ;

    return 0;
}





Measured memory_bytes: 3836
n = gets.to_i
a = gets.split.map(&:to_i)
sum = a.inject(:+)
x = 0
y = sum
min = 10 ** 15
(0 ... n - 1).each{|i|
    x += a[i]
    y -= a[i]
    abs = (x - y).abs
    if abs < min
        min = abs
    end
}
puts min


Measured memory_bytes: 27252
fun main(args: Array<String>) {
    val input = readLine()!!.split(" ").map { it.toInt() }
    val n = input[0]
    val x = input[1]
    val a = readLine()!!.split(" ").map { it.toInt() }
    val sorted = a.sorted()

    var current  = x
    for (i in (sorted.indices)){
        if (sorted[i] <= current) {
            current -= sorted[i]
        } else {
            print(i)
            return
        }
    }

    if (current == 0) {
        print(n)
    } else {
        print(n - 1)
    }
}

Measured memory_bytes: 38004
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    constexpr ll mod = 998244353;
    ll n, m;
    cin >> n >> m;
    vll a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    vll c = convolution<mod>(a, b);
    for(ll& i : c) cout << i << ' ';
    cout << endl;
    return;
}

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

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

typedef long long ll;
int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  
  ll c = n / (a+b);
  ll d = n % (a+b);
  
  ll ans = 0;
  ans = ans + c * a;
  if(d >= a){
    ans = ans + a;
  } else { 
    ans = ans + d;
  }
  cout << ans << endl;

}

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

int R, C;
int V[3005][3005];
int64_t dp[5][3005][3005];

int64_t f(int rem, int r, int c) {
	if (r == R && c == C) {
		if (rem) return V[r][c];
		return 0;
	}
	if (dp[rem][r][c] != -1) return dp[rem][r][c];
	int64_t ans = -1e18;
	if (c < C) ans = max(ans, f(rem, r, c+1));
	if (r < R) ans = max(ans, f(3, r+1, c));
	if (rem && V[r][c]) {
		if (c < C) ans = max(ans, f(rem-1, r, c+1)+V[r][c]);
		if (r < R) ans = max(ans, f(3, r+1, c)+V[r][c]);
	}
	return dp[rem][r][c] = ans;
}

int main() {
	int K;
	cin >> R >> C >> K;
	for (int i = 0 ; i < K; ++i) {
		int r, c, v;
		cin >> r >> c >> v;
		V[r][c] = v;
	}
	memset(dp, -1, sizeof dp);
	cout << f(3, 1, 1) << endl;
}

Measured memory_bytes: 391896
S = input()
T = input()

iteration = len(S) - len(T) + 1

if T in S:
    ans = 0
else:
    minimum = len(T)
    for i in range(iteration):
#         print('---------------')
        s = S[i:len(T)+i]
#         print(s)
#         print(T)
        count = 0
        for j in range(len(T)):
            if s[j] != T[j]:
                count += 1
#             print(count)
        minimum = min(minimum, count)
    ans = minimum
    
print(ans)

Measured memory_bytes: 8960
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

const int MAX_N=100001;

// iツ嘉アツ姪堋づ泳ツ古つ連ツ堕アツつオツづ偲ヲツづェツづゥツ確ツ猟ヲツづーツ格ツ納
double dp[MAX_N][51];
double ret[MAX_N];

int main(){

	dp[1][1]=1.0;
	ret[1]=1.0;
	for(int i = 2; i < MAX_N; i++){
		double ss=0;
		// iツ嘉アツ姪堋づ泳ツ古つ連ツ堕アツつオツづ偲ヲツづェツづゥツ確ツ猟ヲツづーツ計ツ算
		for(int j = 0; j <= min(i,50); j++){
			// ツ債。ツ嘉アツミツス
			if(j==0){
				for(int k = 1; k <= min(i-1,50); k++)
					dp[i][j]+=dp[i-1][k]*(1-pow(0.5,k));
			}
			// ツ連ツ堕アツ偲ヲツ督セ
			else{
				dp[i][j]=dp[i-1][j-1]*(pow(0.5,j-1));
				ss+=dp[i][j];
			}
		}
		ret[i]=ss+ret[i-1];
	}

	int n;
	while(cin>>n&&n!=0){
		printf("%.3lf\n",ret[n]);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;

int n, a[maxn];
int main(){
	cin>>n;
	for(int i = 1; i <= n; i ++)cin>>a[i];
	
	int cnt = 0, s = 1;
	while(cnt < n && s != 2){
		cnt ++;
		s = a[s];
	}
	if(cnt == n)printf("-1");
	else printf("%d", cnt);
	return 0;
}

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

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto AS = new int[](N+1);
    foreach (a; readln.split.to!(int[])) ++AS[a];
    sort!"a > b"(AS);
    int[] bs;
    foreach (a; AS) {
        if (a == 0) break;
        bs ~= a;
    }
    sort!"a < b"(bs);
    auto d = max(0, bs.length.to!int - K);
    int r;
    foreach (i; 0..d) r += bs[i];
    writeln(r);
}

Measured memory_bytes: 11656
import java.util.Scanner;

public class Main {

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

		int[][][] rooms = new int[4][3][10];
		
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();

			rooms[b-1][f-1][r-1] += v;
		}

		String sep = "####################";
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				StringBuffer line = new StringBuffer();
				for (int k = 0; k < 10; k++) {
					line.append(' ');
					line.append(rooms[i][j][k]);
				}
				System.out.println(line);
			}
			if (i != 4 - 1) {
				System.out.println(sep);
			}
		}
		
		sc.close();
	}
}

Measured memory_bytes: 21056
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;

vector<int> a;

void input() {
  cin >> n;

  a.resize(n);
  for (auto&& i : a) {
    cin >> i;
  }
}

void solve() {
  sort(a.rbegin(), a.rend());

  int sum = 0;

  for (int i = 1; i < n; ++i) {
    sum += a[i];
  }

  string ans = "No";

  if (a[0] < sum)
    ans = "Yes";

  cout << ans << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n=8;
  vector<string> s;
  string t;
  while(cin>>t)s.push_back(t);

  rep(i,s.size()){
    for(j=i;j<i+n;j++)rep(k,n)if(s[j][k]=='1'){
	if(j+1<i+n && k+1<n && s[j][k+1]=='1' && s[j+1][k]=='1' && s[j+1][k+1]=='1')
	  cout<<"A"<<endl;
	if(j+3<i+n && s[j+1][k]=='1' && s[j+2][k]=='1' && s[j+3][k]=='1')
	  cout<<"B"<<endl;
	if(k+3<n && s[j][k+1]=='1' && s[j][k+2]=='1' && s[j][k+3]=='1')
	  cout<<"C"<<endl;
	if(j+2<i+n && k!=0 && s[j+1][k]=='1' && s[j+1][k-1]=='1' && s[j+2][k-1]=='1')
	  cout<<"D"<<endl;
	if(j+1<i+n && k+2<n && s[j][k+1]=='1' && s[j+1][k+1]=='1' && s[j+1][k+2]=='1')
	  cout<<"E"<<endl;
	if(j+2<i+n && k+1<n && s[j+1][k]=='1' && s[j+1][k+1]=='1' && s[j+2][k+1]=='1')
	  cout<<"F"<<endl;
	if(j+1<n+i && k && k+1<n && s[j][k+1]=='1' && s[j+1][k]=='1' && s[j+1][k-1]=='1')
	  cout<<"G"<<endl;
	goto END;
      }
  END:i+=n-1;
  }
}

Measured memory_bytes: 3040
n=int(input())
h=list(map(int, input().split()))
count_max=0
count=0
hei=h[0]
for x in range(1,n):
  if h[x]<=hei:
    count+=1
  else:
    count=0
  if count>count_max:
    count_max=count
  hei=h[x]
  
print(count_max)
  

       

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

using namespace std;

using ll = long long;

int main() {
  array<ll, 3> v;
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if (v[0] % 2 && v[1] % 2 && v[2] % 2) {
    cout << v[0] * v[1] << endl;
  } else {
    cout << 0 << endl;
  }
}


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

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;



/******************************************************************************************/


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



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


ll dp[1 << 14];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<int> a(M), b(M), c(M, 0);


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

		int cnt = 0;
		for (int j = 0; j < b[i]; j++)
		{
			int t;
			cin >> t;
			cnt += (1 << (t - 1));
		}
		c[i] = cnt;
	}
	for (int i = 0; i < 1 << 14 - 1; i++)
	{
		dp[i] = LINF;
	}

	dp[0] = 0;

	for (int i = 0; i < (1 << N); i++)
	{
		for (int j = 0; j < M; j++)
		{
			bool can_use = false;

			for (int mask = 13; mask >= 0; mask--) {

				if (!((i >> mask) & 1)) {
					//bitが立っていない（まだ使っていない）
					can_use = true;
					break;
				}
			}

			if (can_use) {
				//j番目を使う
				
				dp[(i | c[j])] = min(dp[(i | c[j])], dp[i] + a[j]);
			}
		}
	}

	if (dp[(1 << N) - 1] == LINF) {
		cout << "-1" << endl;
	}
	else
	{
		cout << dp[(1 << N) - 1] << endl;
	}

}



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

int main(void)
{

  //char s;
  char k[20];
  //int s[20] = {0};
  int dif = 1000;

  scanf("%s", k);
  /*printf("%s", k);
  printf("%d\n", (100 * (k[0] - '0') + 10 * (k[1] - '0') + (k[2] - '0')));*/

  /*for (int i = 0; s[i] != '\0'; i++)
  {

    s[i] = k[i] - '0';
  }*/
  /*for (int i = 0; s[i] == 0; i++)
  {(k[0]- '0')
    printf(":%d", s[i]);
  }*/

  for (int i = 0; k[i + 2] != '\0'; i++)
  {

    if (dif > abs((100 * (k[i] - '0') + 10 * (k[i + 1] - '0') + (k[i + 2] - '0')) - 753))
    {
      dif = abs((100 * (k[i] - '0') + 10 * (k[i + 1] - '0') + (k[i + 2] - '0')) - 753);
    }
  }

  printf("%d", dif);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int h,w;
  cin >> h >> w;
  rep(i,0,h+2){
    if(i == 0 || i == h+1 ){
      rep(j,0,w+2)
        cout << "#";
    }
    else{
      string s;
      cin >> s;
      cout << "#" << s << "#";
    }

    cout << endl;
  }
  ret 0;

}

Measured memory_bytes: 256
/*
 * aoj/1167_2nd/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const ll MAX_N = 1000100;
ll N;
ll P[180];
ll dp[MAX_N];
ll dp_odd[MAX_N];

void build() {
  for (int n=1; n<=180; n++) {
    P[n-1] = n * (n+1) * (n+2) / 6;
  }
}


bool input() {
  cin >> N;
  if (N==0) return false;
  return true;
}

void receive() {
  for (ll n=1; n<MAX_N; n++) {
    for (int i=0; i<180; i++) {
      if (i==0) { dp[n] = n; dp_odd[n] = n; continue; } // P[i] = 1 (奇数)
      if (n-P[i]>=0) chmin(dp[n], dp[n-P[i]] + 1);
      if (n-P[i]>=0 and P[i] % 2 == 1) chmin(dp_odd[n], dp_odd[n-P[i]] + 1);
    }
  }
}

void solve() {
  cout << dp[N] << " " << dp_odd[N] << endl;
}

int main() {
  // cout.precision(15);
  build();
  receive();
  while (input()) solve();
  return 0;
}



Measured memory_bytes: 18652
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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 rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！

int main(){
    int a,b;
    std::cin >> a>>b;
    if(a==1)a=14;
    if(b==1)b=14;
    if(a>b)std::cout << "Alice" << std::endl;
    else if(a<b)std::cout << "Bob" << std::endl;
    else std::cout << "Draw"<< std::endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main()  {
	var n, m int64
	fmt.Scan(&n, &m)
	ed := make(drinks, n)

	for i:=0;int64(i)<n;i++ {
		fmt.Scan(&ed[i].a, &ed[i].b)
	}

	sort.Sort(ed)

	var ans int64
	for i:=0;m>0;i++ {
		if ed[i].b > m {
			ans += ed[i].a*(m)
		} else {
			ans += ed[i].a*ed[i].b
		}
		m -= ed[i].b
	}
	fmt.Println(ans)
}

type energyDrink struct {
	a int64
	b int64
}
type drinks []energyDrink
func (s drinks) Len() int           { return len(s) }
func (s drinks) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s drinks) Less(i, j int) bool { return s[i].a < s[j].a }

Measured memory_bytes: 5376
import java.util.*;

public class Main {


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

    public void execute() {
        Scanner sc = new Scanner(System.in);
        final int D = sc.nextInt();
        final int G = sc.nextInt() / 100;

        int[] score = new int[D];
        int[] p = new int[D];
        int[] c = new int[D];

        for (int i = 0; i < D; i++) {
            score[i] = i + 1;
            p[i] = sc.nextInt();
            c[i] = sc.nextInt() / 100;
        }

        int minTurns = Integer.MAX_VALUE;

        for (int mask = 0, bound = (1 << D); mask < bound; mask++) {
            int s = 0;
            int turns = 0;
            boolean[] ptn = getPatterns(D, mask);
            for (int i = 0; i < D; i++) {
                if (ptn[i]) {
                    s += p[i] * score[i] + c[i];
                    turns += p[i];
                }
            }
            if(s>=G){
                minTurns = Math.min(minTurns, turns);
                continue;
            }

            for (int i = (D - 1); i >= 0; i--) {
                if (ptn[i]) {
                    continue;
                }
                for (int j = 0; j < p[i] - 1; j++) {
                    s += score[i];
                    turns++;
                    if (s >= G) {
                        minTurns = Math.min(minTurns, turns);
                        break;
                    }
                }
            }
        }

        System.out.println(minTurns);
        sc.close();

    }

    private boolean[] getPatterns(int d, int mask) {
        boolean[] patterns = new boolean[d];
        for (int i = 0; i < d; i++) {
            if ((mask & (1 << i)) > 0) {
                patterns[i] = true;
            }
        }
        return patterns;
    }

}

Measured memory_bytes: 21716
#include <stdio.h>
#define N 101
int main(){
  int n,k,u,v,i,j,d[N][N];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      d[i][j]=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      d[i][v-1]=1;
    }
  }
    for(i=0;i<n;i++){
      if(i!=0)printf("\n");
      for(j=0;j<n;j++){
       	printf("%d",d[i][j]);
	if(j!=n-1)printf(" ");
      }
    }
    printf("\n");
    return 0;
}



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

int main()
{
    string s;
    getline(cin, s);
    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        if (c >= 0x41 && c <= 0x5a) c += 0x20;
        else if (c >= 0x61 && c <= 0x7a) c -= 0x20;
        cout << c;
    }
    cout << endl;
}



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

int main()
{
	int n, res = 1, mini;
	bool ok = true;
	cin >> n;
	int a[n+1];

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

	mini = a[0];

	for(int i=1; i<n; i++){
		if(a[i] > mini){
			ok = false;
		}
		else if(a[i] < mini){
			mini = a[i];;
		}
		if(ok) res++;
		ok = true;
	}

	cout << res;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair <int,int> P;
typedef long long ll;
#define f first
#define s second
#define INF 1000000000
int tree[4][(1<<19)];
int n,d;
pair <int,pair <int,int> > star[(1<<18)];

void update(int i,int x,int flg){
  i = (1<<18)+i-1;
  tree[flg][i] = x;
  while(i){
    i = (i-1)/2;
    tree[flg][i] = max(tree[flg][i*2+1],tree[flg][i*2+2]);
  }
}

int find(int a,int b,int M,int L,int R,int flg){
  if(b <=L || a >= R) return -INF;
  if(a <=L && R <= b) return tree[flg][M];
  int nx = (L+R)/2;
  return max(find(a,b,M*2+1,L,nx,flg),find(a,b,M*2+2,nx,R,flg));
}

int main() {
  cin >> n >> d;
  for(int i=0;i<(1<<19);i++) 
    for(int j=0;j<4;j++) tree[j][i] = -INF;
  for(int i=0;i<n;i++) cin >> star[i].s.f >> star[i].s.s >> star[i].f;
  sort(star,star+n);
  for(int i=0;i<n;i++) {
    update(i,star[i].s.f,0); // max(x);
    update(i,star[i].s.s,1); // max(y);
    update(i,-star[i].s.f,2); // min(x);
    update(i,-star[i].s.s,3); // min(y);
  }
  ll now = 0,minx,maxx,miny,maxy,S=0;
  for(int i=0;i<n;i++) {
    while(now < n && star[now].f -star[i].f <=d) now++;
    maxx = find(i,now,0,0,(1<<18),0);
    maxy = find(i,now,0,0,(1<<18),1);
    minx = find(i,now,0,0,(1<<18),2);
    miny = find(i,now,0,0,(1<<18),3);
    S = max(S,((ll)maxx+minx)*((ll)maxy+miny));
  }
  cout << S <<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
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]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec a(n);
    Vec b(n);
    Vec c(n-1);
    rep(i,n){
       cin>>a[i];
       a[i]--;
    }
    rep(i,n){
        cin>>b[i];
    }
    rep(i,n-1){
        cin>>c[i];
    }
    ll ans=0;
    rep(i,n){
        if(i>0){
            if(a[i-1]+1==a[i]){
                ans += c[a[i-1]];
            }
        }
        ans += b[a[i]];
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m, a=0, t=0;
	cin >> n >> m;
	for (int i=1; i<=n; i++)
	{
		int x;
		cin >> x;
		a+=x;
		if (a<=m) t++;
	 } 
	cout << t+1 << endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int mojisuu=0;
    mojisuu = s.size();

    string ans;

    for(int i=0; i<mojisuu; i = i+2)
    {
        ans += s.at(i);
    }

    cout << ans << endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  long long x[N],y[N],h[N];
 
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i] >> h[i];
  }
 
  long long pans,d;
  long long Ans;
  int xa, ya;
  bool flag = false;
  bool middleflag = true;
 
  for(int i = 0; i <= 100; i++){
    if(flag) break;
    for(int j = 0; j <= 100; j++){
      pans = -1;
      middleflag = true;
      for(int k = 0; k < N; k++){
        if(h[k] > 0){
          d = h[k] + abs(i-x[k]) + abs(j-y[k]);
          if(pans == -1){
            pans = d;
          }else{
            if(d != pans){
              middleflag = false;
              break;
            }
          }
        }
      }
      if(middleflag){
        bool smallflag = true;
        for(int k = 0; k < N; k++){
          if(h[k] == 0){
            d =  abs(i-x[k]) + abs(j-y[k]);
            if(d < pans){
              smallflag = false;
              break;
            }
          }
        }
 
        if(smallflag){
          Ans = pans;
          xa = i;
          ya = j;
          flag = true;
          break;
        }
      }
    }
  }
 
  printf("%d %d %lld\n",xa,ya,Ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  if(N >= 30) Yes;
  else No;

  return 0;
}


Measured memory_bytes: 3624
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    #r = stdin.readline()[:-1]
    n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    from math import ceil,floor
    print(ceil(n/2)*floor(n/2))

if __name__ == '__main__':
    main()



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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B == C+D){
    cout << "Balanced" << endl;
    return 0;
  }
  else if(A+B < C+D){
    cout << "Right" << endl;
    return 0;
  }
  cout << "Left" << endl;
return 0;

}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int a,b;
  int c;
  c=0;
  scanf("%d%d",&a,&b);
  if(a>=13){
    printf("%d\n",b);
  }else if((6<=a)&(a<=12)){
    b=b/2;
    printf("%d\n",b);
  }else{
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 128
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int main(){

    int K,X;
    cin>>K>>X;
    int i;
    for(i=X-K+1;i<=X+K-1;i++){
        cout<<i<<" ";
    }
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    Vi a(n);
    vin(a);

    int ans=0,now=0;
    REP(i,0,n){
        if(a[i]!=0){
            now+=a[i];
        }else{
            ans+=now/2;
            now=0;
        }
    }
    cout<<ans+now/2<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

        int X = sc.nextInt();

        for (int i = X; i < X * 2; i++)
            if (isPrime(i)) {
                System.out.println(i);
                return;
            }

    }

    static boolean isPrime(int num) {
        if (num == 1 || num == 2) return true;
        if (num % 2 == 0) return false;

        for (int i = 3; i < Math.sqrt(num); i += 2)
            if (num % i == 0) return false;

        return true;
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int f[11][11],b[11];
int main()
{
	int n,m,i,j,k,ans=0;cin>>n>>m;int lim=(1<<n);
	for (i=1;i<=m;i++)
	{
		cin>>k;
		for (j=1;j<=k;j++) cin>>f[i][j];
	}
	for (i=1;i<=m;i++) cin>>b[i];
	for (i=0;i<lim;i++)
	{
		int flg=1;
		for (j=1;j<=m;j++)
		{
			int t=b[j];
			for (k=1;k<=n;k++)
			{
				t^=((i>>(f[j][k]-1))&1);
			}
			if (t) {flg=0;break;}
		}
		if (flg) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
total = [0] * 31
for i in a:
    for j in range(31):
        if i >> j & 1:
            total[j] += 1
# print(total)
for i in a:
    ans = 0
    for j in range(31):
        if total[j] % 2 != (i >> j & 1):
            ans += 2 ** j
    print(ans, end=" ")
print()


Measured memory_bytes: 94056