akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int h,w;
char s[401][401];
int f[401][401];
 
struct masu{
    int i,j;
    char color;
};
 
 queue<masu> st;
 
    int mi[] = {1,-1,0,0};
    int mj[] = {0,0,1,-1};
 
 
 
int main(){
    cin >> h >> w;
    for(int i = 0; i < h; i++)  cin >> s[i];
 
    masu start;
 
    ll ans = 0;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++)  f[i][j]=0;
    }
 
    ll suma,sumb;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(f[i][j])  continue;
            start.i = i;
            start.j = j;
            start.color = s[i][j];
    
            st.push(start);
  
            suma = sumb = 0;

    while(!st.empty()){
        masu mem = st.front();
        st.pop();
        masu ne;
        if(f[mem.i][mem.j]) continue;
        f[mem.i][mem.j] = 1;
        if(mem.color == '.')    ++suma;
        else    ++sumb;
 

        for(int ii = 0; ii < 4; ii++){
            int ni = mem.i+mi[ii];
            int nj = mem.j+mj[ii];
 
            if(ni < h && ni >= 0 && nj < w && nj >= 0){
                if(s[ni][nj] != mem.color){
                    ne.i = ni;
                    ne.j = nj;
                    ne.color = s[ni][nj];
                    st.push(ne);
                }
            }
        }
    }
    ans += suma*sumb;
        }
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
    string a;
    int kari,n1;
    cin >> a;
    n1 = stoi(a);
    int n = a.size();
    REP(i,n){
        char b = a[i];
        kari += ctoi(b);
    }
    (n1%kari == 0)? cout << "Yes" : cout << "No";
    return 0;
}

Measured memory_bytes: 256
class TreeNode():

  def __init__(self, val, parent=-1):
    self.val = val
    self.children = []
    self.parent_val = parent
    self.depth = None

  def node_type(self):
    if self.depth == 0:
      return "root"
    elif len(self.children) > 0:
      return "internal node"
    else:
      return "leaf"

  def children_values(self):
    return [ c.val for c in self.children ]

  def __str__(self):
    return "node {0}: parent = {1}, depth = {2}, {3}, {4}".format(str(self.val), str(self.parent_val), str(self.depth), self.node_type(), self.children_values())

def calc_depths(node, level):
  if node is None: return 
  node.depth = level
  for ch in node.children:
    calc_depths(ch, level+1)

num = int(input())
nodes = {}

for i in range(num):
  ins = list(map(int, input().split()))
  val = ins[0]

  if nodes.get(ins[0]) is None:
    nodes[val] = TreeNode(val)

  n = nodes[val]
  if ins[1] > 0:
    for j in ins[2:]:
      nodes.setdefault(j, TreeNode(j, n.val))
      n.children.append(nodes[j])
      nodes[j].parent_val = n.val

parent = [node for node in nodes.values() if node.parent_val == -1][0]
calc_depths(parent, 0)
sort_nodes = sorted(nodes.items(), key=lambda x:x[0] )

for _, node in sort_nodes:
  print(node)


Measured memory_bytes: 47492
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<algorithm>
#define f first
#define s second
#define pb push_back
using namespace std;
int const INF=0x3f3f3f3f;
int const maxn=105;
typedef long long ll;
typedef pair<int,int>P;
char s[maxn][maxn];
int num[maxn][maxn];
bool vis[maxn][maxn];
int mv[2][2]={{1,0},{0,1}};
queue<P>que;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%d\n",(n-1)*n/2+(m-1)*m/2);
}


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

using namespace std;

#define long long long
#define INF ((long) 1e18)
#define MOD ((long) 1e9 + 7)
#define mll map<long, long>
#define pll pair<long, long>
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (i, 0, v.size()) cout << v[i] << " "; cout << "\n";

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

  long n;
  cin >> n;

  vector<long> a(n);
  for (auto &x : a) cin >> x;

  long total = 0;
  FOR (i, 1, n) {
    if (a[i] == a[i-1]) {
      total++;
      i++;
    }
  }
  printf("%lld\n", total);
}


Measured memory_bytes: 768
from collections import deque
n, q = map(int, input().split())
deq = deque()
for i in range(n):
    name, time = input().split(); time = int(time)
    deq.append((time, name))
ans = []
cur = 0
while deq:
    time, name = deq.popleft()
    if time <= q:
        cur += time
        ans.append("%s %d" % (name, cur))
    else:
        cur += q
        deq.append((time-q, name))
print(*ans, sep="\n")

Measured memory_bytes: 15480
try:
  n = int(input())
  if(n>=400 and n<=599):
    print(8)
  elif(n>=600 and n<=799):
    print(7)
  elif(n>=800 and n<=999):
    print(6)
  elif(n>=1000 and n<=1199):
    print(5)
  elif(n>=1200 and n<=1399):
    print(4)
  elif(n>=1400 and n<=1599):
    print(3)
  elif(n>=1600 and n<=1799):
    print(2)
  elif(n>=1800 and n<=1999):
    print(1)
except EOFError:
  print(" ")

Measured memory_bytes: 9212
import java.util.Scanner;

class Main {

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

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            max = Math.max(max, a[i]);
        }
        countingSort(a, b, max);
        printArray(b);
    }

    private static void countingSort(int[] a, int[] b, int k) {
        int[] c = new int[k + 1];
        for (int e : a) {
            c[e]++;
        }
        for (int i = 1; i < k + 1; i++) {
            c[i] = c[i] + c[i - 1];
        }
        for (int i = a.length - 1; i >= 0; i--) {
            c[a[i]]--;
            b[c[a[i]]] = a[i];
        }
    }

    private static void printArray(int/*or long*/[] array) {
        if (array.length == 0) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < array.length; i++) {
            sb.append(array[i]);
            if (i != array.length - 1) {
                sb.append(" ");
            }
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 516184
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>

using namespace std;

const int MOD = 200003;

const double PI = acos(-1.0);
using P = complex<double>;

void dft(vector<P>& v, int inv){
    const int n = v.size();
    int rev = 0;
    for(int i=1;i<n-1;i++){
        for(int j=n/2;j>(rev^=j);j/=2);
        if(i < rev) swap(v[i], v[rev]);
    }
    for(int m=1;m<n;m*=2){
        P cur = P(1, 0), rot = P(cos(PI/m), inv * sin(PI/m));
        for(int i=0;i<m;i++){
            for(int j=i;j<n;j+=2*m){
                P p = v[j];
                P q = v[j+m] * cur;
                v[j]   = p + q;
                v[j+m] = p - q;
            }
            cur *= rot;
        }
    }
}

vector<long long> convolution(const vector<int>& a, const vector<int>& b){
    int _n = a.size() + b.size();
    int n = 1;
    while(n < _n) n *= 2;
    vector<P> na(n, P(0, 0)), nb(n, P(0, 0));
    for(int i=0;i<a.size();i++) na[i].real(a[i]);
    for(int i=0;i<b.size();i++) nb[i].real(b[i]);
    dft(na, 1);
    dft(nb, 1);
    vector<P> ab(n);
    for(int i=0;i<n;i++) ab[i] = na[i] * nb[i];
    dft(ab, -1);
    vector<long long> res(n);
    for(int i=0;i<n;i++) res[i] = (ab[i].real()/n + 0.5);
    return res;
}

int main(){
    int N; cin >> N;
    vector<int> p(MOD, 0);
    int m = 1;
    for(int i=0;i<MOD-1;i++){
        p[m] = i;
        m = 2*m%MOD;
    }
    vector<int> cnt(MOD-1, 0);
    long long res = 0;
    for(int i=0;i<N;i++){
        long long A; cin >> A;
        if(A == 0) continue;
        res -= A*A%MOD;
        cnt[p[A]]++;
    }
    auto cv = convolution(cnt, cnt);
    m = 1;
    for(int i=0;i<cv.size();i++){
        res += m * cv[i];
        m = 2*m%MOD;
    }
    cout << res/2 << endl;
}

Measured memory_bytes: 34000
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${TYO>cuR480@qAH2g<SksD5J4|Tok8~W85Fi=^lxC{7Uq74hU0=X{&(AMTO53&2Xd%xxXSJz7>bCE!gI2XS<-(vOg8X%LXU;vhylGT3lX}ZdrAE@IQs{2RE9GR(EkmL<t_%ZNs1oq^`kGMW(1(Ga6!i>F7X}`H7r5y^)s+#F<9Kdtv{BTL6HF9?=_=i%VE`DDGzbO~GDv*+Uh77|Wh7Au1V>|0yp(l`$OpW=ry#82-wQ%&5*=L<I3nkS91mLMeyjnxoC_Mo3uVbQ@U1`8@2@<^5lK3Aat{slZ0e;f-VC71YKCFZGT@9(su?&&4({63n|X#@)0TYNZqu@}piynS!l;c`8{%8;w6tA`FP1qj<+5Xskk~=E1`badh}FFHdOq<Z@*POwP?JBF$%S|<lLNOc5Aw%s(BC5>_v-Un{8mi7T;8d_YO*KO;Xw>(82E=B9iEFXbHIzhll}vB`qr2")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 9640
from heapq import heappop, heappush
n = int(input())
p = [int(x) for x in input().split()]


class SegmentTree:  # 0-indexed
    def __init__(self, array, operation=min, identity=10**30):
        self.identity = identity
        self.n = len(array)
        self.N = 1 << (self.n - 1).bit_length()
        self.tree = [self.identity] * 2 * self.N
        self.opr = operation
        for i in range(self.n):
            self.tree[i+self.N-1] = array[i]
        for i in range(self.N-2, -1, -1):
            self.tree[i] = self.opr(self.tree[2*i+1], self.tree[2*i+2])

    def values(self):
        return self.tree[self.N-1:]

    def update(self, k, x):
        k += self.N-1
        self.tree[k] = x
        while k+1:
            k = (k-1)//2
            self.tree[k] = self.opr(self.tree[k*2+1], self.tree[k*2+2])

    def query(self, p, q):  # [p,q)
        if q <= p:
            print("Oops!  That was no valid number.  Try again...")
            exit()
        p += self.N-1
        q += self.N-2
        res = self.identity
        while q-p > 1:
            if p & 1 == 0:
                res = self.opr(res, self.tree[p])
            if q & 1 == 1:
                res = self.opr(res, self.tree[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.opr(res, self.tree[p])
        else:
            res = self.opr(self.opr(res, self.tree[p]), self.tree[q])
        return res


ind = [0]*(n+1)
Odd = SegmentTree([10**30]*n)
Even = SegmentTree([10**30]*n)

for i in range(n):
    ind[p[i]] = i
    if i % 2 == 0:
        Even.update(i, p[i])
    else:
        Odd.update(i, p[i])

cand = []
heappush(cand, (Even.query(0, n), 0, n, True))

q = []
while len(q) < n:
    first, l, r, is_even = heappop(cand)
    if is_even:
        second = Odd.query(ind[first]+1, r)
        q.extend([first, second])
        if l < ind[first]:
            heappush(cand, (Even.query(l, ind[first]), l, ind[first], True))
        if ind[first] + 1 < ind[second]:
            heappush(
                cand, (Odd.query(ind[first]+1, ind[second]), ind[first]+1, ind[second], False))
        if ind[second]+1 < r:
            heappush(
                cand, (Even.query(ind[second], r), ind[second]+1, r, True))
    else:
        second = Even.query(ind[first]+1, r)
        q.extend([first, second])
        if l < ind[first]:
            heappush(cand, (Odd.query(l, ind[first]), l, ind[first], False))
        if ind[first] + 1 < ind[second]:
            heappush(
                cand, (Even.query(ind[first]+1, ind[second]), ind[first]+1, ind[second], True))
        if ind[second]+1 < r:
            heappush(
                cand, (Odd.query(ind[second], r), ind[second]+1, r, False))

print(*q)


Measured memory_bytes: 151484
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int t[100001];
int sum[100001];

int isPrime(int n){
    if(n==1){
        return 0;
    }
    if(n==2||n==3){
        return 1;
    }
    if(n%2==0||n%3==0){
        return 0;
    }
    for(int i=5;i*i<=n;i+=2){
        if(i%3==0){
            continue;
        }
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

void init(){
    rep(i, 1, 100001){
        t[i] = -1;
    }
    t[0] = 0;
    t[1] = 0;
    for(int i=2; i<=100000; i++){
        t[i] = isPrime(i);
    }
    sum[0] = 0;
    rep(i, 1, 100001){
        int buf = 0;
        if(i%2==1 && t[i]==1 && t[(i+1)/2]==1){
            buf = 1;
        }
        sum[i] = sum[i-1] + buf;
    }
    return;
}

int main(){
    init();
    int q;
    scanf("%d", &q);
    int ans[q];
    rep(i, 0, q){
        int l ,r;
        scanf("%d %d", &l, &r);
        ans[i] = sum[r] - sum[l-1];
    }
    rep(i, 0, q){
        printf("%d\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  for(int i=0;i<5;i++)cout<<s[i];
  cout<<" ";
  for(int i=6;i<13;i++)cout<<s[i];
  cout<<" ";
  for(int i=14;i<19;i++)cout<<s[i];
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<limits.h>

#define int long long

using namespace std;

signed main(void) {
	int N, W;
	cin >> N >> W;

	vector<vector<int>> value(4);
	for (int j = 0; j < 4; j++) value[j].push_back(0);
	int w;
	cin >> w;

	int v;
	cin >> v;
	value[0].push_back(v);
	

	for (int i = 1; i < N; i++) {
		int w_temp, v_temp;
		cin >> w_temp >> v_temp;
		if (w_temp - w < 0 || w_temp - w > 3) {
			cout << "は？" << endl;
			exit(0);
		}
		value[w_temp - w].push_back(v_temp);
	}

	for (int i = 0; i <= 3; i++) {
		sort(value[i].rbegin(), value[i].rend() - 1);
		for (int j = 1; j < value[i].size(); j++){
			value[i][j] = value[i][j] + value[i][j - 1];
			//cout << value[i][j] << " ";
		}
		//cout << endl;
	}

	int ans = 0;
	for(int i = 0; i < value[0].size(); i++)
		for(int j = 0; j < value[1].size(); j++)
			for (int k = 0; k < value[2].size(); k++)
				for (int l = 0; l < value[3].size(); l++) {
					int value_sum = 0, wt;
					wt = w * i + (w + 1) * j + (w + 2) * k + (w + 3) * l;
					//cout << i << " " << j << " " << k << " " << l << "  ";
					//cout << wt << endl;
					if (wt > W) {
						l = INT_MAX;
						continue;
					}
					value_sum += value[0][i];
					value_sum += value[1][j];
					value_sum += value[2][k];
					value_sum += value[3][l];
					ans = max(ans, value_sum);
				}

	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    string s; cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy\n";
    } else if (s == "Cloudy") {
        cout << "Rainy\n";
    } else if (s == "Rainy") {
        cout << "Sunny\n";
    }
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        String[] str=new String[N];
        
        for(int i=0;i<N;i++){
            str[i]=sc.next();
        }
        
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                if(str[i].equals(str[j])){
                    System.out.println("No");
                    return;
                }
            }
        }
        
        String bfo=str[0];
        int len=bfo.length();
        char last=bfo.charAt(len-1);
        
        for(int i=1;i<N;i++){
            bfo=str[i];
            if(bfo.charAt(0)!=last){
                System.out.println("No");
                return;
            }
            len=bfo.length();
            last=bfo.charAt(len-1);
        }
        
        System.out.println("Yes");
    }
}


Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;

namespace AtCoderSolve
{
    class Solve
    {

        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static int H, W;
        static string[] a;
        
        //static long[] A, B;


        public static void Input()
        {
            var cin = new Scanner();
            var input = cin.SplitReader();
            H = input[0];
            W = input[1];
            a = new string[H];
            for(var i = 0; i < H; i++)
            {
                a[i] = Console.ReadLine();
            }
        }


        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            long[,] dp = new long[H, W];
            bool ok = true;
            for(var i = 0; i < W; i++)
            {
                if (a[0][i] == '#')
                {
                    ok = false;
                }
                dp[0, i] = ok ? 1 : 0;
            }

            for(var i = 1; i < H; i++)
            {
                for(var j = 0; j < W; j++)
                {
                    if (j == 0)
                    {
                        dp[i, j] = a[i][j] == '.' ? dp[i - 1, j] : 0;
                    }
                    else
                    {
                        dp[i, j] = a[i][j] == '.' ? (dp[i - 1, j] + dp[i, j - 1]) % mod : 0;
                    }
                }
            }

            Console.WriteLine(dp[H - 1, W - 1]);

            //Console.Out.Flush();
        }
    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
}






Measured memory_bytes: 29276
N=gets.to_i
b=N.times.map{gets.split.map(&:to_i)}.transpose
dp=Array.new(N){Array.new(3,-1)}
dp[0][0]=b[0][0]
dp[0][1]=b[1][0]
dp[0][2]=b[2][0]
for i in 1..N-1#date
    for j in 0..2#todaychice
        for k in 0..2#yesterdaychoice
            if j==k
                next
            end
            l=dp[i-1][k]+b[j][i]
            dp[i][j]=(l > dp[i][j] ? l : dp[i][j])
        end
    end
end
puts [dp[N-1][0],dp[N-1][1],dp[N-1][2]].max

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    string s;
    cin >> s;
    bool f = false;
    for (int i = 0; i < s.size(); i++) {
        f += (i % 2 && s[i] == 'R');
        f += (!(i % 2) && s[i] == 'L');
        if (f) {
            return cout << "No" << endl, 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s1, s2, s3;
int main() {
	while (cin >> s1, s1 != "0") {
		cin >> s2 >> s3;
		if (s1[0] != '+' && s1[0] == s1[1] && s1[1] == s1[2])cout << s1[0] << endl;
		else if (s2[0] != '+' && s2[0] == s2[1] && s2[1] == s2[2])cout << s2[0] << endl;
		else if (s3[0] != '+' && s3[0] == s3[1] && s3[1] == s3[2])cout << s3[0] << endl;
		else if (s1[0] != '+' && s1[0] == s2[0] && s2[0] == s3[0])cout << s1[0] << endl;
		else if (s1[1] != '+' && s1[1] == s2[1] && s2[1] == s3[1])cout << s1[1] << endl;
		else if (s1[2] != '+' && s1[2] == s2[2] && s2[2] == s3[2])cout << s1[2] << endl;
		else if (s1[0] != '+' && s1[0] == s2[1] && s2[1] == s3[2])cout << s1[0] << endl;
		else if (s1[2] != '+' && s1[2] == s2[1] && s2[1] == s3[0])cout << s1[2] << endl;
		else cout << "NA\n";
	}
}


Measured memory_bytes: 3236
import io
import sys

MOD = 10 ** 9 + 7


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
12 3 7
'''


def MAIN():
  # T_IN()
  A()


def A():
  a, b, c = IN_L_I()
  w = c - (a - b)
  if w < 0:
    w = 0

  print(w)

  return None


def B():
  return None


def C():
  return None


MAIN()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
enum { OP_VALUE, OP_MAX, OP_MIN };
struct Node {
    int op = OP_VALUE, valmin = 0, valmax = 99;
    Node *lhs = nullptr, *rhs = nullptr, *par = nullptr;
};
bool propagate(Node *node) {
    if (node->op == OP_MAX) {
        if (node->lhs && node->rhs) {
            node->valmin = max(node->lhs->valmin, node->rhs->valmin);
            node->valmax = max(node->lhs->valmax, node->rhs->valmax);
        } else if (node->lhs) {
            node->valmin = node->lhs->valmin;
            node->valmax = 99;
        }
    }
    if (node->op == OP_MIN) {
        if (node->lhs && node->rhs) {
            node->valmin = min(node->lhs->valmin, node->rhs->valmin);
            node->valmax = min(node->lhs->valmax, node->rhs->valmax);
        } else if (node->lhs) {
            node->valmin = 0;
            node->valmax = node->lhs->valmax;
        }
    }
    if (node->par == nullptr) {
        return node->valmin == node->valmax;
    } else {
        return propagate(node->par);
    }
}
struct Input {
    string str;
    int curr, used;
    Input(const string &s) : str(s), curr(0), used(0) {}
    char peek() {
        used = max(used, curr + 1);
        return str[curr];
    }
    char get() {
        char c = peek();
        curr += 1;
        return c;
    }
    void eat(char expected) {
        if (get() != expected) exit(1);
    }
};
bool expr(Input &in, Node *node) {
    char c = in.peek();
    if (c == '^' || c == '_') {
        node->op = (c == '^' ? OP_MAX : OP_MIN);
        in.get();
        in.eat('(');
        node->lhs = new Node;
        node->lhs->par = node;
        if (expr(in, node->lhs)) return true;
        in.eat(',');
        node->rhs = new Node;
        node->rhs->par = node;
        if (expr(in, node->rhs)) return true;
        in.eat(')');
    } else {
        node->op = OP_VALUE;
        if (in.peek() == '0') {
            in.get();
            node->valmin = node->valmax = 0;
            if (propagate(node)) return true;
            return false;
        }
        int n = in.get() - '0';
        node->valmin = n;
        node->valmax = n * 10 + 9;
        if (propagate(node)) return true;
        if (!isdigit(in.peek())) {
            node->valmax = node->valmin;
            if (propagate(node)) return true;
        } else {
            int m = in.get() - '0';
            node->valmin = node->valmax = n * 10 + m;
            if (propagate(node)) return true;
        }
    }
    return false;
}
pair<int, int> solve(const string &s) {
    Input in(s);
    Node *root = new Node;
    expr(in, root);
    return { root->valmin, in.used };
}
int main() {
    int Q; cin >> Q;
    while (Q--) {
        string s; cin >> s;
        auto p = solve(s);
        cout << p.first << ' ' << p.second << '\n';
    }
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>

using namespace std;

int main(){
    int n, count, flag, A[100];
    count = 0;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    
    flag = 1;
    while(flag){
        flag = 0;
        for(int j = n - 1; j > 0; j--){
            if(A[j] < A[j-1]){
                int temp;
                temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
                flag = 1;
                count++;
            }
        }
    }
    
    cout << A[0];
    for(int i = 1; i < n; i++){
        cout << " " << A[i];
    }
    cout << endl << count << endl;
    
    return 0;
    
}



Measured memory_bytes: 3112
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

#define MOD 1000000007

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

  vll lst(N);
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    sum += tmp;
    lst[i] = tmp;
  }

  ll cand1 = sum / N;
  ll cand2 = cand1 + 1;
  ll cost1 = 0;
  ll cost2 = 0;
  for (int i = 0; i < N; i++) {
    cost1 += (cand1 - lst[i]) * (cand1 - lst[i]);
    cost2 += (cand2 - lst[i]) * (cand2 - lst[i]);
  }
  ll ans = min(cost1, cost2);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

N=int(input())
amat=[[-1]]
for i in range(N):
  alist=list(map(int,input().split()))
  amat.append(list(reversed(alist)))
  
#print(amat)
cleared_num=0
new_search_index=set(range(1,N+1))
for answer in range(1,N**3):
  matched_set=set()
  unchanged=True

  search_index=new_search_index;
  new_search_index=set()
  for i in search_index:
    if i in matched_set:
      continue
      
    ai_next = amat[i][-1]
    if amat[ai_next][-1]==i and not ai_next in matched_set:
      #print(i,ai_next,answer)
      matched_set.add(amat[i].pop())
      matched_set.add(amat[ai_next].pop())
      if len(amat[i])==0:
        cleared_num+=1
      else:
        new_search_index.add(i)  
      if len(amat[ai_next])==0:
        cleared_num+=1
      else:
        new_search_index.add(ai_next)
      unchanged=False
      
  if unchanged:
    print(-1)
    sys.exit()
  elif cleared_num==N:
    print(answer)
    sys.exit()

Measured memory_bytes: 62300
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<list>
using namespace std;
#define MAXN 100100
#define eps 1e-7
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define cr clear()
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fre freopen
#define pi acos(-1.0)
#define inf 1e9+9
#define Vector Point
const int Mod=1e9+7;
const long long Maxx=2e18;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
int a[MAXN];
int n;
void solve(){
	cin>>n;
	int maxx=0;
	ll ans=0;
	For(i,1,n) scanf("%d",&a[i]),maxx=max(a[i],maxx),ans+=a[i]-1;
	cout<<ans<<endl;
	
}
int main(){
//  fre("in.txt","r",stdin);
    int t=0;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #define lli long long int
    using namespace std;
    int gcd(int a, int b) 
    { 
        if (b == 0) 
            return a; 
        return gcd(b, a % b);  
          
    } 
    int main(){
      	int a, b;
      	cin>>a>>b;
      	int r = gcd(a, b);
      	lli e = a *1LL * b;
      	e  = e / (r*1LL);
      	cout<<e<<endl;
      	return 0;
    }

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

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

	vector<vector<int>> abc(n+1, vector<int>(3));
	vector<vector<long long>> dp(n+1,vector<long long>(3,0));

	for(int i=0; i<n; i++) for(int j=0; j<3; j++) cin >> abc[i][j];

	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				if(j==k) continue;
				dp[i+1][k] = max(dp[i+1][k],dp[i][j]+abc[i][k]);
			}
		}
	}

	long long ans = 0;
	for(int i=0; i<3; i++) ans = max(ans,dp[n][i]);
	cout << ans << endl;
}

Measured memory_bytes: 14096
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,m = LI()
    e = collections.defaultdict(set)
    k = []
    for _ in range(m):
        a,b = LI_()
        e[a].add(b)
        e[b].add(a)
        k.append((a,b))

    # メソッドのみ版
    def search(s):
        d = [inf] * n
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            v[u] = True

            for uv in e[u]:
                ud = 1
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    heapq.heappush(q, (vd, uv))

        return d

    r = 0
    for a,b in k:
        e[a].remove(b)
        e[b].remove(a)
        d = search(0)
        if max(d) == inf:
            r += 1
        e[a].add(b)
        e[b].add(a)

    return r


print(main())




Measured memory_bytes: 6832
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

typedef long long ll;

int main(void) {
  ll nS, nC;
  cin >> nS >> nC;
  ll res = min(nS, nC/2);
  nS -= res;
  nC -= res*2;
  res += nC / 4;
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstring>
#include <string>
#include <sstream>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

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

int main(void){
    ll dp[21][100] = { 0 };
    int n, a; cin >> n;

    rep(i, n - 1){
        cin >> a;
        if(!i) dp[a][i] = 1;
        else rep(j, 21) dp[j][i] += (0 <= j - a ? dp[j - a][i - 1]:0) + (j + a <= 20 ? dp[j + a][i - 1]:0);
    }

    cin >> a;
    cout << dp[a][n - 2] << endl;

    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  if ((N-1)*(N-2)/2 < K) {
    cout << -1 << endl;
    return 0;
  }
  int M = (N-1) + (N-1)*(N-2)/2 - K; 
  cout << M << endl;
  for (int i=1;i<=N-1;i++){
    cout << N << " " << i << endl;
  }
  int num = 0;
  for (int i=1;i<=N-1;i++){
    for (int j=1;j<i;j++){
      if (num + N - 1 >= M) return 0;
      cout << i << " " << j << endl;
      num++;
    }
  }

  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 a = sc.nextInt();
		int b = sc.nextInt();
		int n = b - a;
		System.out.println(n * (n + 1) / 2 - b);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include<iostream>
#include<cmath>


int main() {
	int n; std::cin >> n;
	std::string str; std::cin >> str;
	if (n % 2 == 0) {
		bool can_make = true;
		for (auto i = 0; i < n / 2; ++i) {
			if (str[i] != str[i + n / 2]) {
				can_make = false;
				break;
			}
		}
		if (can_make) {
			std::cout << "Yes\n";
		}
		else {
			std::cout << "No\n";
		}
	}
	else {
		std::cout << "No\n";
	}
}


Measured memory_bytes: 888
#include<stdio.h>
int main(){
  char s[11];
  int i,l,yj=0,yd=0,k=0,yk=0;
  scanf("%s",s);
  for(i=0;s[i]!='\0';i++);
  l=i;
  if(s[0]!='A')yj=810;
  for(i=2;i<=l-2;i++){
    if(s[i]=='C'&&k==0)k=i;
    else if(s[i]=='C'&&k!=0)yk=810;
    }
    if(k==0)yk=810;
    for(i=1;i<l;i++){
      if(i==k)continue;
      if(s[i]<'a'||'z'<s[i])yd=810;
    }
  if(yj!=810&&yd!=810&&yk!=810)printf("AC");
  else printf("WA");
  return 0;
  
}

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

int main(){
    int n,y;
    cin>>n>>y;
    int X,Y,Z;
    int temp=y/1000-n;
    bool flag=false;
    for(int x=0;x<=2000;x++){
        for(int y=0;y<=2000;y++){
             if(9*x+4*y==temp&&n-x-y>=0){
                X=x,Y=y,Z=n-x-y;
                flag=true;
                break;
            }
        }
    }
    if(flag){
        cout<<X<<" "<<Y<<" "<<Z<<"\n";
    }else{
        cout<<"-1 -1 -1"<<"\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <utility>

int bubble_sort(std::vector<int>& arr)
{
  using std::swap;
  int swap_num = 0;
  for (int i = 0; i < arr.size(); i++) {
    for (int j = arr.size() - 1; j > i; j--) {
      if (arr[j] < arr[j - 1]) {
        swap(arr[j], arr[j - 1]);
        swap_num++;
      }
    }
  }
  return swap_num;
}

int main()
{
  int N;
  std::vector<int> arr;

  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int temp;
    scanf("%d", &temp);
    arr.push_back(temp);
  }

  int n = bubble_sort(arr);

  for (int i = 0; i < arr.size(); i++) {
    if (i == arr.size() - 1) {
      printf("%d\n", arr[i]);
    }
    else {
      printf("%d ", arr[i]);
    }
  }
  printf("%d\n", n);

  return 0;
}



Measured memory_bytes: 2764
//By Vlgd
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	Point operator + (Point p){return Point(x+p.x,y+p.y);}
	Point operator - (Point p){return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);}
	Point operator / (double a){return Point(x/a,y/a);}
	double abs() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;
struct Segment {Point p1,p2;};
typedef Segment Line;
class Circle{
public:
	Point c;
	double r;
	Circle(Point c=Point(),double r=0.0): c(c),r(r){}
};
double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}
Point project(Segment s,Point p){
	Vector base=s.p2-s.p1,a=p-s.p1;
	double r=dot(base,a)/base.norm();
	return s.p1+base*r;
	
}
pair<Point,Point> CP(Circle c,Line l){
	Point x=project(l,c.c);
	Vector pr=x-c.c,base=l.p2-l.p1;
	Vector e=(l.p1-l.p2)/base.abs();
	double d=sqrt(c.r*c.r - pr.norm());
	return make_pair(x+e*d, x-e*d);
}
main(){
	int cx,cy,r;
	scanf("%d%d%d",&cx,&cy,&r);
	Point p(cx,cy);
	Circle c(p,r);
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x1,x2,y1,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		Line l;
		l.p1=Point(x1,y1),l.p2=Point(x2,y2);
		pair<Point,Point>ans=CP(c,l);
		Point a=ans.first;
		Point b=ans.second;
		if(b<a) swap(a,b);
		printf("%.8lf %.8lf %.8lf %.8lf\n",a.x,a.y,b.x,b.y);
	}
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto &ai:A){
    cin >> ai; ai--;
  }

  vector<ll> n(N);
  for(auto ai:A){
    n[ai]++;
  }

  ll sum=0;
  for(auto ni:n){
    sum+=ni*(ni-1)/2;
  }

  for(auto ai:A){
    cout << sum-n[ai]*(n[ai]-1)/2+(n[ai]-1)*(n[ai]-2)/2 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <cassert>
using namespace std;
int s[10];
int c[10];
int main(){
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    cin >> s[i];
    cin >> c[i];
  }
  //先頭チェック
  if (N > 1){
    for (int i = 0; i < M; i++){
      if (s[i] == 1 && c[i] == 0){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  //重複チェック
  for (int i = 0; i < M; i++){
    for (int j = 0; j < M; j++){
      if (s[i] == s[j] && s[i] != -1 && i != j){
        if (c[i] != c[j]){
          cout << -1 << endl;
          return 0;
        } else {
          s[i] = -1;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++){
    if (s[i] == -1) continue;
    ans += c[i] * pow(10, N - s[i]);
  }
  if (ans == 0 && N == 1){
    cout << 0 << endl;
    return 0;
  }
  if (ans < pow(10, N - 1)){
    ans += pow(10, N - 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n + 1);
	vector<ll> b(n + 1,0);

	//Aにとんでもない値が入っているときのための初期化
	rep(i, n)
	{
		cin >> a[i];
		b[max(0LL, i - a[i])]++;
		b[min(n, i + a[i] + 1)]--;
	}
	rep(i, n)
	{
		b[i + 1] += b[i];
	}

	k--;
	if (k == 0)
	{
		cout << b[0];
		rep(i, n-1)
		{
			cout << " " << b[i + 1];
		}
		cout << endl;
		ret;
	}

	rep(i, n)
	{
		a[i] = b[i];
		b[i] = 0;
	}
	b[n] = 0;

	bool key =false;

	while (!key)
	{
		key = true;
		rep(i, n)
		{
			b[max(0LL, i - a[i])]++;
			b[min(n, i + a[i] + 1)]--;
		}
		rep(i, n)
		{
			b[i + 1] += b[i];
			a[i] = b[i];
			b[i] = 0;
			if (a[i] != n)
				key = false;
		}
		b[n] = 0;
		k--;
		if (k == 0)
		{
			cout << a[0];
			rep(i, n - 1)
			{
				cout << " " << a[i + 1];
			}
			cout << endl;
			ret;
		}
	}

	cout << a[0];
	rep(i, n - 1)
	{
		cout << " " << a[i + 1];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 6368
import itertools

N, M, Q = map(int, input().split())

a, b, c, d = [0] * Q, [0] * Q, [0] * Q, [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

M_list = [_ for _ in range(1, M+1)]
A_list = []
for pair in itertools.combinations_with_replacement(M_list, N):
    A_list.append(pair)

sum_list = []
for i in range(len(A_list)):
    sum_list_ = []
    for j in range(Q):
        if A_list[i][b[j]-1] - A_list[i][a[j]-1] == c[j]:
            sum_list_.append(d[j])
    sum_list.append(sum(sum_list_))

print(max(sum_list))

Measured memory_bytes: 24980
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n;
llong a[200005];

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

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

    llong ans = 1ll << 60ll;
    for (int i = 0; i < n - 1; i++) {
        llong f = a[i];
        llong s = a[n - 1] - a[i];

        ans = min(ans, abs(f - s));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+5,mod=1e9+7;
ll f[N],invf[N];
ll C(int n,int m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
ll c1,c2,r1,r2;
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
ll g(ll x,ll y)
{
    return C(x+1+y,x+1);
}
int main()
{
    f[0]=f[1]=invf[0]=invf[1]=1;
    for(int i=2;i<N;i++) f[i]=f[i-1]*i%mod,invf[i]=(mod-mod/i)*invf[mod%i]%mod;
    for(int i=2;i<N;i++) invf[i]=invf[i-1]*invf[i]%mod;
    scanf("%lld%lld%lld%lld",&r1,&c1,&r2,&c2);
    ll ans=0;
    for(int i=r1;i<=r2;i++)
        ans=(ans+g(i,c2)-g(i,c1-1))%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


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

int main () {
	int e;
	while (cin >> e, e) {
		int result = 0x7ffffff;
		for (int z = 0; z * z * z <= e; z++) {
			int y = sqrt(e - z * z * z);
			int x = e - z * z * z - y * y;
			result = min(x + y + z, result);
		}
		cout << result << endl;
	}
	return 0;
}

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

void main()
{
    auto N = readln.chomp.to!int;
    auto as = new int[](N);
    foreach (i; 0..N) as[i] = readln.chomp.to!int;
    sort!"a > b"(as);

    uint x;
    foreach (i; 1..N) if ((as[i-1] - as[i]) % 2) {
        x ^= i;
    }
    if (as[$-1] % 2) x ^= N;
    writeln(x ? "first" : "second");
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, k, r, s, p; cin >> n >> k >> r >> s >> p;
	string t; cin >> t;
	int ans = 0;
	rep(i, n){
		if(i >= k && t[i] == t[i - k]) t[i] = '.';
		else ans += t[i] == 's' ? r : t[i] == 'r' ? p : s;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)
	ll y=1;
int digit(ll n){
	ll x=10,k=0;
	while(n/x>0){
		x=x*10;
		k++;
	}
	return k;
} 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
	    ll n,i,j,k,l,d=0;;
	    cin>>n;
	   	ll a[n];
  	REP(i,0,n-1)cin>>a[i];
  	ll ans=1;
  sort(a,a+n);
  int f=0;
  REP(i,0,n-1){
  	k=digit(a[i]);
  	y*=a[i]/pow(10,k);
  	{
  		if(y>1000000000000000000){
  			f=1;
  			break;

  		}
  	}
  	d+=k;
  }
  if(a[0]==0){
  	cout<<"0";
  }
  else if(d>18||f==1){
  	cout<<"-1";
  }
  else{
  	k=digit(y);
  	if(k+d>18){
  		cout<<"-1";
  	}
  	else{
  		ans=1;
  		REP(i,0,n-1)ans*=a[i];
  		if(ans>1000000000000000000)cout<<"-1";
  		else cout<<ans;
  	}
  }

	return 0;
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;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; }
using ll=long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    int a=n/15;
    cout<<(800*n)-200*a<<endl;
 }



Measured memory_bytes: 3568
n = input()

ans = 0

while True:
    if len(n) == 0:
        break
    if len(n) == 1:
        ans = ans + int(n)
    elif len(n) % 2 != 0:
        ans = ans + int(n) - int((len(n) - 1) * '9')
    n = (len(n) - 1) * '9'

print(ans)

Measured memory_bytes: 38256