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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)

int e[34][34];

int dp[15][1 << 15];

int solve(int n, int m, int w) {
    int ans = 0;
    rep(i, n) {
        if(w & (1 << i)) {
            rep(j, n) {
                if(m & (1 << j)) {
                    ans += e[i][j];
                }
            }
        }
    }
    return ans;
}

signed main() {
    int n, m;
    cin >> n >> m;
    rep(i, n) {
        rep(j, n) {
            e[i][j] = 0;
        }
    }
    rep(i, m) {
        int a, b, w;
        cin >> a >> b >> w;
        a--;
        b--;
        e[a][b] = w;
        e[b][a] = w;
    }
    rep(i, n) {
        rep(j, 1 << n) {
            dp[i][j] = inf;
        }
    }
    rep(iw, 1 << (n - 1)) {
        int i = 1 + (iw << 1);
        dp[0][i] = 0;
    }
    rep(iw, 1 << (n - 1)) {
        int i = 1 + (iw << 1);
        vector<pair<int, int>> q;
        rep(j, n) {
            if(i & (1 << j)) {}
            else {
                q.push_back(make_pair(j, solve(n, i, 1 << j)));
            }
        }
        rep(k, 1 << q.size()) {
            int w = 0;
            int s = 0;
            rep(_, q.size()) {
                if(k & (1 << _)) {
                    w += 1 << q[_].first;
                    s += q[_].second;
                }
            }
            rep(j, q.size()) {
                if(k & (1 << j)) {
                    rep(_, n) {
                        if((i & (1 << _)) && e[q[j].first][_] > 0) {
                            dp[q[j].first][i + w] = min(dp[q[j].first][i + w], dp[_][i] + s - e[_][q[j].first]);
                        }
                    }
                }
            }
        }
    }
    cout << dp[n - 1][(1 << n) - 1] << endl;
}


Measured memory_bytes: 4096
n, k = gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i)

sum = []
n.times do |i|
  if i == 0
    sum[i] = p[i]
  else
    sum[i] = p[i] + sum[i-1]
  end
end

max = 0
arr = []
(n-k+1).times do |i|
  if i == 0
    tmp = sum[i+k-1]
  else
    tmp = sum[i+k-1] - sum[i-1]
  end
  if max < tmp
    max = tmp
    arr = p[i, k]
  end
end
ans = 0
arr.each{|e| ans += (e + 1)/2.0}
p ans


Measured memory_bytes: 17612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	const int big = 1000 * 100 + 1;
	vi o(big), e(big);
	forn(i, n){
		cin >> a[i];
		if(i % 2 == 0){
			e[a[i]]++;
		}
		else o[a[i]]++;
	}
	vpi op, ep;
	forn(i, big){
		if(o[i]){
			op.push_back({o[i], i});
		}
		if(e[i]){
			ep.push_back({e[i], i});
		}
	}
	sort(all(op));reverse(all(op));
	sort(all(ep));reverse(all(ep));
	int ans;
	if(op[0].second == ep[0].second){
		if(op.size() == 1){
			op.push_back({0, -1});
		}
		if(ep.size() == 1){
			ep.push_back({0, -2});
		}
		ans = min(n - op[0].first - ep[1].first, n - op[1].first - ep[0].first);
	}
	else{
		ans = n - op[0].first - ep[0].first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2428
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			double[] c = new double[6];
			for (int i = 0; i < 6; i++) {
				c[i] = scanner.nextDouble();
			}
			double x = (c[4] * c[2] - c[1] * c[5]) / (c[0] * c[4] - c[3] * c[1]);
			double y = (c[0] * c[5] - c[3] * c[2]) / (c[0] * c[4] - c[3] * c[1]);
			if (x == -0) x = 0;
			if (y == -0) y = 0;
			System.out.printf("%.3f %.3f\n", x, y);
		}
	}
}

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

int N;

void solve()
{
	if(!N) cout << 0 << '\n';
	else{
		string s;
		while(N){
			if(N%(-2) == -1){
				s += '1';
				N += -2;
			}else{
				s += (N%(-2))+'0';
			}
			N /= -2;
		}
		reverse(s.begin(),s.end());
		cout << s << '\n';
	}
	return;
}

int main()
{
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a >= 10 || b >= 10)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << a * b << endl;
    }
    return 0;
}

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

#define loop(i,a,b) for(int i=a;i<(int)(b);i++)
#define rep(i,b) loop(i,0,b)
typedef long long ll;

// 1 indexed

int main(){
    ll n;
    while(cin >> n && n){
        vector<int> a(n), b(n);
        rep(i,n) cin >> a[i] >> b[i], a[i]--, b[i]--;
        vector<int> seen(n,false);
        rep(i,31){
            int min_fine = 100;
            int idx = -1;
            rep(j,n){
                if(!seen[j] && min_fine > b[j] && a[j] <= i && i <= b[j]){
                    min_fine = b[j];
                    idx = j;
                }
            }
            if(idx != -1){
                seen[idx] = true;
            }
        }
        int s = 0;
        rep(i,n) if(seen[i]) s++;
        // rep(i,n){
        //     cout << seen[i] << " ";
        // }
        // cout << endl;
        int ans = s*100 + (31-s)*50;
        cout << ans << endl;
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
	int w, n;
	cin >> w >> n;
	vector <int> S(w);
	for ( int i = 0; i < w; i++ )
		S[i] = i+1;

	for ( int i = 0; i < n; i++ )
	{
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap( S[a-1], S[b-1] );
	}

	for ( int i = 0; i < w; i++ )
	{
		cout << S[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];
int p[MAXN];


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    ll sum = 0;
	for (int i = 1; i <= n; i++) {
		a[i] = readInt();
		sum += a[i];
	}
	if (sum % ((n * (n + 1ll)) / 2) == 0) {
		ll k = sum / ((n * (n + 1ll)) / 2);
		a[n+1] = a[1];
		for (int i = 1; i <= n; i++) {
			if ((k - (a[i + 1] - a[i])) < 0) {
				cout << "NO";
				return 0;
			}
			if ((k - (a[i + 1] - a[i])) % n != 0) {
				cout << "NO";
				return 0;				
			}
		}
		cout << "YES";
		return 0;
	} else {
		cout << "NO";
	}
    return 0;
}

Measured memory_bytes: 4352
h,w=map(int,input().split())
a=[input() for i in range(h)]
b=[]
d=[]
for j in range(h):
 if int('#' in a[j])==1:b.append(a[j])
for l in range(w):
  c=0
  for k in range(len(b)):
    if list(b[k])[l]=='#':c+=1
  if c!=0:d.append(l)
for m in range(len(b)):
  x=[]
  for n in d:
    x.append(b[m][n])
  x=''.join(x)
  print(x)

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int ha, sa, hb, sb;
  cin >> ha >> sa >> hb >> sb;
  while (1) {
    hb -= sa;
    if (hb <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    ha -= sb;
    if (ha <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N, A;
    cin >> N >> A;
    vector<ll> X(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i];
    }
    // 合計,枚数, 選び方
    map<pair<int,int>, ll> num, numt;
    num[make_pair(0,0)]++;
    for ( int i = 0; i < N; i++ ) {
        numt.clear();
        for ( auto p : num ) {
            auto knext = make_pair(p.first.first + X[i], p.first.second + 1);
            auto kcurr = make_pair(p.first.first, p.first.second);
            numt[knext] += num[kcurr];
        }
        for ( auto p : numt ) {
            num[p.first] += p.second;
        }
    }
    
    ll ans = 0;
    for ( auto p : num ) {
        if ( p.first.second == 0 ) continue;
        if ( p.first.second * A == p.first.first ) {
            ans += p.second;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 2816
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
ans=0
for i in range(k):
  x=i
  cnt=0
  while x+k<n:
    if t[x]==t[x+k]:
      cnt+=1
    else:
      if t[x]=='r':
        ans+=p*(cnt//2+1)
      elif t[x]=='s':
        ans+=r*(cnt//2+1)
      else:
        ans+=s*(cnt//2+1)
      cnt=0
    x+=k
  if t[x]=='r':
    ans+=p*(cnt//2+1)
  elif t[x]=='s':
    ans+=r*(cnt//2+1)
  else:
    ans+=s*(cnt//2+1)
print(ans)

Measured memory_bytes: 3316
//51
#include<iostream>

using namespace std;

int main(){
  static char s[1000001];
  cin.read(s,1000001);
  int b[3]={};
  int a=0;
  for(int i=0;s[i];i++){
    switch(s[i]){
    case 'J':
      if(b[1]||b[2]){
	b[0]=b[1]=b[2]=0;
      }
      b[0]++;
      break;
    case 'O':
      if(b[2]==0&&b[0]>b[1]){
	b[1]++;
      }else{
	b[0]=b[1]=b[2]=0;
      }
      break;
    case 'I':
      if(b[0]>=b[1]&&b[1]>b[2]){
	b[2]++;
	if(b[0]>=b[1]&&b[1]==b[2]&&a<b[2]){
	  a=b[2];
	}
      }else{
	b[0]=b[1]=b[2]=0;
      }
      break;
    }
  }
  cout<<a<<endl;
  return 0;
}

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

int main(){
  string s;
  int ans = 0;
  cin >> s;
  if(s[0] == '1') ans++;
  if(s[1] == '1') ans++;
  if(s[2] == '1') ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
  int main(void){
 
      int N,i;
 
      scanf("%d",&N);
 
      int K[N],P[N];
 
      for(i=0;i<N;i++)
         scanf("%d %d",&K[i],&P[i]);
 
 
      for(i=0;i<N;i++){
         if(K[i]%P[i]==0)
           printf("%d\n",P[i]);
         else
           printf("%d\n",K[i]%P[i]);
      }
      return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n)  for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fi first
#define se second
#define pb(x) push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  LL  long long
const int MAXN = 1e9+7;
int dp[10004];
int main(){
	for(int i = 1;i<=10004;++i){
		dp[i] = MAXN;
	}
	int h,n;
	cin>>h>>n;
	int a[n],b[n];
	for(int i =0;i<n;++i){
		cin>>a[i]>>b[i];
	}
	for(int i = 1;i<=h;++i){
		for(int j = 0;j<n;++j){
			   if(i-a[j]<0){
			   	  dp[i] = min(dp[i],b[j]);
			   }
			   else{
			   	dp[i] = min(dp[i],dp[i-a[j]]+b[j]);
			   }
		}
	}
	cout<<dp[h];
}

Measured memory_bytes: 384
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	a := make([][]int, 3)
	for i := 0; i < 3; i++ {
		a[i] = make([]int, 3)
	}

	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			a[i][j] = stdin.ReadInt()
		}
	}

	n := stdin.ReadInt()
	for i := 0; i < n; i++ {
		b := stdin.ReadInt()
		for x := 0; x < 3; x++ {
			for y := 0; y < 3; y++ {
				if a[x][y] == b {
					a[x][y] = -1
				}
			}
		}
	}

	bingo := false

	for i := 0; i < 3; i++ {
		count := 0
		for j := 0; j < 3; j++ {
			if a[i][j] == -1 {
				count++
			}
		}
		if count == 3 {
			bingo = true
		}
	}

	for j := 0; j < 3; j++ {
		count := 0
		for i := 0; i < 3; i++ {
			if a[i][j] == -1 {
				count++
			}
		}
		if count == 3 {
			bingo = true
		}
	}

	if a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1 {
		bingo = true
	}
	if a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1 {
		bingo = true
	}

	if bingo {
		stdout.Println("Yes")
	} else {
		stdout.Println("No")
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,i,a[1000],q,co,b,e,mx,mn,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++)	{
		scanf("%d %d %d",&co,&b,&e);
		if(co==0)	{
			mn=a[b];
			for(j=b+1;j<e;j++)	mn=min(mn,a[j]);
			printf("%d\n",mn);
		}
		else {
			mx=a[b];
			for(j=b+1;j<e;j++)	mx=max(mx,a[j]);
			printf("%d\n",mx);
		}
	}
	return 0;
}


Measured memory_bytes: 2740
N, M = (int(x) for x in input().split())
H=list(map(int, input().split()))
check=[True]*N
ans=N
for i in range(M):
  A, B = (int(x) for x in input().split())
  if check[A-1]==True and H[A-1]<H[B-1]:
    check[A-1]=False
    ans-=1
  elif check[B-1]==True and H[A-1]>H[B-1]:
    check[B-1]=False
    ans-=1
  elif H[A-1]==H[B-1]:
    if check[A-1]==True:
      ans-=1
      check[A-1]=False
    if check[B-1]==True:
      ans-=1
      check[B-1]=False
print(ans)

Measured memory_bytes: 20136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
    int n;
    string s;
    cin >> n >> s;
    cout << (s.substr(0,n/2) == s.substr(n/2) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
ll fang(ll a){
  return a > 1 ? fang(a - 1) + a : 1;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int a,b,c;
  cin >> a >> b >> c;
  if(b - a == c - b)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
l = list(map(int, input().split()))
l.insert(0, 0)
cnt = 0
d = []

for i in range(n+1):

    d.append(sum(l[:i+1]))

for i in range(n+1):

    if d[i]<=x:
        cnt += 1


print(cnt)

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

using namespace std;

#ifdef LOCAL_DEFINE
  #include "../../library/DEBUG.hpp"
#else
  #define debug(...) 0
#endif

vector<long long> powers(13);

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  powers[0] = 1LL;
  for (int i = 1; i < 13; i++) {
    powers[i] = 26LL * powers[i - 1];
  }
  long long n;
  cin >> n;
  int pos = 1;
  while (n > powers[pos]) {
    n -= powers[pos];
    ++pos;
  }
  int dig = pos;
  string ans = string(dig, '?');
  for (int i = 0; i < dig; i++) {
    for (int c = 0; c < 26; c++) {
      if (n <= powers[dig - i - 1]) {
        ans[i] = (char) ('a' + c);
        break;
      }
      n -= powers[dig - i - 1];
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(10**6)

h,w = map(int,input().split())

sl = []

for _ in range(h):
    s = list(input())
    sl.append(s)

used = [-1 for i in range(h*w)]
def dfs(i, j):
    used[i] = j
    if i % w + 1 < w:
        if sl[i//w][i%w] != sl[i//w][i%w+1]:
            if used[i+1] == -1:
                dfs(i + 1, j)
    if i % w - 1 >= 0:
        if sl[i//w][i%w] != sl[i//w][i%w-1]:
            if used[i-1] == -1:
                dfs(i - 1, j)
    if i // w + 1 < h:
        if sl[i // w][i % w] != sl[i // w+1][i % w]:
            if used[i+w] == -1:
                dfs(i + w, j)
    if i // w - 1 >= 0:
        if sl[i // w][i % w] != sl[i // w-1][i % w]:
            if used[i-w] == -1:
                dfs(i -w, j)

while True:
    if min(used) >= 0:
        break
    for i, j in enumerate(used):
        if j == -1:
            dfs(i, i)

from collections import defaultdict
dic = defaultdict(list)

for i, j in enumerate(used):
    dic[j].append(i)

ans = 0
for group in dic.values():
    a = 0
    b = 0
    for p in group:
        i = p // w
        j = p % w
        if sl[i][j] == "#":
            a += 1
        else:
            b += 1
    ans += a*b
print(ans)


Measured memory_bytes: 160904
#include <stdio.h>

int main()
{
  int i,n,a[100];
  scanf("%d",&n);
  
  for(i = 0; i < n; i++)
  {
    scanf("%d",&a[i]);
  }

  for(i = 1; i <= n; i++)
  {
    printf("%d",a[n - i]);
    if(i != n) printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b)
    {
        return b;
    }
    return a; 
}

template<class T>
bool chmin(T &a, const T &b) {
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0; 
}

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

    ll n = s.size();
    ll l = 0; ll count = 0;
    rep(i, n) {
        if (i != n-1 && s[i] != s[i+1]) count++;
        if (s[i] == 'W') l++;
    }
    
    ll r = 0;
    for (int i = n-1; i >= 0; i--)
    {
        if (i != 0 && s[i] != s[i-1]) count++;
        if (s[i] == 'B') r++;
    }

    // cout << l << " " << r << endl;
    ll ans = 0;
    if (count == 2*n-2) ans = n - 1;
    else if (0 == l || 0 == r) ans = 0;
    else if (n == l + r && count == 2) ans = 1;
    else ans = count/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int main(void){
  int a, b;
  cin >> a >> b;

  if (a >= 13) {
    cout << b << endl;
  } else if (a >= 6) {
    cout << b / 2 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Union_Find_Tree{
    vector<int> par, rank, num;
    
    Union_Find_Tree(int N){
        par.assign(N, -1);
        rank.assign(N, 0);
        num.assign(N, 1);
    }
    
    int root(int x){
        if(par[x] < 0 || par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return;
        elif(rank[x] < rank[y]) par[x] = y, num[y] += num[x];
        else{
            par[y] = x, num[x] += num[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    
    int size(int x) {return num[root(x)];}
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void clear(){
        fill(all(par), -1);
        fill(all(rank), 0);
        fill(all(num), 1);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    int p[N];
    rep(i, N) {cin >> p[i]; p[i]--;}
    Union_Find_Tree uf(N);
    rep(i, M){
        int u, v; cin >> u >> v; u--, v--;
        uf.unite(u, v);
    }
    int ans = 0;
    rep(i, N) ans += uf.same(i, p[i]);
    cout << ans << endl;
}

Measured memory_bytes: 4840
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let k: usize = read!();

    let mut scores = Vec::with_capacity(n);

    for _ in 0..n {
        let score: usize = read!();
        scores.push(score);
    }

    for i in k + 1..=n {
        let ans = if scores[i - 1] > scores[i - k - 1] {
            "Yes"
        } else {
            "No"
        };
        println!("{}", ans);
    }
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdlib>
#define D_MAX 101

using namespace std;

int main () {
  while( 1 ) {
    int n, q;
    cin >> n >> q;
    if ( !n && !q ){ return EXIT_SUCCESS; }
    int pd[ D_MAX ] = { 0 };
    int maxd = 0;
    for ( int i = 0; i < n; i++ ) {
      int m;
      cin >> m;
      for ( int j = 0; j < m; j++ ) {
        int temp;
        cin >> temp;
        pd[ temp ]++;
      }
    }
    for( int i = 1; i < D_MAX; i++ ){
      if(
          ( maxd == 0 || pd[ i ] > pd[ maxd ] ) &&
          pd[ i ] >= q
        ) {
        maxd = i;
      }
    }
    cout << maxd << endl;
  }
}

Measured memory_bytes: 1160
if __name__ == '__main__':
    # import time
    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    from copy import deepcopy
    # import numpy as np
    from numpy import random as np_random
    # import math
    import random
    input = stdin.readline

    ans_list = [0]*60001
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                n = x**2+y**2+z**2+x*y+y*z+z*x
                ans_list[n] += 1

    n = int(input())
    for i in range(1, n+1):
        print(ans_list[i])



Measured memory_bytes: 27488
#include <iostream>

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  long long ans = 0;
  for (int r = 0; r <= N / R; ++r) {
    for (int g = 0; g <= N / G; ++g) {
      const long long s0 = g * G + r * R;
      if (s0 > N)
        break;
      int left = -1;
      int right = N / B;
      while (right - left > 1) {
        int mid = (left + right) / 2;
        if (s0 + mid * B >= N)
          right = mid;
        else
          left = mid;
      }
      if (s0 + right * B == N)
        ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int H,W; cin >> H >> W;
  vector<string> s(H);
  
  for(int i=0;i < H;i++) 
    cin >> s.at(i);
  
  for(int i=0;i < W+2;i++)
    cout << "#";
  cout << endl;
  
  for(int j=0;j < H;j++) {
    cout << "#" << s.at(j) << "#";
  cout <<endl;
  }
  
  for(int i=0;i < W+2;i++)
    cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <regex>
#include <algorithm>
#include <typeinfo>
#include <cstdlib>

int main()
{
  /* declaration */
  std::string sentence;
  std::string pattern;
  int sidx, pidx;

  /* input */
  std::getline(std::cin >> std::ws, sentence);
  std::getline(std::cin >> std::ws, pattern);

  /* calculate problem */
  sidx=pidx=0;
  while(sidx<sentence.size()){
    if(sentence[sidx]==pattern[pidx]){
      pidx++;
    }else{
      pidx=0;
    }
    sidx++;
    if(pidx==pattern.size()) break;
  }

  if(sidx==sentence.size()){
    if(pidx<pattern.size()){
      sidx=0;
      while(pidx<pattern.size()){
        if(sentence[sidx]==pattern[pidx]){
          sidx++;
          pidx++;
        }else{
          break;
        }
      }
    }
  }

  if(pidx==pattern.size()){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int N;
	cin >> N;
	int num = 2;
	int bit = -1;
	string S{};
	while(N != 0){
		if(N % num != 0){
			N += bit;
			S += "1";
		}
		else S += "0";
		bit *= -2;
		num *= 2;
	}
	if(S == ""){
		cout << 0 << endl;
		return 0;
	}
	reverse(S.begin(), S.end());
	cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e9
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        int a,b,c,d,e;
        cin>>a>>b>>c>>d>>e;
        if(a==0) cout<<1<<endl;
        else if(b==0) cout<<2<<endl;
        else if(c==0) cout<<3<<endl;
        else if(d==0) cout<<4<<endl;
        else cout<<5<<endl;
    }
    return 0;
}


Measured memory_bytes: 3604
s = input()

if int(s[2:4]) < 13 and int(s[0:2]) < 13 and 0 < int(s[2:4]) and 0 < int(s[0:2]):
    print("AMBIGUOUS")
elif int(s[2:4]) < 13 and 0 < int(s[2:4]):
    print("YYMM")
elif int(s[0:2]) < 13 and 0 < int(s[0:2]):
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
char buf[4];
int t[30];
bool check()
{
	for(int i=0;i<26;++i)
		if(t[i]!=0 && t[i]!=2)
			return false;
	return true;
}
int main()
{
	scanf("%s",buf);
	for(int i=0;i<4;++i)
		++t[buf[i]-'A'];
	if(check())
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a - b >= c) cout << 0;
  else cout << c - (a - b) << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
N = int(input())
l = list(map(int,input().split()))
m = {0:0,1:abs(l[1]-l[0])}
for i in range(2,N):
    m[i] = min(m[i-1]+abs(l[i]-l[i-1]),m[i-2]+abs(l[i]-l[i-2]))
print (m[N-1])


Measured memory_bytes: 23148
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define mkp make_pair
#define pi pair<int,int>
#define push push
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<<endl;}}
#define print1d(mat,n){for(int i=0;i<(int)(n);i++)cout<<mat[i]<<" ";cout<<endl;}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<endl;
#define init(v,x) for (auto &itr:v){itr=x;}
#define minpq(x) x,vector<x>,greater<x>
#define ln length()
#define sz size()
#define inf 1e18;
const int mod= 1e9+7;

void solve(){
   int h,w,m1,r,c;
  map <int , set<int> > mc,mr;
    cin>>h>>w;
    cin>>m1;
   rep(i,0,m1){
       cin>>r>>c;
       mc[c].insert(r);
       mr[r].insert(c);
   }
//   return ;
   multiset < pair <int, set<int>> , greater<pair <int, set<int>> > >   m;
   rr(mc){
       m.insert({val.se.sz,val.se});
   }
   int ans=0;
   rep(i,1,h+1){
    //   cout<<i<<ans<<endl;
       if(mr[i].sz>0){
           int s= (*m.begin()).fi;
            rr(m){
                if (val.fi!=s){
                    break;
                }
                if (val.se.find(i)==val.se.end()){
                    ans=max(ans,(int)mr[i].sz+val.fi);
                    break;
                }
                else{
                    ans=max(ans,(int)mr[i].sz+val.fi-1);
                }
                // break;
            }
       }
   }
   cout<<ans<<endl;
}

int32_t main(){
    fastIO
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 130196
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int a, b, c, d; cin>>a>>b>>c>>d;
    int a1 = max(a*c, b*d);
    int a2 = max(a*d, b*c);
    cout<<max(a1, a2);
}   


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<cstdio>
#include<iterator>
#include<algorithm>
#include<string>
using namespace std;
#define LL long
#define MOD LL(1e9+7)

LL n, a[100000], flag[100000];
LL mod_pow(LL x, LL n)
{
	LL res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		flag[a[i]]++;
	}
	if (flag[0] != 1 && n % 2)
	{
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < n; i++)
	{

		if (flag[a[i]] > 2)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	cout << mod_pow(2, n / 2) << endl;;

}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;
#define int ll

ll mpow(ll x, ll n) { //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % MOD;
		x = x * x % MOD;
		n = n >> 1;
	}
	return ans;
}

signed main() {
	int N, A, B; cin >> N;
	int maxL = 60;
	vector<vector<int>> accum(maxL, vi(2)); // {N of zero, N of one}
	vector<bitset<60>> input(N); 
	rep(i, N) {
		int x; cin >> x;
		bitset<60> bs = x;
		input[i] = bs;
	}
	;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < maxL; j++) {
			if (input[i][j] == 0) {
				accum[j][0]++;
			}
			else {
				accum[j][1]++;
			}
		}
	}

	int res = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < maxL; j++) {
			if (input[i][j] == 0) {
				res += mpow(2, j) * accum[j][1] % MOD;
				res %= MOD;
			}
			else {
				res += mpow(2, j) * accum[j][0] % MOD;
				res %= MOD;
			}
		}
	}
	res %= MOD;
	if (res % 2 != 0) {
		res += MOD;
		res /= 2;
		res %= MOD;
	}
	else {
		res /= 2;
	}
	cout << res << endl;
}

Measured memory_bytes: 5628
import math

a,b,x = [int(i) for i in input().split()]
s = x / a
if s<=a*b/2:
    print(math.atan(b**2/(2*s))/math.pi*180)
else:
    print(math.atan(2*(a*b-s)/(a**2))/math.pi*180)



Measured memory_bytes: 9368
#include <cstdio>

#define a(d, n) if (*(unsigned short*)s == *(unsigned short*)d) { puts(#n); return 0; }

int main()
{
  char s[4];
  scanf("%s", s);
  a("SUN", 7);
  a("MON", 6);
  a("TUE", 5);
  a("WED", 4);
  a("THU", 3);
  a("FRI", 2);
  puts("1");
  return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	int A,B,C;
	cin >> A >> B >> C;

	if(A+B+C>=22)	cout << "bust" << endl;
	else	cout << "win" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())

if (N & -N) == N:
    print('No')
    sys.exit()

N2 = N if N%2 else N-1
anss = []
for i in range(2, N2+1):
    anss.append((1, i))
for i in range(2, N2+1):
    anss.append((i, (i^1)+N))
anss.append((2+N, 1+N))

if N%2 == 0:
    N2 = N+1
    k = 1<<(N2.bit_length()-1)
    anss.append((N, k))
    anss.append((2*N, N2^k))

print('Yes')
print('\n'.join(map(lambda x: str(x[0])+' '+str(x[1]), anss)))


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
typedef vector<string> vecst;

int main(){
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    K = K - 1;
    if(S.at(K) == 'A') S.at(K) = 'a';
    else if(S.at(K) == 'B') S.at(K) = 'b';
    else S.at(K) = 'c';
    cout << S <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int FirstNum, SecondNum, GCD, LCM;
	while(scanf("%d %d",&FirstNum,&SecondNum) != EOF){
		GCD = gcd(FirstNum, SecondNum);
		LCM = FirstNum/GCD * SecondNum;
		printf("%d %d\n", GCD, LCM);
	}
	return 0;
}

int gcd(int u, int v){
	if (v)
		return gcd(v, u%v);
	else
		return u < 0 ? -u : u;
}

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

using namespace std;

const int maxi=1e6;
int n;
int a[maxi];
long long ans;
int main()
{
    cin>>n;

    for (int i=1;i<=n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        ans+=abs(y-x)+1;
    }

    cout<<ans;

  return 0;
}


Measured memory_bytes: 256
main=do
 [r,g,b,n]<-map read.words<$>getLine
 print$length[1|i<-[0..div(n+r-1)r],j<-[0..div(n-i*r+g-1)g],let x=n-i*r-j*g,x>=0&&x`mod`b==0]

Measured memory_bytes: 892
<?php
$count = trim(fgets(STDIN));

$numbers = range(1, $count);

$filterd = array_filter($numbers, function ($value) {
  return !($value % 3 == 0 || $value % 5 == 0);
});

$result = 0;
foreach ($filterd as $f) {
  $result += $f;
}

echo $result. PHP_EOL;

Measured memory_bytes: 80928
#n = int(input())
from collections import deque

h,w,ans = map(int,input().split())
tmap = ['']*w
map = []
count = 0

for i in range(h):
    map.append(input())

for i in range(2**h):
    for j in range(2**w):
        map2 = []
        tmap2 = ['']*w
        sharp = 0
        for k in range(h):
            if((i>>k)&1):
                map2.append(['.']*w)
            else:
                map2.append(map[k])
            for l in range(w):
                tmap2[l] += map2[k][l]
        for k in range(w):
            if not((j>>k)&1):
                sharp += tmap2[k].count('#')
        if sharp == ans:
            count += 1
        #print(i,j,sharp,map2,tmap2)

print(count)

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

int comp_int(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}

int main()
{
    // 整数の入力
    int N;
    cin >> N;

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

	qsort(v, N, sizeof(int), comp_int);

	double sum;

	sum = v[0];
	for (i=1; i<N; i++) {
		sum+=v[i];
		sum/=2;
	}

	printf("%lg\n",sum);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count0 = 0;
  
  for (int i = 0; i < S.size(); i++) if (S.at(i) == '0') count0++;
  
  int count1 = S.size() - count0;
  cout << 2 * min(count0,count1) << endl;
}

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

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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h , n; cin >> h >> n;
    int sum = 0;
    rep(i, n) {
        int a; cin >> a;
        sum += a;
        if (sum >= h) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;


}


Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            int i, j;
            int subTotal = 0;
            int total = 0;

            //整数受け取りok
            string[] str = Console.ReadLine().Split(' ');
            n = int.Parse(str[0]);
            m = int.Parse(str[1]);

            //2次元配列数値受け取り
            int[,] array1 = new int[n, m];
            

            for (i = 0; i < n; i++)

            {
                string[] str2 = Console.ReadLine().Split(' ');
                for (j = 0; j < m; j++)
                { 
                    array1[i, j] = int.Parse(str2[j]);
                }
            }

            //配列数値受け取り
            int[] array2 = new int[m];
            
            for (j = 0; j < m; j++)
            {
                string str3 = Console.ReadLine();
                array2[j] = int.Parse(str3);
            }

            //計算

            for (i = 0; i < n; i++)
            {
                for (j = 0; j < m; j++)
                {
                    subTotal = array1[i, j] * array2[j];
                    total += subTotal;
                    subTotal = 0;
                }
                Console.WriteLine(total);
                total = 0;
            }
        }
    }



Measured memory_bytes: 9244
#include<stdio.h>
int main(){
  int count[4][3][10];
  int b,f,r,v,i,j,n,k,m,w=0,p=0,a=0,o=0;
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    count[i][j][k]=0;
      }
    }
  }
  scanf("%d",&n);
  for(m=0;m<n;m++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    if(b==1){
      i=0;
      j=f-1;
      k=r-1;
      w=count[i][j][k]+v;
      if(w>9){
    w=9;
      }
      count[i][j][k]=w;
      w=0;
    }else if(b==2){
      i=1;
      j=f-1;
      k=r-1;
      o=count[i][j][k]+v;
      if(o>9){
    o=9;
      }
      count[i][j][k]=o;
      o=0;
    }else if(b==3){
      i=2;
      j=f-1;
      k=r-1;
      p=count[i][j][k]+v;
      if(p>9){
    p=9;
      }
      count[i][j][k]=p;
      p=0;
    }else if(b==4){
      i=3;
      j=f-1;
      k=r-1;
      a=count[i][j][k]+v;
      if(a>9){
    a=9;
      }
      count[i][j][k]=a;
      a=0;
    }
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    if(k<10){
      printf(" ");
    }
    printf("%d",count[i][j][k]);
 
      }    
      printf("\n");
    }
    if(i<3){
      printf("####################\n");
    }
  }
  return (0);
}


Measured memory_bytes: 2104