akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int cnt,ans=0;
  int n; cin>>n;
  for(int i=1;i<=n;i+=2) {
    cnt=0;
    for(int j=1;j<=n;j++) {
      if(i%j==0) cnt++;
    }

    if(cnt==8) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3616
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	int a[n+1];
	int b[n];
	int tot=0,sum=0;
	for(int i=0;i<=n;i++)	cin>>a[i], tot+=a[i];
	for(int i=0;i<n;i++)	cin>>b[i];
	for(int i=0;i<n;i++){
		int hero=b[i];
		if(hero>=a[i]){
			hero-=a[i];
			a[i]=0;
			if(hero>=a[i+1]){
				hero-=a[i+1];
				a[i+1]=0;
			}
			else{
				a[i+1]-=hero;
			}
		}
		else
			a[i]-=hero;
	}
	for(int i=0;i<=n;i++)	sum+=a[i];
	cout<<tot-sum<<endl;
	
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=505,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m;
int main(){
//	freopen("1.in","r",stdin);
	m=read();n=500;
	if (m<=500){
		printf("%d\n",m);
		for (int i=1;i<=m;i++){
			for (int j=1;j<=m;j++) printf("%d ",i);
			printf("\n");
		}
		return 0;
	}
	m-=n;printf("%d\n",n);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			int t=(i+j)%n+1;
			if ((t<=m)&&(i&1)) t+=n;
			printf("%d ",t);
		}
		printf("\n");
	}
	return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll L, R, d; cin >> L >> R >> d;

  ll x = R / d;
  ll y = (L-1) / d;
  cout << x - y << endl;

  return 0;
}



Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class AX {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int a,b;
        in>>a>>b;
        out<<max({a+b,a-b,a*b})<<endl;
    }
};

int main() {
    AX solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from math import sqrt
import sys
def input() -> str:
    return sys.stdin.readline()
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            divisors.add(n//i)
    return list(divisors)
def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
a, b = map(int, input().split())
print(len([div for div in make_divisors(gcd(a, b)) if is_prime(div)]) + 1)

Measured memory_bytes: 67432
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define eb emplace_back
 
typedef long long ll;

const int INF = 1e9;
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	ll L, R; cin >> L >> R;
	
	if (R-L+1>=2019) {
		cout << 0 << endl;
	} else {
		ll res = 1e18;
		for (ll i=L; i<=R; i++) {
			for (ll j=L; j<i; j++) {
				res = min(res, ((i%2019)*(j%2019))%2019);
			}
		}
		cout << res << endl;
	}
}


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

int main()
{
	long long t, a, b, sum = 0, mini = INT_MAX;
	cin >> t;
	while (t--)
	{
		cin >> a >> b;
		sum += a;
		if (a > b)
			mini = min(mini, b);
	}
	if (mini == INT_MAX)
		cout << 0 << endl;
	else
	cout << sum - mini << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  long long int x, y, a, b, c;
  cin>>x>>y>>a>>b>>c;
  vector<long long int> p(a);
  for(long long int i=0; i<a; i++){
    cin>>p.at(i);
  }
  vector<long long int> q(b);
  for(long long int i=0; i<b; i++){
    cin>>q.at(i);
  }
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  vector<long long int> hoge(x+y+c);
  for(long long int i=0; i<x; i++){
    hoge.at(i)=p.at(p.size()-1-i);
  }
  for(long long int i=0; i<y; i++){
    hoge.at(x+i)=q.at(q.size()-1-i);
  }
  for(long long int i=0; i<c; i++){
    cin>>hoge.at(i+x+y);
  }
  sort(hoge.begin(),hoge.end());
  long long int ans=0;
  for(long long int i=0; i<x+y; i++){
    ans+=hoge.at(hoge.size()-1-i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3968
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	dp := make([]int, n+1)
	for i := 1; i <= n; i++ {
		dp[i] = dp[i-1]
		for l := 1; l <= i; l *= 6 {
			if dp[i-l] < dp[i] {
				dp[i] = dp[i-l]
			}
		}
		for l := 1; l <= i; l *= 9 {
			if dp[i-l] < dp[i] {
				dp[i] = dp[i-l]
			}
		}
		dp[i]++
	}
	fmt.Println(dp[n])
}


Measured memory_bytes: 1408
def main():
    import sys
    sys.setrecursionlimit(10**9)
    from sys import stdin
    def input() : return stdin.readline().rstrip()
    N,M = map(int,input().split())
    dist = [-1] * N
    G = dict()
    for i in range(N):
        G[i] = []   
    for _ in range(M):
        a,b = map(int,input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    q = [0]
    pre = [0] * N
    dist[0] = 0
    while (q != []):
        v = q[0]
        q.remove(q[0])
        for vertex in G[v]:
            if dist[vertex] != -1:
                continue
            dist[vertex] = dist[v] + 1
            pre[vertex] = v
            q.append(vertex)
    print("Yes")
    for v in range(1,N): 
        print(pre[v]+1)
if __name__ == '__main__':
    main()


Measured memory_bytes: 42368
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			int m=sc.nextInt();
			if(n==0&&m==0) break;
			Integer[] data = new Integer[n];
			for(int i=0;i<n;++i){
				data[i]=sc.nextInt();
			}
			int max=-1;
			for(int i=0;i<n-1;++i){
				for(int j=i+1;j<n;++j){
					if(max<data[i]+data[j]&&data[i]+data[j]<=m) max=data[i]+data[j];
				}
			}
			if(max==-1) System.out.println("NONE");
			else System.out.println(max);
		}
	}
}


Measured memory_bytes: 52508
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <string.h>
#include <algorithm>
#include <math.h>
//#include <bits/stdc++.h>
#define ll long long
#define wtcl return
#define PI acos(-1)
#define MAXN 100005
using namespace std;
const ll mod = 1e9+7;
inline ll read()
{
	ll s = 0, f = 1;
	char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));
	return s * f ;
}
inline void out(ll x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) out(x/10);
	putchar(x%10+'0');
}

int main()
{
	int n;
	cin>>n;
	int k=1;
	int a;
	cin>>a;
	int mine = a;
	for(int i=1;i<n;i++)
	{
		cin>>a;
		if(a<mine)
			k++;
		mine=min(mine,a);
	}
	cout<<k<<endl; 
	wtcl 0;
}

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

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        long N = cin.nextLong();
        long[] A = new long[N];

        for (long i = 0; i < N; i++) A[i] = cin.nextLong();

        Array.Sort(A);

        long cumsum = 0;
        long ans = 0;

        for(long i = 0;i<N-1; i++)
        {
            cumsum += A[i];
            if (A[i + 1] > 2 * cumsum) ans = 0;
            else ans++;
        }
        ans++;

        Console.WriteLine(ans);
        Console.Read();
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 31708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  if(!(N[1] == N[2])) {
	  cout << "No" << endl;
  }
  else if(N[0] == N[1] || N[2] == N[3]) {
	  cout << "Yes" << endl;
  }
  else {
	  cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, k, s = [int(x) for x in input().strip().split()]

if s != 10 ** 9:
    ans = [s] * k + [s+1] * (n - k)
else:
    ans = [s] * k + [s-1] * (n - k)
print(*ans)

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

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

using namespace std;

int main(){
	int n,x; cin>>n>>x;
	int mn;
	rep(i,n){
		int a; cin>>a;
		x-=a;
		if(i==0 || mn>a) mn=a;
	}
	cout<<n+x/mn<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int n = nextInt();
		int[] A = new int[n+1];
		for(int i=0;i<n;i++)A[i] = nextInt();
		sc.close();
		int[] XorA = new int[n];//Aの累積 XOR
		XorA[0]=A[0];
		for(int i=0;i<n-1;i++)XorA[i+1] = XorA[i]^A[i+1];

		int INF = 20;
		long[] dp1 = new long[1<<INF];
		long[] dp0 = new long[1<<INF];
		long[] cnt = new long[1<<INF];
		Arrays.fill(dp0, 1);
		int zero=0;
		for (int i=0;i<n;i++) {
			if (XorA[i]==0) {
				zero++;
			} else {
				dp0[XorA[i]]+=dp1[XorA[i]]*(zero-cnt[XorA[i]]);
				dp1[XorA[i]]+=dp0[XorA[i]];
				dp0[XorA[i]]%=Mod;
				dp1[XorA[i]]%=Mod;

				cnt[XorA[i]]=zero;
			}
		}

		if (XorA[n-1]>0) {
			out.println(dp0[XorA[n-1]]);
		} else {
			long sum = 1;
			for (int i=0;i<zero-1;i++) {
				sum*=2;
				sum%=Mod;
			}
			for (int i=0;i<(1<<INF);i++) {
				sum+=dp1[i];
				sum%=Mod;
			}
			System.out.println(sum);
		}
	}
	private int min(int a, int b) {
		return Math.min(a, b);
	}
	private int nextInt() {
		return Integer.parseInt(next());
	}
	private long nextLong() {
		return Long.parseLong(next());
	}
	private String next() {
		return sc.next();
	}
}


Measured memory_bytes: 94988
#include <bits/stdc++.h>
using namespace std;
#define mo 100005
struct node
{
    int x,y;
}d[mo],p[mo];

int chaji(node a,node b,node c)
{
    return ((b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x));
}


bool cmp(node a,node b)
{
    if(a.y!=b.y)return a.y<b.y;
    return a.x<b.x;
}
void run(int n)
{
    sort(d,d+n,cmp);
    int tot=0;
    for(int i=0;i<n;i++)
    {
        while(tot>1&&chaji(p[tot-2],p[tot-1],d[i])<0) tot--;
        p[tot++]=d[i];
    }

    for(int i=n-2;i>=0;i--)
    {
        while(tot>1&&chaji(p[tot-2],p[tot-1],d[i])<0) tot--;
        p[tot++]=d[i];
    }
    cout<<tot-1<<endl;
    for(int i=0;i<tot-1;i++)
    {
        cout<<p[i].x<<' '<<p[i].y<<endl;
    }

}

int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
            cin>>d[i].x>>d[i].y;

        run(n);
    }



}



Measured memory_bytes: 4272
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

lint solve(const vector<int> &values) {
  int n = values.size();
  lint result = 0;

  if (n > 0 && values[0] != 0)
    return -1LL;

  set<int> marks;
  int mark_delta = 0;

  for (int i = n - 1; i >= 0; --i) {
    marks.insert(values[i] - mark_delta);
    if (*marks.rbegin() != values[i] - mark_delta)
      return -1LL;
    while (!marks.empty() && *marks.begin() + mark_delta <= 0)
      marks.erase(marks.begin());
    result += marks.size();
    --mark_delta;
  }

  return result;
}

int main() {
  int n;
  scanf("%d", &n);
  vector<int> values(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &values[i]);
  printf("%lld\n", solve(values));
  return 0;
}


Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		double a= Double.parseDouble(reader.readLine());
		System.out.printf("%6f %6f",a*a*Math.PI,a*2*Math.PI);
	}
}

Measured memory_bytes: 16932
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

shops = sorted(
    ab,
    key=lambda x: x[0]
)
paid = 0
for cost, stock in shops:
    num = min(m, stock)
    paid += num * cost
    m = m - num
    if m == 0:
        break
print(paid)

Measured memory_bytes: 29796
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(N, M) = reads()

conn = [[False] * N for _ in range(N)]

for _ in range(M):
  (a, b) = reads()
  (a, b) = (a-1, b-1)
  conn[a][b] = conn[b][a] = True

count = 0

for p in permutations(range(1, N)):
  if conn[0][p[0]] and all(conn[p[i]][p[i+1]] for i in range(N-2)):
    count += 1

print(count)


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
const int N=1000,M=1000;
int n,m;
char a[N+1][M+5];
int dp[N+1][M+1];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i]+1;
	dp[1][1]=1;//边界 
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(i!=1||j!=1)//转移 
		if(a[i][j]=='.')dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
	cout<<dp[n][m];//目标 
	return 0;
}
/*1
3 4
...#
.#..
....
*/
/*2
5 2
..
#.
..
.#
..
*/
/*3
5 5
..#..
.....
#...#
.....
..#..
*/
/*4
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
*/

Measured memory_bytes: 5120
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val A = sc.next().toLong()
        val B = sc.next().toLong()
        val N = sc.next().toLong()
        var x = B * (N / B) - 1
        if (x < 0) x = N
        val AxB = A * x / B
        val xB = x / B
        val ans = AxB - (A * xB)
        pw.println(ans)
    }
}


Measured memory_bytes: 34224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n, d;
  cin >> n >> d;
  int x[15][15];
  rep(i,n)rep(j,d) cin >> x[i][j];

  vi sl;
  rep(i,161) sl.pb(i*i);

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      int d2 = 0;
      rep(k,d) {
        d2 += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      if (find(rng(sl),d2) != sl.end()) ans++;
    }
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define ll long long
using namespace std;
struct dog {
	string a;
	int b;
};
int main()
{
	dog shiba; dog pa;
	cin >> shiba.a >> pa.a;
	cin >> shiba.b >> pa.b;
	string key;
	cin >> key;
	if (shiba.a == key)shiba.b -= 1;
	else if (pa.a == key)pa.b -= 1;
	cout << shiba.b << " " << pa.b;

}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100000500];
ll memory[100000500];
ll u=1;
ll stroage(ll n)
{
    for(int i=1; i<=u; i++)
        if(memory[i]==n)
            return 1;
    memory[u++]=n;
    return 0;
}
int main()
{
    ll s;
    cin>>s;
    a[1]=s;
    stroage(s);
    for(ll i=2;;i++)
    {

        if(a[i-1]%2==0)
        {
            a[i]=a[i-1]/2;
            if(stroage(a[i])==1)
            {
                cout<<i<<endl;
                break;
            }
        }
        else if(a[i-1]%2==1)
        {
            a[i]=3*a[i-1]+1;
        if(stroage(a[i])==1)
            {
                cout<<i<<endl;
                break;
            }

        }
    }
    return 0;
}


Measured memory_bytes: 2304
#include<iostream>

using namespace std;

int main()
{
  int a, b;
  
  cin >> a >> b;
  
  int sum = 0;
  switch(a){
      case 1:
      sum += 300000;
      break;
      case 2:
      sum += 200000;
      break;
      case 3:
      sum += 100000;
      break;
   }
  
  switch(b){
      case 1:
      sum += 300000;
      break;
      case 2:
      sum +=200000;
      break;
      case 3:
      sum+= 100000;
      break;
  }
  
  if(a == 1 && b == 1)
    sum += 400000;
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

ans = 0

for b in range(1, N+1):
    p = N // b
    r = N % b
    ans += p * max(0, b - K)  # 繰り返される部分
    ans += max(0, r - K + 1)  # 最後に付け加えられる部分

if K == 0:
    # 1~NのN回 b に関する演算を行なっているから -N
    ans -= N  # 各bに対して,本来許されない a=0 をカウントしてしまっているから帳尻合わせをする

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	init();

	int N; cin >> N;
	vector<int>a(N);
	for (auto& v : a)cin >> v;
	int four = 0, num = 0;
	bool is = false;
	rep(i, 0, N) {
		if (a[i] % 4 == 0)four++;
		else if (a[i] % 2 == 0)is = true;
		else num++;
	}
	if (is)num++;
	if (four < num && abs(four - num) > 1)cout << "No" << "\n";
	else cout << "Yes" << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct point {
    double x, y;
    point (){}
    point (double x, double y) : x(x), y(y){}
    point friend operator - (point l, point r) {
        return point (l.x - r.x, l.y - r.y);
    }
    double friend operator * (point l, point r) {
        return l.x * r.x + l.y * r.y;
    }
    double len () {
        return sqrt (x * x + y * y);
    }
} A, B, C, D;
int main () {
//    freopen ("in.txt", "r", stdin);
    int Q;
    double x1, y1, x2, y2;
    cin >> A.x >> A.y >> B.x >> B.y;
    D = B - A;
    cin >> Q;
    while (Q --) {
        cin >> C.x >> C.y;
        C = C - A;
        double cel = C * D;
        cel /= D.len() * D.len ();
        printf ("%.10f %.10f\n", D.x * cel + A.x, D.y * cel + A.y);
    }
    return 0;
}



Measured memory_bytes: 3288
a, b = map(int, input().split())
ans = 'Draw'
if a == 1:
    if b != 1:
        ans = 'Alice'
elif b == 1:
    if a != 1:
        ans = 'Bob'
else:
    if a > b:
        ans = 'Alice'
    elif a < b:
        ans = 'Bob'
print(ans)


Measured memory_bytes: 2940
n = int(input())
p = [int(i) for i in input().split()]

ans = 'YES'
judge = False
for i in range(n):
    if (p[i] != i + 1 and judge == False):
        if(p[p[i] - 1] == i + 1):
            judge = True
            a = p[i] - 1
            p[i] = i + 1
            p[a] = a + 1
        else:
            ans = 'NO'
            break
    elif (p[i] != i + 1 and judge == True):
        ans = 'NO'
        break
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
    int x[4],y[4],r,a;
    while(1){
    scanf("%d",&r); scanf("%d",&a);
    if(a==0&&r==0) break;
   for(int i=4;i>=1;i--){
       x[i]=r%10; y[i]=a%10;
       r=r/10; a=a/10;
       //printf("%d %d\n",x[i],y[i]);
   }
    
    int hit=0,blow=0;
    for(int i=1;i<=4;i++){
        for(int j=1;j<=4;j++){
        if(x[i]==y[j]){
            if(i==j) hit++;
            else blow++;
        }
        }
    }
    printf("%d %d\n",hit,blow);
}
   return 0; 
}


Measured memory_bytes: 1980
# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]


# s = input()
N = int(input())
s = [input() for _ in range(N)]
# N, K = map(int, input().split())
# b = list(map(int, input().split()))
# c = [list(map(int, input().split())) for _ in range(N)]

ab_inner_count = 0
ab_top_bottom_count = 0
b_top_count = 0
a_bottom_count = 0
none_count = 0

for s_i in s:
    if s_i[0] == 'B' and s_i[-1] == 'A':
        ab_top_bottom_count += 1
    elif s_i[0] == 'B':
        b_top_count += 1
    elif s_i[-1] == 'A':
        a_bottom_count += 1
    else:
        none_count += 1

    for i in range(len(s_i) - 1):
        if s_i[i] == 'A' and s_i[i+1] == 'B':
            ab_inner_count += 1

ans = ab_inner_count

if ab_top_bottom_count == 0:
    ans += min(b_top_count, a_bottom_count)
elif a_bottom_count == 0:
    if b_top_count > 0:
        ans += ab_top_bottom_count
    else:
        ans += ab_top_bottom_count - 1
elif b_top_count == 0:
    if a_bottom_count > 0:
        ans += ab_top_bottom_count
    else:
        ans += ab_top_bottom_count - 1
else:
    ans += ab_top_bottom_count + 1
    ans += min(b_top_count - 1, a_bottom_count - 1)

print(ans)
# print(ab_top_bottom_count)
# print(a_bottom_count)
# print(b_top_count)

















Measured memory_bytes: 3700
N, Q = map(int, input().split())
s = input()
nlis = [0]
cnt = 0
for i in range(len(s)-1):
    if(s[i:i+2] == "AC"): 
        cnt += 1
    nlis.append(cnt)
#print(nlis)
for i in range(Q):
    in0, in1 = map(int, input().split())
    print(nlis[in1-1]-nlis[in0-1])

Measured memory_bytes: 6100
import sys
from heapq import heappush, heappop
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())

INF = 10**18


class HeapSet:
    def __init__(self):
        self.minQue = []
        self.maxQue = []
        self.counter = defaultdict(lambda: 0)

    def insert(self, x):
        heappush(self.minQue, x)
        heappush(self.maxQue, -x)
        self.counter[x] += 1

    def delete(self, x):
        self.counter[x] = max(0, self.counter[x] - 1)

    def get_max(self):
        while self.maxQue and self.counter[-self.maxQue[0]] == 0:
            heappop(self.maxQue)
        return -self.maxQue[0] if self.maxQue else None

    def get_min(self):
        while self.minQue and self.counter[self.minQue[0]] == 0:
            heappop(self.minQue)
        return self.minQue[0] if self.minQue else None

    def __str__(self):

        min = []
        sl = sorted(list(set(self.minQue)))
        for i in range(len(sl)):
            if self.counter[sl[i]]:
                min += [sl[i]] * self.counter[sl[i]]

        return min.__str__()


def main():

    N, C = in_nn()
    xv = []

    for i in range(N):
        x, v = in_nn()
        xv.append((x, v))

    if N == 1:
        ans = 0
        x, v = xv[0]
        ans = max(ans, v - min(x, C - x))
        print(ans)
        exit()

    xv.sort()

    tsum = [0] * (N + 1)
    for i in range(N):
        tsum[i + 1] = tsum[i] + xv[i][1]

    for i in range(N):
        tsum[i + 1] -= xv[i][0]

    rev_tsum = [0] * (N + 1)
    for i in range(N):
        rev_tsum[i + 1] = rev_tsum[i] + xv[N - 1 - i][1]

    for i in range(N):
        rev_tsum[i + 1] -= C - xv[N - 1 - i][0]

    heap = HeapSet()

    for i in range(N + 1):
        heap.insert(tsum[i])

    # print(tsum)
    # print(rev_tsum)
    # print(dmin)

    ans = heap.get_max()
    for i in range(1, N + 1):
        heap.delete(tsum[N + 1 - i])
        v1 = heap.get_max()
        v2 = rev_tsum[i]
        c2 = C - xv[N - i][0]
        value = v1 + v2 - c2
        ans = max(ans, value)

    heap2 = HeapSet()
    for i in range(N + 1):
        heap2.insert(rev_tsum[i])

    ans = max(ans, heap2.get_max())
    for i in range(1, N + 1):
        heap2.delete(rev_tsum[N + 1 - i])
        v1 = heap2.get_max()
        v2 = tsum[i]
        c2 = xv[i - 1][0]
        value = v1 + v2 - c2
        ans = max(ans, value)

    print(ans)


if __name__ == '__main__':
    main()


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

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

    long long int c,d;
    c = n/(a+b);
    d = n%(a+b);

    if(d <= a){
        cout << c*a + d << endl;
    }else{
        cout << (c+1) * a << endl;
    }

}

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



int main() {
	long long int n, d, a;
	cin >> n;
	cin >> d;
	cin >> a;
	map<long long int, pair<long long int, long long int> > m;
	for (long long int i=0; i<n; i++) {
		long long int b, c;
		cin >> b;
		cin >> c;
		m[b] = make_pair(c, 0);
	}
	long long int destroy = 0;
	long long int bombs = 0;

	map<long long int, pair<long long int, long long int> >::iterator it = m.begin();
	while (it != m.end()) {
		int x = it->first;
		pair<long long int, long long int> values = it->second;
		int health = values.first;
		int update = values.second;
		health -= destroy;
		if (health > 0) {
			long long int times = (health-1) / a + 1;
			bombs += times;
			if (d==0) {
				it++;
				continue;
			}
			destroy += times*a;
			if (m.count(x+2*d)) m[x+2*d] = make_pair(m[x+2*d].first, times);
			else m[x+2*d] = make_pair(0, times);	
		}
		destroy -= update*a;
		it++;
	}
	cout << bombs;
	return 0;
			
}	


Measured memory_bytes: 18944
import java.util.Scanner

object Main {

  def solve(sc: => Scanner): Unit = {
    val A = sc.next
    if (A != ".") {
      val B = sc.next
      if (A.equals(B)) (println("IDENTICAL"))
      else {
        val arrA = A.split("\"", -1)
        val arrB = B.split("\"", -1)
        if (arrA.length == arrB.length && arrA.zipWithIndex.filter(i => i._2 % 2 == 0).deep == arrB.zipWithIndex.filter(i => i._2 % 2 == 0).deep) {
          val arrAx = arrA.zipWithIndex.filter(i => i._2 % 2 == 1)
          val arrBx = arrB.zipWithIndex.filter(i => i._2 % 2 == 1)

          var count = 0
          for (i <- 0 until arrAx.length) (if (arrAx(i) != arrBx(i)) count += 1)
          if (count == 1) (println("CLOSE")) else (println("DIFFERENT"))
        } else (println("DIFFERENT"))
      }
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 46552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,count=0;
  long long int a,ans=0,mins=LLONG_MAX;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a<0){
      count++;
      a*=-1;
    }
    mins=min(mins,a);
    ans+=a;
  }
  if(count%2==0) cout<<ans<<endl;
  else cout<<ans-(mins*2)<<endl;
  return(0);
}


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

int main(){
	int w,h,n; cin>>w>>h>>n;
	vector<vector<int>> v(w,vector<int>(h));
	rep(i,n){
		int x,y,a; cin>>x>>y>>a;
		if(a==1){
			for(int i=0; i<x; i++){
				for(int j=0; j<h; j++){
					v[i][j]=1;
				}
			}
		}
		if(a==2){
			for(int i=x; i<w; i++){
				for(int j=0; j<h; j++){
					v[i][j]=1;
				}
			}
		}
		if(a==3){
			for(int i=0; i<w; i++){
				for(int j=0; j<y; j++){
					v[i][j]=1;
				}
			}
		}
		if(a==4){
			for(int i=0; i<w; i++){
				for(int j=y; j<h; j++){
					v[i][j]=1;
				}
			}
		}
	}
	int cnt=0;
	for(int i=0; i<w; i++){
		for(int j=0; j<h; j++){
			if(v[i][j]==0) cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3624
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  vector<vector<int>> v;
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 1; j < (1 << n); j++) {
      for (int k = 1; k < (1 << n); k++) {
        if (!(i & j) && !(i & k) && !(j & k)) {
          v.push_back({i, j, k});
        }
      }
    }
  }
  int ans = INT64_MAX;
  for (auto &el : v) {
    int x = el[0], y = el[1], z = el[2];
    int t = (__builtin_popcount(x) + __builtin_popcount(y) + __builtin_popcount(z) - 3) * 10;
    int suma = 0, sumb = 0, sumc = 0;
    for (int i = 0; i < n; i++) {
      if (x & (1 << i)) suma += l[i];
      if (y & (1 << i)) sumb += l[i];
      if (z & (1 << i)) sumc += l[i];
    }
    t += abs(suma - a) + abs(sumb - b) + abs(sumc - c);
    ans = min(ans, t);
  }
  cout << ans << "\n";
}



Measured memory_bytes: 2872
// Aizu 0580: Fish
// 2017.10.25 bal4u@uu
// 2017.12.6

#include <stdio.h>
#include <stdlib.h>

#define MAX  52
#define MAX2 104

typedef struct { int x1, y1, d1, x2, y2, d2; } PP;
PP p[MAX];
int x[MAX2], y[MAX2], d[MAX2], sz, xs, ys, ds;
char map[MAX2][MAX2][MAX2];

int cmp(int *a, int *b) { return *a - *b; }

int uniq(int *a, int n)
{
	int i, j;
	for (i = 0, j = 1; j < n; j++) {
		while (j < n && a[j] == a[i]) j++;
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i+1;
}

int bsch(int *a, int x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l + r) >> 1;
		if (a[m] == x) break;
        if (a[m] < x) l = m + 1; else r = m;
    }
	return m;
}

int main()
{
	int n, k, i, xx, yy, dd, x1, y1, x2, y2, d1, d2;
	long long ans;

	scanf("%d%d", &n, &k);
	for (sz = 0, i = 0; i < n; i++) {
		scanf("%d%d%d%d%d%d", &p[i].x1, &p[i].y1, &p[i].d1, &p[i].x2, &p[i].y2, &p[i].d2);
		x[sz] = p[i].x1, x[sz+1] = p[i].x2;
		y[sz] = p[i].y1, y[sz+1] = p[i].y2;
		d[sz] = p[i].d1, d[sz+1] = p[i].d2;
		sz += 2;
	}
	qsort(x, sz, sizeof(int), cmp), xs = uniq(x, sz);
	qsort(y, sz, sizeof(int), cmp), ys = uniq(y, sz);
	qsort(d, sz, sizeof(int), cmp), ds = uniq(d, sz);

	for (i = 0; i < n; i++) {
		x1 = bsch(x, p[i].x1, xs), x2 = bsch(x, p[i].x2, xs);
		y1 = bsch(y, p[i].y1, ys), y2 = bsch(y, p[i].y2, ys);
		d1 = bsch(d, p[i].d1, ds), d2 = bsch(d, p[i].d2, ds);
		for (xx = x1; xx < x2; xx++) for (yy = y1; yy < y2; yy++) for (dd = d1; dd < d2; dd++)
			map[xx][yy][dd]++;
	}

	ans = 0;
	for (xx = 0; xx < xs; xx++) for (yy = 0; yy < ys; yy++) for (dd = 0; dd < ds; dd++) {
        if (map[xx][yy][dd] >= k)
			ans += (long long)(x[xx+1]-x[xx]) * (y[yy+1]-y[yy]) * (d[dd+1]-d[dd]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2728
N,M,X,Y = map(int,input().split(' '))
A = list(sorted(map(int,(input().split(' ')))))
B =list(sorted(map(int,(input().split(' ')))))

if A[N-1] >= B[0]:
  print('War')
else:
  for Z in range(A[N-1]+1,B[0]+1):
    if A[N-1] < Z <= B[0] and X < Z <= Y:
      if Z == B[0]:
        print('No War')
        break
    else:
      print('War')
      break
  
  

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
s = [int(x) for x in input().split()]
s.sort()
cnt = 0

tmp = abs(s[0] - s[1])
if tmp % 2 == 0:
    cnt += tmp // 2
else:
    cnt += tmp // 2 + 1
    s[2] += 1

print(cnt+s[2]-s[1])

Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    res = 0
    for i in range(1, n + 1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            res += i

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

ll powl(ll a, ll p, ll m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		return (powl((a * a) % m, p / 2, m)) % m;
	} else {
		return (a * powl((a*a) % m, (p - 1) / 2, m)) % m;
	}
}
ll solve(ll n) {
	int c = 0;
	while (n != 0) {
		n %= __builtin_popcount(n);
		c++;
	}
	return c;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	string S;
	cin >> S;
	reverse(all(S));
	int ones = 0;
	for (int i = 0; i < N; i++) {
		ones += (S[i] == '1');
	}
	//db(ones);
	ll rmp1 = 0, rmm1 = 0;
	ll modp1 = ones + 1;
	ll modm1 = ones - 1;
	for (int i = 0; i < N; i++) {
		if (S[i] == '1') {
			rmp1 += powl(2, i, modp1);
			rmp1 %= modp1;
			if (modm1 != 0) {
				rmm1 += powl(2, i, modm1);
				rmm1 %= modm1;
			}
		}
	}
	//db(ones);
	//db(rmp1);
	//db(rmm1);
	for (int i =  N - 1; i >= 0; i--) {
		ll rr;
		if (S[i] == '0') {
			rr = rmp1;
			rr += powl(2, i, modp1);
			rr %= modp1;
		}
		else {
			if (modm1 == 0) {
				cout << "0\n";
				continue;
			}
			rr = rmm1;
			rr -= powl(2, i, modm1);
			rr = (rr + modm1) % modm1;
		}
		//db(rr);
		cout << solve(rr) + 1 << "\n";
	}
}

//23
//10110111001011011001110



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

int w, a, b;

main()
{
    cin >> w >> a >> b;
    if ((b <= a && b + w >= a) || (b >= a && b <= a + w))
        cout << 0 << endl;
    else if (a + w < b)
        cout << b - a - w << endl;
    else
        cout << a - b - w << endl;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++a[i];
  }
  int cur = 0;
  for (int i = 0; i < m; ++i) cur += a[i];
  int best = cur;
  for (int i = m; i < n; ++i) {
    cur -= a[i - m];
    cur += a[i];
    best = max(best, cur);
  }
  cout << 0.5 * best << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
using namespace std;

class Point{
public:
  int a,b,c;
  bool f[9];
};

int main(){
  int i,j,n,a[9],b[9],sum,ans;
  cin >> n;
  for(int t=0;t<n;t++){
    for(i=0;i<9;i++) cin >> a[i];
    for(i=0;i<9;i++) cin >> b[i];
    sum = ans = 0;

    queue<Point> Q;
    Point u,v;
    for(j=0;j<9;j++) u.f[j] = false;
    u.a = u.b = u.c = 0;
    
    Q.push(u);
    while(!Q.empty()){
      u = Q.front();
      Q.pop();
      
      if(u.c >= 9){
	sum++;
	if(u.a > u.b) ans++;
	continue;
      }
      
      for(int k=0;k<9;k++){
	if(!u.f[k]){
	  v = u;
	  if(a[v.c] > b[k]) v.a += a[v.c] + b[k];
	  else v.b += a[v.c] + b[k]; 
	  v.f[k] = true;
	  v.c++;
	  Q.push(v);
	}
      }
    }
  
    double answer = (double)ans / sum;
    printf("%f %f\n",answer,1.0 - answer);
    
  }
  return 0;
}

Measured memory_bytes: 9708
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair


void solve()
{
    string s;
    cin >> s;
    
    for(int mask = 0; mask < (1 << 4); mask++)
    {
        int sum = 0;
        for(int i = 0; i < 4; i++)
        {
            if((mask >> i) & 1)
            {
                sum += s[i] - '0';
            }
            else
            {
                sum -= s[i] - '0';
            }
        }
        if(sum == 7)
        {
            for(int i = 0; i < 4; i++)
            {
                if(i == 0)
                {
                    cout << s[i];
                    continue;
                }
                if((mask >> i) & 1)
                {
                    cout << "+" << s[i];
                }
                else
                {
                    cout << "-" << s[i];
                }
            }
            cout << "=7";
            break;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
N, M = map(int,input().split(" "))

ans = [0]*N
wc_c = [0]*N
pena = 0

for i in range(M):
    p, s = input().split(" ")
    p = int(p) - 1
    s = str(s)
    
    if s == "AC" and ans[p] == 0:
        ans[p] = 1
        pena += wc_c[p]
        
    elif s == "WA" and ans[p] == 0:
        wc_c[p] += 1
        
print(sum(ans), pena)
      
    

Measured memory_bytes: 4596
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            if (D == 25)
            {
                Console.WriteLine("Christmas");
            }
            else if (D == 24)
            {
                Console.WriteLine("Christmas Eve");
            }
            else if (D == 23)
            {
                Console.WriteLine("Christmas Eve Eve");
            }
            else
            {
                Console.WriteLine("Christmas Eve Eve Eve");
            }
        }
    }
}

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

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


Measured memory_bytes: 3104