akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
#define all(v) v.begin(),v.end()
///////////////////////////////////////////
/// choose such no such that every 5 sum of nu mber is divisible by 5
void solve(){
  ll n,m;
  cin>>n>>m;
  mat con(10,vll(10));
  fr(i,0,10){
    fr(j,0,10){
      cin>>con[i][j];
    }
  }

      for( int k=0;k<10;k++){
       
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
        con[i][j]=min(con[i][j],con[i][k]+con[k][j]);
      }
    }
  }
  
  ll ans=0;
  for(int i=0;i<n;i++){
    fr(j,0,m){
      ll x;
      cin>>x;
      if(x==-1)
      continue;
      ans+=con[x][1];

    }
  }

 cout<<ans;

}




int main(){
    ll t=1;
 // cin>>t;
  ll f=1;
    while(f<=t){
      //  cout<<"Case #"<<f<<": ";
        solve();
        cout<<endl;
        f++;
    }
    return 0;
}

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

class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int H, W, N;
		H = in.nextInt();
		W = in.nextInt();
		N = in.nextInt();

		String[] map = new String[H+3];
		String str = "";
		for(int i=0;i<W+2;i++) {
			str += "X";
		}
		map[0] = str;

		in.nextLine();
		for(int i=0;i<H;i++) {
			String s = in.nextLine();
			map[i+1] = "X" + s + "X";
		}
		map[H+1] = str;

		solve(map, H, W, N);
	}

	public static void solve(String[] ma, int H, int W, int N) {
		int ans = 0;
		int posx[] = new int[N+1];
		int posy[] = new int[N+1];

		// ??????S?????´????????¢???
		for(int i=1;i<=H;i++) {
			int pos = ma[i].indexOf("S");
			if(pos >= 0) {
				posx[0] = i;
				posy[0] = pos;
				ma[i].replace("S", "0");
				break;
			}
		}
		for(int i=1;i<=H;i++) {
			for(int j=1;j<=N;j++) {
				int pos = ma[i].indexOf(""+j);
				if(pos >= 0) {
					posx[j] = i;
					posy[j] = pos;
				}
			}
		}

		for(int i=1;i<=N;i++) {
			ans += bfs(ma, posx[i-1], posy[i-1], H, W, ""+i);
		}
		System.out.println(ans);
	}

	public static int bfs(String[]ma, int sh, int sw, int H, int W, String target) {
		// ???????????¢?´¢??§target??¨????????????????????§??????????????¢????¨????
		boolean[][] visited = new boolean[H+2][W+2];
		Queue<P> q = new PriorityQueue<>();
		q.offer(new P(sh, sw, 0)); // ??????????????°????????\??????

		while(!q.isEmpty()) {
			P p = q.poll();
			visited[p.sh][p.sw] = true;

			// ??°?????????????????£???
			if((""+ma[p.sh].charAt(p.sw)).equals(target)) {
				return p.dist;
			}

			int dh[] = {0, 0, +1, -1};
			int dw[] = {1,-1,  0,  0};
			for(int i=0;i<4;i++) {
				int h = p.sh + dh[i];
				int w = p.sw + dw[i];
				if((""+ma[h].charAt(w)).equals("X") || visited[h][w]) continue;
				visited[h][w] = true;
				q.offer(new P(h, w, p.dist + 1));
			}
		}

		assert (false);
		return -1;
	}
}

class P  implements Comparable<P> {
	int sh;
	int sw;
	int dist;
	P(int sh, int sw, int dist) {
		this.sh = sh;
		this.sw = sw;
		this.dist = dist;
	}

	@Override
	public int compareTo(P p) {
		return this.dist - p.dist;
	}
}

Measured memory_bytes: 293032
H, W = map(int, input().split())
S = []
S.append('.' * (W + 2))
S.extend(['.' + input() + '.' for _ in range(H)])
S.append('.' * (W + 2))

if ''.join(S).count('#') <= 1:
    print("Yes")
    quit()

for y in range(1, H + 1):
    for x in range(1, W + 1):
        if S[y][x] == '#' and set([S[y - 1][x], S[y + 1][x], S[y][x - 1], S[y][x + 1]]) == set('.'):
            print("No")
            quit()
print("Yes")


Measured memory_bytes: 3064
abc = sorted(list(map(int,input().split())))
ans = 0
ans += abc[2] - abc[1]
abc[0] += abc[2] - abc[1]
if (abc[2] - abc[0]) % 2 == 0:
  ans += (abc[2] - abc[0]) // 2
else:
  ans += (abc[2]+1 - abc[0]) // 2 + 1
print(ans)

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	vt n, m, a = 0, w = 0;
	cin >> n >> m;
	vector<pair<vt, string>> vec(m);
	rep(i, m) {
		cin >> vec.at(i).first >> vec.at(i).second;
		vec.at(i).first--;
	}
	vector<bool> wa(n, true);
	vector<vt> ac(n, 0);
	rep(i, m) {
		if (vec.at(i).second.at(0) == 'W' && vec[i].second.at(1) == 'A') {
			if (wa.at(vec.at(i).first)) ac.at(vec.at(i).first)++;
		}
		else {
			if (wa.at(vec.at(i).first)) {
				wa.at(vec.at(i).first) = false;
				a++;
			}
		}
	}
	rep(i, n) {
		if (!(wa.at(i))) {
			w += ac.at(i);
		}
	}
	cout << a << " " << w << endl;
	return 0;
}

Measured memory_bytes: 7296
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const euc = (x, y) => {
    if (x == 0) return y
    if (y == 0) return x
    if (x > y) {
        return euc(x % y, y)
    } else {
        return euc(y % x, x)
    }
}
const Main = () => {
    const [A, B, C, D] = next().split(" ").map(el => BigInt(el))
    //B
    let bc = B / C
    let bd = B / D
    let min = C * D / euc(C, D)
    let bcd = B / min
    let b = B - bc - bd + bcd
    //A
    let ac = (A-1n) / C
    let ad = (A-1n) / D
    let acd = (A-1n) / min
    let a = A-1n - ac - ad + acd

    console.log(String(b-a))
}
Main()


Measured memory_bytes: 29568
import sys
# input = sys.stdin.buffer.readline
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())
A = [[int(x) for x in input().split()] for _ in range(H)]
B = [[int(x) for x in input().split()] for _ in range(H)]
C = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j] - B[i][j])
center = 80 * (H+W) # (80+80)*80=12800

dp = [[0] *W for _ in range(H)]
dp[0][0] = (1 << (center - C[0][0])) | (1 << (center + C[0][0]))
for i in range(H):
    for j in range(W):
        if i:
            dp[i][j] |= dp[i-1][j] << C[i][j]
            dp[i][j] |= dp[i-1][j] >> C[i][j]
        if j:
            dp[i][j] |= dp[i][j-1] << C[i][j]
            dp[i][j] |= dp[i][j-1] >> C[i][j]
ans = center * 2
for i in range(center*2):
    if (dp[H-1][W-1] >> i) & 1:
        ans = min(ans, abs(i-center))
print(ans)

Measured memory_bytes: 20340
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000






int main() {
	vector<pair<long long, long long> >a;
	long long b[N];
	f(i, N)b[i] = 0;
	long long n, k, kk;
	long long x, y, z;
	long long s, ss, ans;
	bool v = true;
	ans = 0;
	ss = 0;
	scanf("%lld", &n);
	f(i, n) {
		scanf("%lld", &x);
		ss += x;
		a.push_back(make_pair(-x, i));
	}
	sort(a.begin(), a.end());
	k = a[0].second;
	s = 0;//石sum
	ans = 0;
if(k==0){
  b[0]=ss;
  	f(i, n) {
		printf("%lld\n", b[i]);
	}  
 return 0; 
}
	f(i, n) {
		kk = a[i].second;
		if (kk < k) {
			x = s + (i*(a[i].first));
			b[k] = x - ans;
			ans = x;
			k = kk;
			if (k == 0) {
				b[0] = ss - ans;
				break;
			}
		}
		s -= a[i].first;

	}
	f(i, n) {
		printf("%lld\n", b[i]);
	}

	return 0;
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int n,a[N],now;
bool cmp(int x,int y){return x>y;}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;++i)if(a[i+1]<i+1){
		for(;a[i+now+1]==i;++now);
		if(((a[i]-i)&1) || (now&1)) cout<<"First";
		else cout<<"Second";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;

namespace AtCoderDISCO
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] prices = Enumerable.Range(0, 206).Select(x => 0).ToArray();
            prices[3] = 100000;
            prices[2] = 200000;
            prices[1] = 300000;
            int sl = 0;
            int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            sl += prices[info[0]] + prices[info[1]];
            if (info[0] * info[1] == 1)
                sl += 400000;
            Console.WriteLine(sl);
        }
    }
}


Measured memory_bytes: 13524
import java.util.Scanner;

public class Main {

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

		int max = 1;
		for (int i = 1; i < s.length(); i++) {
			if (s.subSequence(0, i / 2).equals(s.substring(i / 2, i))) max = i;
		}

		System.out.println(max);


		sc.close();

	}

}

Measured memory_bytes: 35516
local N = io.read("n")
local L = {}
local max_len = 0
local sum = 0
for i=1,N do
    L[i] = io.read("n")
    max_len = math.max(L[i], max_len)
    sum = sum + L[i]
end
sum = sum - max_len
print(max_len < sum and "Yes" or "No")

Measured memory_bytes: 760
// template {{{
#![allow(clippy::many_single_char_names)]

#[allow(dead_code)]
mod ngtio {
    use ::std::collections::VecDeque;

    pub struct Buffer {
        buf: VecDeque<String>,
    }

    impl Buffer {
        pub fn new() -> Self {
            Self {
                buf: VecDeque::new(),
            }
        }

        fn load(&mut self) {
            while self.buf.is_empty() {
                let mut s = String::new();
                let length = ::std::io::stdin().read_line(&mut s).unwrap();
                if length == 0 {
                    break;
                }
                self.buf.extend(s.split_whitespace().map(|s| s.to_owned()));
            }
        }

        pub fn string(&mut self) -> String {
            self.load();
            self.buf
                .pop_front()
                .unwrap_or_else(|| panic!("入力が終了したのですが。"))
        }

        pub fn string_char_vec(&mut self) -> Vec<char> {
            let s = self.string();
            s.chars().collect::<Vec<_>>()
        }

        pub fn string_char_vec_trusted_len(&mut self, len: usize) -> Vec<char> {
            let s = self.string();
            let s = s.chars().collect::<Vec<_>>();
            assert_eq!(s.len(), len, "あら、思ったのと長さ違いますね……");
            s
        }

        pub fn char(&mut self) -> char {
            let string = self.string();
            let mut chars = string.chars();
            let res = chars.next().unwrap();
            assert!(
                chars.next().is_none(),
                "char で受け取りたいのも山々なのですが、さては 2 文字以上ありますね？"
            );
            res
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T
        where
            <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
        {
            self.string()
                .parse::<T>()
                .expect("Failed to parse the input.")
        }

        pub fn read_vec<T: ::std::str::FromStr>(&mut self, len: usize) -> Vec<T>
        where
            <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
        {
            (0..len).map(|_| self.read::<T>()).collect()
        }
    }

    macro_rules! define_primitive_reader {
        ($($ty:tt,)*) => {
            impl Buffer {
                $(
#[inline]
                    pub fn $ty(&mut self) -> $ty {
                        self.read::<$ty>()
                    }
                )*
            }
        }
    }

    define_primitive_reader! {
        u8, u16, u32, u64, usize,
        i8, i16, i32, i64, isize,
    }

    impl Default for Buffer {
        fn default() -> Self {
            Self::new()
        }
    }
}

#[allow(unused_imports)]
use std::{collections, iter, mem, ops};
// }}}

fn main() {
    let mut buf = ngtio::Buffer::new();
    let a = buf.i64();
    let b = buf.i64();
    let c = buf.i64();
    let d = buf.i64();
    let ans = *[a * c, a * d, b * c, b * d].iter().max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 2152
from collections import Counter

N = int(input())
input_list = sorted([int(i) for i in input().split()])
inupt_dict = Counter(input_list)
sorted_input_dict = sorted(dict(filter(lambda x:x[1]>1, inupt_dict.items())).items(), key=lambda x: x[0], reverse=True)
result = 1

if sorted_input_dict == []:
    result = 0
else:
    result *= sorted_input_dict[0][0]
    if sorted_input_dict[0][1] > 3:
        result *= sorted_input_dict[0][0]
    else:
        result *= sorted_input_dict[1][0]

print(result)

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

int n;
int a[9999];
int dp[5001][2];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; ++i)scanf("%d", a + i - 1);
	memset(dp, 0x7F, sizeof(dp));
	dp[0][0] = dp[0][1] = 0;
	for (int j = 0; j <= n / 2; ++j)dp[j][1] = 0;
	for (int i = 1; i <= n / 2; ++i)
	{
		dp[0][0] = 0;
		dp[0][1] = 123456789;
		for (int j = 1; j <= n / 2; ++j)
		{
			dp[j][0] = std::min(dp[j][0], dp[j][1] + a[i + j - 2]);
			dp[j][1] = std::min(dp[j - 1][0] + a[i + j - 2], dp[j - 1][1]);
		}
	}
	printf("%d\n", std::min(dp[n / 2][0], dp[n / 2][1]));
	return 0;
}

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

int main() {
    string A, B; cin >> A >> B;
  int a, b; cin >> a >> b;
  string C; cin >> C;
  if (A == C) cout << a - 1 << " " << b << endl;
  else cout << a << " " << b -1  << endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let s = iter.next().unwrap().chars().collect::<Vec<char>>();
    let k: usize = iter.next().unwrap().parse().unwrap();    
    let mut ans = 1;
    for i in 0..k {
        if s[i] != '1' {
            ans = (s[i] as i32 - '0' as i32);
            break;
        }
    }
    println!("{}", ans);
}



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

int main(void){
 
    string s;
    map<char,int> map{};
    cin >> s;
    
    for(int i=0;i<4;i++){
        map[s[i]] = 1;
    }
    
    if(map.size() == 2){
        cout << "Yes" <<endl;   
    }
    else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 3596
import java.util.*;
 
public class Main {
 
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<Integer>();
 

    String str = sn.nextLine();
      
String[] num = str.split(" ", 3);
      int[] ia = new int[num.length];
for (int i = 0; i < num.length; i++) {
    ia[i] = Integer.parseInt(num[i]); // throws NumberFormatException
}
		int A=ia[1]/ia[0];
		if(A>ia[2]){
		    A=ia[2];
		}
      System.out.println(A);

}
}

Measured memory_bytes: 22612
#include<iostream>
using namespace std;
int main()
{
	int n,i,x,minn=0x7fffffff,cnt=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if(x<=minn)
		{
			minn=x;
			cnt++;
		}
	} 
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 300000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int n;
int a[214514], b[224514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)b[a[i] - 1]++;
	rep(i, n)cout << b[i] << endl;
	ggr
}


Measured memory_bytes: 6812
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int x = sc.nextInt();

            if (a <= x && x <= a + b) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }

        }
    }

}


Measured memory_bytes: 23764
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

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

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << a[k-1] << '\n';

    return 0;
}


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

typedef long long ll;

int main () {
	ll A, B; cin >> A >> B;
	ll l = A%4, r = B%4;

	ll ans = 0;
	for (; l < 4; l++) 
		ans ^= (A++);
	for (; r >= 0; r--)
		ans ^= (B--);
	cout << ans << endl;
	return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n;
	cin >> n;
	if (n <= 599)print("8");
	else if (600<=n && n <= 799)print("7");
	else if (800 <= n && n <= 999)print("6");
	else if (1000 <= n && n <= 1199)print("5");
	else if (1200 <= n && n <= 1399)print("4");
	else if (1400 <= n && n <= 1599)print("3");
	else if (1600 <= n && n <= 1799)print("2");
	else if (1800 <= n )print("1");
}

Measured memory_bytes: 3604
def main():
    N, T = map(int, input().split())
    ts = list(map(int, input().split()))

    ans = 0
    for i in range(N - 1):
        t1 = ts[i]
        t2 = ts[i + 1]
        ans += min(t2 - t1, T)
    ans += T

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26836
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

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

	long long cumul = 0;
	map<long long, int> nums;
	nums[0] = 1;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cumul += a;
		nums[cumul]++;
	}

	long long ans = 0;
	for (auto p: nums) {
		if (p.second >= 2) {
			ans += 1LL * p.second * (p.second - 1) / 2;
		}
	}
	cout << ans << endl;
	return 0;
}


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

signed main(){
    ll n,m;
    cin>>n>>m;
    ll l[n],r[n];
    map<ll,ll> mp;

    for(int i=0;i<n;i++){
        cin>>l[i]>>r[i];
        mp[l[i]]=0;
        mp[r[i]]=0;
    }
    int cnt=0;
    vector<ll> v;
    for(auto i:mp){
        v.push_back(i.first);
        mp[i.first] = cnt;
        cnt++;
    }
    ll imos[cnt+5]={};
    for(int i=0;i<n;i++){
        imos[mp[l[i]]]++;
        imos[mp[r[i]]+1]--;
    }
    ll d=imos[0];
    for(int i=1;i<=cnt;i++){
        imos[i] += imos[i-1];
        d = max(d,imos[i]);
    }
    ll ans = (d-1) * m;
    //cerr<<ans<<endl;
    ll dist=0;

    if(d%2==0){
        for(int i=0;i<cnt;i++){
            if(imos[i]==d){
                dist = i;
                break;
            }
        }
        ans += m-v[dist];
    }
    else{
        for(int i=0;i<cnt;i++){
            if(imos[i]==d) dist = i;
        }
        ans += v[dist];
    }
    //cerr << v[dist] << endl;
    cout << ans << endl;
    
}


Measured memory_bytes: 37252
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);

    rep(i,n) cin >> a[i] >> b[i];

    sort(all(a)); sort(all(b));

    if(n %2 == 1){
        cout << b[n/2] - a[n/2] + 1 << endl;
    }
    else{
        ll num1 = b[n/2] - a[n/2] + 1;
        ll num2 = b[n/2-1] - a[n/2-1] + 1;
        cout << num1 + num2 - 1 << endl;
    }

}


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

signed main(){
  ll n, K; cin >> n >> K;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<vector<ll> > dp(50, vector<ll> (2, -1));
  dp[40][0] = 0;
  for(int d = 45; d >= 0; d--){
   ll num = 0, mask = 1LL << d;
   for(int j = 0; j < n; j++) if(a[j] & mask) num++;
   if(dp[d + 1][1] != -1) dp[d][1] = max(dp[d][1], dp[d + 1][1] + mask * max(num, n - num));
   if(dp[d + 1][0] != -1){
     if(K & mask){
       dp[d][1] = max(dp[d][1], dp[d + 1][0] + mask * num);
       dp[d][0] = max(dp[d][0], dp[d + 1][0] + mask * (n - num));
     }
     else dp[d][0] = max(dp[d][0], dp[d + 1][0] + mask * num);
   }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>

int main()
{
	int h, m, s;
	
	while( 1 ){
	 	std::cin >> h >> m >> s;
		
		if( h == -1 && m == -1 && s == -1 ) break;
		
		int sec = h * 3600 + m * 60 + s;
		
		int ans1 = 7200 - sec;
		int ans2 = ans1 * 3;
		
		printf( "%02d:%02d:%02d\n", ans1 / 3600, ans1 % 3600 / 60, ans1 % 60 );
		printf( "%02d:%02d:%02d\n", ans2 / 3600, ans2 % 3600 / 60, ans2 % 60 );
	}

 	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main()
{
	int n, x, t, a;
	scanf("%d %d %d", &n, &x, &t);
	if (n % x == 0) {
		a = n / x;
	}
	else {
		a = n / x + 1;
	}
	
	printf("%d", a * t);
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,flag=0,c;
	cin>>n;
	vi a(n);
	REP(i,0,n-1)cin>>a[i];
	REP(i,0,n-1){
		if(a[i]%2!=0){
			flag=1;
			c=0;
			break;
		}
		else{
			a[i]=a[i]/2;
		}
	}
	if(flag!=1)c=1;
	while(flag!=1){
		REP(i,0,n-1){
			if(a[i]%2!=0)
			{
			flag=1;
			break;
		}
		else a[i]=a[i]/2;
	
	}
	if(flag==1)break;
	else c++;
	}
	cout<<c;
	return 0;

//   TimeTaken();
}


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

int main(void){
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for(int i = 0; i < 3; ++i){
		if(s[i] == t[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
class BingoCard():
  A1 = []
  A2 = []
  A3 = []
  
  def __init__(self):
    self.A1 = [int(x) for x in input().split(' ')]
    self.A2 = [int(x) for x in input().split(' ')]
    self.A3 = [int(x) for x in input().split(' ')]

  def BingoProgress(self):
    N  = int(input())
    for i in range(N):
      B = int(input())
      if B in self.A1:
        self.A1[self.A1.index(B)] = 0
      if B in self.A2:
        self.A2[self.A2.index(B)] = 0
      if B in self.A3:
        self.A3[self.A3.index(B)] = 0

  def BingoJudge(self):
    flg = 0
    #横判定
    if sum(self.A1) == 0 or sum(self.A2) == 0 or sum(self.A3) == 0:
      flg = 1
    
    #縦判定
    if flg == 0:
      for i in range(3):
        if (self.A1[i] + self.A2[i] + self.A3[i]) == 0:
          flg = 1
          break
          
    #斜め判定
    if flg == 0:
      if (self.A1[0] + self.A2[1] + self.A3[2]) == 0 or (self.A1[2] + self.A2[1] + self.A3[0]) == 0:
        flg = 1

    #ビンゴ判定
    print('Yes' if flg == 1 else 'No')
    
def main():
  Bingo = BingoCard()
  Bingo.BingoProgress()
  Bingo.BingoJudge()

if __name__=='__main__':
  main()

Measured memory_bytes: 3192
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
b = [0 for _ in range(h * w)]
for i in range(h):
    for j in range(w):
        b[a[i][j] - 1] = [i, j]
c = [0 for _ in range(h * w)]
m = 0
l = 0
i, j = 0, 0
for _ in range(h * w):
    c[i] = abs(b[i][0] - b[j][0]) + abs(b[i][1] - b[j][1])
    j = i
    if i >= d:
        c[i] += c[i - d]
    i += d
    if i >= h * w:
        l += 1
        i = l
        j = l
c.insert(0, 0)
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(c[r] - c[l])

Measured memory_bytes: 20860
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int t,i;
  vector<int> A;
  for(i=0;i<3;i++){
    cin>>t;
    A.push_back(t);
  }
  sort(A.begin(),A.end());
  if(A[0]==5&&A[1]==5&&A[2]==7){
    cout<<"YES\n";
  }
  else{
    cout<<"NO\n";
  }
  return 0;
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		var H = new long[2];
		var M = new long[2];
		for(long i = 0; i < 2; i++)
		{
			H[i] = GetLong();
			M[i] = GetLong();
		}

		var S = H[0] * 60 + M[0];
		var T = H[1] * 60 + M[1];

		var K = GetLong();
		var cnt = 0;
		for(long i = S; ; i++)
		{
			if(i + K >= T)
				break;

			cnt++;
		}
		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27404
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	while (1) {
		auto x = readln.chomp.split.map!(to!int);
		if (x[0] == -1) break;
		(Date(x[3], x[4], x[5]) - Date(x[0], x[1], x[2])).total!"days".writeln;
	}
}

Measured memory_bytes: 1168
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
int sz[110000];
int p[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)sz[i]=1;
	p[0]=1;
	for(int i=0;i<b;i++){
		int s,t;scanf("%d%d",&s,&t);s--;t--;
		if(p[s]){
			p[t]=1;
			if(sz[s]==1)p[s]=0;
		}
		sz[s]--;
		sz[t]++;
	}
	int ret=0;
	for(int i=0;i<a;i++)if(p[i])ret++;
	printf("%d\n",ret);
}

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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back

int mod=1e9+7;

int32_t main() {
    long double l;
    cin>>l;

    cout<<setprecision(14);
    cout<<l*(l)*(l)/(long double)27<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
// #define all(_x) (_x.begin(),_x.end()) 
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;

	ll x , y , a , b , c ;
	cin>> x >> y >> a >> b >> c ;
	vector<ll> A(a) , B(b) , C(c);
	for(ll i=0;i<a ;i++)cin>>A[i];
	for(ll i=0 ; i< b ; i++)cin>>B[i];
	vector<ll> ps;
	sort(A.begin(),A.end(),greater<ll>());
	sort(B.begin(),B.end(),greater<ll>());

	for(ll i=0,a;i<c ;i++){
		cin>> a ;
		ps.pb(a);
	}
	for(ll i=0;i< x ; i++)ps.pb(A[i]);
	for(ll i=0;i< y ; i++)ps.pb(B[i]);
	sort(ps.begin(),ps.end(),greater<ll>());
	ll ans =0 ;
	for(ll i=0;i<x+y ; i++)ans+=ps[i];
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 8688
from bisect import bisect_left, insort_left
N = int(input())
S = [c for c in input()]
Q = int(input())
d = {i: [] for i in range(26)}
for i, c in enumerate(S):
    d[ord(c) - ord("a")].append(i)

# print(d)
for _ in range(Q):
    q = input().split()
    if int(q[0]) == 1:
        iq, cq = int(q[1]), q[2]
        iq -= 1
        if S[iq] == cq:
            continue
        else:
            idx = bisect_left(d[ord(S[iq]) - ord("a")], iq)
            d[ord(S[iq]) - ord("a")].pop(idx)
            S[iq] = cq
            insort_left(d[ord(cq) - ord("a")], iq)
    else:
        l, r = int(q[1]), int(q[2])
        l -= 1
        ans = 0
        for i in range(26):
            idx = bisect_left(d[i], l)
            if d[i] and l <= d[i][-1] and d[i][idx] < r:
                ans += 1
        print(ans)



Measured memory_bytes: 30344
s = input()
ans =[]
for i in range(len(s)):
    if s[i] == "0":
        ans.append(0)
    elif s[i] == "1":
        ans.append(1)
    elif s[i] == "B":
        if len(ans) != 0:
            ans.pop()
for i in range(len(ans)):
    print(ans[i], end="")
    

Measured memory_bytes: 9052
a, b, c, k = [int(i) for i in input().split()]

output = 0

left_after_a = k - a

if left_after_a <= 0:
    output = k
else :
    output += a
    
left_after_b = left_after_a - b

if left_after_b <= 0:
    pass
else :
    left_after_c = left_after_b - c
    if left_after_c <= 0:
        output -= left_after_b
    else :
        output -= c
        
print(output)

Measured memory_bytes: 9212
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int[] alphabet = new int[26];

        do {
            String s = input.nextLine();
            for (char c : s.toCharArray()) {
                if ((c < 'A' || 'Z' < c) && (c < 'a' || 'z' < c)) {
                    continue;
                }
                alphabet[Character.toLowerCase(c) - 'a']++;
            }
        } while (input.hasNext());

        for (char c = 'a'; c <= 'z'; c++) {
            System.out.println(c + " : " + alphabet[c - 'a']);
        }
    }
}



Measured memory_bytes: 26104
#include <iostream>
using namespace std;
int main()
{
	int n,counter=0,mx=0;
	cin>>n;
	
	string s;
	cin.ignore();
	getline(cin,s);
	
	for(int i=0;i<n;i++)
	{
		if(s[i] == 'I')
		{
			counter++;
		}
		else if(s[i] == 'D')
		{
			counter--;
		}
		if(mx<counter)
		{
			mx=counter;
		}
	}
	cout<<mx;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int a[1000010],n,cnt=0,G[110],p=1;
void createG()
{
	int i,h=1;
	G[1]=1;
	for(i=2;i<=100;i++)
	{
		h=h*3+1;
		if(h<=n)
			G[i]=h;
		else
			break;
		p++;
	}
	return;
}
void output()
{
	int i;
	printf("%d\n",p);
	for(i=p;i>=2;i--)
		printf("%d ",G[i]);
	printf("%d\n",G[1]);
	printf("%d\n",cnt);
	for(i=1;i<=n;i++)
		printf("%d\n",a[i]);
	return;
}
void shellsort(int g)
{
	int v,i,j;
	for(i=g+1;i<=n;i++)
	{
		v=a[i];
		j=i-g;
		while(j>=1 && a[j]>v)
		{
			a[j+g]=a[j];
			j-=g;
			cnt++;
		}
		a[j+g]=v;
	}
	return;
}
int main()
{
	int i;
	scanf("%d",&n);
	//我喜欢从1开始计数，就把a[0]给废掉了
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	createG();
	for(i=p;i>=1;i--)
		shellsort(G[i]);

	output();
	return 0;
}


Measured memory_bytes: 5628
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A[222222];

  std::cin >> N;

  long long S = 0;

  int i = 0, j = 0, s = 0, x = 0;
  
  for ( ; i < N; i ++) {
    std::cin >> A[i];

    s += A[i];
    x ^= A[i];

    if (s == x) {
    }
    else {
      int c = i - j;

      for ( ; ; j ++) {
        if (s == x)
          break;

        S += i - j - 1;
        
        s -= A[j];
        x ^= A[j];
      }
    }
  }

  int c = i - j;

  for ( ; j < i; j ++)
    S += i - j - 1;

  std::cout << S + N << std::endl;

  return 0;
}


Measured memory_bytes: 1024
N = int(input())
scores = [int(input()) for i in range(N)]

not_multiple_of_ten = [i for i in scores if i % 10 != 0]

max_score = sum(scores)

if max_score % 10 != 0:
    print(max_score)
else :
    if len(not_multiple_of_ten) == 0:
        print(0)
    else :
        print(max_score-min(not_multiple_of_ten))

Measured memory_bytes: 3060
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	s := next()

	// can[i]: マスi以降にある，進めるマス
	can := make([]int, n+1)
	can[n] = n
	for i := n - 1; i >= 0; i-- {
		if s[i] == '1' {
			can[i] = can[i+1]
		} else {
			can[i] = i
		}
	}

	ans := make([]int, 0)
	from, to := n, n
	for from > 0 {
		to = can[max(0, from-m)]
		if to == from {
			puts(-1)
			return
		}
		ans = append(ans, from-to)
		from = to
	}

	for i := len(ans) - 1; i > 0; i-- {
		putf("%d ", ans[i])
	}
	puts(ans[0])
}


Measured memory_bytes: 6104
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,ans;
    cin >>n>>k;
    ans = 0;

    FOR(i, k, n+1 )ans += (n+1-i)*i+1;//i個選んだときの値の数=(上からk個-下からk個)の幅+1=k個*(n+1-k)+1
    cout << ans%1000000007 << endl;
    return 0;
}

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

typedef long long int LLi;
typedef long long LL;
typedef vector<LLi> VLL;
typedef vector<string> VS;


#define For(i,n) for (LLi i = 0; i < (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define exit(); return 0;

LLi max_3(LLi a, LLi b, LLi c)
{
    return max(a,max(b,c));
}
LLi min_3(LLi a, LLi b, LLi c)
{
    return min(a,min(b,c));
}


main()
{
    LLi a=0,b=0,c=0,d=0,e=0,f=0,g,h,j,k,l,m=0,n,o=0,q=0,r,s,t,u,w,x,y,z, sum=0;
    LLi i=0;
    LLi co=0, co1=0,co2;
    string str, str1, str2;
    LLi flag=0, flag1=0,flag2=0;
    double dou1,dou2,dou3;
    VLL v,v1,v2,v3,v4,v5,v6,v7,v8;
    VS vs, vs1, vs2;
    pair<char, int> pa12;
    list <LLi> li,li1,li2;
    LLi a1,a2,a3,a4;

//char Ch[n];
//strcpy(C, str.c_str());
//
    //cin>>t;
   // while(t--)
    //{
        flag=0,a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,o=0,q=0,r=0,co=0,co1=0,co2=0;
        v.clear(),v1.clear(), v2.clear(),str.clear(),str1.clear(), str2.clear(), vs.clear();
       LLi ar[10000];
        vector<pair<string, LLi> >vps;
        vector<pair<LLi, LLi> > vp;
        vector<char> vc;
        map<LLi, LLi> mp;
        char ch,ch1,ch2,ch3,ch4,ch5,ch6;
        double pi= 3.141592653589793;
        set<LLi> st;
        set<char>ststr;
        //set<LLi>:: iterator it;
        map<LLi, LLi>::iterator it;
        dou1=0.0;
        pair<LLi, LLi> pa[100];
        LLi x1,x2,y1,y2;
        vector<int>::iterator its;


        cin>>n>>a>>b;
        for(i=a; i<=b; i++)
        {
            if(i%n==0)
            {
                flag=1;
                break;
            }
        }
        if(flag==1)cout<<"OK"<<endl;
        else cout<<"NG"<<endl;










   // }








//     ####   ####  #               ####  #        ##   #    # #    # ###### #####
//    #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
//     ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
//         # #  # # #                   # #      ###### #    # #    # #      #####
//    #    # #   #  #              #    # #      #    # #    # #    # #      #   #
//     ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #

    exit()

}







Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
        x=x*10+ch-'0',ch=getchar();
    return x*f;
}
ll ans=0,a,b,c;
int main()
{
    a=read();
    ans=read();
    read();
    b=read();
    c=read();
    read();
    read();
    if(!a||!b||!c)
    {
        printf("%lld\n",ans+a/2*2+b/2*2+c/2*2);
        return 0;
    }

    if(a%2==b%2&&b%2==c%2)
    {
        printf("%lld\n",ans+a+b+c);
        return 0;
    }
    printf("%lld\n",ans+a+b+c-1);
    return 0;
}


Measured memory_bytes: 256
import sys
N, M = map(int, input().split())
aLst = list(input() for i in range(N))
bLst = list(input() for i in range(M))
ans = False
cnt = 0
for j in range(N - M + 1):
    for k in range(N - M + 1):
        if aLst[j][k:k + M] == bLst[0]:
            cnt += 1
            for l in range(1, M):
                if aLst[j + l][k:k + M] == bLst[l]:
                    cnt += 1
                else:
                    break

            if cnt == M:
                print('Yes')
                sys.exit()
            cnt = 0

print('No')


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 998244353;
const ll LINF = 1e18;

const ll FAC_MAX = 510000;

ll fac[FAC_MAX]; //階乗
ll finv[FAC_MAX]; //階乗の逆元

//繰り返し二乗法
//x^n mod
ll mod_pow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 1) { //奇数
        return mod_pow(x, n - 1) * x % MOD; //偶数の再帰にできるように変形
    } else { //偶数
        ll t = mod_pow(x, n / 2); //半分のものを求めて、2乗する
        return t * t % MOD;
    }
}

void init() {
    fac[0] = 1;
    for (ll i = 1; i < FAC_MAX; ++i) {
        fac[i] = (fac[i - 1] * i) % MOD; //階乗を計算
    }

    for (ll i = 0; i < FAC_MAX; ++i) {
        finv[i] = mod_pow(fac[i], MOD - 2); //フェルマーの小定理を使い、階乗の逆元を計算
    }
}

//nCr
ll comb(ll n, ll r) {
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return (((fac[n] * finv[r]) % MOD) * finv[n - r]) % MOD;
}

int main() {

    ll n, m, k; cin >> n >> m >> k;

    init();

    ll ans = 0;

    ll col = m;
    for (ll i = n - 1; i >= 0; --i) {
        if (i <= k) {
            ll sum = col % MOD;
            sum *= comb(n - 1, i);
            ans += sum;
            ans %= MOD;
        }

        col *= (m - 1);
        col %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 11604