akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) // gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define hell 		(ull)1e9
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
using namespace std;
//ll maxi = 3005;
ll dp[3005][3005];
void boost()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    cout.tie(NULL);
}



int main(void)
{
    boost();
    ll n , k;
    cin>>n>>k;
    vi v(n);
    rep(i,0,n)
        cin>>v[i];
    ll a[k+1];

    rep(i,0,k+1)
        a[i] = 2;
    // rep(i,0,k+1)
    //     cout<<a[i]<<" ";
    //cout<<"\n";
    // rep(i,0,n)
    //     a[v[i]] = 1;
    rep(i,1,k+1){
        rep(j,0,n){
            //cout<<(k - v[j])<<"\n";
            if ((i - v[j]) < 0)
                break;
            else{
                if (a[i - v[j]] == 2)
                    a[i] = 1;
            }
        }
    }
    if (a[k] == 1)
        cout<<"First"<<"\n";
    
    else
        cout<<"Second"<<"\n";
    // rep(i,0,k+1){
    //     cout<<a[i]<<" ";
    // }
    

}   

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

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

    int arr[n+1];
    
    fill_n(arr, n+1, 0);

    for(int i=1;i<n;i++) {
        int n;
        cin>>n;

        arr[n]++;
    }

    for(int i=1;i<n+1;i++) {
        cout<<arr[i]<<endl;
    }

}




Measured memory_bytes: 4444
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    while(true){
     
    cin >> a >> op >>b;
    if (op == '+'){
        cout << (a+b) << endl;
    }
    else if (op == '-'){
        cout << (a-b) << endl;
    }
    else if (op == '*'){
        cout << (a*b) << endl;
    }
    else if (op == '/'){
        cout << (a/b) << endl;
    }
    else if (op == '?'){
        break;
    }
    }
}


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

int f[50];

int fibo(int n)
{
  if(n <= 1) return 1;
  else{
    if(f[n]){
      return f[n];
    }
    else{
      return f[n] = fibo(n-1)+fibo(n-2);
    }
  }
}

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

  cout << fibo(n) << endl;
  return 0;
}



Measured memory_bytes: 3100
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        List<String[]> input = new ArrayList<String[]>();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String[] s = sc.nextLine().split(" ");
            input.add(s);
        }
        sc.close();

        int a = Integer.parseInt(input.get(0)[0]);
        int b = Integer.parseInt(input.get(0)[1]);

        int pa = a * 3 / 2;
        int pb = a * 3 % 2 == 1 ? (b + 1) / 2 : b / 2;

        int pi = pa + pb;
        System.out.println(pi);
    }
}


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

using namespace std;

const long long INF = 1LL<<50;

int main(){
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    int totalE = 0;
    int totalW = 0;
    
    for (int i = 0; i < (int)s.size(); i++){
        if (s[i] == 'E')totalE++;
        else totalW++;
    }
    
    int ans = (int)s.size();
    
    int tempE = 0;
    int tempW = 0;
    
    for (int i = 0; i < (int)s.size(); i++){
        
        int reverseE = totalE - tempE;
        if (s[i] == 'E') reverseE--;
        
        ans = min(ans, reverseE + tempW);
        
        if (s[i] == 'W') tempW++;
        else tempE++;
    }
    
    cout << ans << endl;
}

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

int main()
{
    int N;
    cin >> N;
    int i = N;
    while(1){
	if((i % 2 == 0) && (i % N == 0)) {
	    cout << i << endl;	
	    break;
	} 
	++i;
    } 
    return 0;
}


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

int main()
{
	//char fox;
	//cin >> fox;
	//if (fox < 94)
	//	cout << "A";
	//else
	//	cout << "a";

	int a, b = 0;
	cin >> a >> b;
	int *arr = new int[a];
	for (int i = 0; i < a; i++)
	{
		cin >> arr[i];
	}
	sort(arr, arr + a);
	int min = 0;
	for (int i = 0; i < b; i++)
	{
		min += arr[i];
	}
	cout << min;
	//for (int i = 0; i < a; i++)
	//{
	//	cout<<arr[i]<<" ";
	//}
    return 0;
}


Measured memory_bytes: 3640
S = input()
SFlag = True
while S:
    if S[-7:]=='dreamer':
        S = S[:-7]
    elif S[-6:]=='eraser':
        S = S[:-6]
    elif S[-5:]=='dream' or S[-5:]=='erase':
        S = S[:-5]
    else:
        SFlag = False
        break
print(['NO','YES'][SFlag])

Measured memory_bytes: 9264
#include <iostream>

int maxFrac(int larger, int smaller) {
  if (larger < smaller) {
    return maxFrac(smaller, larger);
  }

  for (int i = smaller; 0 < i; --i) {
    if (larger % i == 0 && smaller % i == 0) {
      return i;
    }
  }

  return 1;
}

int main() {
  int w, h, c, f;
  std::cin >> w >> h >> c;
  f = maxFrac(w, h);
  std::cout << w / f * h / f * c << std::endl;

  return 0;
}



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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int n, x;
  cin >> n >> x;
  int d = 0, cnt = 1;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    d += l;
    if (d <= x) {
      ++cnt;
    }
  }

  cout << cnt << endl;
}

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

  solve();
  return 0;
}


Measured memory_bytes: 3648
from collections import defaultdict

N = int(input())
if N == 1:
    print(0)
    exit()

index = int(pow(N, 0.5) + 1)
ans = []
for i in range(2, index):
    while N % i == 0:
        N //= i
        ans.append(i)

if N != 1:
    ans.append(N)

if ans == []:
    print(1)
    exit()
d = defaultdict(int)
for i in ans:
    d[i] += 1

sosuLst = []
for v, c in d.items():
    cnt = 1
    while c > 0:
        c -= cnt
        cnt += 1
        if c != 0 and c < cnt:
            sosuLst.append(v ** cnt)
            break
        else:
            sosuLst.append(v ** (cnt - 1))

print(len(set(sosuLst)))

Measured memory_bytes: 9736
#include <iostream>

using namespace std;

int main() {
  int x = -1;
  int i = 1;
  while (x != 0) {
    cin >> x;
    if (x == 0) {
      break;
    }
    cout << "Case " << i << ": " << x << endl;
    i++;
  }
  return 0;
}



Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n,m;
int a[110000];

main(){
  cin>>n>>m;
  rep(i,m){
    int l,r;
    cin>>l>>r;
    a[l]++;
    a[r+1]--;
  }

  int ans=0;
  FOR(i,1,n+1){
    a[i]+=a[i-1];
//    cout<<a[i]<<endl;
    if(a[i]==m) ans++;
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 1024
n, k = map(int, input().split())
# = int(input())
# = input()
# = list(map(int, input().split()))
h = []
for i in range(n):
	h.append(int(input()))
h.sort()
mi = -1
for i in range(n-k+1):
	if mi == -1:
		mi = h[i+k-1] - h[i]
	else:
		mi = min(mi, h[i+k-1] - h[i])
print(mi)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll h,w;
    cin >> h >> w;
    if(h==1||w==1){
        cout << 1 << endl;
        return 0;
    }
    if(h%2&&w%2){
        cout << (h * w + 1) / 2 << endl;
    }else if(h%2==0&&w%2==0){
        cout << (h * w) / 2 << endl;
    }else{
        cout << (h * w) / 2 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N,tmp;
	int sum = 0,max = 0;
	scanf("%d",&N);
	while ( N-- ) {
		scanf("%d",&tmp);
		if ( max < tmp ) {
			sum += max;
			max = tmp;
		} else {
			sum += tmp;
		}
	}

	if ( max < sum ) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
  return 0;
}

Measured memory_bytes: 128
import itertools

N,M,X = map(int,input().split())
c = []
d = [0]*(M+1)
e = []
for _ in range(N):
  c.append(list(map(int,input().split())))
for r in range(1,N+1):
  for x in itertools.combinations(c,r):
    for y in range(len(x)):
      for z in range(M+1):
        d[z] += x[y][z]
    for z in range(1,M+1):
      if d[z]<X:
        d = [0]*(M+1)
        break
      elif z == M:
        e.append(d[0])
        d = [0]*(M+1)
if len(e)>0:
  print(min(e))
else:
  print(-1)


Measured memory_bytes: 9232
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(mst_a,mst_b) memset(mst_a,mst_b,sizeof(mst_a))
#define fora(fora_x,fora_a,fora_b) for(re nti (fora_x)=(fora_a);(fora_x)<=(fora_b);++(fora_x))
#define forb(forb_x,forb_a,forb_b) for(re nit (forb_x)=(forb_a);(forb_x)>=(forb_b);--(forb_x))
#define foral(foral_x,foral_a,foral_b) for(re ll (foral_x)=(foral_a);(foral_x)<=(foral_b);++(foral_x))
#define forbl(forbl_x,forbl_a,forbl_b) for(re ll (forbl_x)=(forbl_a);(forbl_x)>=(forbl_b);--(forbl_x))
#define re register
#define stt struct
#define nms namespace
#define gc getchar
#define sl(sl_a) strlen(sl_a)
#define gt(gt_a) goto gt_a
#define rt return
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define abss(abss_x) ((abss_x)>(0)?(abss_x):(-1)*(abss_x))
#define maxx(maxx_a,maxx_b) ((maxx_a)>(maxx_b)?(maxx_a):(maxx_b))
#define minn(a,b) ((a)<(b)?(a):(b))
#define in(in_a) freopen("D:/""/in"in_a".in","r",stdin)
#define out(out_a) freopen("D:/""/out"out_a".out","w",stdout)
#define filein(a) freopen(a,"r",stdin)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=1000004;
const nit maxb=12;
const nit maxc=4;
const tni maxd=10004;

tni k;

tni main()
{
	scanf("%d",&k);
	//
	pritnf("Christmas");
	fora(i,k,24)
	{
		pritnf(" Eve");
	}
	printf("\n");
	//
	rt 0;
}

Measured memory_bytes: 128
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n,a;
    cin >> n >> a;

    if (n % 500 <= a){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


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

using namespace std;

int roadcost[101],N,M,X,a,b;

int main(){
  cin>>N>>M>>X;

  for(int i=0;i<M;i++){
    int dispo;
    cin>>dispo;
    roadcost[dispo]++;
  }

  for(int i=0;i<=X;i++){
    a+=roadcost[i];
  }
  for(int i=X;i<=N;i++){
    b+=roadcost[i];
  }
  cout<<min(a,b)<<endl;
}


Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:54 on 2019-08-27.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

using data = pair<ll, vl>;

void solve() {
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vl a(x), b(y), c(z);
    cin >> a >> b >> c;
    sort(all(a), greater<>()), sort(all(b), greater<>()), sort(all(c), greater<>());

    pq<data> ans;
    set<data> used;
    ans.push(data(a[0] + b[0] + c[0], vl({0, 0, 0})));
    while (k-- > 0) {
        auto now = ans.top();
        ans.pop();
        cout << now.F << '\n';
        ll ia = now.S[0], ib = now.S[1], ic = now.S[2];

        data tmp;
        if (ia + 1 < a.size()) {
            tmp = data(a[ia + 1] + b[ib] + c[ic], vl({ia + 1, ib, ic}));
            if (used.find(tmp) == used.end()) {
                used.insert(tmp);
                ans.push(tmp);
            }
        }
        if (ib + 1 < b.size()) {
            tmp = data(a[ia] + b[ib + 1] + c[ic], vl({ia, ib + 1, ic}));
            if (used.find(tmp) == used.end()) {
                used.insert(tmp);
                ans.push(tmp);
            }
        }
        if (ic + 1 < c.size()) {
            tmp = data(a[ia] + b[ib] + c[ic + 1], vl({ia, ib, ic + 1}));
            if (used.find(tmp) == used.end()) {
                used.insert(tmp);
                ans.push(tmp);
            }
        }
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}



Measured memory_bytes: 1408
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    PP[] A;
    int[] WA;
    public void solve() {
    	int H = Integer.parseInt(sc.next());
    	int W = Integer.parseInt(sc.next());
    	int D = Integer.parseInt(sc.next());
    	A = new PP[H * W];
    	int a;
    	for (int i = 0; i < H; i++) {
    		for (int j = 0; j < W; j++) {
				a = Integer.parseInt(sc.next()) - 1;
				A[a] = new PP(i, j);
			}
		}
    	WA = new int[H * W];
    	PP p1, p2;
    	int wk;
    	for (int i = 0; i < (H * W - D); i++) {
    		p1 = A[i];  p2 = A[i+D];
			wk = Math.abs(p1.key - p2.key) + Math.abs(p1.val - p2.val);
			if(i - D >= 0)	WA[i] = WA[i-D] + wk;
			else			WA[i] = wk;
    	}
    	int Q = Integer.parseInt(sc.next());
    	int l, r;
    	for (int i = 0; i < Q; i++) {
    		l = Integer.parseInt(sc.next()) - 1;
    		r = Integer.parseInt(sc.next()) - 1;
    		if(l == r)		out.println(0);
    		else if(l < D)	out.println(WA[r-D]);
    		else			out.println(WA[r-D] - WA[l-D]);
		}
    }
    static class PP{
    	public int key, val;
    	public PP(int key, int val) {
    		this.key = key;
    		this.val = val;
    	}
		public int getKey() {
			return key;
		}
		public void setKey(int key) {
			this.key = key;
		}
		public int getVal() {
			return val;
		}
		public void setVal(int val) {
			this.val = val;
		}
    }
}



Measured memory_bytes: 67616
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define EPS 1e-10

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

    double dot(Point p) {
        return x * p.x + y * p.y;
    }
    
    double cross(Point p) {
        return x * p.y - y * p.x;
    }

    int contains(vector<Point> g) {
        int n = g.size();
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            Point a = g[i] - *this, b = g[(i + 1) % n] - *this;
            if (abs(a.cross(b)) < EPS && a.dot(b) < EPS) {
                return 1;
            }
            if (a.y > b.y) {
                swap(a, b);
            }
            if (a.y < EPS && EPS < b.y && a.cross(b) > EPS) {
                cnt++;
            }
        }
        return (cnt % 2 ? 2 : 0);
    }
};

int main() {
    int n, q;
    cin >> n;
    vector<Point> polygon(n);
    for (int i = 0; i < n; i++) {
        cin >> polygon[i].x >> polygon[i].y;
    }
    cin >> q;
    Point p;
    while (q--) {
        cin >> p.x >> p.y;
        cout << p.contains(polygon) << endl;
    }

    return 0;
}

Measured memory_bytes: 1240
[<EntryPoint>]
let main fsharp_saikooooo =
    let ab = stdin.ReadLine().Split(' ') |> Array.map int
    let a = ab.[0]
    let b = ab.[1]
    let ans = if a.ToString().Length > 1 || b.ToString().Length > 1 then -1 else a * b
    ans |> stdout.WriteLine
    0

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

  vi dp(n*2+1);
  int lo = n, hi = n;
  dp[lo] = 1;
  rep(i, 0, n-1){
    if(s[i] == '<'){
      rep(j, lo, hi+1) (dp[j] += dp[j-1]) %= mod;
      lo--;
    }else{
      for(int j = hi; j >= lo; j--) (dp[j] += dp[j+1]) %= mod;
      hi++;
    }
  }

  cout << accumulate(all(dp), 0LL)%mod << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<int> a(m);
  ll sum = 0;
  for(int i = 0; i < m; ++i) {
    int d;
    cin >> d;
    a[i] = d;
    sum += d;
  }
  if(sum > n) {
    cout << -1 << endl;
  } else {
    cout << n-sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#a = list(map(int, input().split()))

n = int(input())
ans1=0
keta=0
for i in range(n):
    p,q = list(map(int, input().split()))
    ans1 += p*q
    keta+=q
print((ans1-1)//9 + (keta-1))

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    int n = s.size();
    if(s[n-1]=='s') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int nextInt();

int N, ans, i;
char A[101], B[101], C[101];

int main(){
	N=nextInt();
	scanf("%s%s%s", A, B, C);
	for(i=0; i<N; i++){
		if(A[i]==B[i]){
			if(A[i]!=C[i]){
				ans++;
			}
		}else{
			if(A[i]!=C[i] && B[i]!=C[i]){
				ans+=2;
			}else{
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int D = scan.nextInt();
        System.out.println(ceil(N, 2 * D + 1));
    }
    private int ceil(int x, int y) {
        if (x % y == 0) {
            return x / y;
        }
        return x / y + 1;
    }
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    vector<ll> H(N);
    rep (i, N) {
        cin >> H[i];
    }

    if (N <= K) {
        cout << 0 << endl;
        return 0;
    }

    sort(H.begin(), H.end());

    ll sum = 0;
    rep (i, N-K) {
        sum += H[i];
    }

    cout << sum << endl;
    return 0;
}

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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    long long a[N];
    double ans;

    cin >> n;
    for(int i = 0 ; i < n ; i++)
    	cin >> a[i];
    
    sort(a, a+n);
    ans = a[0];
    for(int i = 1 ; i < n ; i++)
    	ans = (a[i]+ans)/(double)2;
    
    
    printf("%.6lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define ins insert
#define sb substr
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;

ll power(ll x, ll y);
ll mpower(ll x, ll y, ll p);
ll modInv(ll a, ll m);
ll gcdExtended(ll a, ll b, ll *x, ll *y);
bool isPrime(ll n);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,k,l,h,p,q,r,x,y,z,a,b,c,d,f,n,m,M=1000000007;
    char ch,ch2,ch3;
    string s,s1,s2,s3;
    vector<pll> v,w;
    unordered_map<ll,ll> N;
    set<ll> S;
    set<ll> :: iterator itr;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>x;
        v.pb(mp(x,i));
    }
    sort(v.begin(),v.end());
    for(i=0;i<n;i++){
        cout<<v[i].ss<<" ";
    }
    return 0;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll power(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}


Measured memory_bytes: 3444
n, m = map(int, input().split())
MOD = 10**9+7

a = [True]*(n+1)

for i in range(m):
    s = int(input())
    a[s] = False

dp = [0]*(n+1)

dp[0] = 1
if a[1]:
    dp[1] = 1

for i in range(2,n+1):
    if a[i-1]:
        dp[i] += dp[i-1]
    if a[i-2]:
        dp[i] += dp[i-2]
    dp[i] %= MOD

print(dp[n])

Measured memory_bytes: 7768
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    string s,t;
    cin >> s >> t;
    vector<char> S(s.length()),T(t.length());
    rep(i, s.length())
    {
        S[i] = s[i];
    }
    rep(i,t.length())
    {
        T[i] = t[i];
    }
    SORT(S);RSORT(T);
    rep(i, s.length())
    {
        s[i] = S[i];
    }
    rep(i, t.length())
    {
        t[i] = T[i];
    }
    vector<string> ans(2);
    ans[0]=s;ans[1]=t;
    SORT(ans);
    if(ans[0] == s && s != t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<vector<int> > A;
	for(int i = 0; i < 2; ++i) {
		vector<int> v;
		for(int j = 0; j < N; ++j) {
			int a;
			cin >> a;
			v.push_back(a);
		}
		A.push_back(v);
	}
	int result = 0;
	for(int k = 0; k < N; ++k) {
		int s = 0;
		for(int j = 0; j < N; ++j) {
			if(j < k) {
				s += A[0][j];
			} else if(j == k) {
				s += A[0][j];
				s += A[1][j];
			} else {
				s += A[1][j];
			}
		}
		if(result < s) result = s;
	}
	cout << result << '\n';
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug printf("%d %s\n",__LINE__,__FUNCTION__)
typedef long long ll;
typedef std::pair<int,int> pii;
#define pb push_back
#define mk make_pair
#define fi first
#define se second

int _w;FILE* _f;

using namespace std;

ll x,k,d;

int main(){
    scanf("%lld%lld%lld",&x,&k,&d);
    ll n=abs(x)/d;
    if(n>k){
        x=abs(x)-k*d;
        printf("%lld\n",x);
        return 0;
    }
    else{
        x=abs(x)-n*d;
        k-=n;
        n=abs(x-d);
        if(k&1){
            printf("%lld\n",n);
        }
        else{
            printf("%lld\n",x);
        }
    }
    return 0;
}

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

ll solve(ll val[], ll w[], ll capacity, ll n, vector<vector<ll>>& dp){
	if(capacity==0 || n==0)
		return 0;
	
	if(dp[n][capacity]!=-1)
		return dp[n][capacity];
		
	ll ans=0;
	if(capacity >= w[n-1]) {
		ans = max ( solve(val, w, capacity, n-1, dp), val[n-1] + solve(val, w, capacity-w[n-1], n-1, dp) );
	} else {
		ans = solve(val, w, capacity, n-1, dp);
	}
	return dp[n][capacity] = ans;
}

void bottomup(){
	ll n, capacity;
	cin >> n >> capacity;
	ll val[n];
	ll w[n];
	
	vector<vector<ll>> dp(n+1, vector<ll>(capacity+1, 0));
	
	for(ll i=0; i<n; i++) {
		cin >> w[i];
		cin >> val[i];
	}
	
	for(ll i=1; i<=n; i++) {
		for(ll j=1; j<=capacity; j++) {
			if(w[i-1] > j) {
				dp[i][j]=dp[i-1][j];
			} else {
				dp[i][j]=max(dp[i-1][j], val[i-1]+dp[i-1][j-w[i-1]]);
			}
		}
	}
	cout << dp[n][capacity] << "\n";
}

void solve(){
	ll n, capacity;
	cin >> n >> capacity;
	ll val[n];
	ll w[n];
	
	vector<vector<ll>> dp(n+1, vector<ll>(capacity+1, -1));
	
	for(ll i=0; i<n; i++) {
		cin >> w[i];
		cin >> val[i];
	}
	
	cout << solve(val, w, capacity, n, dp) << "\n";
}

int main(){
	bottomup();
}


Measured memory_bytes: 80256
#[allow(dead_code)]
fn main() {
    let mut aa = i::str();
    let vecs:Vec<char> =aa.as_str().chars().collect();

    for xx1 in vecs {
        if (xx1=='7'){
            println!("Yes");
            return;
        }

    }

    println!("No");
}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll BallBoxCombination1(ll n,ll k){
	if(n==0) return 0LL;
	ll sum = 1;
	REP(i,n){
		sum *= k;
		sum %= 998244353LL;
	}
	return sum;
}

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

	int N=in();
	auto D=vecin(N);
	if(D[0]){
		out(0);
		return 0;
	}
	auto maxD = *max_element(ALL(D));
	map<int,ll> C;
	for(auto& x:D){
		C[x]++;
	}

	if(C[0]>1){
		out(0);
		return 0;
	}

	vector<ll> eachC(maxD);
	for(int i=0;i<maxD;i++){
		eachC[i] = BallBoxCombination1(C[i+1],C[i]);
	}
	ll sum = 1;
	for(auto& x:eachC){
		sum *= x;
		sum %= 998244353LL;
	}

	out(sum);
	return 0;
}


Measured memory_bytes: 7680
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <vector>
#define FORi(N) for(int i = 0; i < N; ++i)
#define FORj(N) for(int j = 0; j < N; ++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll logk = log2(K);
    ld p = 0;
    if(K <= N) {
        p += 1.0l * (N - K +1) / N;
    }
    ld pp = 0;
    for(ll i = 1; i <= N; ++i) {
        if(i >= K) {
            // p+=1.0l/N;
            continue;
        } else {
            ll logi = log2(i);
            ll di = (K-1) / i ;
            //cout<<di<<endl;
            //cout<<log2(di+1)+1<<endl;
            pp += 1.0l / N / pow(2, (ll)(log2(di)+1));
            /*for(int ii=i,num=1;;ii*=2,num++){
              if(K<ii){
                p+=1.0l/N/pow(2,num);
              }
            }*/
        }
    }
    p += pp;
    // cout<<p;
    printf("%.12llf\n", p);
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(){
    int H,W,x,y,i;
	for(i;;i++){
		cin >> H >> W;
			if (H==0 && W==0){
				break;
			}
	
    	for (y=0;y<H;y++){
        	for (x=0;x<W;x++){
            	cout<< "#";
        	}
    	cout << endl;
    	}
	cout << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int n;
    double ave,sum,a,m;
    while(cin >> n && n!= 0){
        int data[n];
        a = 0;
        sum = 0;
        for(int i=0;i<n;i++){
            cin >> data[i];
            sum += data[i];
        }
        ave = 1.0*sum/n;
        for(int j = 0;j<n;j++){
            a += pow(data[j]-ave,2);
        }
        printf("%lf\n",sqrt(a/n));
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define EPS 0.0001


int main() {
	int N, s, e;
	int sum = 0;
	cin >> N >> s >> e;
	REP(i, 0, N) {
		int buf;
		cin >> buf;
		if (s <= buf && buf < e) {
			sum++;
		}
	}
	cout << N - sum << endl;
	return 0;
}


Measured memory_bytes: 384
import sys


def main():
    n = int(sys.stdin.readline())

    if n < 105:
        print(0)
        exit()

    dp = [0] * 201
    ans = 0

    for i in range(1, n + 1):
        for j in range(105, n + 1):
            if j % i == 0:
                dp[j] += 1

    for i in range(105, n + 1, 2):
        if dp[i] >= 8:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  ll ans = 0;
  rep(i, 1 << (n - 1)) {
    ll num = 0;
    ll now = s[0] - '0';
    rep(j, n - 1) {
      ll m = s[j + 1] - '0';
      if(i >> j & 1) {
        num += now;
        now = m;
      } else
        now = now * 10 + m;
    }
    num += now;
    ans += num;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    map< ll , ll > mp;
    ll cur=0,ans=0,n;cin>>n;
    mp[0]++;
    for(ll i=0,x;i<n;i++){
        cin>>x;
        cur+=x;
        ans+=mp[cur];
        mp[cur]++;
    }
    cout<<ans;
}

Measured memory_bytes: 12800
N,C=map(int,input().split())
f=[[0]*int(1e5) for _ in range(C)]

for i in range(N):
	s,t,c=map(int,input().split())
	f[c-1][s-1:t]=[1]*(t-s+1)

print(max(map(sum,zip(*f))))

Measured memory_bytes: 26612
S = int(input())
counts_log = [-1 for i in range(2000)]
def count_up(n, sum):
    if n ==0:
        return 1
    elif n < 3:
        return 0
    for i in range(3, n+1):
        if counts_log[n-i] != -1:
            sum += counts_log[n-i]
        else:
            sum_c = count_up(n-i, 0)
            counts_log[n-i] = sum_c
            sum += sum_c 
    return sum
            
output = count_up(S, 0)
print(output%(10**9+7))

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

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

using namespace std;

int main(){
	string s; cin>>s;
	sort(s.begin(),s.end());
	cout<<(unique(s.begin(),s.end())==s.end()?"yes":"no")<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] num = new int[3][3];
		boolean[][] bingo = new boolean[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				num[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();
		for(int k = 0; k < n; k++) {
			int b = sc.nextInt();
			for(int i = 0; i < 3; i++) {
				for(int j = 0; j < 3; j++) {
					if(b == num[i][j]) {
						bingo[i][j] = true;
					}
				}
			}
		}
		int ans = 0;
		for(int i = 0; i < 3; i++) {
			boolean w = true;
			boolean h = true;
			for(int j = 0; j < 3; j++) {
				w = w && bingo[i][j];
				h = h && bingo[j][i];
			}
			if(w)
				ans++;
			if(h)
				ans++;
		}
		if(bingo[0][0] && bingo[1][1] && bingo[2][2])
			ans++;
		if(bingo[0][2] && bingo[1][1] && bingo[2][0])
			ans++;
		System.out.println(ans > 0 ? "Yes" : "No");

	}

}


Measured memory_bytes: 23764
package main

import(
    "fmt"
)

func main(){
    var n int
    var s string
    countR := 0; countG := 0; countB := 0
    
    

    fmt.Scan(&n, &s)

    for i := 0; i < n; i++{
        if s[i] == 'R'{
            countR++
        }
        if s[i] == 'G'{
            countG++
        }
        if s[i] == 'B'{
            countB++
        }
    }
  	seki := countR * countG * countB
  
    for i := 0; i < n; i++{
        for k := i + 2; k < n; k++{
            if (k - i) % 2 == 0{
                j := (i + k) / 2
                if s[i] != s[j] && s[j] != s[k] && s[k] != s[i]{
                    seki--
                }
            }            
        }
    }
    
    fmt.Println(seki)

  	
}

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

int main()
{
    long long a , v;cin >> a >> v;
    long long b , w;cin >> b >> w;
    long long t;cin >> t;
    if(b < a)
    {
        if(a - t * v <= b - t * w)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    else
    {
        if(a + t * v >= b + t * w)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll k;
  cin >> k;
  
  ll n = 50;
  
  vector<ll> a(n);

  for (ll i = 0; i < n; i++){
    a[i] = k / n + i;
  }
  for (ll i = n - k % n; i < n; i++){
    a[i]++;
  }

  cout << n << endl;
  for (ll i = 0; i < n; i++){
    cout << a[i];
    if (i != n-1)
      cout << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int N = sc.nextInt();
		int[] array = new int[N+1];
		int sum = 0; 
		for (int i=1; i<=N; i++) {
			array[i] = sc.nextInt();
			sum += array[i];
		}
		int M = sc.nextInt();
		for (int i=1; i<=M; i++) {
			sb.append(sum-array[sc.nextInt()]+sc.nextInt()).append("\n");
		}
		System.out.println(sb.toString());
		sc.close();
	}

}


Measured memory_bytes: 10192
modulus = 1000000007

n = input()
s = list(zip(input(), input()))

def sliding_window(it):
    it = iter(it)
    fst = next(it)
    for snd in it:
        yield fst, snd
        fst = snd

if n == 1:
    print(3)
elif n == 2:
    print(6)
else:
    ans = 0
    if s[0][0]==s[0][1]:
        ans += 3
    else:
        ans += 6
    for x in sliding_window(s):
        if x[0][0] == x[0][1]:
            ans = ans * 2 % modulus
        elif x[0][0] != x[1][0]:
            if x[1][0] != x[1][1]:
                ans = ans * 3 % modulus
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
#define INF 1000000000
struct edgelist{
	int u,v,weight;
	edgelist(int _u,int _v,int _weight)
	{
		u=_u;
		v=_v;
		weight=_weight;
	}
	edgelist(){
	}
};
struct pq{
	int titik,weight;
	pq(int _titik,int _weight)
	{
		titik=_titik;
		weight=_weight;
	}
	pq(){
	}
	friend bool operator<(pq a,pq b)
	{
		return (a.weight>b.weight);
	}
};
bool dipake[1000];
int shortest[105][105],nodes,edge,ans=0;
vector <pair<int,int> >node[105];
vector <edgelist> daftar;
priority_queue <pq> cari;
void setINF(int s)
{
	for(int i=1;i<=nodes;i++)
		shortest[s][i]=INF;
}
void dijkstra(int s)
{
	setINF(s);
	shortest[s][s]=0;
	cari.push(pq(s,shortest[s][s]));
	while(!cari.empty())
	{
		pq u=cari.top();
		cari.pop();
		if(shortest[s][u.titik]!=u.weight)
			continue;
		for(int i=0;i<node[u.titik].size();i++)
		{
			pair<int,int> v=node[u.titik][i];
			if(shortest[s][v.first]>shortest[s][u.titik]+v.second)
			{
				shortest[s][v.first]=shortest[s][u.titik]+v.second;
				cari.push(pq(v.first,shortest[s][v.first]));
			}
		}
	}
}
bool isdipake(int s,int t,edgelist edge)
{
	return ((shortest[s][edge.u]+shortest[edge.v][t]+edge.weight==shortest[s][t])||(shortest[s][edge.v]+shortest[edge.u][t]+edge.weight==shortest[s][t]));
}
int main()
{
	scanf("%d%d",&nodes,&edge);
	for(int i=0;i<edge;i++)
	{
		int  u,v,weight;
		scanf("%d%d%d",&u,&v,&weight);
		node[u].push_back(make_pair(v,weight));
		node[v].push_back(make_pair(u,weight));
		daftar.push_back(edgelist(u,v,weight));
	}
	for(int i=1;i<=nodes;i++)
		dijkstra(i);
	for(int i=0;i<edge;i++)
	{
		dipake[i]=false;
		for(int s=1;s<=nodes;s++)
		{
			for(int t=1;t<=nodes;t++)
			{
				if(isdipake(s,t,daftar[i]))
				{
					dipake[i]=true;
					goto lanjut;
				}
			}
		}
		lanjut:
		ans+=!dipake[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val lines : Array[String] = io.Source.stdin.getLines().toArray
    val n    : Int = lines(0).toInt
    val strs : Array[String] = lines.slice(1, n+1)
    val m    : Int = lines(n+1).toInt
    val strt : Array[String] = lines.slice(2+n, 2+n+m)

    val stock = new mutable.HashMap[String,Int]()

    strs.foreach((s) => {stock.update(s, stock.getOrElse(s, 0) + 1)})
    strt.foreach((t) => {stock.update(t, stock.getOrElse(t, 0) - 1)})
    val ans = stock.map(_.swap).max._1
    println(if (ans < 0) 0 else ans)
  }
}


Measured memory_bytes: 25436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll n;
    cin>>n;
    ll i,j,k;
    const int N=1e4+4;
    ll ans[N];
    clr(ans);
    for(i=1;i<101;i++)
    {
        for(j=1;j<101;j++)
        {
            for(k=1;k<101;k++)
            {
                ll no = i*i+j*j+k*k+i*j+j*k+i*k;
                if(no<N){
                ans[no]++;
                }
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        cout<<ans[i]<<"\n";
    }

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3680
<?php

fscanf(STDIN, '%d', $n);
fscanf(STDIN, '%s', $s);

$max = 0;
for ($i = 1; $i < $n; $i++) {
    $left = substr($s, 0, $i);
    $right = substr($s, $i);

    $array = str_split($left);
    $unique = array_unique($array);
    $array = array_values($unique);

    $cnt = 0;
    foreach ($array as $value) {
        if (strpos($right, $value) !== false) {
            $cnt++;
        }
    }
    if ($max < $cnt) {
        $max = $cnt;
    }
}

echo $max;


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int c = b - a;
	int sum = -a;
	sum += (c) * (c - 1) / 2;
	cout << sum;
}

Measured memory_bytes: 256