akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

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

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

int h,w;

bool jud(int y,int x){return (0<=y and y<h)and(0<=x and x<w);}

int main(){
	cin>>h>>w;
	
	vector<string> s(h);
	REP(i,h) cin>>s[i];
	
	vvi dp(h,vi(w,INF));
	if(s[0][0]=='#') dp[0][0]=1;
	else dp[0][0]=0;
	REP(i,h)REP(j,w){
		REP(k,2){
			int ny=i+dy[k];
			int nx=j+dx[k];
			if(jud(ny,nx)){
				if(s[ny][nx]==s[i][j] or s[ny][nx]=='.') chmin(dp[ny][nx],dp[i][j]);
				else chmin(dp[ny][nx],dp[i][j]+1);
			}
		}
	}
	//REP(i,h) line(dp[i]);
	
	cout<<dp[h-1][w-1]<<endl;
}

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

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

    int treatsArray[n] = {};
    for (auto ik = 0; ik < k; ik++) {
        int d;
        cin >> d;

        for (auto id = 0; id < d; id++) {
            int a;
            cin >> a;
            treatsArray[a-1]++;
        }
    }

    int tricks;
    for (auto treats: treatsArray) if (treats == 0) tricks++;
    cout << tricks;
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N = 0;
    cin >> N;
    string name = "";
    int point = 0;

    vector<string> names = vector<string>();
    vector<int> points = vector<int>();
    vector<int> ranks = vector<int>();
    for(int i = 0; i < N; i++){
        cin >> name >> point;
        ranks.push_back(1);
        names.push_back(name);
        points.push_back(int(point));
        if(i == 0){
            continue;
        }else if(i == 1){
            if(name < names[0]){
                ranks[0]++;
            }else if(name == names[0] && point > points[0]){
                ranks[0]++;
            }else{
                ranks[1]++;
            }
        }else{
            for(int j = 0; j < i; j++){
                if(name < names[j]){
                    ranks[j]++;
                }else if(name == names[j] && point > points[j]){
                    ranks[j]++;
                }else{
                    ranks[i]++;
                }
            }
        }
    }
    vector<int> ans = ranks;
    for(int i = 0;i < N; i++){
        for(int j = 0;j < N; j++){
            //printf("%d\n", ranks[j]);
            if(i+1 == ranks[j]){
                ans[i] = j+1;
            }
        }
    }
    for(int i : ans){
        printf("%d\n", i);
    }
    return 0;
}


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

using Elist = vector<vector<int>>;
int n;
Elist elist;

priority_queue<int,vector<int>,greater<int>> unused;

vector<int> label;

int ans;

void Dfs(int n, int p=-1){
  for(auto&e:elist[n]){
    if(e == p)continue;
    Dfs(e,n);
    ans += label[e];
  }
  label[n] = unused.top();
  unused.pop();
}

int main(){
  cin >> n;
  elist.resize(n);
  label.resize(n);
  for(int i = 0; i < n-1; ++i){
    int a, b; cin >> a >> b; a--; b--;
    elist[a].push_back(b);
    elist[b].push_back(a);
  }
  for(int i = 0; i < n; ++i){
    int x; cin >> x; unused.push(x);
  }
  Dfs(0);
  cout << ans << endl;
  for(int i = 0; i < n; ++i){
    if(i) cout << ' ';
    cout << label[i];
  }
  cout << endl;

  return 0;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int x;
	cin >> x;
	x /=200;

	cout << 10 - x << endl;







	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	int c=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if((i+1)%2!=0 && a[i]%2!=0){
            c++;
        }
    }
    cout<<c<<"\n";
    
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;



int main()
{
    int n,m;
    cin >> n >> m;
    int c[m];
    for(int i = 0; i < m; i++){
        cin >> c[i];
    }
    int dp[n+1];
    for(int i = 0; i < n+1; i++) dp[i] = inf;
    dp[0] = 0;
    for(int i = 0; i < m; i++){
        for(int j = 0; j <= n; j++){
            if(j - c[i] >= 0){
                dp[j] = min(dp[j],dp[j-c[i]] + 1); 
            }
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
#define endl "\n" 
using namespace std;
#define debug(x) cout<<"The value of "<<#x<<" is "<<x<<endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    cin.sync_with_stdio(0); cin.tie(0); 
    string a,b;
    cin>>a>>b;
    if(a==b.substr(0,b.size()-1)) 
    cout<<"Yes"<<endl;
    else 
    cout<<"No"<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>
#include <string.h>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

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

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


		if (tmp <= A)
		{
			freq[0]++;
		}
		else if (tmp <= B)
		{
			freq[1]++;
		}
		else
		{
			freq[2]++;
		}
	}

	int ans = min(freq[0], min(freq[1], freq[2]));

	cout << ans << endl;

	return 0;
}


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

typedef pair<int, int> P;

int main()
{
	int h, w;
	cin >> h >> w;
	bool maze[20][20] = { 0 };
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			if (c == '#')
			{
				maze[i][j] = true;
			}
		}
	}
	int max = 0;
	queue<P> que;
	for (int sy = 0; sy < h; sy++)for (int sx = 0; sx < w; sx++)
	{
		if (maze[sy][sx])
			continue;
		
		bool visit[20][20] = { 0 };

		P s = make_pair(sy, sx);
		visit[sy][sx] = true;

		que.push(s);

		int max_ = 0;

		while (1)
		{
			queue<P> que2;
			while (!que.empty())
			{
				P now = que.front();
				que.pop();
				int& ny = now.first;
				int& nx = now.second;

				if ((nx == 0 ? false : maze[ny][nx - 1] ? false : visit[ny][nx - 1] ? false : true))
				{
					que2.push(make_pair(ny, nx - 1));
					visit[ny][nx - 1] = true;
				}
				if ((nx == w - 1 ? false : maze[ny][nx + 1] ? false : visit[ny][nx + 1] ? false : true))
				{
					que2.push(make_pair(ny, nx + 1));
					visit[ny][nx + 1] = true;
				}
				if ((ny == 0 ? false : maze[ny - 1][nx] ? false : visit[ny - 1][nx] ? false : true))
				{
					que2.push(make_pair(ny - 1, nx));
					visit[ny - 1][nx] = true;
				}
				if ((ny == h - 1 ? false : maze[ny + 1][nx] ? false : visit[ny + 1][nx] ? false : true))
				{
					que2.push(make_pair(ny + 1, nx));
					visit[ny + 1][nx] = true;
				}
			}
			if (que2.empty())
				break;
			que = que2;
			max_++;
		}

		max = (max_ > max ? max_ : max);
	}
	
	cout << max << endl;

	return 0;
}

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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  if(A == B) {
    ans+= A * 2;
  } else {
    ans += max(A, B) + max(A, B) - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::stdin;
use std::collections::HashMap;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let _n = st.trim().parse::<usize>().unwrap();
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let s:Vec<char> = st.trim().chars().collect();
    let mut map:HashMap<&char, i64> = HashMap::new();
    for i in &s {
        let count = map.entry(i).or_insert(1);
        *count += 1;
    };
    let mo = 1000000007;
    let mut result:i64 = 1;
    for (_i, j) in map.iter() {
        result = (result*j)%mo;
    };
    println!("{}", result-1);
}

Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = long.Parse(Console.ReadLine());
            var B = long.Parse(Console.ReadLine());
            var C = long.Parse(Console.ReadLine());
            var D = long.Parse(Console.ReadLine());
            var E = long.Parse(Console.ReadLine());
            decimal ret = 4;
            var min = GetMin(A, B, C, D, E);
            ret += Math.Ceiling((decimal) N / (decimal) min);
            Console.WriteLine(ret);
        }

        static long GetMin(params long[] args)
        {
            return args.Min();
        }
        
    }
}

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

using namespace std;

using   ll=long long;
using   ld=long double;

#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define long long      int 
#define pb             push_back
#define mp             make_pair
#define ff             first
#define ss             second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define inf 		   LLONG_MAX
#define ones(x)		   __builtin_popcount(x)

void solve()
{
	string s;
	
	cin>>s;
	
	if(s !="AAA" && s!="BBB")
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No";
	}
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int l,i;
	int m,n,sum,flg;
	while(1){
		cin>>l;
		sum=flg=0;
		if(l==0) break;
		for(i=1;i<=12;i++) {
			cin>>m>>n;
			sum+=m-n;
			if(sum>=l && flg==0) flg=i;
		}
		if(sum<l) cout<<"NA"<<endl;
		else if(flg!=0)cout<<flg<<endl;
	}
	return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var ans = 0;            
            
            for(var i = 0; i < A.Length; i++)
            {
                var a = A[i];
                while (true)
                {
                    if (a % 2 == 0) { a /= 2; ans++; }
                    else break;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 14176
from collections import defaultdict
H,W,M = map(int,input().split())
L=[]
bomb = defaultdict(lambda: 0)
for i in range(M):
    h,w = map(int,input().split())
    L.append([h-1,w-1])
    bomb[(h-1,w-1)] = 1

h = dict()
w = dict()

for i in range(M):
    val = L[i][0]
    if val in h:
        h[val] += 1
    else:
        h[val] = 1

for i in range(M):
    val = L[i][1]
    if val in w:
        w[val] += 1
    else:
        w[val] = 1

maxh = []
maxw = []
m=-1
for val in h:
    if h[val]>m:
        m = h[val]

for val in h:
    if m==h[val]:
        maxh.append(val)

ans = m
m=-1
for val in w:
    if w[val]>m:
        m=w[val]

for val in w:
    if m==w[val]:
        maxw.append(val)

ans += m
#print(maxh)
#print(maxw)
for mh in maxh:
    for mw in maxw:
        if bomb[(mh,mw)]==0:
            print(ans)
            exit()

print(ans-1)

Measured memory_bytes: 201980
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := iScan(), iScan(), iScan()
	if a == b && b == c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){
    int n;
    cin >> n;
    int c[10][10] = {};

    for(int i = 1; i <= n; ++i){
        string s = to_string(i);
        c[s.front() - '0'][s.back() - '0']++;
    }

    LL ans = 0;

    for(int i = 0; i <= 9; ++i){
        for(int j = 0; j <= 9; ++j){
            ans += c[i][j] * c[j][i];
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  if (Y%2 != 0 || Y/2 < X || Y/2 > 2*X)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

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

int main() {
    int N, a;
    cin >> N;
    bool flag=true;
    for(int i=0; i<N; i++){
	cin >> a;
	if(a%2==0){
	    if(a%3==0)
		;
	    else if(a%5==0)
		;
	    else
		flag=false;				
	}
    }
    cout << (flag? "APPROVED": "DENIED") << endl;
} 



Measured memory_bytes: 256
let n = stdin.ReadLine() |> int
let ab = [| for i in 1..n -> stdin.ReadLine().Split() |> Array.map int |]

let _,doesSuccess = 
    ab 
    |> Array.sortBy(fun [| _; y; |] -> y) 
    |> Array.fold 
        (fun (xTotal,doesSuccess) [| x; y; |] ->
            let xTotal = xTotal + x
            xTotal, doesSuccess && (y - (xTotal)) >= 0 )
        (0, true)

match doesSuccess with
| true -> "Yes"
| false -> "No"
|> stdout.WriteLine 


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

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

    int ri = -1;
    int rj = -1;
    int rk = -1;
    for(int i = 0; i <= N; ++i) {
        for(int j = 0; i + j <= N; ++j) {
            int k = N - i - j;
            int total = i * 10000 + j * 5000 + k * 1000;
            if(total == Y) {
                ri = i;
                rj = j;
                rk = k;
            }
        }
    }
    cout << ri << " " << rj << " " << rk << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int num[] = new int[5];
		char cs[] = {'m','a','r','c','h'};
		for(int i=0;i<n;i++) {
			String s = fs.next().toLowerCase();
			char c = s.charAt(0);
			for(int j=0;j<5;j++) {
				if(cs[j] == c) {
					num[j] ++;
				}
			}
		}
		long ans = 0;
		for(int i=0;i<1<<5;i++) {
			int cnt = 0;
			long res = 1;
			for(int j=0;j<5;j++) {
				if((i>>j&1)==1) {
					cnt ++;
					res *= num[j];
				}
			}
			if(cnt != 3)continue;
			ans += res;
		}
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

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

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

Measured memory_bytes: 40772
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;



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

  ll n,m;
  std::cin>>n>>m;

  std::vector<std::vector<P>> graph(n);

  rep(i,0,m){
    ll u,v,s;
    std::cin>>u>>v>>s;

    u--;v--;
    graph[u].push_back({v,s});
    graph[v].push_back({u,s});
  }

  std::vector<P> num(n,{0,-1});
  num[0]={0,0};

  ll min=1,max=MOD;

  std::queue<ll> que;
  que.push(0);

  while(!que.empty()){
    ll e=que.front();que.pop();

    for(P next:graph[e]){
      P temp={next.second-num[e].first,num[e].second^1};
      if(temp.second) chmin(max,temp.first-1);
      else chmax(min,1-temp.first);

      if(num[next.first].second==-1){
        num[next.first]=temp;
        que.push(next.first);
      }else{
        if(num[next.first].second^temp.second){
          if(num[next.first].second==1){
            if((num[next.first].first-temp.first)%2!=0){
              std::cout<<0<<"\n";
              return 0;
            }
            chmax(min,(num[next.first].first-temp.first)/2);
            chmin(max,(num[next.first].first-temp.first)/2);
          }else{
            if((-num[next.first].first+temp.first)%2!=0){
              std::cout<<0<<"\n";
              return 0;
            }
            chmax(min,(-num[next.first].first+temp.first)/2);
            chmin(max,(-num[next.first].first+temp.first)/2);
          }
        }else{
          if(num[next.first].first!=temp.first){
            std::cout<<0<<"\n";
            return 0;
          }
        }
      }
    }
  }

  if(min<=max)std::cout<<max-min+1<<"\n";
  else std::cout<<0<<"\n";

  return 0;
}

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

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

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const long long  INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

ll n, x, a[110], ans;

int main() {
	cin >> n >> x;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0;i < n;i++) {
		if (i == n - 1&&a[i]==x) {
			ans++;
			break;
		}
		else if (i == n - 1) {
			break;
		}
 		if (a[i] <= x)ans++, x -= a[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a,b;
  cin>>a>>b;
  if(a.size()==b.size()){
    rep(i,a.size()){
      cout<<a[i]<<b[i];
    }
  }
  else if(a.size()>b.size()){
    rep(i,b.size()){
      cout<<a[i]<<b[i];
    }
    FOR(i,b.size(),a.size()){
      cout<<a[i];
    }
  }
  else{
    rep(i,a.size()){
      cout<<a[i]<<b[i];
    }
    FOR(i,a.size(),b.size()){
      cout<<b[i];
    }
  }

}
     









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

int calc(int n,int s,int min)
{
    int r=0;
    if (s<min)
	return 0;
    if (n==1)
    {
	if (s<10)
	    return 1;
	else
	    return 0;
    }
    for (int i=min; i<10; i++)
    {
	r+=calc(n-1,s-i,i+1);
    }
    return r;
}

int main()
{
    int n,s;
    while (1)
    {
	cin >> n >> s;
	if (n==0)break;
	cout << calc(n,s,0) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

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

    ll ans = 0;
    REPS (i, N) {
        if (i % 3) {
            if (i % 5) {
                ans += i;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include<string>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b<c||d<a){
        cout<<0<<endl;
        return 0;
    }
    cout<<min(b,d)-max(a,c)<<endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
kk = int(input())

ls = len(s)
m = ['zzzzz']*5
for i in range(ls):
    for j in range(i, i+5):
        ss = s[i:j+1]
        if ss in m:
            continue
        for k in range(len(m)):
            if m[k] > ss:
                m.insert(k, ss)
                break
        m = m[0:5]
print(m[kk-1])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define N            1000000//31630=sqrt(pow(10,9))
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
//bool pf[N+1ll];
//vec prim;
//void sieve()
//{
//    repi(i,0,N)
//    pf[i]=true;
//	pf[0] = pf[1] = false;
//    for (int i = 2; i <= N; i++) {
//        if (pf[i]) 
//		{
//            prim.push_back(i);
//            for (int j = i + i; j <= N; j+=i) {
//                pf[j] = false;
//            }
//        }
//    }
//}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll m,i,l,h,j,mx,my,ans,d,n,r,g,b,e,f;
//    	cin>>m;
//    	cout<<fixed<<setprecision(10);
//    	lld k=M_PI;
//    	k=k*(2.00)*(m*1.00);
//    	cout<<k;
    	cin>>n>>m;
    	l=0;
    	rep(i,0,m)
    	{
    		cin>>j;
    		l+=j;
		}
    	cout<<max(-1ll,n-l);
	}
	return 0;
} 

Measured memory_bytes: 3696
from collections import Counter

def prime_factorize(n):
    a = 0
    while n % 2 == 0:
        a += 1
        n //= 2
    return a

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

ans = 0

for i in a:
    ans += prime_factorize(i)
print(ans)

Measured memory_bytes: 4532
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

using namespace std;

int main(){

    int n, x;
    cin >> n >> x;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];

    unsigned long long ans = max(0,a[0]-x);
    a[0] = min(x,a[0]);

    for(int i=1;i<n;i++){
        unsigned long long tmp = max(0,a[i]+a[i-1]-x);
        a[i] -= tmp;
        ans += tmp;
        //cout << ans << endl;
    }

    cout << ans << endl;

}


Measured memory_bytes: 640
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

a = LIST()
to = max(a)
sm = sum(a)

if (sm - to) % 2:
    to += 1
ans = 0
for i in range(3):
    ans += to - a[i]
ans //= 2
print(ans)


Measured memory_bytes: 59628
#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 int MOD = 1e9 + 7;

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<ll> x(n);
    for (int i = 0; i < n; i++)
        cin >> x[i];
    ll L, Q;
    cin >> L >> Q;
    // r[i][j] := ホテル i から 2^j 日で到達できる最右ホテル
    vector<vector<int>> r(n, vector<int>(20));
    for (int i = 0; i < n; i++)
    {
        auto itr = upper_bound(x.begin(), x.end(), x[i] + L);
        itr--;
        r[i][0] = distance(x.begin(), itr);
    }
    for (int j = 1; j < 20; j++)
    {
        for (int i = 0; i < n; i++)
            r[i][j] = r[r[i][j - 1]][j - 1];
    }
    while (Q--)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (a > b)
            swap(a, b);
        int ret = 1;
        for (int i = 19; i >= 0; i--)
        {
            if (r[a][i] < b)
            {
                a = r[a][i];
                ret += 1 << i;
            }
        }
        cout << ret << endl;
    }
}


Measured memory_bytes: 14976
unittest
{
	assert( [ "5", "2", "1", "4", "5", "3" ].solve == 2 );
	assert( [ "4", "0", "0", "0", "0" ].solve == 4 );
}



import std.container;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.to!( long );
	}
	
	auto rbt = redBlackTree!( true, long )();
	foreach( a; as )
	{
		auto ls = rbt.lowerBound( a );
		if( !ls.empty ) rbt.removeKey( ls.back );
		rbt.insert( a );
	}
	return rbt.length;
}


Measured memory_bytes: 8548
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int64_t N, ans = 0;
  cin >> N;
  if (N % 2)
  {
    cout << 0 << endl;
    return 0;
  }
  int64_t n = 5;
  while (n <= N)
  {
    ans += (N / 2) / n;
    n *= 5;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int findSumOfDigits(int n) {
    int sum = 0;
    while (n > 0) { // n が 0 になるまで
        sum += n % 10;
        n /= 10;
        }
return sum;
}

int main(){
    int N;
    cin >> N;
    int min = 1000000;
    int temp;

    for(int a = 1; a < N; a++){
        int b = N - a;

        temp = findSumOfDigits(a) + findSumOfDigits(b);
        if(min > temp) min = temp;

    
    }

    cout << min << endl;


}

Measured memory_bytes: 256
import math
min_steps = 1e18
number = int(input())
a = math.sqrt(number)
for k in range (1,int(a)+1):
    if number%k == 0:
        i = number//k
        steps = k + i - 2
        if steps <= min_steps:
            min_steps = steps
print(min_steps)



Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;
const long long P = 1000000007;

int bubblesort(int a[],int n) {
  int sw = 0;
  bool flag = 1;
  for(int i = 0; flag; i++) {
    flag = 0;
    for(int j = n-1; j >= i+1; j--) {
      if(a[j] < a[j-1]) {
        swap(a[j],a[j-1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main() {
  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(d2 == 1 && m2-m1 == 1) {
    cout << '1' << endl;
  }else {
    cout << '0' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

def gcd_list(nums):
    return reduce(fractions.gcd, nums)

n, s = map(int, input().split())
X = list(map(int, input().split()))

X.append(s)
X.sort()

Y = [(X[i] - X[i - 1]) for i in range(1, n + 1)]

print(gcd_list(Y))

Measured memory_bytes: 16304
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    ll A, B, N;
    cin>>A>>B>>N;
    ll x = min(B-1, N);
    cout<<((A*x)/B)<<"\n";

}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3516
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define inf (1LL<<61)
#define int long long
typedef long long ll;
#define ld long double
#define ff first
#define ss second

int32_t main()
{
    IOS;
  
    int n;
    cin >> n;
    string a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        if(a[i] == b[i])
        {
            if(a[i] == c[i])
                ;
            else
                ans += 1;
        }
        else
        {
            if(b[i] == c[i])
                ans += 1;
            else
                if(a[i] == c[i])
                    ans += 1;
                else
                    ans += 2;
        }
    }
    cout << ans;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> I(N);
  vector<int> r(N);
  
  for (int i = 0; i < N; i++) {
	cin >> I.at(i) >> r.at(i);
  }//I,r出力
  int c =0;
  for (int i = 0; i < N; i++) {
    c = c +r.at(i) - I.at(i) +1;
  }//１組ごとの人数カウント
 cout << c << endl;
}

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

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0) : d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    ll N;
    cin >> N;
    vector<P> xy(N);
    vector<ll> original(N), xPlaceAtY(N);
    set<ll> yset;
    rep(i, N) {
        cin >> xy[i].first >> xy[i].second;
        --xy[i].first;
        --xy[i].second;
        yset.insert(xy[i].second);
        xPlaceAtY[xy[i].second] = xy[i].first;
        original[i] = xy[i].first;
    }

    sort(xy.begin(), xy.end());
    UnionFind uf = UnionFind(N);
    rep(i, N) {
        yset.erase(xy[i].second);
        if (uf.size(i) > 1) {
            continue;
        }
        // cerr << "i=" << i << "xy[i].first=" << xy[i].first << "xy[i].second=" << xy[i].second << endl;
        for (auto itr = yset.upper_bound(xy[i].second); itr != yset.end(); ++itr) {
            uf.unite(i, xPlaceAtY[*itr]);
        }
    }

    rep(i, N) {
        cout << uf.size(original[i]) << "\n";
    }

    return 0;
}

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

int64_t ceil_div(int64_t a, int64_t b) {
    return (a + b - 1) / b;
}

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

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    // int t;cin>>t;

    // while(t--){
    // }

    int n,k;
    cin>>n>>k;
    vector<int> a(n);

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int ans=0;

    for(int i=0;i<k;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3584
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
int a,b,c;
cin>>a>>b>>c;
if(a!=b&&b!=c&&a!=c){
print("No");
}else if(a==b&&b==c){
print("No");
}else{
print("Yes");
}

    

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
min = 10000000000000000000000000000000000
sum = 0
for i in range(-100,101):
  for j in range(len(a)):
    sum += (a[j]-i)**2
  if sum < min:
    min = sum
  sum = 0
print(min)


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


int main(){
    int n,l;
    cin >> n >> l;
    int a[n + 1];
    int sum = 0;
    for(int i = 1; i <= n; i++){
        a[i] = l + i - 1;
        sum += a[i];
    }
    
    int min = 1000;
    int ans =0;
    for(int i = 1; i <= n; i++){
        if(abs(sum - (sum - a[i])) < min){
            min = abs(sum - (sum - a[i]));
            ans = sum - a[i];
        }
    }    
   // cout << sum << " " << min << endl;
    cout <<ans << endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

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

	ll sn = s.length(), tn = t.length();
	ll ans = INF;

	REP(i, sn - tn + 1){
		ll minicnt = 0;
		REP(j, tn){
			if(s[i+j] != t[j]){
				minicnt ++;
			}
		}
		chmin(ans, minicnt);
	}

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long x,y;
long long ba=0,bb=0;
int flag1=0,flag2=0;
long long ans=0;
int main()
{
	scanf("%lld%lld",&x,&y);
	if((x==0||x==-0)&&y>0)
	{
		ba=y;
		printf("%lld",ba+bb);
		return 0;
	}
	if((x==0||x==-0)&&y<0)
	{
		y=-y;
		bb=bb+1;
		ba=y;
		printf("%lld",ba+bb);		
		return 0;
	}
	if((y==0||y==-0)&&x>0)
	{
		ba=x;
		bb=bb+1;
		printf("%lld",ba+bb);
		return 0;
	}
	if((y==0||y==-0)&&x<0)
	{
		ba=-x;
		printf("%lld",ba+bb);
		return 0;
	}
	if(x>0)
		flag1=1;
	if(y>0)
		flag2=1;
	if(flag1==flag2)
	{
		if(flag1==0)
		{
			if(x<y)
			{
				ba=abs(x)-abs(y);
				printf("%lld",ba+bb);
				return 0;
			}
			x=-x;
			y=-y;
			bb=bb+1;
			ba=abs(y-x);
			bb=bb+1;
			printf("%lld",ba+bb);
			return 0;
		}
		if(flag1==1)
		{
			if(x>y)
			{
				ba=abs(y-x);
				bb=bb+2;
				printf("%lld",ba+bb);
				return 0;				
			}
			ba=abs(y-x);	
			printf("%lld",ba+bb);
			return 0;			
		}
	}
	else 
	{
		if(flag1==0)
		{
			x=-x;
			bb=bb+1;
			ba=abs(y-x);		
			printf("%lld",ba+bb);
			return 0;
		}
		if(flag1==1)
		{
			y=-y;
			bb=bb+1;
			ba=abs(y-x);
			printf("%lld",ba+bb);
			return 0;
		}						
	}
	printf("%lld",ba+bb);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using ll = long long;



int main()
{
    int n;
    string s;
    cin >> n >> s;
    vector<char> ch = {'R', 'G', 'B'};

    vector<vector<int>> sum(n + 1, vector<int>(3));
    for(int i = 0; i < n; i++){
        sum[i + 1][0] = sum[i][0] + (s[i] == 'R');  
        sum[i + 1][1] = sum[i][1] + (s[i] == 'G');  
        sum[i + 1][2] = sum[i][2] + (s[i] == 'B');  

    }

    ll ans = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n - 1; j++){
            if(s[i] == s[j])continue;


            for(int t = 0; t < 3; t++){
                if(s[i] != ch[t] && s[j] != ch[t]){
                    //cerr << i << " " << j << " " << " " << sum[j + 2][t] - sum[j + 1][t]<< endl;

                    ans += sum[n][t] - sum[j + 1][t];
                    if(j + (j - i) >= n)continue;
                    ans -= (s[j + (j - i)] == ch[t]);
                }
            }
        }
    }
    /*
    for(int i = 0; i < 3; i++){
        for(int j = 0; j <= n; j++){
            cout << sum[j][i] << " "; 
        }
        cout << endl;
    }
    */

    cout << ans << endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main() {
    int n,y;
    cin>>n>>y;
    
    int i,j;
    for(i=0;i<=n;++i){
        for(j=0;j<=n-i;++j){
            if(10000*i+5000*j+1000*(n-i-j)==y){
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}

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

ans=0
mi=1000

for i in range(n):
    a=int(input())
    ans+=a
    if a%10>0 and mi>a:
        mi=a

if ans%10==0:
    if mi<1000:
        print(ans-mi)
    else:
        print(0)
else:
    print(ans)

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define mp(a, b) make_pair(a, b) 

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;

const long double PI  = 3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll n;
	cin>>n;
	ll x = log2(n);
	x++;
	ll ans = (1LL << x) - 1;
	cout<<ans<<endl;
}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

void show(vector<int> &v) {
	for (int i = 0; i < v.size(); i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << v[i];
	}
	cout << endl;
}

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

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


	vector<int> v, cumul;
	v = a;
	for (int i = 0; i < k; i++) {
		vector<int> w;
		w.assign(n + 1, 0);

		for (int j = 0; j < n; j++) {
			int l = max(0, j - v[j]);
			int r = min(n, j + v[j] + 1);

			w[l]++;
			w[r]--;
		}

		bool stops = true;

		v.assign(n, 0);
		v[0] = w[0];
		if (v[0] != n) {
			stops = false;
		}
		for (int j = 0; j < n; j++) {
			v[j] = v[j-1] + w[j];
			if (v[j] != n) {
				stops = false;
			}
		}

		// show(v);
		if (stops) {
			break;
		}
	}
	show(v);
	return 0;
}


Measured memory_bytes: 5264