akhauriyash/Code-Regression huggingface dataset:
s=gets.chomp
k=gets.to_i
n=s.size
c=0
i=0
f=true if s.split("").uniq.size==1

if s.size==1
  puts k/2
  exit
end

while i<n-1
  if s[i]==s[i+1]
    if i<n-2 and s[i+1]==s[i+2]
      i+=1
    end
    c+=1
  end
  i+=1
end
if k==1
  puts c
  exit
end
#puts c

if f
  puts (n.odd?)? c*k+k/2 : c*k
  exit
end

a=c*k
if s[0]==s[-1]
  if a==0
    a=k
  end
  i=0
  j=-1
  i+=1 while i<n-1 and s[i]==s[i+1]
  j-=1 while j>-n+1 and s[j]==s[j-1] 
    #puts i;puts j
    #puts i+1+j.abs
  if i==0 and j==-1
    a+=k-1
  elsif i==0 or j==-1
    if (i+1+j.abs).even?
      a+=k-1
    end
  elsif i.even? and j.abs.odd?
    a+=k-1
  end
end
puts a

Measured memory_bytes: 1788
N,M,X = map(int, input().split())
book = []
hm = []
total_price = []
for i in range(N):
  one = list(map(int, input().split()))
  hm.append(one[0])
  one.pop(0)
  book.append(one)

for i in range(2 ** N):
  sougaku = 0
  point = [0] * M
  for j in range(N):
    if ((i >> j) & 1):
      point = [x + y for (x, y) in zip(point,book[j])]
      sougaku += hm[j]
  if min(point) >= X:
    total_price.append(sougaku)

if total_price == []:
  print(-1)
else:
  print(min(total_price))

Measured memory_bytes: 9316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a1 = ReadInts();
            var a2 = ReadInts();
            var a3 = ReadInts();

            var n = ReadInt();
            var list = new List<int>();
            for (int i = 0; i < n; i++)
            {
                var b = ReadInt();
                list.Add(b);
            }
            if (list.Contains(a1[0]) && list.Contains(a1[1]) && list.Contains(a1[2]))
            {

            }
            else if (list.Contains(a2[0]) && list.Contains(a2[1]) && list.Contains(a2[2]))
            {

            }
            else if (list.Contains(a3[0]) && list.Contains(a3[1]) && list.Contains(a3[2]))
            {

            }
            else if (list.Contains(a1[0]) && list.Contains(a2[0]) && list.Contains(a3[0]))
            {

            }
            else if (list.Contains(a1[1]) && list.Contains(a2[1]) && list.Contains(a3[1]))
            {

            }
            else if (list.Contains(a1[2]) && list.Contains(a2[2]) && list.Contains(a3[2]))
            {

            }

            else if (list.Contains(a1[0]) && list.Contains(a2[1]) && list.Contains(a3[2]))
            {

            }
            else if (list.Contains(a1[2]) && list.Contains(a2[1]) && list.Contains(a3[0]))
            {

            }
            else
            {
                WriteLine("No");
                return;
            }
            WriteLine("Yes");
        }

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


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

typedef long long LL;

const int N = 200005;

int n;
int a[N];
map<int, int> q;

int main() {
    LL ans, tmp;
    while (~scanf("%d", &n)) {
        q.clear();
        for (int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
            q[a[i]]++;
        }
        ans = 0;
        for (auto &t: q) ans += (LL) t.second * (t.second - 1) / 2;
        for (int i = 0; i < n; i++) cout << ans - q[a[i]] + 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 8320
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
#define vel vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
pin solve(V<pin>& ab, int ex) {
	if (ex == 0) { return mkp(1, 0); }
	V<pin> ab0, ab1;
	for (auto x : ab) {
		int a1 = x.first;
		int b1 = x.second;
		if (b1 % 2 == 0) {
			ab0.push_back(mkp(a1 / 2, b1 / 2));
			if (a1 % 2 == 1) { ab1.push_back(mkp(a1 / 2, b1 / 2)); }
		}
		else {
			ab1.push_back(mkp(a1 / 2, b1 / 2));
			if (a1 % 2 == 1) { ab0.push_back(mkp(a1 / 2, (b1 + 1) / 2)); }
		}
	}
	vel c0(2), c1(2);
	for (auto x : ab0) {
		int qa = x.first % 3; qa = 3 - qa;
		int qb = x.second % 3;
		int qc = (qa + qb) % 3;
		if (qc == 0) { c0[0] ^= 1; }
		if (qc == 1) { c0[1] ^= 1; }
		if (qc == 2) { c0[0] ^= 1; c0[1] ^= 1; }
	}
	for (auto x : ab1) {
		int qa = x.first % 3; qa = 3 - qa;
		int qb = x.second % 3;
		int qc = (qa + qb) % 3;
		if (qc == 0) { c1[0] ^= 1; }
		if (qc == 1) { c1[1] ^= 1; }
		if (qc == 2) { c1[0] ^= 1; c1[1] ^= 1; }
	}
	vel ze(2, 0);
	if (c0 == ze) {
		pin ans = solve(ab1, ex - 1);
		ans.first *= 2; ans.second *= 2;
		ans.second++;
		return ans;
	}
	if (c1 == ze) {
		pin ans = solve(ab0, ex - 1);
		ans.first *= 2; ans.second *= 2;
		return ans;
	}
	rep(i, ab.size()) { ab[i].first++; }
	pin ans = solve(ab, ex);
	ans.first--;
	return ans;
}
signed main() {
	int inf = 1;
	rep(i, 57) { inf *= 2; }
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		int a, b; cin >> a >> b;
		a += inf; b += inf;
		ab[i] = mkp(a, b);
	}
	pin ret = solve(ab, 70);
	ret.first -= inf;
	ret.second -= inf;
	cout << ret.first << " " << ret.second << endl;
}

Measured memory_bytes: 11988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100005;

int n;
bitset<N> eaten;

ll ans;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    eaten.reset();
    cin >> n;
    // A for takashi ordering, b for aoki
    vector<pair<int, pair<int, int>>> a, b;
    for (int i = 0 ; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a.push_back({x + y, {x, i}});
        b.push_back({x + y, {y, i}});
    }
    sort(a.begin(), a.end(), greater<pair<int, pair<int, int>>>());
    sort(b.begin(), b.end(), greater<pair<int, pair<int, int>>>());
    int ai = 0, bi = 0;
    for (int i = 0; i < n; i++) {
        if (!(i % 2)) {
            while (eaten[a[ai].second.second]) ai++;
            eaten[a[ai].second.second] = true;
            ans += a[ai].second.first;
        } else {
            while (eaten[b[bi].second.second]) bi++;
            eaten[b[bi].second.second] = true;
            ans -= b[bi].second.first;
        }
    }
    cout << ans;
}


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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T, size_t N> ostream& operator << (ostream &os, const array<T, N> &a) {os << "("; for (int i=0; i<(int)N; i++) {if (i) os << ", "; os << a[i];} return os << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    bool ok = true;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0)
            ok &= (a % 3 == 0 || a % 5 == 0);
    }

    cout << (ok ? "APPROVED" : "DENIED") << "\n";

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var a, b int
	fmt.Scan(&a, &b)

	if a >= 13 {
		fmt.Println(b)
	} else if a <= 12 && a >= 6 {
		fmt.Println(b / 2)
	} else if a <= 5 {
		fmt.Println(0)
	}

}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define pr(x) cerr<<#x<<"="<<x<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define N 1000
int n,ans=10000000,i;
char ch[1000000];
int main()
{	
	scanf("%s",ch);int len=strlen(ch);for (i=1;i<len;i++) if (ch[i-1]!=ch[i])ans=min(ans,max(i,len-i));
	if (ans==10000000) printf("%d\n",len);
	else 
	printf("%d\n",ans);
	return 0;
}

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

int		main()
{
	int		N, K;
	long long	 sum = 0;

	scanf("%d %d\n", &N, &K);
	long long min = 0;
	// printf("%d %d\n", N, K);
	for(int i = 0; i <=(K-1); i++)
	{
		min += i;
		min %= 1000000007;
	}
	long long max = 0;
	for(int i = (N-(K-1)); i <=N; i++)
	{
		max += i;
		max %= 1000000007;
	}
	int n = 0;
	int i = K;
	while(i<=N+1)
	{
		if (n != 0)
		{
			min += (K - 1 + n);
			max += (N - (K - 1) - n);
		}
		sum += max - min + 1;
		sum %= 1000000007;
		n++;
		i++;
	}
	if (sum < 0)
		sum += 1000000007;
 	printf("%lld\n", sum);
	return (0);
}

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

using namespace std;

using ll = long long;

int main(){

    ll n; cin >> n;
	map<ll, ll> mp;
	for(ll i = 0; i < n; ++i){
		ll tmp; cin >> tmp;
		mp[tmp]++;
	}
	ll m; cin >> m;
	for(ll i = 0; i < m; ++i){
		ll tmp; cin >> tmp;
		if(mp[tmp] > 0){
			mp[tmp]--;
		}
		else{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 16108
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    if (n == 1){
        cout << "Hello World" << endl;
    } else {
        cout << a+b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean flag = true;
        int count = 0;
        int N = sc.nextInt();
        int[] tmp = new int[N];
        for(int i = 0; i<N; i++) {
            tmp[i] = sc.nextInt();
        }
        while(true) {
            for(int i = 0; i<N; i++){
                if(tmp[i] % 2 != 0) {
                    flag = false;
                    break;
                }
                tmp[i] /= 2;
            }

            if (flag == false) break;
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int a[100000], b[100000];
int cnt[100000];
signed main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		scanf("%d%d", &a[i], &b[i]); a[i]--; b[i]--;
		cnt[a[i]]++; cnt[b[i]]++;
	}
	rep(i, n) {
		if (cnt[i] % 2) {
			puts("NO"); return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 1408
def main():
    n = int(input())
    count = 0
    for _ in range(n):
        a, b = map(int, input().split())
        if a == b:
            count +=1
            if count == 3:
                print('Yes')
                return
        else:
            count = 0
    else:
        print('No')

        
if __name__ == '__main__':
    main()

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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 200005;


integer main(){
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<int> v;
    for (int i = 0; i < n; i++){

        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());

    int ans = 0;
    for (int i = 0; i < n-k; i++){

        ans += v[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 2420
def main():
    n = int(input())
    S = input()
    r_inds = []
    g_inds = []
    b_inds = []
    for i in range(len(S)):
        if S[i] == "R":
            r_inds.append(i)
        elif S[i] == "G":
            g_inds.append(i)
        else:
            b_inds.append(i)

    total_comb = len(r_inds)*len(g_inds)*len(b_inds)
    ded = 0
    for i in r_inds:
        for j in g_inds:
            s_ind = min(i, j)
            b_ind = max(i, j)
            diff = b_ind - s_ind
            bigger_ind = b_ind + diff
            smaller_ind = s_ind - diff
            if bigger_ind < len(S) and bigger_ind in b_inds:
                ded += 1
            if smaller_ind >= 0 and smaller_ind in b_inds:
                ded += 1
            if diff % 2 == 0:
                mid_diff = diff // 2
                mid_ind = s_ind + mid_diff
                if mid_ind in b_inds:
                    ded += 1
    print(total_comb - ded)

            
if __name__ == "__main__":
    main()

Measured memory_bytes: 68972
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    int p[n];
    int copy[n];
    rep(i, n) {
        cin >> p[i];
        copy[i] = p[i];
    }

    sort(p, p + n);
    int num = 0;
    rep(i, n){
        if(p[i] != copy[i]) num++;
    }
    if(num <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b;
  for(int i=0; i<m ; i++) {
    int tp; cin >> tp; b.push_back(tp);
  }
  int cnt = 0;
  for(int i=0; i<n; i++) {
    int cum = c;
    for(int j=0; j<m; j++) {
      int tp;
      cin >> tp;
      cum += tp * b[j];
    }
    if(cum > 0) cnt++;
  }
  cout << cnt << '\n';
  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();
        long[] line = new long[n];
        for (int i = 0; i < n; i++) {
            line[i] = sc.nextLong();
        }
        if (n < 3) {
            System.out.println("0");
            return;
        }

        int ans = 0;
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                for (int k = j + 1; k < n; k++) {
                    if (canTriangle(line[i], line[j], line[k])) {
                        if (line[i] != line[j] && line[j] != line[k] && line[i] != line[k]) {
                            //System.out.println(i + " " + j + " " + k);
                            ans++;
                        }
                    }
                }
            }
        }
        System.out.println(ans);
    }

    static boolean canTriangle(long a, long b, long c) {
        return (a + b > c) && (b + c > a) && (c + a > b);
    }
}


Measured memory_bytes: 36532
#include <iostream>  
  
using namespace std;  
  
const int N = 100;  
int a[N];  
  
void output_result(int a[], int n)  
{  
    for(int i=0; i<n; i++) {  
        if(i > 0)  
            cout << " ";  
        cout << a[i];  
    }  
    cout << endl;  
}  
  
void insertion_sort(int a[], int n)  
{  
    for(int i=1; i<n; i++) {  
        int key = a[i];  
        /* insert A[i] into the sorted sequence A[0,...,j-1] */  
        int j = i - 1;  
        while(j >= 0 && a[j] > key) {  
            a[j + 1] = a[j];  
            j--;  
        }  
        a[j + 1] = key;  
  
        output_result(a, n);  
    }  
}  
  
int main()  
{  
    int n;  
    cin >> n;  
    for(int i=0; i<n; i++)  
        cin >> a[i];  
  
    output_result(a, n);  
  
    insertion_sort(a, n);  
  
    return 0;  
}  


Measured memory_bytes: 3056
#pragma region Header
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
#pragma endregion

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

    int h_size, w_size, bomb_size;
    cin >> h_size >> w_size >> bomb_size;
    vector<pair<int, int>> bombs(bomb_size);
    vector<int> cnt_h(h_size), cnt_w(w_size);
    rep(i, bomb_size)
    {
        int h, w;
        cin >> h >> w;
        --h;
        --w;
        bombs[i] = {h, w};
        ++cnt_h[h];
        ++cnt_w[w];
    }

    // cnt_h, cnt_w の max
    int max_h = accumulate(cnt_h.begin(), cnt_h.end(), 0, [](int acc, int x) { return max(acc, x); });
    int max_w = accumulate(cnt_w.begin(), cnt_w.end(), 0, [](int acc, int x) { return max(acc, x); });

    // max を実現するh, wの個数
    int n_h = accumulate(cnt_h.begin(), cnt_h.end(), 0, [&](int acc, int x) {
        return acc + (x == max_h ? 1 : 0);
    });
    int n_w = accumulate(cnt_w.begin(), cnt_w.end(), 0, [&](int acc, int x) {
        return acc + (x == max_w ? 1 : 0);
    });

    // n_h, n_wに含まれるbombの個数
    int n_bomb = 0;
    for (auto &[h,w] : bombs)
    {
        if (cnt_h[h] == max_h and cnt_w[w] == max_w)
        {
            ++n_bomb;
        }
    }
    
    cout << max_h + max_w - ((i64)n_h * n_w > (i64)n_bomb ? 0 : 1) << endl;

    return 0;
}


Measured memory_bytes: 7960
using System;

class Program{
    class Node{
        public int k;
        public int[] children;
        public int parent;
        public int depth;
    }

    static void CalcDepth(Node[] nodes, int idx, int depth){
        nodes[idx].depth=depth;
        for(var i=0; i<nodes[idx].k; i++){
            CalcDepth(nodes, nodes[idx].children[i], depth+1);
        }
    }

    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        var nodes=new Node[n];
        for(var i=0; i<n; i++){
            nodes[i]=new Node();
            nodes[i].parent=-1;
        }
        for(var i=0; i<n; i++){
            var s=Console.ReadLine().Split(' ');
            var id=int.Parse(s[0]);
            var k=int.Parse(s[1]);
            nodes[id].k=k;
            nodes[id].children=new int[k];
            for(var j=0; j<k; j++){
                nodes[id].children[j]=int.Parse(s[j+2]);
                nodes[nodes[id].children[j]].parent=id;
            }
        }

        for(var i=0; i<n; i++){
            if(nodes[i].parent==-1){
                CalcDepth(nodes, i, 0);
            }
        }

        var sout=new System.Text.StringBuilder();
        for(var i=0; i<n; i++){
            sout.Append("node "+i+": parent = "+nodes[i].parent+", ");
            sout.Append("depth = "+nodes[i].depth+", ");
            if(nodes[i].parent==-1){
                sout.Append("root");
            } else if(nodes[i].k==0){
                sout.Append("leaf");
            } else{
                sout.Append("internal node");
            }
            sout.Append(", [");
            if(nodes[i].k!=0){
                for(var j=0; j<nodes[i].k; j++){
                    sout.Append(nodes[i].children[j]);
                    if(j<nodes[i].k-1){
                        sout.Append(", ");
                    }
                }
            }
            sout.Append("]\n");
        }
        Console.Write(sout);
    }
}

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


void func160c() {
  long long k, n;
  long long i;
  cin >> k >> n;
  vector<long long> a(n+1);
  vector<long long> d(n+1);
  a[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    d[i] = a[i] - a[i - 1];
  }
  d[1] = d[1] + k - a[i-1];
  long long max = *max_element(d.begin(), d.end());
  cout << k - max << endl;
}



int main(void) {
  func160c();
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> C(H, vector<int>(W, 0));
    ll A = 0;

    rep(i, H)
    {
        rep(j, W)
        {
            char c;
            cin >> c;
            if (c == '.')
            {
                C[i][j] = 0;
            }
            else
            {
                C[i][j] = 1;
            }
        }
    }

    for (int bit = 0; bit < (1 << H); ++bit)
    {
        for (int bit2 = 0; bit2 < (1 << W); ++bit2)
        {
            vector<vector<int>> B = C;
            for (int i = 0; i < H; ++i)
            {
                for (int j = 0; j < W; ++j)
                {
                    // cout << ((bit & (1 << i)) > 0) << endl;
                    // cout << ((bit2 & (1 << j)) > 0) << endl;
                    if (((bit & (1 << i)) > 0) || ((bit2 & (1 << j)) > 0))
                    {
                        // print("Hit!");
                        B[i][j] = 0;
                    }
                }
            }

            int temp = 0;
            rep(l, H)
            {
                rep(m, W)
                {
                    temp += B[l][m];
                }
            }

            if (temp == K)
            {
                A++;
            }
        }
    }

    cout << A << endl;
}

Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, L = map(int, input().split())
# 複数行に複数の入力値を取得し、出力する
S = [input() for i in range(N)]
S = sorted(S)
# 出力
# リストSの各要素に対してlen()を取得したリストの各要素がすべてLと一致するか否かの判定
len_list = [s_length == L for s_length in list(map(lambda s: len(s), S))]
S_concat = ""
if all(len_list):
  for i in range(len(S)):
    S_concat+=S[i]
  print(S_concat)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
   int n;
   cin>>n;
   int a[110];
   int b[110];
   int c[110];
   for(int i=0;i<n;i++){
       cin>>a[i];
       
   }
   for(int i=0;i<n;i++){
       cin>>b[i];
   }
   
   int sum_a=0;
   int sum_b=0; 
   for(int i=0;i<n;i++){
       sum_a+=a[i];
       sum_b+=b[i];
   }
  
   for(int i=0;i<n;i++){
       int sum1=0;
       int sum2=0;
       for(int j=0;j<=i;j++){
           sum1+=a[j];
           sum2+=b[j];
       }
       c[i]=sum1+(sum_b-sum2+b[i]);
   }
 
    int max=0;
    for(int i=0;i<n;i++){
        if(max<c[i])max=c[i];
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<P> p(m);
	rep(i, m) cin >> p[i].first >> p[i].second;
	sort(p.begin(), p.end(), [&](const auto& x, const auto& y) {
		return x.second < y.second;
		});
	int ans = 0;
	int prev_b = -inf;
	rep(i, m) {
		if (p[i].first > prev_b) {
			prev_b = p[i].second - 1;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3944
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$a = (int)$input[0];
$b = (int)$input[1];
$c = (int)$input[2];

if (($a === $b && $a !== $c) || ($a === $c && $a !== $b)  || ($b === $c && $a !== $b)) {
	echo 'Yes';
}else{
	echo 'No';
}


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    string s;
    cin >> s;
    int ans = M;
    for (int i = 0; i + 2 < s.length(); ++i) {
        int a = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        ans = min(ans, abs(753 - a));
    }
    cout <<  ans << "\n";
    return 0;
}


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

using namespace std;

bool bingocheck(vector<vector<bool>> bingostatus) {
    int count = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (bingostatus.at(i).at(j)) {
                count++;
            }
        }
        if (count == 3) {
            return true;
        }
        count = 0;
    }

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (bingostatus.at(j).at(i)) {
                count++;
            }
        }
        if (count == 3) {
            return true;
        }
        count = 0;
    }

    for (int i = 0; i < 3; i++) {
        if (bingostatus.at(i).at(i)) {
            count++;
        }
    }
    if (count == 3) {
        return true;
    }
    count = 0;

    for (int i = 0; i < 3; i++) {
        int j = 2 - i;
        if (bingostatus.at(i).at(j)) {
            count++;
        }
    }
    if (count == 3) {
        return true;
    }
    count = 0;

    

    return false;
}

int main() {
    vector<vector<int>> bingocard(3, vector<int> (3));
    vector<vector<bool>> bingostatus(3, vector<bool> (3, false));

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> bingocard.at(i).at(j);
        }
    }

    int n, b;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> b;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if(bingocard.at(j).at(k) == b) {
                    bingostatus.at(j).at(k) = true;
                }
            }
        }
    }

    if (bingocheck(bingostatus)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <math.h>
#include <numeric>
#include <sstream>
#include <unordered_map>
#include <vector>
using namespace std;

int main() {
  int n, x, tmp, sum = 0;
  std::vector<int> v;

  std::cin >> n >> x;

  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    v.push_back(tmp);
  }

  int i;
  for (i = 0; i < v.size(); i++)
  {
	  sum += v[i];
	  if(sum > x){
		  break;
	  }
  }

  cout << i+1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<bitset>

using namespace std;

int main() {
	int n, i, j, x, count, max_money, money;
	int p[100][11];
	unsigned short a, f[100], m;

	cin >> n;

	for (i = 0; i < n; i++) {
		f[i] = 0;
		for (j = 0; j < 10; j++) {
			cin >> x;
			f[i] = f[i] << 1;
			f[i] += x;
		}
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < 11; j++) {
			cin >> x;
			p[i][j] = x;
		}
	}

	a = 0b1111111111;
	money = 0;
	for (i = 0; i < n; i++) {
		count = 0;
		m = a & f[i];
		for (j = 0; j < 10; j++) {
			count += (m >> j) & 1;
		}
		money += p[i][count];
	}
	max_money = money;

	for (a = 0b1111111110; a > 0b0; a--) {
		money = 0;
		for (i = 0; i < n; i++) {
			count = 0;
			m = a & f[i];
			for (j = 0; j < 10; j++) {
				count += (m >> j) & 1;
			}
			money += p[i][count];
		}
		if (max_money < money)
			max_money = money;
	}

	cout << max_money;

	return 0;
}

Measured memory_bytes: 256
def read():
    N, M = map(int, input().strip().split())
    X = map(int, input().strip().split())
    return N, M, X


def solve(N, M, X):
    if N >= M:
        return 0
    else:
        X = sorted(X)
        dX = [X[i + 1] - X[i] for i in range(len(X) - 1)]
        dX = sorted(dX)
        return sum(dX[:M-N])


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
  int ans = a - b;
  if(ans >= 0) cout << "delicious" << endl;
  else if(abs(ans) <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}

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

int main() {
    long long A[100000],answer = 1,max = 1000000000000000000;
    int n,i;
    scanf("%d",&n);
    
    for (i = 0;i < n;i++){
        scanf("%lld",&A[i]);
    }
    
    for (i = 0;i < n;i++){
        if (A[i] == 0){
            printf("0");
            return 0;
        }
    }
        
    for (i = 0;i < n;i++){
        if(max / A[i] < answer){
            answer = -1;
            break;
        }
        answer *= A[i];
    }
    
    printf("%lld\n",answer);
    
    return 0;
}


Measured memory_bytes: 2508
#include <iostream>

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

    if (a > b) {
        std::cout << "a > b" << std::endl;
    } else if (a < b) {
        std::cout << "a < b" << std::endl;
    } else {
        std::cout << "a == b" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1156
import itertools

a, b = map(int, input().split())
k = 50
grid = [['.' if x < k else '#' for _ in range(k * 2)] for x in range(k * 2)]

for x, y in itertools.product(range(0, k, 2), range(0, k * 2, 2)):
    if b == 1: break
    grid[x][y] = '#'
    b -= 1

for x, y in itertools.product(range(k + 1, k * 2, 2), range(0, k * 2, 2)):
    if a == 1: break
    grid[x][y] = '.'
    a -= 1

print(k * 2, k * 2)
for row in grid:
    print(''.join(row))

Measured memory_bytes: 3316
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e9
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a*b%2==0)
        cout<<"Even"<<endl;
    else
        cout<<"Odd"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  v(f80) P(N);
  cin >> P;

  vv(f80) dp(N+1, v(f80)(N+1, 0));
  dp[0][0] = 1;

  rep(i, N) rep(j, N){
    dp[i+1][j] += dp[i][j] * (1-P[i]);
    dp[i+1][j+1] += dp[i][j] * P[i];
  }

  f80 ans = 0;
  rep(i,(N+1)/2, N+1){
    ans += dp[N][i];
  }
  cout << ans << "\n";
}

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

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

int main(){
	char ch;
	while(1){
		scanf("%c",&ch);
		if(ch=='\n'){
			printf("\n");
			break;
		}
		if(islower(ch)) ch=toupper(ch);
		else if(isupper(ch)) ch=tolower(ch);
		cout<<ch;
	}
	return 0;
}

Measured memory_bytes: 3136
#include<iostream>

int main()
{
	int sec, min, hour;
	std::cin >> sec;
	min = sec / 60;
	hour = min / 60;
	min = min % 60;
	sec = sec % 60;
	std::cout << hour << ":" << min << ":" << sec << std::endl;

	return 0;
}

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

int main () {
    int x, n;
    cin >> x >> n;
    if (n == 0) {
        cout << x << endl;
    }
    else {
        vector<int> p(n);
        for (int i = 0; i < n; i++) {
            cin >> p[i];
        }
        sort(p.begin(), p.end());
        int a;
        for (int i = 0; i <= 100; i++) {
            for (int j : {-1, 1}) {
                a = x + i * j;
                if (count(p.begin(), p.end(), a) == 0) {
                    cout << a << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll c[n+1];
  mem(c);
  REP(x,1,111) {
    REP(y,1,111) {
      REP(z,1,111) {
        ll d=x*x+y*y+z*z+x*y+y*z+z*x;
        if(d<=n) c[d]++;
      }
    }
  }
  REP(i,1,n+1) pr(c[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3704
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<math.h>
#include<map>
using namespace std;

#define MST(vis,x) memset(vis,x,sizeof(vis))
#define INF 0x3f3f3f3f
#define ll long long
#define maxn  30000005
int main()
{
    char s1[1000];
    int all,n;
    while(scanf("%d",&n)!=EOF)
    {
        all=1;
        while(n>0)
        {
            int temp=n%10;
            s1[all++]=temp+48;
            n/=10;
        }
        all--;
        int judge=0;
        if(all%2==0)
        {
            int dis=all/2;
            for(int a=1,b=all;a<=dis;a++,b--)
            {
                if(s1[a]!=s1[b])
                {
                    judge=1;
                    break;
                }
            }
        }
        else
        {
            int dis=all/2;
            for(int a=1,b=all;a<=dis;a++,b--)
            {
                if(s1[a]!=s1[b])
                {
                    judge=1;
                    break;
                }
            }
        }
        if(judge)printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int maxn=1e6+10;
int n,c[maxn],st[maxn],to[maxn],nt[maxn],topt,si[maxn],num[maxn];
long long ans[maxn];
inline void add(int x,int y){to[++topt]=y; nt[topt]=st[x]; st[x]=topt;}
inline long long f(int x){return 1ll*x*(x+1)/2;}
void dfs(int x,int fa)
{
	si[x]=1; int k=num[c[x]],p=st[x];
	while (p)
	{
		if (to[p]!=fa) 
		{
			int now=num[c[x]]; dfs(to[p],x); 
			si[x]+=si[to[p]]; now=si[to[p]]-(num[c[x]]-now); ans[c[x]]-=f(now);
		}
		p=nt[p];
	}
	num[c[x]]=k+si[x];
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&c[i]),ans[i]=f(n);
	for (int i=1;i<n;i++) {int x,y; scanf("%d%d",&x,&y); add(x,y); add(y,x);}
	dfs(1,0);
	for (int i=1;i<=n;i++) ans[i]-=f(n-num[i]),printf("%lld\n",ans[i]);
return 0;
}

Measured memory_bytes: 27092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,x,y;
    int i,r,t;
    cin>>n>>k;
   x=n%k;
   y=k-x;
  if(n>=k)
   {

   if(x<=y)
   {
       cout<<x<<endl;
   }
   else
   {
       cout<<y<<endl;
   }
}
   else
   {
       cout<<min(abs(n-k),abs(abs(n-k)-k))<<endl;
   }

}


Measured memory_bytes: 256
m,d=map(int,input().split())
ans=0
if m>=4 and d>=22:
    for i in range(4,m+1):
        for j in range(22,d+1):
            d2=j//10
            d1=j%10
            if d2>=2 and d1>=2 and d2*d1==i:
                ans+=1
print(ans)

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

int main() {
	int n,k;
	int ans = 0,w_sum,b_sum;
	vector<vector<int>> b(2010,vector<int>(2010,0)),w(2010,vector<int>(2010,0));

	cin >> n >> k;
	for (int i = 0;i < n;++i) {
		int x,y;
		char c;
		cin >> x >> y >> c;
		if (c == 'B') b[x%(2*k)+1][y%(2*k)+1]++;
		else w[x%(2*k)+1][y%(2*k)+1]++;
	}

	for (int i = 0;i < 2*k;++i) {
		for (int j = 0;j <= 2*k;++j) {
			w[i+1][j] += w[i][j];
			b[i+1][j] += b[i][j];
		}
	}
	for (int i = 0;i <= 2*k;++i) {
		for (int j = 0;j < 2*k;++j) {
			w[i][j+1] += w[i][j];
			b[i][j+1] += b[i][j];
		}
	}

	for (int i = 0;i < k;++i) {
		for (int j = 0;j < k;++j) {
			w_sum = w[2*k-i][2*k]+w[2*k][2*k-j]+2*w[k-i][2*k-j]+2*w[2*k-i][k-j]-w[k-i][2*k]-w[2*k][k-j]-2*w[2*k-i][2*k-j]-2*w[k-i][k-j];
			b_sum = b[2*k-i][2*k]+b[2*k][2*k-j]+2*b[k-i][2*k-j]+2*b[2*k-i][k-j]-b[k-i][2*k]-b[2*k][k-j]-2*b[2*k-i][2*k-j]-2*b[k-i][k-j];
			ans = max(ans ,max(w_sum+b[2*k][2*k]-b_sum, b_sum+w[2*k][2*k]-w_sum));
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  while (1)  {
    int m, f, r;
    char s;
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }
    if (m == -1 || f == -1) {
      s = 'F';
    }
    else if (m + f >= 80) {
      s = 'A';
    }
    else if (m + f >= 65) {
      s = 'B';
    }
    else if (m + f >= 50) {
      s = 'C';
    }
    else if (m + f >= 30) {
      s = 'D';
      if (r >= 50) {
        s = 'C';
      }
    }
    else {
      s = 'F';
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3068
#include <stdio.h>
#include <math.h>

int main (void) {
    int gold = 0;
    int five_h, five = 0;
    int result = 0;
    
    scanf("%d", &gold);

    five_h = gold / 500;
    
    if (gold % 500 != 0) {
        five = (gold % 500) / 5;
    }

    result = five_h * 1000 + five * 5;
    printf("%d\n", result);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long int ar[1000000];
int main()
{
  long long  int x, y,rem,temp,i,j,total,f=0;
   cin >> x >> y;
    temp=x;
    for(i=0;i<1000000;i++)
    ar[i]=-1;
     i=0;
    while(temp>=1)
    {
        rem=temp%y;
        temp=temp/y;
        ar[i]=rem;
        i++;

    }
    for(j=0;j<i;j++)
    {
         total=ar[j]%10;
            f++;
    }
    cout<<f<<endl;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<double> pvec;
	for (int i = 0; i < n; i++) {
		double t;
		cin >> t;
		double p;
		p = (1 + t) / 2;
		pvec.push_back(p);
		//cout << p << ' ';
	}
	//cout << endl;
	//first ans
	double ans = 0;
	for (int i = 0; i < k; i++) {
		ans += pvec.at(i);
	}
	double st = ans;
	for (int i = 0; i + k < n; i++) {
		st = st - pvec.at(i) + pvec.at(i + k);
		if (ans < st) {
			ans = st;
		}
	}
	printf("%.10f\n", ans);
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll labs(ll v){
	if(v<0)return -v;
	return v;
}

ll t[2];
ll a[2],b[2];

int main(void){
	scanf("%lld%lld",&t[0],&t[1]);
	scanf("%lld%lld",&a[0],&a[1]);
	scanf("%lld%lld",&b[0],&b[1]);
	ll adif=a[0]-b[0];
	ll bdif=a[1]-b[1];
	if(adif<0LL && bdif<0LL){
		printf("0\n");
	}else if(adif>0LL && bdif>0LL){
		printf("0\n");
	}else{
		if(labs(adif*t[0])==labs(bdif*t[1])){
			printf("infinity\n");
		}else{
			ll gdif=labs(labs(adif*t[0])-labs(bdif*t[1]));
			if(labs(adif*t[0])>labs(bdif*t[1])){
				printf("0\n");
			}else{
				ll v1=labs(adif*t[0]);
				ll cnt=(v1/gdif)*2LL+1LL;
				if(v1%gdif==0){
					cnt--;
				}
				//printf("%lld %lld %lld %lld\n",adif,bdif,v1,gdif);
				printf("%lld\n",cnt);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int n, m;
char field[1010][1010];
int d[1010][1010];
int sx=0, sy=0;
int gx=0, gy=0;

void bfs() {
	rep(i, n)rep(j, m)d[i][j] = INF;
	queue<P>que;
	rep(i, n)rep(j, m) {
		if (field[i][j] == '#') {
			d[i][j] = 0; que.push(P(i, j));
		}
	}
	//d[sx][sy] = 0;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		//if (p.first == gx && p.second == gy)break;
		rep(i, 4) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if (0 <= nx && nx < n && 0 <= ny && ny < m && /*field[nx][ny] != '#' &&*/ d[nx][ny] == INF) {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	rep(i, n)rep(j, m)cin >> field[i][j];
	bfs();
	int ans = 0;
	rep(i, n)rep(j, m) {
		chmax(ans, d[i][j]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 25652
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#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() {
  string c;
  cin >> c;
  c[0]++;
  cout << c << endl;
}


Measured memory_bytes: 256