akhauriyash/Code-Regression huggingface dataset:
using System;

class Atcoder125
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int k = int.Parse(input[1]);
        string letters = Console.ReadLine();

        string letter = letters[k - 1].ToString();
        string change = letter.ToLower();

        string output = "";

        for (int i = 0; i < n; i++)
            if (i == k - 1)
                output += change;
            else
                output += letters[i];

        Console.WriteLine(output);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n),dp(n,0);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  dp[0]=0;
  for(int i=1;i<n;i++){
    int m=M;
    for(int j=i-1;j>=i-k;j--){
      if(j>=0){
        m=min(abs(a[i]-a[j])+dp[j],m);
      }
    }
    dp[i]=m;
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

from itertools import accumulate

s = list(accumulate(a))
#s = [a[0]]
#for i in range(1, n):
#    s.append(a[i] + s[i-1])

l = 0
r = 2
ans = float("inf")

for m in range(1, n-1):
    while l < m - 1 and abs(s[m] - 2 * s[l]) > abs(s[m] - 2 * s[l+1]):
        l += 1
    while r <= m or r < n - 1 and abs(s[n-1] - 2 * s[r] + s[m]) > abs(s[n-1] - 2 * s[r+1] + s[m]):
        r += 1
    mx = max(s[l], s[m] - s[l], s[r] - s[m], s[n-1] - s[r])
    mn = min(s[l], s[m] - s[l], s[r] - s[m], s[n-1] - s[r])
    ans = min(ans, mx - mn)

print(ans)


Measured memory_bytes: 24704
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }




int main() {
    int n, q;
    char s[1000001];
    scanf("%d %s %d", &n, s, &q);
    for(int a = 0; a < q; a++){
        int k;
        scanf("%d", &k);
        
        int d = 0, m = 0;
        long long x = 0, z = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == 'D'){
                d++;
            }
            else if(s[i] == 'M'){
                x += d;
                m++;
            }
            else if(s[i] == 'C'){
                z += x;
            }
            
            if(i - k + 1 >= 0){
                if(s[i - k + 1] == 'D'){
                    d--;
                    x -= m;
                }
                else if(s[i - k + 1] == 'M'){
                    m--;
                }
            }
        }
        printf("%lld\n", z);
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n), id(n);
  rep(i, n) {
    cin >> A[i];
    id[i] = i;
  }
  sort(all(id), [&](int i, int j) {
    return A[i] < A[j];
  });
  rep(i, n) cout << id[i]+1 << ' ';
  cout << endk;
  return 0;
}


Measured memory_bytes: 4716
#include<bits/stdc++.h>
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int MX=1e5+9;
const ll inf=(1ll<<60);
const ll mod=1e9+7;
ll n,a[MX];
int main(){
    a[1]=1;
    for(int i=2;i<=MX-2;i++){
        a[i]=a[i-1]*i;
        a[i]%=mod;
    }
    scanf("%lld",&n);
    printf("%lld\n",a[n]);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define     bit_1(a)       __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front
#define     mpr            make_pair
#define     ins            insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     vstr           vector<string>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))
#define     orderset1      tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define     orderset2      tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));
/// lcm(a,b)=a/gcd(a,b)*b (handle overflow)

bool sortinrev1(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second>b.second);
    else return (a.first > b.first);
}
bool sortinrev2(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second<b.second);
    else return (a.first > b.first);
}
int fx[]={1,-1,0,0};
int fy[]={0,0,1,-1};


int main()
{
    /*int n;
    cin>>n;
    if(n>=30)cout<<"Yes\n";
    else cout<<"No\n";*/
    mll mp;
    ll n,d,xi,yi,ans=0;
    cin>>n>>d;
    while(n--){
        cin>>xi>>yi;
        ll p=ceil(sqrt((xi*xi)+(yi*yi)));
        if(p<=d)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3780
#include <iostream>
#include <math.h>
#include<vector>
#include<cstdio>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=1;
    while(ans*2<=n) ans*=2;
    cout<<ans<<endl;
    //cout<<"ABC"<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
n,x,y= list(map(int, input().split()))
x-=1
y-=1
ans=[0]*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        z=min(abs(i-j),abs(i-x)+abs(j-y)+1)
        ans[z-1]+=1
for k in ans:
    print(k)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,k;cin>>n>>k;
    vector<ll> a(n),f(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>f[i];
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    ll left=-1,right=1e18;
    while(right-left>1){
        ll mid=(right+left)/2;
        ll tot=0;
        rep(i,n){
            ll buf=a[i]*f[i];
            buf-=mid;
            tot+=max((ll)0,(buf+f[i]-1)/f[i]);
        }
        if(tot>k)left=mid;
        else right=mid;
    }
    cout<<right<<endl;
}


Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<long long> a(n),b(n);
    long long suma=0,sumb=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        suma+=a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        sumb+=b[i];
    }
    long long t=sumb-suma;
    if(t<0){
        cout<<"No"<<endl;
        return 0;
    }
    long long q1=0,q2=0;
    for(int i=0;i<n;i++){
        while(a[i]!=b[i]){
            if(a[i]<b[i]){
                long long d=(b[i]-a[i]+1)/2;
                q1+=d;
                a[i]+=d*2;
            }
            else{
                long long d=a[i]-b[i];
                q2+=d;
                b[i]+=d;
            }
        }
    }
    //cout<<t<<" "<<q1<<" "<<q2<<endl;
    if(t<q1||t<q2)cout<<"No"<<endl;
    else if(q1==t&&q2==t)cout<<"Yes"<<endl;
    else if((t-q1)*2==(t-q2))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main()
{
    int x,y;
    int i=0;
    while(i<3000){cin>>x>>y;if(x==0&&y==0)break;
    if(x<y){cout<<x<<" "<<y<<endl;}
    else{cout<<y<<" "<<x<<endl;}
    i++;}
    return 0;
                       
    }


Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef vector<int> Vi;
typedef pair<int,int> Pii;
typedef pair<int,Pii> Pip; 
const int INF = (1<<30);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  int n, m;
  int a[1001] = {0};
  int data[1001];
  cin >> n >> m;

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

  for(int i=0; i<m; i++) {
    int b;
    cin >> b;

    for(int j=0; j<n; j++) {
      if( b >= data[j] ) {
	a[j]++;
	break;
      }
    }
  }

  int max = 0, maxn;
  for(int i=0; i<n; i++) {
    if( max < a[i] ) {
      max = a[i];
      maxn = i;
    }
  }

  cout << maxn+1 << endl;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cmath>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long d[n+1];
    d[0] = 2;
    d[1] = 1;
    for (int i=2; i<=n; i++) {
        d[i] = d[i-1] + d[i-2];
    }
    cout << d[n] << '\n';
    
    return 0;
}

Measured memory_bytes: 3600
def scale(unit):
    if unit == "JPY":
        scale = 1.0
    else:
        scale = 380000.0

    return scale


def normalize_money(money):
    _price, unit = money.split()
    price = float(_price)

    return price * scale(unit)


def solve(str_in_arr):
    moneys = str_in_arr[1::]
    normalized_money = [normalize_money(money) for money in moneys]

    return sum(normalized_money)

  
def main():
    _num_relative = input()
    num_relative = int(_num_relative)

    std_in = [num_relative if idx == 0 else input() for idx in range(num_relative+1)]
    print(solve(std_in))


if __name__ == "__main__":
    main()


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> point;

const int MAXN = 3e5;

int n;
point dp[MAXN];

point merge(point A, point B){
    point ret;
    if(A.first < B.first)
        swap(A, B);
    ret = point(A.first, max(A.second, B.first));
    return ret;
}

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

    cin >> n;
    REP(i, (1 << n)){
        cin >> dp[i].first;
        dp[i].second = 0;
    }

    REP(i, n)
        REP(j, (1 << n)){
            if(j & (1 << i)){
                int mask = j ^ (1 << i);
                dp[j] = merge(dp[j], dp[mask]);
                //cout << dp[i].first _ dp[i].second << "\n";
            }
        }
    FOR(i, 1, (1 << n))
        dp[i].first = max(dp[i].first + dp[i].second, dp[i - 1].first);

    FOR(i, 1, (1 << n))
        cout << dp[i].first << "\n";
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  int a=0;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='1'){
	a++;
      }
  }
      cout<<a<<"\n";
      
  return 0;
  }

Measured memory_bytes: 3600
N,M,L=map(int,input().split())
A=[[0 for i in range(M)] for j in range(N)]
B=[[0 for i in range(L)] for j in range(M)]
C=[[0 for i in range(L)] for j in range(N)]


for i in range(N):
    A[i] = list(map(int, input().split()))
    
for i in range(M):
    B[i] = list(map(int, input().split()))
    
for i in range(N):
    for j in range(L):
        sum=0
        for k in range(M):
            sum+=A[i][k]*B[k][j]
        C[i][j]=sum

for line in C:
    print(*line)


Measured memory_bytes: 7084
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)
ok = 10**12
ng = -1

while ok-ng>1:
  X = (ok+ng)//2
  tmp = 0
  for i,e in enumerate(A):
    tmp += max(e-X//F[i],0)
  if tmp<=K:
    ok = X
  else:
    ng = X
print(ok)

    
  

Measured memory_bytes: 119500
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<int> edge[110000];

Int asum[110000];
Int bsum[110000];
Int sum;
Int a[110000];
Int b[110000];

void dfs(int x, int last = -1){
    asum[x] = a[x];
    bsum[x] = b[x];
    for(auto to:edge[x]){
        if(to == last)continue;
        dfs(to, x);
        asum[x] += asum[to];
        bsum[x] += bsum[to];
    }
}

Int minval = LINF;
Int val[110000];
void dfs2(int x, int last = -1){
    minval = min(minval, val[x]);
    for(auto to:edge[x]){
        if(to == last)continue;
        Int send = bsum[to] - asum[to];
        val[to] = val[x] - send;
        dfs2(to, x);
    }
}

int main(){
    Int n, u, v;
    cin >> n;
    for(int i = 0;i < n-1;i++){
        cin >> u >> v;u--,v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    for(int i = 0;i < n;i++){
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0;i < n;i++)cin >> b[i];

    dfs(0);
    dfs2(0);

    Int ans = 0;
    for(int i = 0;i < n;i++){
        ans += val[i]-minval;
    }
    cout << ans << endl;
    
    return 0;
}


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

public class Solution
{
    public static long Count(int n, int x, int y, int z)
    {
        var left = x * x + y * y + z * z + x * y + y * z + z * x;
        if (left == n)
        {
            if (x == y && y == z)
            {
                return 1;
            }
            if (x == y || y == z || z == x)
            {
                return 3;
            }
            return 6;
        }

        if (left > n)
        {
            return -1;
        }

        return 0;
    }

    public static long Count(int n)
    {
        long count = 0;
        var max = (int)Math.Sqrt(n);
        for (int x = 1; x <= max; x++)
        {
            for (int y = x; y <= max; y++)
            {
                for (int z = y; z <= max; z++)
                {
                    var v = Count(n, x, y, z);
                    if (v < 0)
                    {
                        break;
                    }
                    count += v;
                }
            }
        }
        return count;
    }

    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var counts = Enumerable.Range(1, N).Select(i => Count(i)).ToArray();
        Console.WriteLine(string.Join(Environment.NewLine, counts));
    }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int64_t> h(n);
  for (int i = 0; i < n; i++) cin >> h.at(i);
  sort(h.begin(), h.end());
  int64_t s = 0;
  for (int i = 0; i < n - k; i++) s += h.at(i);
  cout << s << endl;
}


Measured memory_bytes: 1792
package main

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

var scanner *bufio.Scanner

func printIt() {
	rows := nextInt()
	cols := nextInt()
	table := make([][]int, rows+1)
	for r := 0; r < rows; r++ {
		nums := make([]int, cols+1)
		for c := 0; c < cols; c++ {
			nums[c] = nextInt()
		}
		nums[cols] = 0
		table[r] = nums
	}
	table[rows] = make([]int, cols+1)

	for r := 0; r < rows; r++ {
		sum := 0
		for c := 0; c < cols; c++ {
			sum += table[r][c]
		}
		table[r][cols] = sum
	}

	for c := 0; c <= cols; c++ {
		sum := 0
		for r := 0; r < rows; r++ {
			sum += table[r][c]
		}
		table[rows][c] = sum
	}

	for r := 0; r <= rows; r++ {
		for c := 0; c <= cols; c++ {
			if c != 0 {
				fmt.Print(" ")
			}
			fmt.Print(table[r][c])
		}
		fmt.Println()
	}
}

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

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1272
// Atcoder120 - B
function divisor(n) {var ret=[]; for (var i=1;i*i<=n;i++){if(n%i==0){ret.push(i);if(i*i!=n)ret.push(n/i);}}return ret;}
function main(input) {
  var inputs = input.split('\n');
  var abks = inputs[0].split(' ');
  var a = abks[0];
  var b = abks[1];
  var k = abks[2];

  var aDivisors = divisor(a);
  var bDivisors = divisor(b);

  var counter = 0;
  var kthCd = 0;
  aDivisors.sort((i, j) => j - i).some((item) => {
    counter += bDivisors.indexOf(item) >= 0 ? 1 : 0;
    if (counter == k) {
      kthCd = item;
      return true;
    }
  });

  console.log(kthCd);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
/*
 */
#include <iostream>
#include <algorithm>

using namespace std;

// init
// fe[u
int prime[9692]; // 9,592(100,000 ÈºÌfÌ) + 100(iP ÌÅål)
int primeN;

// input
int iN; // 0 <= N <= 100,000
int iP; // 1 <= P <= 100

// manage
int iM[5050]; // 1 ~ 100 ÜÅÌa

// ú»
void init() {
  int i, j;
  bool isPrime[101198]; // 9692 ÔÚÌf = 101197

  primeN = 0;
  fill(isPrime, isPrime + 101198, true);
  isPrime[0] = isPrime[1] = false;

  for (i = 2; i < 101198; i++) {
    if (isPrime[i]) {
      prime[primeN++] = i;
      for (j = 2; i * j < 101198; j++) {
        isPrime[i * j] = false;
      }
    }
  }
}

// üÍ
bool input() {
  scanf("%d %d", &iN, &iP);
  if (iN == -1 && iP == -1) return false;
  return true;
}

// 
void manage(){
  int i, j, k;
  int cnt = 0;
  int tmp;

  // iN æèå«¢f©ç 2 ÂðIñÅaðÆé
  for (i = 0; i < primeN; i++) {
    if (prime[i] > iN) break;
  }
  for (j = 0; j < iP; j++) {
    for (k = j; k < iP; k++) {
      iM[cnt++] = prime[i + j] + prime[i + k];
    }
  }

  // ou\[g(æª©çiPÔÜÅ\[g)
  for (j = 0; j < iP; j++) {
    for (k = cnt - 1; k > j; k--) {
      if (iM[k - 1] > iM[k]) {
        tmp = iM[k];
        iM[k] = iM[k - 1];
        iM[k - 1] = tmp;
      }
    }
  }
}

// oÍ
void output(){
  printf("%d\n", iM[iP - 1]);
}

// mizoSâ¤Ê
int main() {
  init(); // ú»
  while(1) {
    if (!input()) break; // üÍ + I¹»è
    manage(); // 
    output(); // oÍ
  }
  return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    int h[n];
    
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    int c[n]; c[0] = 0;
    
    for (int i = 1; i < n; i++) {
        int min_cost = INT_MAX;
        for (int j = i - 1; j >= (i - k); j--) {
            if (j < 0) {
                continue;
            }
            int cost = c[j] + abs(h[i] - h[j]);
            
            if (cost < min_cost) {
                min_cost = cost;
            }
        }
        c[i] = min_cost;
    }
    
    cout << c[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
#define PI acos(-1)

const ll INF = 10010001010;

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

typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}

int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    int L, R;
    L = R = 0;
    vector<int> ruisekiwa(N + 1);
    int ans =14121431;
    ruisekiwa[0] = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> W[i];
        ruisekiwa[i + 1] = ruisekiwa[i] + W[i];
    }
    for (int i = 0; i < N;i++)
    {
        int test = 0;
        R = ruisekiwa[N] - ruisekiwa[i];
        L = ruisekiwa[N] - R;
        ans = min(abs(R - L), ans);
    }
    cout << ans << endl;
}


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

int main()
{
    int n, m;

    while( cin >> n >> m )
    {
        if( n == 0 && m == 0 )
            break;
        
        int x[n];
        for( int i = 0; i < n; i++ )
            x[i] = 0;

        int i = 0, j = 1, sum = 0;
        while( sum != n )               //全員抜けたら終了
        {
            if( i == n )                //iを0~n-1まで繰り返す処理
                i %= n;
            if( j == m + 1 )            //jを1~mまで繰り返す処理
                j = 1;

            if( x[i] == 0 )
            {
                if( j == m )
                {
                    x[i] = 1;
                    sum++;
                }
                j++;
            }
            i++;
        }
        cout << i << endl;              //配列の添え字はi-1だが、人は基数的に数える。
    }
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep2(i,m,n) for(int i=int(m);i<int(n);i++)
#define drep2(i,m,n) for(int i=int(m-1);i>=int(n);i--)
#define rep(i,n) rep2(i,0,n)
#define drep (i,n) drep2(i,n,0)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int MOD = int(1e9)+7;

int main()
{
    int n,m,k;cin >>n >>m>>k;
    bool flg=false;
    rep(i,n+1)rep(j,m+1){
        if(k==m*i+n*j-i*j*2)flg=true;
    }
    if(flg)puts("Yes");
    else puts ("No");
    return 0;
}


Measured memory_bytes: 256
import math
from collections import deque
def main():
    a,b = tuple([int(t)for t in input().split()])

    for i in range(1,100000):
        a_tax = i *8 //100
        b_tax = i * 10//100

        if a == a_tax and b == b_tax:
            print(i)
            return

    print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n;
	cin>>n;
	ll a[n],b[n],c[n];
	for(i=0;i<n;i++)
	cin>>a[i]>>b[i]>>c[i];
	ll dp[n][3]={0};
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	//cout<<dp[0][0]<<" "<<dp[0][1]<<dp[0][2];
	for(i=1;i<n;i++)
	for(j=0;j<3;j++)
	{
		if(j==0)
	dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i];
	else if(j==1)
	dp[i][j]=max(dp[i-1][0],dp[i-1][2])+b[i];
	else if(j==2)
	dp[i][j]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}
	ll ans=dp[n-1][0];
	for(i=1;i<3;i++)
	ans=max(ans,dp[n-1][i]);
	cout<<ans;
	cout<<"\n"; 
 } 
}


Measured memory_bytes: 4992
<?php

$_n = fgets(STDIN);
$cstr = fgets(STDIN);

$cards = array_map(function ($a) {
    return intval($a);
}, preg_split("/ /", $cstr));
rsort($cards);

$alice = 0;
$bob = 0;

foreach($cards as $i => $c) {
    if($i % 2 == 0) {
        $alice += $c;
    } else {
        $bob += $c;
    }
}


$s = $alice - $bob;
echo "$s\n";


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

int main() {
  ll n;
  cin >> n;
  ll ans = 1e15;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i != 0) continue;
    ll j = n / i;
    ans = min(ans, i + j - 2);
  }
  cout << ans << endl;
  return 0;
}

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

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

  if ( N % 500 <= A) {
   cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 256
from bisect import bisect
s=input()
t=input()
n,m=len(s),len(t)
alf=list("abcdefghijklmnopqrstuvwxyz")
data=[[] for i in range(26)]
for i in range(26):
    for j in range(n):
        if alf[i]==s[j]:
            data[i].append(j)
l=[0]*26
for i in range(26):
    l[i]=len(data[i])
ind=-1
count=0
for i in range(m):
    k=alf.index(t[i])
    if data[k]:
        p=bisect(data[k],ind)
        if p==l[k]:
            count+=1
            ind=data[k][0]
        else:
            ind=data[k][p]
    else:
        print(-1)
        break
else:
    print(n*count+ind+1)

Measured memory_bytes: 47580
n = int(input())
ls = list(map(int, input().split()))
indices = []
m = n
while True:
    indices.append(m)
    m -= 2
    if m < 1:
        break
m = 1 if m == 0 else 2
while len(indices) < n:
    indices.append(m)
    m += 2
    if m > n:
        break
res = [ls[i - 1] for i in indices]
print(*res)

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

struct node{
	unsigned int key;	//キーの値
	struct node *next;	//前のキーのポインタ
	struct node *prev;	//後ろのキーのポインタ
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
	NodePointer t;
	//リストの先頭から走査
	for(t = nil->next;t != nil;t = t->next){
		//目的のキーが見つかれば返す
		if(t->key == key){
			return t;
		}
	}
	return nil;
}

//最初の要素の領域を確保
void init(){
	nil = malloc(sizeof(struct node));
	nil->next = nil;	//リストの先頭
	nil->prev = nil;	//リストの末尾
}

//出力
void printList(){
	NodePointer cur = nil->next;
	int isf = 1;
	while(1){
		if ( cur == nil ) break;
		//最初の要素以外は前に空白を付ける
		if ( isf == 0)  printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
		isf = 0;
	}
  printf("\n");
}

//指定された要素を削除
void deleteNode(NodePointer t){
	/*
	削除する要素の前と後ろの要素を
	変数に入れる
	*/
	NodePointer a_del = t->next,b_del = t->prev;
	
	if(a_del == nil){
		nil->prev = b_del;
		b_del->next = nil;
	}
	else if(b_del == nil){
		nil->next = a_del;
		a_del->prev = nil;
	}
	else{
		a_del->prev = b_del;
		b_del->next = a_del;
	}
	/*
	削除された要素の
	メモリ領域を解放
	*/
	free(t);
}

//先頭の要素を削除
void deleteFirst(){
	NodePointer t = nil->next;
	if ( t == nil ) return;
	deleteNode(t);
}

//末尾の要素を削除
void deleteLast(){
	NodePointer t = nil->prev;
	if ( t == nil ) return;
	deleteNode(t);
}

//指定されたキーを持つ要素を削除
void delete(int key){
	NodePointer t = listSearch(key);
	if(t == nil)return;
	deleteNode(t);
}

//先頭への継ぎ足し
void insert(int key){
	NodePointer x;
	x = malloc(sizeof(struct node));
	x->key = key;
	
	//リストの末尾がNULLのとき
	if(nil->prev == NULL){
		//リストの暫定末尾に
		nil->prev = x;
	}
	//リストの先頭がNULLのとき
	if(nil->next == NULL){
		nil->next = x;
		x->prev = nil;
		x->next = nil;
	}
	//２回目以降の挿入
	else{
		nil->next->prev = x;
		x->next = nil->next;
		x->prev = nil;
		nil->next = x;
	}
}

int main(){
	int key, n, i;
	int size = 0;	//要素数
	char com[20];	//命令用文字列
	int np = 0, nd = 0;	//挿入と削除の回数
	
	scanf("%d", &n);
	
	init();
	
	for ( i = 0; i < n; i++ ){
		//入力
		scanf("%s%d",com,&key);
		//insertのとき
		if ( com[0] == 'i' ) {
			insert(key);
			np++;
			size++;
		}
		//それ以外(delete)
		else if ( com[0] == 'd' ) {
			if (strlen(com) > 6){
				if ( com[6] == 'F' ){
					deleteFirst();
				}
				else if ( com[6] == 'L' ){
					deleteLast();
				}
			}
			else{
				delete(key);
				nd++; 
			}
			size--;
		}
	}
	
	printList();
	return 0;
}



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

int main(){
  long long T;
  cin >> T;
  for(int t=0;t<T;t++){
    long long N,ans=0;
    cin >> N;
    vector<pair<long long,long long>> A(0),B(0);
    for(int i=0;i<N;i++){
      long long k,l,r;
      cin >> k >> l >> r;
      k--;
      if(l>r){
        A.push_back(make_pair(l-r,k));
        ans += r;
      }
      else if(l<r){
        B.push_back(make_pair(r-l,N-k-2));
        ans += l;
      }
      else ans += l;
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    sort(B.begin(),B.end());
    reverse(B.begin(),B.end());
    
    set<long long> Sa;
    for(int i=0;i<N;i++) Sa.insert(i);
    for(int i=0;i<A.size();i++){
      auto it = Sa.upper_bound(A[i].second);
      if(it!=Sa.begin()){
        it--;
        Sa.erase(*it);
        ans += A[i].first;
      }
    }
    
    set<long long> Sb;
    for(int i=0;i<Sa.size();i++) Sb.insert(i);
    for(int i=0;i<B.size();i++){
      auto it = Sb.upper_bound(B[i].second);
      if(it!=Sb.begin()){
        it--;
        Sb.erase(*it);
        ans += B[i].first;
      }
    }
    
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 17412
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
using namespace std;

const unsigned long long BASE = 1e9 + 7;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N; cin >> N;
    int dp[100100];
    const int INF = 1001001001;
    Fill(dp, INF);
    dp[0] = 0;
    dp[1] = 1;
    rep(i,0,N){
        chmin(dp[i+1], dp[i]+1);
        int j = 6;
        while(i+j <= N){
            chmin(dp[i+j], dp[i]+1);
            j *= 6;
        }
        j = 9;
        while(i+j <= N){
            chmin(dp[i+j], dp[i]+1);
            j *= 9;
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 3984
//abc152_d.cpp
//Sun Jan 19 20:45:46 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	map<P,ll> mp;

	for (int i=1;i<=n;i++){
		int keta = log10(i);
		keta = pow(10,keta);
		if (keta==0){
			keta++;
		}
		int matsu = i%10;
		int sento = i/keta;
		if (mp.find(P(sento,matsu))!=mp.end()){
			mp[P(sento,matsu)]++;
		}else {
			mp[P(sento,matsu)] = 1;
		}
//		cout << i << " " << sento << " " << matsu << " " << keta << endl;
	}

	ll ans = 0;
	for (int i=1;i<10;i++){
		for (int j=i;j<10;j++){
			P temp = P(i,j);
//			cout << i << " " << j << " " << mp[temp] << endl;
			if (i==j){
				ans += mp[temp]*mp[temp];
			}else {
				ans += mp[temp]*mp[P(j,i)]*2;
			}
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ka[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    PRINT(ka[k-1]);
}


Measured memory_bytes: 256
#B - 3人でカードゲームイージー

S = [input() for _ in range(3)]

#Aさんからスタート
str = 'a'
turn = 'A'

while True:
  if str == 'a':
    turn = 'A'
    str = S[0][:1]
    S[0] = S[0][1:]
  elif str == 'b':
    turn = 'B'
    str = S[1][:1]
    S[1] = S[1][1:]
  elif str == 'c':
    turn = 'C'
    str = S[2][:1]
    S[2] = S[2][1:]
  else:
    break

print(turn)


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

using namespace std;

int main(){
    int n,m;
    while(cin >> n >> m){
        if((n|m) == 0) break;
        int a[n], b[m];
        int suma=0, sumb=0;
        int reta = -1, retb = -1;
        for(int i=0;i<n;i++){
            cin >> a[i];
            suma += a[i];
        }
        for(int i=0;i<m;i++){
            cin >> b[i];
            sumb += b[i];
        }
        sort(a,a+n);
        sort(b,b+m);
        bool able = false;
        for(int i=0;i<n && able == false;i++){
            for(int j=0;j<m && able == false;j++){
                if(2 * (a[i] - b[j]) == suma - sumb){
                    reta = a[i];
                    retb = b[j];
                    able = true;
                }
            }
        }
        if(able){
            cout << reta << " " << retb << endl;
        }else{
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 0
def getval():
    n = int(input())
    return n

def main(n):
    dp = [0]
    arr = [1]
    a1 = 6
    a2 = 9
    for i in range(1,100):
        if a1**i<=n:
            arr.append(a1**i)
        else:
            break
    for i in range(1,100):
        if a2**i<=n:
            arr.append(a2**i)
        else:
            break
    arr.sort()
    
    for i in range(1,n+1):
        temp = i 
        for j in arr:
            if j>i:
                break
            temp = min(temp,dp[i-j]+1)
        dp.append(temp)

    print(dp[n])

if __name__=="__main__":
    n = getval()
    main(n)

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll re = 0;
  rep(i, n - 2) if (s.substr(i, 3) == "ABC")++ re;
  cout << re << endl;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    long long A[N], C[M];
    int B[M];
    vector<pair<long long, int> > a;

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

    for(int i = 0; i < M; i++){
        cin >> B[i] >> C[i];
        a.push_back(make_pair(C[i], B[i]));
    }

    sort(a.begin(), a.end());
    sort(A, A + N);
    int j = 0;

    for(int i = M - 1; i >= 0; i--){
        if(A[j] >= a[i].first){
            break;
        }
        else{
            int k = 0;
            while(k < a[i].second & a[i].first > A[j+k] & j + k < N){
                A[j+k] = a[i].first;
                k++;
            }
            j += k;
        }
    }

    long long sum = 0;

    for(int i = 0; i < N; i++){
        sum += A[i];
    }

    cout << sum << endl;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
string s;
bool was[300][300][301];
short res[300][300][301];
        
int go (int i, int j, int k) {
	if (i > j) re 0;
	if (i == j) re 1;
	if (i >= n || j < 0) re 0;
	if (was[i][j][k]) re res[i][j][k];
	was[i][j][k] = 1;
	int cur = max (go (i + 1, j, k), go (i, j - 1, k));
	if (s[i] == s[j]) cur = max (cur, go (i + 1, j - 1, k) + 2); else
	if (k > 0) cur = max (cur, go (i + 1, j - 1, k - 1) + 2);
	re res[i][j][k] = cur;
}

int main () {
	cin >> s >> m;
	n = sz (s);
	printf ("%d\n", go (0, n - 1, m));
	return 0;
}

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


def calc(k, kiten, a):
    koho1 = abs(kiten -a)
    koho2 = kiten + k - a
    koho3 = a + k - kiten

    return min(koho1, koho2, koho3)


def main():
    k, n = map(int, input().split())
    a_list = list(map(int, input().split()))

    max_kkn = a_list[0] + k - a_list[-1]
    for i in range(n - 1):
        max_kkn = max(max_kkn, a_list[i + 1] - a_list[i])

    print(k - max_kkn)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26436
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    if(cnt == H+W-1) {
        cout << "Possible" << endl;
        return 0;
    }
    else {
        cout << "Impossible" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int c = n/4;
		int d = n/7;
		
		for(int i=0; i<=c; i++) {
			for(int j=0; j<=d; j++) {
				if(4*i + 7*j == n) {
					System.out.println("Yes");
					return;
				}
			}
		}
		
		System.out.println("No");
	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
// 	#ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// 	#endif

    int l;
    cin>>l;
    float a= l/3.00;
    printf("%0.9f",a*a*a);

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc = initScanner(os.Stdin)
	n := scanInt(sc)
	t := scanIntSlice(sc, n)
	m := scanInt(sc)

	solve(t, n, m)
}

func solve(t []int, n, m int)  {
	p := make([]int, m)
	x := make([]int, m)

	for i:=0;i<m;i++ {
		p[i] = scanInt(sc)
		x[i] = scanInt(sc)
	}

	sum := 0
	for i:=0; i<m; i++ {
		sum = 0
		for j := 0 ; j < n; j++ {
			if p[i]-1 == j {
				sum += x[i]
			} else {
				sum += t[j]
			}
		}
		fmt.Println(sum)
	}
}

// --------------- BASE DEFINITIONS ---------------

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)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanFloat64(sc *bufio.Scanner) float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}

func scanFloat64Slice(sc *bufio.Scanner, n int) []float64 {
	fs := make([]float64, n)
	for i := 0; i < n; i++ {
		fs[i] = scanFloat64(sc)
	}

	return fs
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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

int main(){
	string S;
	cin >> S;
	int N = (int)S.size();
	int count1 = 0, count2 = 0;
	for(int i=0;i<N;i++){
		if(S[i] == '0' && i % 2)count1++;
		if(S[i] == '1' && !(i % 2))count1++;  
	}
	for(int i=0;i<N;i++){
		if(S[i] == '1' && i % 2)count2++;
		if(S[i] == '0' && !(i % 2))count2++;  
	}
	cout << min(count1, count2) << endl;
}

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

int main(void)
{
  unsigned long K, A, B, ANS;
  scanf("%ld %ld %ld", &K, &A, &B);
  //printf("K(%ld) A(%ld) B(%ld)\n", K, A, B);

  // 売れない
  if (K < ((A - 1) + 1)) {
    ANS = 1 + K;
  // 売れる
  } else {
    // 最初に叩いた残り回数が偶数の場合
    if ((K - (A - 1)) % 2 == 0) {
      // 売買で儲かる
      if (A + 2 < B) {
        ANS = 1 + (A - 1) + (B - A) * (K - (A - 1)) / 2;
      // 売買で儲からない
      } else {
        ANS = 1 + K;
      }
    // 最初に叩いた残り回数が奇数の場合
    } else {
      // 売買で儲かる
      if (A + 2 < B) {
        ANS = 1 + (A - 1) + (B - A) * (K - (A - 1) - 1) / 2 + 1;
      // 売買で儲からない
      } else {
        ANS = 1 + K;
      }
    }
  }
  printf("%ld\n", ANS);
  return 0;
}

Measured memory_bytes: 128
/*
* Filename:    aoj0033.cpp
* Desciption:  DFS
* Created:     2016-03-02
* Author:      JIngwei Xu [mail:xu_jingwei@outlook.com]
*
*/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#define INT_MAX 2<<30
using namespace std;
//typedef long long ll;
int a[10],n;
int used[10];
bool ans=false;
bool check(){
	int ss=0;
	for (int i = 0; i < 10; i += 1)
	{
		if(used[i]==0){ss=a[i];break;}
	}
	if(ss==0)return true;
	for (int i = 0; i < 10; i += 1)
	{
		if(used[i]==0){
			if(a[i]<ss)return false;
			else ss=a[i];
		}
	}
	return true;
}
void dfs(int k,int rec){
	if(k==10){
		if(check())ans=true;
		return;
	}
	if(ans)return;
	if(a[k]>rec){
		used[k]=1;
		dfs(k+1,a[k]);
		if(ans)return;
		used[k]=0;
		dfs(k+1,rec);
		if(ans)return;
	}
	else{
		used[k]=0;
		dfs(k+1,rec);
	}
}
int main()
{
	scanf("%d",&n);
	for (int i = 0; i < n; i += 1)
	{
		for (int j = 0; j < 10; j += 1)
		{
			scanf("%d",&a[j]);
		}
		ans=false;
		for (int i = 0; i < 10; i += 1)
		{
			memset(used,0,sizeof(used));
			used[i]=1;
			dfs(i+1,a[i]);
			if(ans)break;
		}
		
		
		if(ans)printf("YES\n");
		else printf("NO\n");
		
	}
	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, k;
	ll a2, b2, c, d;
	cin >> n >> a2 >> b2 >> c >> d;
	ll a = min(a2, b2);
	ll b = max(a2, b2);
	if (b - a > d*(n - 1)) {
		cout << "NO" << endl;
		return 0;
	}
	if (b - a >= c*(n - 1)) {
		cout << "YES" << endl;
		return 0;
	}
	for (k = 0; k < n; k++) {
		ll m = c*k - d*(n - 1 - k);
		ll M = d*k - c*(n - 1 - k);
		if (a + m <= b && a + M >= b) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

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

int main(){
  int m, d, ans = 0;
  cin >> m >> d;
  
  rep(i, m+1){
    rep(j, d+1){
      int a, b;
      a = j % 10;
      b = j / 10;
      if(a < 2 || b < 2) continue;
      if(a * b == i) ans++;
    }
  }
  cout << ans << endl;
}

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 all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    ull S;
    cin >> S;
    ll x1 = 0, x2 = 1000000000, x3 = x2-S % x2, y1 = 0, y2 = 1, y3 = (S / x2)+1;
    if(S==1000000000000000000)
    {
        cout << 0 << " " << 0 << " " << x2 << " " << 0 << " " << 0 << " " << x2;
    }
    else
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3;
    return 0;
}

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

int main()
{

    long long int n, d, count = 0;
    cin >> n >> d;

    while (n--)
    {
        long long int x, y;
        cin >> x >> y;

        double p = (x * x) + (y * y);
        p = sqrt(p);

        if (p <= d)
            count++;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define ll long long 
#define pb push_baack 
using namespace  std ;
vector<int>vc;
vector<int>cv;
vector<int>gh;
int main(){

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

Measured memory_bytes: 256