akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int h, w;
int cost[10][10];
int d[10][10];

void dij(int a) {
  d[a][a] = 0;
  priority_queue<P, vector<P>, greater<P>> que;
  que.push(P(0, a));

  while(!que.empty()) {
    P p = que.top(); que.pop();
    if(d[a][p.second] < p.first) continue;
    REP(i, 10) {
      if(p.second != i) {
        if(d[a][i] > p.first + cost[p.second][i]) {
          d[a][i] = p.first + cost[p.second][i];
          que.push(P(d[a][i], i));
        }
      }
    }
  }
}

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

  cin >> h >> w;
  REP(i, 10) REP(j, 10) {
    cin >> cost[i][j];
    d[i][j] = INF;
  }

  REP(i, 10) {
    dij(i);
  }

  int ans = 0;
  REP(i, h) REP(j, w) {
    int a;
    cin >> a;
    if(a != -1 && a != 1) {
      ans += d[a][1];
    }
  }

  cout << ans << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d)
    cout << "Left" << endl;
  else if (a + b == c + d)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;   
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int r,c,i,j;
  cin >> r >> c;
  int a[r+1][c+1];
  for (j=0;j<c+1;j++) {
    a[r][j]=0;
  }
  for (i=0;i<r+1;i++) {
    a[i][c]=0;
  }
  for (i=0;i<r;i++) {
    for (j=0;j<c;j++) {
      cin >> a[i][j];
      a[i][c]+=a[i][j];
      a[r][j]+=a[i][j];
      a[r][c]+=a[i][j];
    }
  }
  for (i=0;i<r+1;i++) {
    for (j=0;j<c+1;j++) {
      cout << a[i][j];
      if (j<c) cout << " ";
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3084
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		for (var k = 1; ; k++)
		{
			var N2 = k * (k - 1) / 2;
			if (N2 > N) { WriteLine("No"); break; }
			if (N2 == N)
			{
				WriteLine("Yes");
				WriteLine(k);
				var s = new List<int>[k];
				for (var i = 0; i < k; i++) s[i] = new List<int>();
				var n = 1;
				for (var i = 0; i < k; i++)
				{
					for (var j = i + 1; j < k; j++)
					{
						s[i].Add(n);
						s[j].Add(n++);
					}
				}
				for (var i = 0; i < k; i++) WriteLine($"{k - 1} {string.Join(" ", s[i])}");
				break;
			}
		}
	}
}


Measured memory_bytes: 19396
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 a, b;
int main() {
  cin >> a >> b;
  i64 x = 0;
  b--;
  while (b > 0) {
    b -= a - 1;
    ++x;
  }
  cout << x << endl;
  return 0;
}


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

mod = 10**9+7
N, K = map(int, input().split())
K -= 1

P = set()
inv = {}
for i in range(1, int(math.sqrt(N)+2)):
    if i**2 > N: break
    P.add(i)
    P.add(N//i)
    if i not in inv:
        inv[i] = N//i
    if N//i not in inv:
        inv[N//i] = i

P1 = sorted(list(P))

T = len(P1)

M = [1]
for i in range(T-1):
    M.append(P1[i+1]-P1[i])


co_to_ind = {}
for i, p in enumerate(P1):
    co_to_ind[p] = i

Inv = []
for p in P1:
    Inv.append(co_to_ind[inv[p]])

dp = [[0]*T for _ in range(K+1)]

dp[0] = M

for i in range(K):
    tosum = [0]*T
    for ik in range(T):
        j = Inv[ik]
        tosum[j] = (tosum[j] + dp[i][ik]) % mod

    sumup = 0
    for ik in reversed(range(T)):
        sumup = (sumup + tosum[ik]) % mod
        dp[i+1][ik] = sumup * M[ik] % mod

ans = 0
for t in range(T):
    ans = (ans + dp[K][t]) % mod

print(ans)

Measured memory_bytes: 148100
n,m=map(int,input().split())
brighes=[list(map(lambda x:int(x)-1,input().split()))for i in range(m)]
neighbor=[set()for i in range(n)]
for brighe in brighes:
  v1,v2=brighe
  neighbor[v1].add(v2)
  neighbor[v2].add(v1)
  
ans=0
for brighe in brighes:
  v=[0 for i in range(n)]
  v[brighe[0]]=1
  stack=[]
  for a in neighbor[brighe[0]]:
    if a!=brighe[1]:
      stack.append(a)
  while stack!=[]:
    a=stack.pop()
    v[a]=1
    for b in neighbor[a]:
      if v[b]!=1:
        stack.append(b)
  if v[brighe[1]]==0:
    ans+=1
print(ans)
    
  

Measured memory_bytes: 3064
#include<stdio.h>
void trace(int A[],int N)
{
    int i;
    for( i=0;i<N;i++)
    {
        if(i>0)printf(" ");
        printf("%d",A[i]);
        
    }
    printf("\n");
    
    
}

void insertionsort(int A[], int N){
    int j,i,v;
    for(i=1;i<N;i++)
    {
        v=A[i];
        j=i-1;
        while(j>=0 &&A[j]>v){
        A[j+1]=A[j];
        j--;
    }
    A[j+1]=v;
    trace(A,N);
        
    }
     }   
        
        int main(){
            int N,i,j;
            int A[100];
            
            scanf("%d",&N);
            for(i=0;i<N;i++)scanf("%d",&A[i]);
            trace(A,N);
            insertionsort(A,N);
            return 0;
            
            
            
            
        }


Measured memory_bytes: 1952
# -*- coding: utf-8 -*-
"""
A - Programming Education
https://atcoder.jp/contests/abc112/tasks/abc112_a

"""
import sys


def solve(N):
    if N == 1:
        return 'Hello World'
    else:
        return int(input()) + int(input())


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

    int d, tmp[128] = {0}, d_max = 0;
    for (int i = 0; i < n; i++) {
        cin >> d;
        tmp[d]++;
        d_max = max(d, d_max);
    }

    int count = 0;
    for (int i = 0; i <= d_max; i++) {
        if (tmp[i] > 0) count++;
    }

    cout << count << endl;
}

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

using namespace std;

int main()
{
    int X;
    cin>>X;
    
    for(int i=X;i>0;i--){
        int a=i;
        for(int j=2;j<=(int)sqrt(i);j++){
            while(1){
                if(a%j==0){
                    a/=j;
                    if(a==1){
                        cout<<i<<endl;
                        exit(0);
                    }
                }else{
                    a=i;
                    break;
                }
            }
        }
    }
    cout<<1<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    ans = N // 2
    if N % 2 == 1:
        ans += 1
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


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

using namespace std;

#define int			long long
#define double 		long double
#define pb			push_back
#define in 			insert
#define mp			make_pair
#define f			first
#define s			second
#define x			first
#define y			second
#define all(el)		el.begin(), el.end()
#define allr(el)	el.rbegin(), el.rend()
#define sz(el)		(int)el.size()
 
template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1ll;} else {return 0ll;}}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1ll;} else {return 0ll;}}

int check(string s) {
	int n = sz(s);
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - 1 - i]) {
			return 0;
		}
	}
	return 1;
}

signed main() {
	
	#ifdef BarkovBG
		freopen("input.txt", "r", stdin);
	#endif

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

	string s;
	cin >> s;
	int n = sz(s);
	if (check(s) && check(s.substr(0, n / 2)) && check(s.substr(n / 2 + 1, n / 2))) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5 3");
            WillReturn.Add("1 2 3 4 5");
            //12
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("15 14");
            WillReturn.Add("50 26 27 21 41 7 42 35 7 5 5 36 39 1 45");
            //386
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int K = wkArr[1];
        int[] LArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        Console.WriteLine(LArr.OrderByDescending(X => X).Take(K).Sum());
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

int s[N], t[N], pos[N];

bool cmp(const int a, const int b) {
	return pos[a] < pos[b];
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, q;
	cin >> n >> q;
	vi v;
	for(int i = 0; i < n; i++) {
		cin >> s[i] >> t[i] >> pos[i];
		s[i] -= pos[i];
		t[i] -= pos[i];
		v.pb(i);
	}
	sort(all(v), cmp);
	set<pii> d;
	for(int i = 0; i < q; i++) {
		int x;
		cin >> x;
		d.insert({x, i});
	}
	int ans[q];
	memset(ans, -1, sizeof(ans));
	for(int j = 0; j < n; j++) {
		int i = v[j];
		vector<pii> remove;
		auto it1 = d.lower_bound({s[i], -1});
		auto it2 = d.lower_bound({t[i], -1});
		for(; it1 != it2; it1++) {
			ans[it1->se] = pos[i];
			remove.pb({it1->fi, it1->se});
		}
		for(auto it : remove) {
			d.erase(it);
		}
	}
	for(int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 27504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;
            
            s = Console.ReadLine();
            char[] cs = s.ToCharArray();
            cs[3] = '8';
            Console.WriteLine(cs);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

N = int(input())
X = list(map(int, input().split()))

ans = 9999999999999
for p in range(1, max(X)+1):
    sum_ = 0
    for i, x in enumerate(X):
        sum_ += (x - p) ** 2

    if ans > sum_:
        ans = sum_

print(ans)

Measured memory_bytes: 20752
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.stream.Collectors;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int X = in.Int();
            int N = in.Int();
            if (N == 0) {
                out.println(X);
                return;
            }
            int[] p = in.Int(N);
            Set<Integer> set = IntStream.of(p).boxed().collect(Collectors.toSet());

            for (int i = 0; i < 100; i++) {
                int l = X - i;
                int r = X + i;
                if (!set.contains(l)) {
                    out.println(l);
                    return;
                }
                if (!set.contains(r)) {
                    out.println(r);
                    return;
                }
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 34532
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void)
{
	int n, m;
	int A[100][100] = { {} }, B[100];

	cin >> n >> m;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> A[i][j];
	for (int i = 0; i < m; i++)
		cin >> B[i];

	for (int i = 0; i < n; i++)
	{
		int sum = 0;
		for (int j = 0; j < m; j++)
		{
			sum += A[i][j] * B[j];
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;

int main(void){

    int n, m;
    cin >> n >> m;

    int ac = 0, wa = 0;

    vector<int> flag(n);
    vector<int> value(n);
    vector<vector<int>> list(m, vector<int>(2));

    for(int i = 0;i < m;i++){
        int num;
        string result;
        cin >> num >> result;
        if(flag[num-1] == 0 && result == "WA") {value[num-1]++;}
        else if(flag[num-1] == 0 && result == "AC") {
            flag[num-1] = 1;
            ac++;
            wa += value[num-1];
        }
    }


    cout << ac << " " << wa << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef pair<int, int> pii;

typedef struct Sequence {
	int length;
	map<int, int> seq;
} Sequence;

int gcd(int a, int b){
	if(a < b){ swap(a, b); }
	if(b == 0){ return a; }
	return gcd(b, a % b);
}

int lcm(int a, int b){
	return a * b / gcd(a, b);
}

Sequence optimize(int length, vector<pii> &seq){
	if(seq.size() < 1){ return Sequence(); }
	int divisor = length;
	for(vector<pii>::iterator it = seq.begin(); it != seq.end(); it++){
		divisor = gcd(divisor, (*it).first);
	}
	Sequence result;
	result.length = length / divisor;
	for(vector<pii>::iterator it = seq.begin(); it != seq.end(); it++){
		result.seq.insert(pii((*it).first / divisor, (*it).second));
	}
	return result;
}

int main(){
	int datasetCount;
	scanf("%d", &datasetCount);
	while(datasetCount--){
		int N;
		scanf("%d", &N);
		vector<Sequence> sequences;
		for(int i = 0; i < N; i++){
			char buffer[2049];
			scanf("%s", buffer);
			int length = strlen(buffer);
			vector<pii> seq;
			for(int j = 0; j < length; j += 2){
				int val;
				sscanf(buffer + j, "%02X", &val);
				if(val != 0){ seq.push_back(pii(j / 2, val)); }
			}
			if(seq.size() > 0){
				sequences.push_back(optimize(length / 2, seq));
			}
		}
		int sequenceLength = 1;
		vector<Sequence>::iterator it = sequences.begin();
		while(it != sequences.end()){
			sequenceLength = lcm(sequenceLength, (*it).length);
			if(sequenceLength > 1024){ break; }
			it++;
		}
		if(sequenceLength > 1024){
			puts("Too complex.");
		}else{
			int index;
			for(index = 0; index < sequenceLength; index++){
				int val = 0;
				vector<Sequence>::iterator it = sequences.begin();
				while(it != sequences.end()){
					if(index * (*it).length % sequenceLength != 0){
						it++;
						continue;
					}
					map<int, int>::iterator evt = (*it).seq.find(
						index * (*it).length / sequenceLength
					);
					if(evt != (*it).seq.end()){ val |= (*evt).second; }
					it++;
				}
				printf("%02X", val);
			}
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 1136
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==6||a==7||a==8||a==9||a==10||a==11||a==12){cout<<b/2;}
  else if(a<6){cout<<0;}
  else cout<<b;
  
  }



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n, top, west, north;
string op;

int main(){
  while(scanf("%d", &n) && n){
    int tmp;
    top = 1;
    north = 2;
    west = 3;
    rep(i, n){
      cin >> op;
      switch(op[0]){
      case 'n':
	tmp = 7 - north;
	north = top;
	top = tmp;
	break;
      case 's':
	tmp = 7 - top;
	top = north;
	north = tmp;
	break;
      case 'e':
	tmp = 7 - top;
	top = west;
	west = tmp;
	break;
      case 'w':
	tmp = 7 - west;
	west = top;
	top = tmp;
	break;
      }
    }
    printf("%d\n", top);
  }
  return 0;
}

Measured memory_bytes: 1228
(format t "~{~A~}~%" (labels ((f (list acc)
                            (if list
                                (case (car list)
                                  (#\0 (f (cdr list) (cons 0 acc)))
                                  (#\1 (f (cdr list) (cons 1 acc)))
                                  (#\B (f (cdr list) (cdr acc))))
                                (reverse acc))))
                       (f (coerce (read-line) 'list) nil)))

Measured memory_bytes: 3304
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main()
{
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ll x,y;
    cin >> x >> y;
    cout << x-y+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

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

    int A, B;
    std::cin >> A >> B;
    std::cout << A*B;

    return 0;
}


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

int main() {
    long long n, ans=1;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    bool flag=true;
    if(n%2==1) {
        if(a[0]!=0) {
            flag=false;
        }
        for(int i=1; i<n; i+=2) {
            if(a[i]!=i+1 || a[i+1]!=i+1) {
                flag=false;
                break;
            }
        }
        for(int i=1; i<=(n-1)/2; i++) {
            ans*=2;
            ans%=1000000007;
        }
    }
    else if(n%2==0) {
        for(int i=0; i<n; i+=2) {
            if(a[i]!=i+1 || a[i+1]!=i+1) {
                flag=false;
                break;
            }
        }
        for(int i=1; i<=n/2; i++) {
            ans*=2;
            ans%=1000000007;
        }
    }
    if(flag) cout << ans;
    else cout << 0;
}


Measured memory_bytes: 640
import sys

n, *a = map(int, sys.stdin.read().split())

cumsum = [0] + a
cumxor = cumsum.copy()
for i in range(1, n):
    cumsum[i+1] += cumsum[i]
    cumxor[i+1] ^= cumxor[i]

def is_ok(l, r):
    s = cumsum[r] - cumsum[l-1]
    x = cumxor[r] ^ cumxor[l-1]
    return s == x

def main():
    res = 0
    l = r = 1
    flag = False
    while l <= n and r <= n:
        if is_ok(l, r):
            if r == n:
                res += r - l + 1
                l += 1
                flag = False
            else:
                flag = True
                r += 1
        else:
            if flag:
                res += r - 1 - l + 1
            else:
                res += r - l + 1
            l += 1
    return res
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 28224
N,K = map(int, input().split())
p = list(map(lambda i: int(i) + 1 , input().split()))

m_r = sum(p[:K])
m_max = m_r

for i in range(N - K):
    m_r -= p[i]
    m_r += p[i + K]
    if m_max < m_r:
        m_max = m_r

print(m_max / 2)

Measured memory_bytes: 25060
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    
    int b = n-k;

    if(k == 1){
      System.out.println(0);
    }else{
      System.out.println(b);
    }
    
  }
}

Measured memory_bytes: 35716
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        long N=sc.nextLong();
        long K=sc.nextLong();
        long ans=0;
        
        if(K%2==0){
            long num=(N+K/2)/K;
            ans+=(num*num*num);
        }
        
        
        long num=N/K;
        ans+=(num*num*num);
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import java.util.Scanner; 
    public class Main{ 
        static final int N = 8; 
        static boolean[] row = new boolean[N]; 
        static boolean[] col = new boolean[N]; 
        static boolean[] dpos = new boolean[2*N -1]; 
        static boolean[] dneg = new boolean[2*N -1]; 
        static boolean[][] X = new boolean[N][N]; 
        static void print_Board(){ 
            for(int i = 0; i < N; i++){ 
                for(int j = 0; j < N; j++){ 
                    if(X[i][j]){ 
                        if(j == N-1) 
                            System.out.println("Q"); 
                        else 
                            System.out.print("Q"); 
                    } 
                    else{ 
                        if(j == N-1) 
                            System.out.println("."); 
                        else System.out.print("."); 
                    } 
                } 
            } 
        } 
        static void putQueen(int i){ 
            if(i == N){ 
                print_Board(); 
                return; 
            } 
            else{ 
                for(int j = 0; j < N; j++){ 
                    if(X[i][j]) 
                        putQueen(i+1); 
                    else if(col[j] || dpos[i+j] || dneg[i-j+N-1]){ 
                        continue; 
                    } 
                    else{ 
                        row[i] = true; 
                        col[j] = true; 
                        dpos[i+j] = true; 
                        dneg[i-j+N-1] = true; 
                        X[i][j] = true; 
                        putQueen(i+1); 
                        row[i] = false; 
                        col[j] = false; 
                        dpos[i+j] = false; 
                        dneg[i-j+N-1] = false; 
                        X[i][j] = false; 
                    } 
                } 
                return; 
            } 
        } 
        public static void main(String[] args){ 
            Scanner scan = new Scanner(System.in); 
            int k = scan.nextInt(); 
            for(int i = 0; i < N; i++){ 
                row[i] = false; 
                col[i] = false; 
            } 
            for(int i = 0; i < 2*N-1; i++){ 
                dpos[i] = false; 
                dneg[i] = false; 
            } 
            for(int i = 0; i < N; i++) 
                for(int j = 0; j < N; j++) 
                    X[i][j] = false; 
            for(int i = 0; i < k; i++){ 
                int x = scan.nextInt(); 
                int y = scan.nextInt(); 
                X[x][y] = true; 
                row[x] = true; 
                col[y] = true; 
                dpos[x+y] = true; 
                dneg[x-y+N-1] = true; 
            } 
            putQueen(0); 
        } 
    }


Measured memory_bytes: 26392
def abc162d_rgb_triplets():
    n = int(input())
    s = input()
    r_cnt = 0
    g_cnt = 0
    b_cnt = 0
    for i in range(n - 1, -1, -1):
        if s[i] == 'R':
            r_cnt += 1
        elif s[i] == 'G':
            g_cnt += 1
        else:
            b_cnt += 1

    result = r_cnt * g_cnt * b_cnt
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            k = j + (j - i)
            if s[i] == s[j] or k >= n or s[i] == s[k] or s[j] == s[k]: continue
            result -= 1
    print(result)



abc162d_rgb_triplets()

Measured memory_bytes: 9084
import sys
input = sys.stdin.readline
n, m = map(int,input().split())
C = [list(map(int,input().split())) for i in range(m)]
S = [0] * n

for i in range(m):
    for j in range(2):
        C[i][j] -= 1

for i in range(m):
    S[C[i][0]] += 1
    S[C[i][1]] -= 1

for i in range(1, n):
    S[i] += S[i-1]

for i in range(n-1):
    if S[i] > 0:
        C.append([i+1, i, 0])

M = [[] for i in range(n)]
for i in range(len(C)):
    M[C[i][0]].append([C[i][1], C[i][2]])
    if C[i][2] > 0:
        M[C[i][1]].append([C[i][0], C[i][2]])

import heapq

D = [float("inf")] * n
P = [-1] * n
D[0] = 0
V = [0] * n
Q = []
for v in range(n):
    heapq.heappush(Q, [D[v], v])

le = len(Q)
while le > 0:
    q = heapq.heappop(Q)
    u = q[1]
    du = q[0]
    if V[u] == 0:
        V[u] = 1
        le -= 1
        for i in range(len(M[u])):
            v = M[u][i][0]
            luv = M[u][i][1]
            if V[v] == 0:
                alt = du + luv
                if D[v] > alt:
                    D[v] = alt
                    P[v] = u
                    heapq.heappush(Q, [alt, v])

ans = D[-1]
if ans == float("inf"):
    ans = -1
print(ans)


Measured memory_bytes: 129832
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<ll> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    int ans = 0;
    sort(l.begin(), l.end());

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(l[i] == l[j]) continue;
            for(int k = j+1; k < n; k++){
                if(l[j] == l[k]) continue;
                if(l[k] < l[i]+l[j]) ans++;
            }
        }
    }

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

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

int main(){
  int N, M;
  int x,y;
  cin >> N >> M;
  //玉の数の配列を作る
  vector<int> tama(N,1);
  //赤が入っている確率のある箱の番号に1、そうでない箱に0をつける配列を作る
  vector<int> kakuritu(N,0);
  kakuritu[0] = 1;
  
  for(int i = 0; i < M; i++){
    cin >> x >> y;
  //球を動かす
    tama[x-1]--;
    tama[y-1]++;
    //kakuritu[x-1]が１ならkakuritu[y-1]を１に
    if(kakuritu[x-1] == 1){
      kakuritu[y-1] = 1;
    }
  //もしそれでtama[x-1]の玉の個数が０になったらkakuritu[x-1]を0にする
    if(tama[x-1] == 0){
      kakuritu[x-1] = 0;
    }
  }
  
  int count = 0;
  //1の数を数える
  for(int i = 0; i < N; i++){
    if(kakuritu[i] == 1){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
// no body cares about your fuckin efforts , only result matters.
// no. of ways 1,1 to n,n only R,D allowed.
// faltu k bloks b ok and can write statements inside of cout etc.
// approach. 
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
string S[1001];
ll m, n;
const ll inf = 1e9 + 7ll ;
ll dp[1001][1001];
void dfs(ll s, ll e) {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	for(ll j = 1; j < n; ++j ) {
		if( S[0][j] == '#' ) {
			dp[0][j] = 0;
		} else {
			dp[0][j] = dp[0][j - 1];
		}
	}

	for(ll i = 1; i < m; ++i ) {
		if( S[i][0] == '#' ) {
			dp[i][0] = 0;
		} else {
			dp[i][0] = dp[i - 1][0];
		}
	}
	for(ll i = 1; i < m; ++i ) {
		for(ll j = 1; j < n; ++j ) {
			if( S[i][j] == '#') {
				dp[i][j] = 0; 
			} else {
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % inf ;
			}
		}
	}
	cout << dp[m - 1][n - 1];
}
int main() {
	cin >> m >> n;
	for(ll i = 0; i < m; ++ i ) 
		cin >> S[i]; 
	dfs(0, 0 );
}

Measured memory_bytes: 9088
n = int(input())

x = {}
a = [0]*n
c = []
ans = []
#a[0] input()
for i in range(0,n):
  tmp = input()
  if(tmp in x):
    valu = x.get(tmp)
    x[tmp] = valu + 1
    #print(x)
  else:
    x[tmp] = 1
    
#x = sorted(x.items(), key=lambda x:x[1])
#x = sorted(x.key())
#print(s)
ma = max(x.values())
#x = list(x)
#print(x)
i=0
for key, value in x.items():
  #print(key,value)
  if(value == ma):
    c.append(key)
    #print(key)

c.sort()
#print(c)
for i in c:
  print(i)
          


Measured memory_bytes: 93764
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
int main(void){
    ll N, ANS=0; char S[105];
    scanf("%lld\n%s", &N, S);
    rep(i, 1, N){
        ll c=0;
        for(char s='a'; s<='z'; s++){
            ll L=0, R=0;
            rep(j, 0, i) if(S[j]==s) L=1;
            rep(j, i, N) if(S[j]==s) R=1;
            if(L&&R) c++;
        }
        ANS = max(ANS,c);
    }
    printf("%lld\n", ANS);
    return 0;
}
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ull unsigned long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--)
 
const int maxn = 1e6 + 5;
const int maxm = 5000 + 5;
const int MOD = 1e9 + 7;

int a[110];


int main()
{
   //ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   //#ifndef ONLINE_JUDGE 
   //freopen("input.txt", "r", stdin);
   //#endif // ONLINE_JUDGE  
   int n; 
   scanf("%d", &n);
   double tot = 1;
   double sum = 0;
   rep(i,1,n) {
      scanf("%d",&a[i]);
      tot *= a[i];
   }
   rep(i,1,n) sum += tot / (double)a[i];
   double ans =  tot / sum;
   printf("%.5lf\n",ans);
   return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];
	int ans = 0;
	F0R(i, N) ans += (i % 2 == 0) && (arr[i] % 2 == 1);
	print(ans);
}

Measured memory_bytes: 3616
S = input()

if S == 'SUN':
    print('7')
elif S == 'MON':
    print('6')
elif S == 'TUE':
    print('5')
elif S == 'WED':
    print('4')
elif S == 'THU':
    print('3')
elif S == 'FRI':
    print('2')
else:
    print('1')

Measured memory_bytes: 8976
#include <random>

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
// constexpr ld eps = 1e-12;
// constexpr int inf = numeric_limits<int>::max() / 2;
// constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  vector<string> s(n);
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    int cnt = 0;
    bool comma = false;
    string ns = "";
    for (auto c : s[i]) {
      if (c == '.') {
        comma = true;
        continue;
      }
      if (comma) cnt++;
      ns += c;
    }
    a[i] = stoll(ns);
    for (int j = 0; j < 9 - cnt; j++) a[i] *= 10;
  }
  vector<vector<ll>> divs(20,vector<ll>(20));
  const ll DEMAND = 18;
  ll ans = 0;
  for(int i=0;i<n;i++){
      ll two = 0, fiv = 0;
      while(a[i]%2==0){
          two++;
          a[i]/=2;
      }
      while(a[i]%5==0){
          fiv++;
          a[i]/=5;
      }
      for(int j=0;j<=DEMAND;j++){
          for(int k=0;k<=DEMAND;k++){
              if(DEMAND<=j+two && DEMAND<=k+fiv) ans += divs[j][k];
          }
      }
      divs[min(DEMAND,two)][min(DEMAND, fiv)]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11120
while True:
    x,y,s = map(int,input().split())
    b = 0
    if x==0 and y == 0 and s == 0:
        break
    else:
        for i in range(1,s):
            for j in range(i,s):
                if i * (100+x)//100 + j * (100+x)//100  != s:
                    pass
                else:
                    a = i * (100+y)//100 + j * (100+y)//100
                    if b <= a:
                        b = a
                    else:
                        pass
    print(b)


Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int a;
    cin>>a;
    if(a>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> a(n);
    vector<int32> cnt(9);
    REP(i,n){
        int32 a;
        cin >> a;
        a /= 400;
        if(a > 8)a = 8;
        cnt[a]++;
    }
    int32 mn = 0;
    REP(i,8)if(cnt[i])mn++;
    int32 mx = mn;
    if(mn == 0)mn = 1;
    mx += cnt[8];
    cout << mn << " " << mx << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())


def base_10_to_n(X, n):
    if (int(X/n)):
        return base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

rslt = base_10_to_n(n, k)

print(len(rslt))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN 200005
#define INF 100000000
// #define int long long

using namespace std;

int N, Q;
int a[2][MAXN << 2];

int init(int sid, int l, int r, int id, int v) {
	if (l == r) {
		return a[sid][id] = v;
	}
	int m = (l + r) >> 1;
	return a[sid][id] = min(init(sid, l, m, id << 1, v), init(sid, m + 1, r, id << 1 | 1, v));
}

int query(int sid, int l, int r, int x, int id) {
	// cerr << l << ' ' << r << ' ' << L << ' ' << R << endl;
	if (r < x || x < l) {
		return INF;
	}
	if (l == x && r == x) {
		return a[sid][id];
	}
	int m = (l + r) >> 1;
	return min({a[sid][id], query(sid, l, m, x, id << 1), query(sid, m + 1, r, x, id << 1 | 1)});
}

void update(int sid, int l, int r, int L, int R, int id, int v) {
	// cerr << l << ' ' << r << ' ' << L << ' ' << R << endl;
	if (r < L || R < l) {
		return;
	}
	if (L <= l && r <= R) {
		a[sid][id] = min(a[sid][id], v);
		return;
	}
	int m = (l + r) >> 1;
	update(sid, l, m, L, R, id << 1, v);
	update(sid, m + 1, r, L, R, id << 1 | 1, v);
}

signed main()
{
	IO;
	cin >> N >> Q;

	init(0, 1, N, 1, N);
	init(1, 1, N, 1, N);

	long long remain = ((long long)N - 2) * ((long long)N - 2);
	while (Q--) {
		int type, x;
		cin >> type >> x;

		if (type == 1) {
			int mn = query(0, 1, N, x, 1);
			remain -= mn - 2;
			update(1, 1, N, 1, mn, 1, x);
		} else {
			int mn = query(1, 1, N, x, 1);
			remain -= mn - 2;
			update(0, 1, N, 1, mn, 1, x);
		}
	}

	cout << remain << endl;
	return 0;
}



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

using namespace std;

// int ball_counter[100];
// int ball_selection[100];


long long ball_counter[200100];
long long ball_selection[200100];


int main(){
    long long N;
    cin >> N;
    vector<long long> a(N);
    for(long long i=0; i<N; ++i) cin >> a[i];

    for(long long i=0; i<N; ++i){
        ball_counter[a[i]]++;
    }

    for(long long i=0; i<200100; ++i){
        if(ball_counter[i] > 1){
            if(ball_counter[i] %2 == 0){
                ball_selection[i] = ball_counter[i]/2 ;
                ball_selection[i] *= (ball_counter[i] - 1);
            }else{
                ball_selection[i] = (ball_counter[i] - 1)/2;
                ball_selection[i] *= ball_counter[i] ;
            }
        }
    }

    long long total = 0;
    for(long long i=0; i<200100; ++i){
        total += ball_selection[i];
    }


    for(int i=0; i<N; ++i){
        long long ans;

        // if( ball_counter[a[i]] - 1 < 2 ){
        //     ans = total;
        // }else{
        ans = total - (ball_counter[a[i]] - 1);
//         }

        cout << ans << endl;
    }
}

Measured memory_bytes: 8008
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    string S;
    cin >> N;
    cin >> S;
    map<char, int> m;
    for (auto x: S) m[x]++;
    long long ans = 1;
    long long mod = 1000000007;
    for (auto x: m) {
        ans *= 1+x.second;
        ans %= mod;
    }
    ans += mod;
    ans--;
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 512
def main():
    S = input()
    N = len(S)
    for i in range(N//2):
        if S[i] != S[N - 1 - i]:
            return False
    x = (N-1)//2
    for i in range((N-1)//2):
        if S[i] != S[x - 1 - i]:
            return False
    for i in range(x + 1,N):
        if S[i] != S[N - 1 - i]:
            return False
    return True
if main():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    set<int> s;
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        if(s.find(a)==s.end()){
            s.insert(a);
        }else{
            s.erase(a);
        }
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 4864
import java.util.Arrays;
import java.util.BitSet;
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int[] boxes = new int[N];
		Arrays.fill(boxes, 1);
		BitSet red = new BitSet(N);
		red.set(0);
		for (int i = 0; i < M; i++) {
			int x = Integer.parseInt(sc.next()) - 1;
			int y = Integer.parseInt(sc.next()) - 1;
			if (boxes[x] > 0) {
				boxes[x] -= 1;
				boxes[y] += 1;
				if (red.get(x)) {
					red.set(y);
					red.set(x, boxes[x] > 0);
				}
			}
		}
		System.out.println(red.cardinality());
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 49852
#include<cstdio>
#include<algorithm>
using namespace std;
int x[1024],y[1024],dp[1024][1024];
int main()
{
    int n,minx=1e9,miny=1e9,ans;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d%d",&x[i],&y[i]);
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++)
            dp[i][j]=1e9;

    for(int i=1;i<=n;i++)
        dp[i][i]=0;

    for(int i=1;i<=n;i++)
        for(int j=1;j+i<=n;j++)
            for(int k=j;k<j+i;k++)
                dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][j+i]+y[k]-y[i+j]+x[k+1]-x[j]);

    printf("%d\n",dp[1][n]);
    return 0;
}

Measured memory_bytes: 5132
#include<iostream>
#include <climits>
#include<vector>
#include<cstring>
using namespace std;

int fun(vector<int> graph[], int src, int dp[]){
	if(graph[src].size() == 0){
		return 0;
	}
	if(dp[src] != -1){
		return dp[src];
	}
	int ans = 0;
	for(auto x : graph[src]){
		int temp = 1 + fun(graph, x, dp);
		ans = max(ans, temp);
	}

	return dp[src] = ans;
}

int Solve(vector<int> graph[], int n){
	int dp[100002];
	memset(dp, -1, sizeof(dp));
	int res = 0;
	for(int i = 1; i <= n; i++){
		res = max(res, fun(graph, i, dp));
	}
	return res;
}



int main(){


	int n, m, u, v;
	cin>>n>>m;

	vector<int> graph[100002];

	for(int i = 1; i <= m; i++){
		cin>>u>>v;
		graph[u].push_back(v);
	}

	// for(int i = 1; i <= n; i++){
	// 	cout<<i<<" --> ";
	// 	for(auto x : graph[i]){
	// 		cout<<x<<" ";
	// 	}
	// 	cout<<endl;
	// }

	cout<<Solve(graph, n)<<'\n';
	// cout<<graph[4].size();

}


Measured memory_bytes: 11740
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000


int main(){

	string S;
	cin>>S;

	vector<int> a(4);
	for(int i=0;i<4;i++){
		a[i] = S[i] - '0';
	}
	
	for(int i=0;i<8;i++){
		string s = "";
		for(int j=0;j<3;j++){
			if((i>>j)%2)s+='+';
			else s+='-';
		}
		int now = a[0];
		for(int j=0;j<3;j++){
			if(s[j]=='+')now+=a[j+1];
			else now-=a[j+1];
		}
		if(now!=7)continue;
		cout<<a[0];
		for(int j=0;j<3;j++){
			cout<<s[j]<<a[j+1];
		}
		cout<<"=7"<<endl;
		return 0;
	}
	
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j,N,v;
  int A[100];
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(j=0;j<N;j++){
    if(j==N-1){
      printf("%d",A[j]);
    }
    else {
    printf("%d ",A[j]);
    }
  }
  printf("\n");
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
    for(j=0;j<N;j++){
      if(j==N-1){
	printf("%d",A[j]);
      }
      else {
	printf("%d ",A[j]);
      }
      }
    printf("\n");
  }
  return 0;
}

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

int main() {
  double D[80]; int d=0;
  char inbuf[99];
  while (gets(inbuf)) {
    char *tp = strtok(inbuf, " \n");
    while (tp!=NULL) {
      if(!strcmp(tp, "+")){
        //      if ((tp[0] == '+') && (tp[1]==0)) {
        D[d-2]+=D[--d];
      }
      else if (tp[0] == '*') {
        D[d-2]*=D[--d];
      }
      else if(!strcmp(tp, "-")){
        //      else if ((tp[0] == '-') && (tp[1]==0)) {
        D[d-2]-=D[--d];
      }
      else if (tp[0] == '/') {
        D[d-2]/=D[--d];
      }
      else {
        D[d++]=atof(tp);
      }
      tp = strtok(NULL, " \n");
    }
    printf("%.6lf\n",D[--d]);
  }
  return 0;
}

Measured memory_bytes: 580