akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


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

        double a,b;
        cin >> a >> b;
        double i,ans=0;
        for(i=1; i<=100000; i++){
            double x=i*0.08;
            double y=i*0.1;
            if((int)x==(int)a && (int)y==(int)b) {
                cout << i;
                return 0;
            }
            
        }
        cout << -1 << '\n';
    

}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;
int k;
vector<ll>r;
void dfs(ll s){
    if(s>3234566667)return;
    r.push_back(s);
    if(s%10==9){
        dfs(s*10+(s%10)-1);
        dfs(s*10+(s%10));
    }
    else if(s%10==0){
        dfs(s*10+(s%10));
        dfs(s*10+(s%10)+1);
    }
    else{
        dfs(s*10+(s%10)-1);
        dfs(s*10+(s%10));
        dfs(s*10+(s%10)+1);
    }
}
int main(){
    cin>>k;
    rep(i,1,10){
        dfs(i);
    }
    sort(all(r));
    cout<<r.at(k-1)<<endl;
return 0;
}

Measured memory_bytes: 1400
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

int countyaku(int a) {
        int ret=0;
        for(int i=1;i*i<=a;++i){
                if(a%i==0) {
                        ret+=2;
                        if(i*i==a){
                                --ret;
                        }
                }
        }

        return ret;
}

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

        int ret=0;

        FOR(i,1,N){
                ret+=countyaku(i);
        }

        cout<<ret<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main()
{
    queue<pair<string,int> > que;
    int n, q;
    int total=0;

    cin >> n >> q;
    for(int i=0 ;i<n; ++i) {
        string str;
        int temp;
        cin >> str >> temp;
        que.push(make_pair(str,temp));
    }

    while(!que.empty()) {
        pair<string,int> Q=que.front(); que.pop();
        if(Q.second<=q) {
            total += Q.second;
            cout << Q.first << " " << total << endl;
        } else {
            total+=q;
            Q.second-=q;
            que.push(Q);
        }
    }

    return 0;
}



Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
    int n, m, cnt_ac = 0, cnt_wa = 0;
    cin >> n >> m;
    vector<int> cnt(n, 0);
    vector<int> f(n, false);
    REP(i, m)
    {
        int p;
        string s;
        cin >> p >> s;
        if (s == "WA" && !f.at(p - 1))
        {
            cnt.at(p-1)++;
        }
        if (s == "AC")
        {
            f.at(p-1) = true;
        }
    }
    REP(i, n)
    {
        if (f.at(i))
        {
            cnt_ac++;
            cnt_wa += cnt.at(i);
        }
    }
    cout << cnt_ac <<" "<< cnt_wa << "\n";
    return 0;
}


Measured memory_bytes: 1152
import sys

input = sys.stdin.readline

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

Aohashi = False
for a in range(N+1):
	for b in range(N+1-a):
		c = N-a-b
		otoshidama = 10000*a+5000*b+1000*c
		if otoshidama==Y:
			Aohashi = True
			break
	if Aohashi: break

if Aohashi:
	print(a,b,c)
else:
	print(-1,-1,-1)

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

int main()
{
    int n,m,k;

    cin>>n>>m;

    k=1;

    stack<int>stk;

    for(int i=1;i<=n;i++){
        k=min(k*2,k+m);
        stk.push(k);
    }
    cout<<stk.top()<<endl;
}


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

namespace CSharpSample01
{

	class Program
	{
		static void Main(string[] args)
		{
			var N = Console.ReadLine();

			if(N[2] == N[3] && N[4] == N[5])
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}

		}

	}
}

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

int main() {
  int a;
  string s;
  cin >> a;
  cin >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=705,M=N*N;
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;
}
struct Edg{
	int nxt,poi;
}e[M];
int c[N],vis[N],G[N][N],l=0,tot=0,first[N],n,m,a[N],b[N];
bitset<N>f;
void addedge(int u,int v){
	l++;
	e[l].nxt=first[u];
	e[l].poi=v;
	first[u]=l;
}
bool dfs(int u,int fa){
	c[u]=c[fa]^1; vis[u]=1;
	if (!c[u]) a[tot]++; else b[tot]++;
	for (int p=first[u];p;p=e[p].nxt){
		int v=e[p].poi;
		if (vis[v]&&c[u]==c[v]) return 0;
		if (!vis[v]&&!dfs(v,u)) return 0;
	}
	return 1;
}
int main(){
	n=read(),m=read();
	for (int i=1;i<=m;i++){
		int u=read(),v=read();
		G[u][v]=G[v][u]=1;
	}
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
	if (!G[i][j]&&i!=j) addedge(i,j);
	for (int i=1;i<=n;i++){
		if (vis[i]) continue;
		tot++;
		if (!dfs(i,0)){printf("-1\n"); return 0;}
	}
	f[0]=1;
	for (int i=1;i<=tot;i++)
	f=(f<<a[i])|(f<<b[i]);
	for (int i=n/2;i>=1;i--){
		if (f[i]){
			printf("%d\n",i*(i-1)/2+(n-i)*(n-i-1)/2);
			return 0;
		}
	}
	return 0;
}

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

#define fastio  ios::sync_with_stdio(false); cin.tie(0);

// minCost(i) = min( abs(a[i]-a[i-1]) + minCost(i-1), abs(a[i]-a[i-2]) + minCost(i-2))
// minCost(2) = abs(a[1]-a[0])
// minCost(3) = min(abs(a[2]-a[0]), abs(a[1]-a[2]) + abs(a[0]-a[1])

class BeingZero{
    public:
        ll minCost(vector<int> a){
            ll n = a.size();
            int dp[n];
            dp[0] = 0;
            dp[1] = abs(a[1]-a[0]);
            //dp[2] = min(abs(a[2]-a[0]), dp[1]+abs(a[2]-a[1]));
            //dp[3] = min(abs(a[2]-a[0]), abs(a[1]-a[0]) + abs(a[2]-a[1]));
            for(int i=2;i<n;i++)
                dp[i] = min( abs(a[i]-a[i-1]) + dp[i-1], abs(a[i]-a[i-2]) + dp[i-2]);
            // for(int i=0;i<n;i++)
            //     cout<<i<<" : "<<dp[i]<<"\n";
            return dp[n-1];
        }
};


int main() {
    fastio;
    BeingZero bz;
    int n;
    while(cin>>n){
        if(n==-1) break;
        vector<int> v(n);
        for(int i=0;i<n;i++)
            cin>>v[i];
        cout<<bz.minCost(v)<<"\n";
    }
    return 0;
}



Measured memory_bytes: 4516
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> st(n), ck(m);
	rep(i, n){
		int a, b;
		cin >> a >> b;
		st.at(i) = make_pair(a, b);
	}
	rep(i, m){
		int a, b;
		cin >> a >> b;
		ck.at(i) = make_pair(a, b);
	}
	rep(i, n){
		int a, b;
		tie(a, b) = st.at(i);
		int ans = -1, cost = 1001001001;
		rep(j, m){
			int c, d;
			tie(c, d) = ck.at(j);
			int add = abs(c-a) + abs(d-b);
			if(cost > add){
				cost = add;
				ans = j;
			}
		}
			cout << ans+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
N = int(input())
unit = [1]
for b in [6,9]:
    u = b
    while u <= N:
        unit.append(u)
        u *= b
unit.sort()
Nu = len(unit)

ans = N
state_pool = [(0, 0, 0, Nu-1)]
while state_pool:
    n, i, parent, pk = state_pool.pop()
    if N - n >= (ans-i)*unit[pk]:
        continue
    elif pk > 0 and i > 0:
        state_pool.append((parent+unit[pk-1], i, parent, pk-1))

    k = bisect_right(unit, N-n, 0, pk+1) - 1
    c = n + unit[k]
    if c == N:
        if i + 1 < ans:
            ans = i + 1
    else:
        state_pool.append((c, i+1, n, k))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  bool ans = true;
  ll n;
  cin >> n;
  while(ans){
    if(n%111==0){
      print(n);
      ans = false;
    }
    else{
      n++;
    }
  }
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    S = input()
    ans = 0
    x = 0
    for c in S:
        if c == "I":
            x += 1
        else:
            x -= 1
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
n = gets.to_i
$pre = gets.split.map(&:to_i)
$in = gets.split.map(&:to_i)
$post = []

$pos = 0

class Node
  attr_accessor :id, :left, :right
  def initialize
    @id = nil
    @left = nil
    @right = nil
  end
end

def reconstruction(l, r)
  if l >= r
    return
  end

  c = $pre[$pos]
  $pos += 1

  m = $in.index(c)

  reconstruction(l, m)
  reconstruction(m+1, r)

  $post << c
end

reconstruction(0, n)

puts $post.join(" ")


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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int dp[2411][2421];

signed main(){
  int n,x;
  cin>>n>>x;
    int sum=0;
  int t[4100];
  lp(i,n){
    cin>>t[i];
    t[n+i]=t[i];
    dp[1][i]=t[i];
    sum+=t[i];
  }
  cout<<endl;
  int ans=100000000000000;
  lp(i,n+1){
    if(i==0) continue;
    if(i!=1){
      sum=0;
      lp(j,n){
        dp[i][j]=min(dp[i-1][j],t[j-i+n+1]);
        //cout<<dp[i][j]<<endl;
        assert(dp[i][j]<DEKAI);
        sum+=dp[i][j];
      }
    }
    ans=min(ans,sum+(i-1)*x);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 39168
N, A, B, C, D = map(int, input().split())
S = str(input())

flag = True
if C < D:
  for i in range(A, D-2):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
else:
  for i in range(A, C-2):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
  if flag:
    flag = False
    for i in range(B-1, D):
      if (S[i-1]=='.') and (S[i]=='.') and (S[i+1]=='.'):
        flag = True
        break
        
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9384
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

const MOD: usize = 1_000_000_000 + 7;

fn main() {
    let (n, k) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1])
    };

    let a: Vec<usize> = read_vec();

    let mut dp = vec![vec![0; k+1]; n+1];

    // init
    dp[0][0] = 1;

    for i in 0..n {
      // 累積和
      let sum = cum_sum(&dp[i], 0usize);

      for j in 0..k+1 {
        dp[i+1][j] = sum[j+1] - sum[j - min(j, a[i])];
        dp[i+1][j] %= MOD;
      }
    }
    
    println!("{}", dp[n][k]);
}

fn cum_sum<T: Copy + std::ops::Add<Output = T>>(v: &Vec<T>, e: T) -> Vec<T> {
    let n = v.len();
    let mut sum = vec![e; n + 1];

    for i in 0..n {
        sum[i + 1] = sum[i] + v[i];
    }

    sum
}

Measured memory_bytes: 108796
// EbTech's Rust template. Thanks EbTech!
#![allow(unused_imports)]
use std::cmp::{max, min, Reverse};
use std::collections::{HashMap, HashSet};
use std::io::{self, prelude::*};
use std::str;

/*
5 2
5 -4 4 3 -5
4 3
3 -1

5 -4 4 3 -5 -> 8
5 -4 4 3 3  -> 11
5 -4 4 -1 3 -> 7
*/

struct Scanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitWhitespace<'static>,
}
impl<R: BufRead> Scanner<R> {
    fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_whitespace(),
        }
    }
    fn next<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace())
            }
        }
    }
}

fn solve<R: BufRead, W: Write>(scan: &mut Scanner<R>, w: &mut W) {
    let d: usize = scan.next();
    let t: usize = scan.next();
    let s: usize = scan.next();

    writeln!(w, "{}", if (d as f64/s as f64 <= t as _) {"Yes"} else {"No"});
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    // let t: u64 = scan.next();
    let t = 1;
    for _ in 0..t {
        solve(&mut scan, &mut out);
    }
}


Measured memory_bytes: 2116
#include <iostream>
using namespace std;
typedef long long ll;
ll n, a, ans;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main(void)
{
	cin >> n;
	cin >> ans;
	for (ll i = 1; i < n; i++)
	{
		cin >> a;
		ans = gcd(ans, a);
	}
	cout << ans << endl;
}

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

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

    string s;
    for(; n; n /= -2) {
        if(n % 2) s += "1", n--;
        else s += "0";
    }

    if(s.empty()) s = "0";

    reverse(s.begin(), s.end());
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s[] = new String[n];
		boolean b = false;
		
		for(int i = 0; i < n; i++) {
			s[i] = scan.next();
			if(s[i].equals("Y")) {
				b = true;
			}
		}
		if(b == true) {
			System.out.println("Four");
		} else {
			System.out.println("Three");
		}
	}
}

Measured memory_bytes: 23252
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut n = read::<i64>();
    for i in 0..100 {
        for j in 0..100 {
            if 4 * i + 7 * j == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int par[100001]; //parent
int rnk[100001]; //depth
ll nodes[100001];
//init with n elements
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        rnk[i] = 0;
        nodes[i] = 1;
    }
}
//find a root of the tree
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}

//merge the sets contains x,y
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (rnk[x] < rnk[y])
    {
        par[x] = y;
        nodes[y] += nodes[x];
    }
    else
    {
        par[y] = x;
        nodes[x] += nodes[y];
        if (rnk[x] == rnk[y])
            rnk[x]++;
    }
}

//the set contains x and y or not
bool same(int x, int y)
{
    return find(x) == find(y);
}
int main()
{
    ll N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    rep(i, M) cin >> A[i] >> B[i];
    vector<ll> ans(M);
    ll all = N * (N - 1) / 2;
    init(N);
    for (int i = M - 1; i >= 0; i--)
    {
        A[i]--;
        B[i]--;
        ans[i] = all;
        if (!same(A[i], B[i]))
        {
            all -= nodes[find(A[i])] * nodes[find(B[i])];
            unite(A[i], B[i]);
        }
    }
    rep(i, M) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;;

class Solver{
  vector<int> a;
  vector<int> accum_xor;
  vector<int> accum_plus;
  int N;
public:
  Solver(){
    cin >> N;
    a = vector<int>(N, 0);
    accum_xor = vector<int>(N+1, 0);
    accum_plus = vector<int>(N+1, 0);

    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 1; i <= N; i++){
      accum_xor[i] = accum_xor[i-1];
      accum_plus[i] = accum_plus[i-1];
      accum_xor[i] ^= a[i-1];
      accum_plus[i] += a[i-1];
    }

  }

  bool judge(int l, int r){
    int xor_sum = accum_xor[r] ^ accum_xor[l-1];
    int sum = accum_plus[r] - accum_plus[l-1];
    if (xor_sum == sum) return true;
    else return false;
  }

  int count(int l){
    int a = l;
    int b = N+1; //[a, b)

    while (abs(a - b) > 1){
      int mid = (a + b) / 2;
      if (judge(l, mid)) a = mid;
      else b = mid;
    }



    return b - l;
  }

  long long solve(){
    long long counter = 0;
    for (int i = 1; i <= N; i++) counter += count(i);
    return counter;
  }
};

int main(void){

  Solver solver;

  cout << solver.solve() << endl;
}


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using P = pair<int,int>;
const int INF = 1e9;

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  int a[n];
  P b[n];
  rep(i,n) {
    cin >> a[i];
    b[i] = P(a[i],i);
  }
  sort(b,b+n);
  vector<int> v;
  int ans = INF;
  v.push_back(-1); v.push_back(n);
  rep(i,n) {
    vector<vector<int>> p(v.size()-1);
    vector<int> r;
    rep(j,v.size()-1) {
      for(int l = v[j]+1; l < v[j+1]; l++) p[j].push_back(a[l]);
      sort(p[j].begin(),p[j].end());
      rep(l,p[j].size()-k+1) r.push_back(p[j][l]);
    }
    sort(r.begin(),r.end());
    if(r.size() >= q) ans = min(ans,r[q-1]-r[0]);
    v.push_back(b[i].second);
    sort(v.begin(),v.end());
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(43);

ll w,h,x,y;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("rps2.in", "r", stdin);
	//freopen("rps2.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> w >> h >> x >> y;
  cout << double(w * h) / 2 << ' ';
  if(x * 2 == w && y * 2 == h)
    cout << 1;
  else
  cout << 0;
  return 0;
}

Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const int MAX = 510000;
const int MOD = 1000000007;

int main() {

    int N,K; cin >> N >> K;
    ll ans = 0;
    vector<ll> a(N+1),s(N+1);

    for(int i = 0; i <= N; i++) a.at(i) = i;
    for(int i = 1; i <= N; i++) {
        s[i] = s[i-1] + a[i];
    }

    //for(auto x : s) cout << x << endl;

    for(int i = K; i <= N; i++) {
        ll left;
        ll right;
        left = s[i-1];
        right = s[N] - s[N-i];
        //cout << left << " " << right << endl;
        ans += right - (left - 1);
        ans %= MOD;
    }
    ans++;
    cout << ans << endl;
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}



//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
int N;cin>>N;int A,B;cin>>A>>B;
  bool ok=false;
  for(int i=A;i<=B;i++){
   if(i%N==0)ok =true;
  }
    
  if(ok)cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
  

}






Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
const int N=3005, mod=1e9+7;
int dp[N][N];

int MOD(int a){
	if(a>=mod) return a%mod;
	if(a<0) return a%mod+mod;
	return a;
}

int main(){
	int i,j,k,l,a,b,c,d;
	int n;
	char cmd;
	scanf("%d",&n);
	dp[0][0] = 1;
	for(i=1;i<n;i++){
		scanf(" %c",&cmd);
		if(cmd == '<'){
			for(j = 1; j<=i; j++) dp[i][j]=MOD(dp[i-1][j-1]+dp[i][j-1]);
		}else{
			for(j = i; j>=0; j--) dp[i][j]=MOD(dp[i-1][j]+dp[i][j+1]);
 		}
	}
	int ans = 0;
	for(i=0;i<n;i++) ans = MOD(ans + dp[n-1][i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 34176
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    count = 0
    for nn in range(1, N):
        count += nn
    print(count)

if __name__ == '__main__':
    main()


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

int main() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n)cin>>v.at(i);
  sort(v.begin(),v.end());
  int ans=v.at(n/2)-v.at(n/2-1);
  cout<<ans;
}

Measured memory_bytes: 3752
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    A = LI()
    As = sorted(A, reverse=True)
    ans = 0

    for i in range(N):
        j = i//2
        if i != 0:
            ans += As[j]
    
    print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 94188
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i] = int.Parse(str[i]);
        }
        Array.Sort(A);
        int count = 0;
        for(int i=1;i<N;i++){
            if(A[i] == A[i-1]){
                count++;
            }
        }
        count = N - count;
        if(count % 2 == 0){
            count--;
        }
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 18912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, ans = 0;
	int a[100010];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool b = false;
	int o = 0;
	for (int j = 0; j < n - 1; j++) {
		if (b == false) {
			b = true;
			if (a[j] > a[j + 1]) {
				o = 0;
			}
			else if (a[j] == a[j + 1]) {
				o = 1;
			}
			else {
				o = 2;
			}
		}
		if (o == 0) {
			if (a[j] < a[j + 1]) {
				ans++;
				b = false;
			}
		}
		if (o == 1) {
			b = false;
		}
		if (o == 2) {
			if (a[j] > a[j + 1]) {
				ans++;
				b = false;
			}
		}
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
import numpy as np
W,H,N=map(int,input().split())

M = np.ones(W*H).reshape(H,W)

for i in range(N):
  x,y,a =map(int,input().split())
  if a==1:
    M[:,:x]=0
  if a==2:
    M[:,x:]=0
  if a==3:
    M[:y,:]=0
  if a==4:
    M[y:,:]=0
  #print(M)
print(int(M.sum()))

Measured memory_bytes: 27256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>

int32_t main()
{
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif
	IOS;

	int n;

	cin >> n;

	int a[n];

	vector<int> pos, neg, zero;

	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if(a[i] > 0)
			pos.pb(a[i]);
		else if(a[i] < 0)
			neg.pb(a[i]);
		else
			zero.pb(a[i]);
	}

	sort(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	
	int ans(0);

	vector<pair<int, int>> v;

	if(zero.size())
	{
		if(pos.size() and !neg.size())
		{
			v.pb({0, pos.back()});
		// exit(0);
			neg.pb(-pos.back());
			pos.pop_back();
			zero.pop_back();
		}
		if(!pos.size() and neg.size())
		{
			v.pb({0, neg.back()});
			pos.pb({0-neg.back()});
			neg.pop_back();
			zero.pop_back();
		}
	}
	if(pos.size() and neg.size())
	{
		for(int i : pos)
			ans += i;
		for(int i : neg)
			ans += abs(i);
		while(pos.size() != 1)
		{
			v.pb({neg.back(), pos.back()});
			int temp = neg.back();
			neg.pop_back();
			temp -= pos.back();
			pos.pop_back();
			neg.pb(temp);
		}
		while(neg.size())
		{
			v.pb({pos.back(), neg.back()});
			pos.back() -= neg.back();
			neg.pop_back();
		}
		while(zero.size())
		{
			v.pb({ans, 0});
			zero.pop_back();
		}
	}
	else if(pos.size())
	{
		for(int i : pos)
			ans += i;
		ans -= 2**pos.begin();
		reverse(pos.begin(), pos.end());
		int temp = pos.back();
		pos.pop_back();
		while(pos.size() != 1)
		{
			v.pb({temp, pos.back()});
			temp -= pos.back();
			pos.pop_back();
		}
		v.pb({pos.back(), temp});
	}
	else if(neg.size())
	{
		for(int i : neg)
			ans += abs(i);
		ans += 2*neg.back();

		int temp = neg.back();
		neg.pop_back();
		while(neg.size())
		{
			v.pb({temp, neg.back()});
			temp -= neg.back();
			neg.pop_back();
		}
	}
	if(ans == 0)
		zero.pop_back();
	while(zero.size())
	{
		v.pb({ans, 0});
		zero.pop_back();
	}	

	cout << ans << '\n';

	for(auto i : v)
		cout << i.x << ' ' << i.y << '\n';

	return 0;
}

Measured memory_bytes: 6000
N, L = map(int, input().split())
S = [0] * N

for n in range(N):
    S[n] = [_ for _ in input()]

S = sorted(S, key=lambda x: [x[i] for i in range(L)])

ans = ''
for item in S:
    ans += ''.join(item)
print(ans)

Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int Maxn=15,inf=0x3f3f3f3f;
int c[Maxn],s[Maxn];
int a[Maxn][Maxn];
int n,m,k,ans=inf;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
inline bool check()
{
	for(int i=1;i<=m;++i)
	if(s[i]<k)return 1;
	return 0;
}
int main()
{
//	freopen("in.txt","r",stdin);
	n=read(),m=read(),k=read();
	for(int i=1;i<=n;++i)
	{
		c[i]=read();
		for(int j=1;j<=m;++j)
		a[i][j]=read();
	}
	for(int x=0;x<(1<<n);++x)
	{
		memset(s,0,sizeof(s));
		int tot=0;
		for(int i=0;i<n;++i)
		{
			if(!((x>>i) & 1))continue;
			++i,tot+=c[i];
			for(int j=1;j<=m;++j)
			s[j]+=a[i][j];
			--i;
		}
		if(check())continue;
		ans=min(ans,tot);
	}
	if(ans==inf)puts("-1");
	else printf("%d\n",ans);
	return 0;
}

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

//なんか全然違うの作ってたけどせっかくなので残そう
int main() {
	int n;
  	cin>>n;
    int sum=0;
  	int kotae=0;
  	vector<int> w(n);
  
  	rep(i,n){
      cin>>w[i];
      sum +=w[i];
    }




  int dokomade=w[0];	
  int kotaekamo;
  int hantei=sum/2;
  

  
  for(int j=1;j<n;j++){
    	dokomade+=w[j];
      if(dokomade>=hantei){
        kotaekamo+=(dokomade-w[j]);
          break;
      }
    }
  int kotaekana=dokomade;
  int kotamo=(kotaekamo-hantei)*(kotaekamo-hantei);
  int kotaka=(kotaekana-hantei)*(kotaekana-hantei);
  
  if(kotaka<=kotamo){
  	kotae=kotaekana;
  }
  
  else{
  	kotae=kotaekamo;
  }
  
  //あとは答えを出す
  
  kotae-=sum-kotae;
  //絶対値が欲しいのでマイナスだったら-1かけてプラスにする
  if(kotae<0)kotae*=-1;
  

  cout<<kotae<<endl;
}

Measured memory_bytes: 256
N=int(input())
S=[]
T=set()
for i in range(ord('a'),ord('z')+1):
	T.add(chr(i))

D={}
for i in range(N):
	d={}
	t=set()
	s=list(input())
	s.sort()
	for j in s:
		if j not in d:
			d[j]=1
			t.add(j)
		else:d[j]+=1
	
	for j in d:
		if j not in D:
			D[j]=d[j]
		else:
			D[j]=min(D[j], d[j])
	
	T&=t

T=sorted(list(T))

if len(T)!=0:
	for i in T:
		print(i*D[i],end='')
	print()

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

ll n;

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main(){
    cin >> n;
    vector<ll> vec;
    for(ll i=1;i<=55555;i++){
        if(is_prime(i)&&i%5==1) vec.push_back(i);
    }
    for(ll i=0;i<n;i++){
        cout << vec[i];
        if(i!=n-1) cout << " ";
        else cout << endl;
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
 const ll mod = 1000000007;

long long modinv(long long a, long long m) {
	 long long b = m, u = 1, v = 0;
	 while (b) {
		 long long t = a / b;
		 a -= t * b; swap(a, b);
		 u -= t * v; swap(u, v);
	 }
	 u %= m;
	 if (u < 0) u += m;
	 return u;
 }

 ll C(int a, int b) {
	 ll ret = 1;
	 for (int i = 1; i <= b; i++) {
		 ret *= (a - b + i);
		 ret %= mod;
		 ret *= modinv(i, mod);
		 ret %= mod;
	 }
	 return ret;
 }

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

	 for (int i = 1; i <= K; i++) {
		 ll blue = C(K - 1, i - 1);
		 ll red = C((N - K + 1), i);
		 ll ans =  blue * red;
		 ans %= mod;
		 cout << ans << endl;
		 // cout << i << ": " <<  blue << ", " << red << ", " << endl;
	 }
		 

	 return 0;
 }

Measured memory_bytes: 384
/**
 *    author:  tourist
 *    created: 12.01.2020 10:08:26       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n), d(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> d[i];
  }
  set<int> s;
  int ans = 0;
  for (int x = 0; x < 2 * n; x++) {
    for (int i = 0; i < n; i++) {
      if (a[i] == x) {
        s.insert(b[i]);
      }
      if (c[i] == x) {
        auto it = s.lower_bound(d[i]);
        if (it != s.begin()) {
          ++ans;
          s.erase(prev(it));
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())
temp=a*a*b/2
if x<=temp:
	ans=math.atan(a*b*b/(2*x))
	ans=ans*180
	ans=ans/math.pi
	print(ans)
else:
	ans=math.atan(2*(a*a*b-x)/(a*a*a))
	ans=ans*180
	ans=ans/math.pi
	print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
void trace(int a[],int n)
{
  for(int i = 0;i<n;i++)
     {
       if(i>0) printf(" ");
       printf("%d",a[i]);
     }
  printf("\n");
}
void insertionsort(int a[],int n)
{
  int v,j;
  for(int i = 1;i<n;i++)
  {
    v = a[i];
    j  = i-1;
    while(j>=0 && a[j]>v)
    {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    trace(a,n);
  }
}
int main (){
  int n,a[104];
  scanf("%d",&n);
  for(int i = 0;i<n;i++)
     scanf("%d",&a[i]);
  trace(a,n);
  insertionsort(a,n);
  return 0 ;
}



Measured memory_bytes: 3192
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] vList = new int[n];

        for(int i = 0; i < n; i++) {
            vList[i] = sc.nextInt();
        }

        int ans = 0;

        for(int i = 0; i < n; i++) {
            ans += Math.max(0, vList[i] - sc.nextInt());
        }

        // 出力
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import sys
Input = []
while True:
    try:
        a,b = list(map(int, input().split()))
        Input += a,b
    except EOFError:
        break
    if a!=0:
        for j in range(a):
            for i in range(b):
                if j==0 or i==0 or j==a-1 or i==b-1:
                    print("#",end="")
                else:
                    print('.',end='')
            print()
        print()



Measured memory_bytes: 7016
// abc150_a
#include <iostream>
#include <math.h>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <string>

#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
#define ULL unsigned long long
using namespace std;

int main(int argc, char const *argv[])
{
    US n, count = 0;
    string s;
    cin >> n >> s;
    for (US i = 0; i < n; i++)
    {
        if ("ABC" == s.substr(i, 3))
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
1をつなげる。
*/

ll n,k,ans=0;
vector<ll> c;
string s;

void init(){
	cin>>n>>k>>s;
	ll cnt=1;
	ll t=s[0]-'0';
	if(t==0){
		c.push_back(0);//1から始めたい。
	}
	reg(i,1,n-1){
		if(s[i]-'0' != t){
			c.push_back(cnt);
			cnt=0;
		}
		cnt++;
		t=s[i]-'0';
	}
	c.push_back(cnt);
	if(t==0){
		c.push_back(0);//1で終わりたい
	}
	rep(i,c.size())cerr<<c[i]<<endl;
	cerr<<"size: "<<c.size()<<endl;
	// cerr<<"初期化終了"<<endl;
}

int main(void){
	init();
	if(c.size()/2<=k){
		ans=n;
	}else{
		ll sum=0;
		rep(i,2*k+1)sum+=c[i];
		ans=max(ans,sum);
		reg(i,2*k+1,c.size()){
			sum=sum+c[i]+c[i+1]-c[i-(2*k+1)]-c[i-(2*k+1)+1];
			i++;
			ans=max(ans,sum);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1528
/**
 * There is a start and there is no end in the space. ---Infinity.
 * It ruins and goes though there is also a start in stars. ---Finite.
 * Only the man who has wisdom can read the most foolish one from the history.
 * Fishes living in the sea doesn't know the life in the land.
 * It also ruins and goes if they have wisdom.
 * It funnier that man exceeds the speed of light than fish start living in the land.
 * It can be said that this is an final ultimatum from the god to the people who can fight.
 *
 * Steins;Gate
 */

#include <bits/stdc++.h>

const int N = 110;

int a[N], b[N];

int main() {

    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &b[i]);
    }
    for(int i = n; i >= 1; i--) {
        bool f = 0;
        for(int j = i; j >= 1; j--) {
            if(b[j] > j) break;
            if(b[j] == j) {
                a[i] = j;
                //printf("a %d = %d \n", i, j);
                for(int k = j; k < i; k++) {
                    b[k] = b[k + 1];
                }
                f = 1;
                break;
            }
        }
        if(!f) {
            printf("-1");
            return 0;
        }
    }
    for(int i = 1; i <= n; i++) {
        printf("%d\n", a[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
  ll n,k;
  cin >> n >> k;
  ll c = n/k;
  ll d = (n-k/2)/k+1;
  if(k%2 == 0){
    if(n >= k/2) cout << c*c*c  + d*d*d << endl;
    else cout << c*c*c << endl;
  }else{
      cout << c*c*c  << endl;
  }  

}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 256
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N,M;
vi g[1010],r[1010];
int used[1010];
int List[1010],l;
int cycle[1010],c;
int inCycle[1010];

void dfs(int cur){
	if(used[cur]){
		int from = 0;
		while(List[from] != cur) from++;
		rep2(i,from,l){
			cycle[c++] = List[i];
		}
		return;
	}
	used[cur] = 1;
	List[l++] = cur;
	if(sz(g[cur]) == 0){
		cycle[c++] = cur;
		return;
	}
	rep(i,sz(g[cur])){
		dfs(g[cur][i]);
	}
}

ll solve(int v){
	ll res = 1;
	used[v] = 1;
	rep(i,sz(r[v])){
		res = res * solve(r[v][i]) % MOD;
	}
	res = (res+1) % MOD;
	return res;
}

ll f(int start){
	l=0;
	c=0;
	dfs(start);
	ll res = 1;
	rep(i,c)inCycle[cycle[i]] = 1;
	rep(i,c)rep(j,sz(r[cycle[i]])){
		if(inCycle[r[cycle[i]][j]])continue;
		res = res * solve(r[cycle[i]][j]) % MOD;
	}
	res = (res+1) % MOD;
	return res;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N>>M;
	rep(i,M){
		int s,d;
		cin>>s>>d;
		s--;d--;
		g[s].pb(d);
		r[d].pb(s);
	}

	ll ans = 1;
	rep(i,N)if(!used[i]){
		ans = ans * f(i) % MOD;
	}
	cout<<ans<<endl;
}

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

int main()
{
    int64_t N, K;
    int64_t count = 0;
    int64_t are = 1000000000 + 7;
    cin >> N >> K;

    vector<int64_t> list(N + 2);

    for (int64_t i = 1; i <= N + 1; i++)
        list[i] = i * (i + 1) / 2;

    for (int64_t i = K; i <= N; i++)
    {
        count += (list[N + 1] - list[N + 1 - i]) - list[i] + 1;
    }

    cout << (count + 1) % are;
}

Measured memory_bytes: 4836
from collections import defaultdict

A, B = map(int, input().split())


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


d = gcd(A, B)
# print(d)


def f(v):
    dic = defaultdict(int)
    if v == 1:
        dic[1] = 1
        return dic
    for i in range(2, v):
        if i * i > v:
            break
        while v % i == 0:
            v //= i
            dic[i] += 1
    if v != 1:
        dic[v] += 1
    dic[1] = 1
    return dic


divisor = f(d)
# print(divisor)
print(len(divisor))


Measured memory_bytes: 3316