akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

int main() {
	int N;
	std::vector<int> a;

	std::cin >> N;
	a.resize(N);

	for (int i = 0; i < N; i++)
		std::cin >> a[i];

	bool beforeEqual = false;
	int temp = 0;
	int ans = 0;
	for (size_t i = 0; i < N - 1; i++) {
		if (!beforeEqual&&a[i] == a[i + 1]) {
			beforeEqual = true;
			temp += 2;
		}
		else if (beforeEqual&&a[i] == a[i + 1])
			temp += 1;

		if (a[i] != a[i + 1] || i == N - 2) {
			ans += temp / 2;
			temp = 0;
			beforeEqual = false;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
using namespace std;
int gys(int a,int b)
{
	if(b == 0)
		return a;
	else
		return gys(b,a%b);
}
int main()
{
	int n,k;
	int t;
	cin >> n >> k;
	vector<int> sz;
	for(t=0;t<n;t++)
	{
		int a;
		cin >> a;
		sz.push_back(a);
	}
	sort(sz.begin(),sz.end());
	if(sz[n-1] < k) cout << "IMPOSSIBLE" << endl;
	else if(sz[n-1] == k)	cout << "POSSIBLE" << endl;
	else
	{
		int gyz = sz[0];
		for(t=1;t<n;t++)
		{
			gyz = gys(gyz,sz[t]);
			if(gyz == 1)	break;
		}
		if((sz[n-1]-k)%gyz == 0)	cout << "POSSIBLE" << endl;
		else	cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 892
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n;
	long long temp;
	vector<long long> x,y;
	cin>>n;
	for(int i=0;i!=n;++i){
		cin>>temp;
		x.push_back(temp);
		cin>>temp;
		y.push_back(temp);
	}
	for(int i=0;i!=n-1;++i){
		long long a=x[i]/x[i+1],b=y[i]/y[i+1];
		if(x[i]%x[i+1])
			++a;
		if(y[i]%y[i+1])
			++b;
		long long mul=max(a,b);
		x[i+1]*=mul;
		y[i+1]*=mul;
	}
	cout<<x.back()+y.back();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 100005
#define MOD 998244353

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE],B[SIZE],C[SIZE];
map <P,int> mp;
ll dp[2][2];
int dx1[2]={-1,0},dy1[2]={0,-1};
int dx2[2]={-2,0},dy2[2]={0,-2};

ll mpow(ll n,ll t)
{
	if(t==0) return 1LL;
	ll ret=mpow(n,t/2);
	ret=ret*ret%MOD;
	if(t%2==1) ret=ret*n%MOD;
	return ret;
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		a--,b--;
		mp[P(a,b)]=c;
		A[i]=a,B[i]=b,C[i]=c;
	}
	ll all=(ll) (n-2)*(ll) (n-3)/2LL;
	for(int i=0;i<m;i++)
	{
		if(abs(A[i]-B[i])>=3)
		{
			all--;
			if(mp.count(P(B[i],A[i]))==1)
			{
				if(A[i]>B[i]) all++;
				if(mp[P(B[i],A[i])]!=mp[P(A[i],B[i])])
				{
					puts("0");
					return 0;
				}
			}
		}
	}
	ll ret=mpow(2LL,all);
	int pos=0;
	dp[pos][0]=dp[pos][1]=ret;
	if(mp.count(P(0,0))!=0) dp[pos][1-mp[P(0,0)]]=0;
	for(int i=1;i<n;i++)
	{
		pos^=1;
		dp[pos][0]=dp[pos][1]=0;
		int X=-1;
		if(mp.count(P(i,i))!=0) X=mp[P(i,i)];
		for(int j=0;j<2;j++)
		{
			for(int s=0;s<2;s++)
			{
				if(X!=-1&&X!=s) continue;
				ll w=dp[pos^1][j];
				int a=s,z=0;
				for(int k=0;k<2;k++)
				{
					int x=i+dx1[k],y=i+dy1[k];
					if(0<=x&&0<=y)
					{
						if(mp.count(P(x,y))==0) z++;
						else a^=mp[P(x,y)];
					}
				}
				if(z>0||a==j)
				{
					int pl=max(0,z-1);
					a=0,z=0;
					for(int k=0;k<2;k++)
					{
						int x=i+dx2[k],y=i+dy2[k];
						if(0<=x&&0<=y)
						{
							if(mp.count(P(x,y))==0) z++;
							else a^=mp[P(x,y)];
						}
					}
					if(i==1||z>0||a==j)
					{
						pl+=max(0,z-1);
						dp[pos][s]+=w*mpow(2LL,pl)%MOD;
						if(dp[pos][s]>=MOD) dp[pos][s]-=MOD;
					}
				}
			}
		}
		//printf("%lld %lld\n",dp[pos][0],dp[pos][1]);
	}
	printf("%lld\n",(dp[pos][0]+dp[pos][1])%MOD);
	return 0;
}


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

using namespace std;


#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
     
#define ll long long int
#define ld long double


#define fr first
#define se second



#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define sunq(v) sort(all(v));v.resize(distance(v.begin(),unique(all(v))))


#define pb push_back
#define mp make_pair

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define emla(a, val) memset(a, val, sizeof(a))

#define easm(a, b) (a + b - 1)/b 


#define PI 3.141592653589793238
#define E  2.718281828459045235


ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}


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

const int N = 1e5 + 10;

ll dp[N];
int n, a[N];


int main(){
  IOS;
  //freopen("input.in", "r", stdin);
  //freopen("output.txt", "w", stdout);
  clock_t z = clock();
  cin >> n;
  for(int i = 0; i < n; i++)cin >> a[i];
  dp[0] = 0, dp[1] = abs(a[1] - a[0]);
  for(int i = 2; i < n; i++)
    dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
  cout << dp[n-1] << endl;
  debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
  /*
  *try tricky test cases:
    -bounds
    -integer overflow
    -small input (0, 1)
    -big input
    -random tests
  */
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    double pi=3.14159;
    double r;cin>>r;
    cout<<2*pi*r<<endl;
    return 0;
}


Measured memory_bytes: 3804
n,a,b=map(int,input().split())
mod=10**9+7
ans=pow(2, n, mod) - 1

def comb(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p*(n-i) % mod
        q = q*(r-i) % mod
        #print(p,q)
    return p * pow(q, mod-2, mod)%mod
    
print((ans- comb(n, a) - comb(n, b)) % mod)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
using namespace std;
#define MAX 1000000

int main(){
	bool p[MAX+1];
	int n, ans;

	for(int i=0 ; i<=MAX ; i++){
		p[i] = (i<=1)? false : true ;
	}

	for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
		if(p[i]){
			for(int j=i*2 ; j<=MAX ; j+=i){
				p[j] = false;
			}
		}
	}

	while( cin >> n ){		
		ans = 0;
		for(int i=0 ; i<=n ; i++){
			if(p[i]){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
# 初期入力
import sys
from itertools import combinations

input = sys.stdin.readline  #文字列では使わない
N = int(input())
L = list(map(int, input().split()))
used =set()
count =0
for t in combinations(L, 3):
    if t[0] !=t[1] and t[1] !=t[2] and t[2] !=t[0]:
        t_l =list(t)
        t_l.sort()
        if t_l[2] < t_l[0] +t_l[1]:
            count +=1
print(count)

Measured memory_bytes: 9188
# D - Wizard in Maze
import sys
from collections import deque
from typing import List, Tuple


class WarpableMaze:
    __slots__ = ["height", "width", "road", "wall", "unsearched", "dist"]

    def __init__(
        self,
        height: int,
        width: int,
        grid: List[bytes],
        road: str = ".",
        wall: str = "#",
    ) -> None:
        self.height = height + 4
        self.width = width + 4
        self.road = road
        self.wall = wall
        self.unsearched = 1 << 30
        self.dist = self._convert_grid_to_dist(grid)

    def _flatten_dxy(self, x: int, y: int) -> int:
        return self.width * x + y

    def _flatten_coordinate(self, h: int, w: int) -> int:
        return self._flatten_dxy(h + 2, w + 2)

    def _convert_grid_to_dist(self, grid: List[bytes]) -> List[int]:
        dist = [-1] * self.height * self.width
        i = self.width * 2 + 1
        for row in grid:
            for c in row.decode():
                i += 1
                if c == self.road:
                    dist[i] = self.unsearched
            i += 4
        return dist

    def bfs(self, start_2d: Tuple[int, int], goal_2d: Tuple[int, int]) -> int:
        start = self._flatten_coordinate(*start_2d)
        goal = self._flatten_coordinate(*goal_2d)

        w = self.width
        walk_to_warp = {
            -w: (-2 * w - 2, -2 * w - 1, -2 * w, -2 * w + 1, -w - 1),
            w: (w + 1, 2 * w - 1, 2 * w, 2 * w + 1, 2 * w + 2),
            -1: (-w - 2, -2, w - 2, w - 1, 2 * w - 2),
            1: (-w + 1, -2 * w + 2, -w + 2, 2, w + 2),
        }

        dist = self.dist[:]
        dist[start] = 0
        queue = deque([start])
        while queue:
            next_queue = deque()
            while queue:
                x = queue.popleft()
                cur_dist = dist[x]
                if x == goal:
                    break
    
                for walk, warp in walk_to_warp.items():
                    nx = x + walk
                    if dist[nx] > cur_dist:
                        dist[nx] = cur_dist
                        queue.append(nx)
                        continue
                    if dist[nx] >= 0:
                        continue
    
                    for dx in warp:
                        nx = x + dx
                        if dist[nx] > cur_dist + 1:
                            dist[nx] = cur_dist + 1
                            next_queue.append(nx)
            queue = next_queue

        return dist[goal] if dist[goal] != self.unsearched else -1


def main():
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline

    H, W = map(int, readline().split())
    CH, CW = map(int, readline().split())
    DH, DW = map(int, readline().split())
    (*S,) = read().split()

    maze = WarpableMaze(H, W, S)
    start, goal = (CH - 1, CW - 1), (DH - 1, DW - 1)
    print(maze.bfs(start, goal))


if __name__ == "__main__":
    main()


Measured memory_bytes: 96600
MOD = 10**9 + 7
S = input()

cur = [0] * 13
cur[0] = 1
r = 1
base = 0
for i in range(len(S)):
    s = S[-(i+1)]
    if s == '?':
        prev = cur
        cur = [sum(prev)] * 13
        for m in range(13):
            for d in range(10,13):
                cur[(m + r*d) % 13] -= prev[m]
        for m in range(13):
            cur[m] %= MOD
    else:
        base = (base + r*int(s)) % 13

    r = (10 * r) % 13

print(cur[(5-base) % 13])

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

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

const int MAX_N=1000;

int N;
int A[MAX_N+5][MAX_N+5];

int id[MAX_N+5][MAX_N+5];
int t;

vector<int> G[MAX_N*MAX_N];
bool isVisited[MAX_N*MAX_N];
bool isCalculated[MAX_N*MAX_N];
int d[MAX_N*MAX_N];

void setId(int i,int j){
    if(i>j)swap(i,j);
    if(id[i][j]==-1)id[i][j]=t++;
}

int getId(int i, int j){
    if(i>j)swap(i,j);
    return id[i][j];
}


int dfs(int v){
    if(isVisited[v]){
        if(!isCalculated[v])return -1;
        return d[v];
    }
    isVisited[v]=true;
    d[v]=1;
    for(auto u:G[v]){
        int res=dfs(u);
        if(res==-1)return -1;
        chmax(d[v],res+1);
    }
    isCalculated[v]=true;
    return d[v];
}

int main(){
    cin>>N;
    for(int i=0;i<MAX_N;++i)for(int j=0;j<MAX_N;++j)id[i][j]=-1;
    for(int i=0;i<N;++i){
        for(int j=0;j<N-1;++j){
            cin>>A[i][j];
            A[i][j]--;
            setId(i,A[i][j]);
        }
    }
    for(int i=0;i<N;++i){
        for(int j=0;j<N-2;++j){
            G[getId(i,A[i][j])].push_back(getId(i,A[i][j+1]));
        }
    }
    int ans=0;
    for(int i=0;i<t;++i){
        int res=dfs(i);
        if(res==-1){
            cout<<-1<<endl;
            return 0;
        }
        chmax(ans,res);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 52992
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int MAX = A[0];
  int g = A[0];
  REP(i, N-1){
    g = __gcd(g, A[i+1]);
    chmax(MAX, A[i+1]);
  }

  if(K%g == 0 && K <= MAX) cout << "POSSIBLE" << "\n";
  else cout << "IMPOSSIBLE" << "\n";

  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        StringBuilder r = new StringBuilder();
        for(int i=0; i<s.length(); i++) {
            char c = s.charAt(i);
            int ci = (int)c;
            ci+=n;
            if(ci>0x5a) {
                ci = ci - 0x5a + 0x40;
            }
            c = (char)ci;
            r.append(c);
        }
        System.out.println(r.toString());
    }
}


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

int main(){
	int d;
	while(cin >> d){
		int s = 0;
		for(int i = 0; i < 600/d; i++){
			s += (d*i)*(d*i)*d;
		}
		cout << s << endl;;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vector<ll> dp(h + 1, inf);
    dp[0] = 0;
    rep(i, n) {
        rep(j, h) {
            if (dp[j] == inf) continue;
            ll v = min(h, j + a[i]);
            chmin(dp[v], dp[j] + b[i]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}


Measured memory_bytes: 3768
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)

cnt = 0
hash = {}
(0..n-1).to_a.combination(3).each do |aa|
	a = arr[aa[0]]; b = arr[aa[1]]; c = arr[aa[2]]
	next if [a, b, c].uniq.length < 3
	cnt += 1 if a + b > c && b + c > a && c + a > b 
end
puts cnt

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

typedef complex<double>Point;

struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Circle{
    Point p;
    double r;
    Circle(const Point &p=Point(),double r=0.0):p(p),r(r){}
};

typedef Point Vector;
typedef Segment Line;
typedef vector<Point>Polygon;

const double PI=acos(-1);
const double EPS=1e-8;
const double INF=1e16;
const int COUNTER_CLOCKWISE=1;
const int CLOCKWISE=-1;
const int ONLINE_BACK=2;
const int ONLINE_FRONT=-2;
const int ON_SEGMENT=0;

inline double square(double a){return a*a;}
inline double norm(const Point &a){return square(a.real())+square(a.imag());}
inline double dot(const Point &a,const Point &b){return (conj(a)*b).real();}
inline double cross(const Point &a,const Point &b){return (conj(a)*b).imag();}
inline double toDeg(double t){return t/PI*180.0;}
inline double toRad(double t){return t/180.0*t;}
#define equals(a,b) (fabs((a)-(b))<EPS)

void getPoint(Point &p){
    double x,y;
    scanf("%lf%lf",&x,&y);
    p=Point(x,y);
}

void getSegment(Segment &s){
    getPoint(s.p1);
    getPoint(s.p2);
}

bool orthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool orthogonal(Point a1,Point a2,Point b1,Point b2){
    return orthogonal(a1-a2,b1-b2);
}

bool orthogonal(Segment s1,Segment s2){
    return orthogonal(s1.p1-s1.p2,s2.p1-s2.p2);
}

bool parallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool parallel(Point a1,Point a2,Point b1,Point b2){
    return parallel(a1-a2,b1-b2);
}

bool parallel(Segment s1,Segment s2){
    return parallel(s1.p1-s1.p2,s2.p1-s2.p2);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}

Point reflection(Segment s,Point p){
    return p+(project(s,p)-p)*2.0;
}

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(cross(a,b)>EPS)return COUNTER_CLOCKWISE;
    if(cross(a,b)<-EPS)return CLOCKWISE;
    if(dot(a,b)<-EPS)return ONLINE_BACK;
    if(norm(a)<norm(b))return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
    return ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&
            ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0;
}

bool intersect(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

int main(){
    int q;
    scanf("%d",&q);
    while(q--){
        Segment s1,s2;
        getSegment(s1);
        getSegment(s2);
        if(intersect(s1,s2))puts("1");
        else puts("0");
    }

    return 0;
}

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


int main(void){
  int tax8, tax10;
  int flg;
  
  cin >> tax8 >> tax10;
  flg = 0;
  for (int i=0; i<1010; i++){
    int x,y;
    x = i*0.08;
    y = i*0.10;
    if (!flg && (flg|=(x==tax8&&y==tax10))) cout << i;
  }
  if (!flg) cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll N, A, B;
	cin>>N>>A>>B;
	ll cnt = (N/(A+B))*A;
	cnt = cnt+min(A,N%(A+B));
	cout<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 256
from math import ceil
N,K=map(int, input().split())

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

left=1
right=10**9+1
ans=float("INF")
while True:
    mid=(left+right)//2
    now=0
    for i in range(N):
        now+=ceil(A[i]/mid)-1

    if now>K:
        if left==mid:
            break
        left=mid
    else:
        ans=min(ans, mid)
        if right==mid:
            break
        right=mid

print(ans)

Measured memory_bytes: 104412
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <cstdio>
using namespace std;

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using vvvll = V<V<V<ll>>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vvpll = V<vpll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;
using vvch = V<vch>;
using dqll = deque<ll>;
using vdqll = V<dqll>;
using pqll = priority_queue<ll>;
using vpqll = V<pqll>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin() 
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define ba back()
#define fr front()
#define pob pop_back()
#define pof pop_front()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,n) substr(a,n)
#define cfs(a) cout<<fixed<<setprecision(a) //
/*vvll v(n,vll(m)) n行m列  continue
A.erase(A.begin()+i); 配列Aのi番目を消せる
std::binary_search(v.bgn,v.en,a); 二分探索
abs(a,b)   pow(a,n)  to_string  stoll
auto Iter=lower_bound(v.bgn,v.en,a); v[i]>=aとなる初のv[i]
v.insert(lower_bound(v.bgn,v.en,a),b); bを入れられる
lower upper  co(*Iter) co(Iter-v.bgn) v[i]>=aとなる初のi
vvll v(100001,vll(0)); v[a].pb(b); v[b].pb(a);
pqll pq; pq.push(ai); pq.top(); pq.pop();
priority_queue<ll,vll,greater<ll>> pqg; 昇順
vdqll dq(3);  dq[0].pb(1); dq[0].pb(2); dq[0].pf(0);
dq[0].fr→0 dq[0].ba→1 dq[0].pof; dq[0].fr→1
que.sz while(!que.empty())
ll a=1,b=2,c=4,xo; xo=a^b^c; if(a^b^c==0)co(xo)→7 if(xo==0)co(xo)→なし
a<<b→a*2^b a>>b→a/2^b
rep(i,1<<10)rep(j,10)if((i>>j)&1)→iの二進で1となる桁のjのみ 
*/

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll pow_mod(ll a,ll n,ll mod){
  ll res=1;        //n=k_2  pow(a,k_2)
  for(;n>0;n/=2){  //ex,pow(a,1011_2)=a^8*a^2*a^1
    if(n%2==1)res=(res*a)%mod;
    a=(a*a)%mod;
  }
  return res;
}
ll digit_sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0)break;
  }
  return m;
}
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}

int main(){
  ll n,a,ans=0;
  cin>>n;
  FOR(i,0,n){
    cin>>a;
    ans+=a-1;
  }
  co(ans);
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
 
const int mod=998244353;
const int maxn=4e5+7;
ll fac[maxn],inv[maxn];
 
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return ans;
}
 
void init(){
    fac[0]=1,fac[1]=1;
    for(int i=2;i<=maxn;i++) fac[i]=fac[i-1]*1ll*i%mod;
    inv[maxn]=power(fac[maxn],mod-2)*1ll;
    for(int i=maxn-1;i>=0;i--) inv[i]=inv[i+1]*1ll*(i+1)%mod;
}
 
ll c(ll n,ll m){
    if(m==0) return 1;
    if(n<m) return 0;
    if(n==m) return 1;
    return fac[n]*1ll*inv[m]*1ll%mod*inv[n-m]%mod;
}
 
 
int main (){
    init();
    int n,a,b;
    ll k,ans=0;
    scanf("%d %d %d %lld",&n,&a,&b,&k);
    if(k==0) { puts("1"); return 0;}
    for(int  x=1;x<=n;x++){
        if((k-a*x)%b) continue;
        ll y=(k-a*x)/b;
        ans=(ans+c(n,x)*1ll%mod*c(n,y)*1ll%mod)%mod;
    }
    printf("%I64d\n",ans);
    return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>

int main (){
    int a=0;
    int b=0;
    int k=0;
    int stop=0;

    scanf("%d %d",&a,&b);

    if(a<b){
        stop=b;
    }else{
        stop=a;
    }

   for(int i=0;i<stop;i++){

       if(abs(a-k)==abs(b-k)){
           k=i;
           break;
       }else{
           k++;
       }
   }
    if(k<stop){
        printf("%d",k);
    }else{
        printf("IMPOSSIBLE");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,s=0;
	cin>>m>>n;
	int a[m+1];
	for(int i=1;i<=m;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+m+1);
	for(int i=1;i<=m;i++)
	{
		if(n>=a[i])
		{
			s++;
			n=n-a[i];
		}
		else
		{
			break;
		}
	}
	if(s==m&&n!=0)
	{
		s--;
	}
	cout<<s;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int main() {
	char S[10010][20];
	long long int N, ans = 0, a = 0, b = 0, ba = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> S[i];
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < strlen(S[i]); j++)
		{
			if (j != (strlen(S[i]) - 1))
			{
				if (S[i][j] == 'A'&&S[i][j + 1] == 'B')ans++;
			}
		}
		if (S[i][0] == 'B'&&S[i][(strlen(S[i]) - 1)] == 'A')ba++;
		else if (S[i][0] == 'B')b++;
		else if (S[i][(strlen(S[i]) - 1)] == 'A')a++;
	}
	if (a == b&&ba > 0 && a + b < ba)
	{
		ba--;
	}
	ans += min(a + ba, b + ba);
	cout << ans;
	return 0;
}


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

int main(){
  	int n;cin>>n;
  	vector<int> p(n);
  	for(int i=0; i<n; i++){
    	cin >> p[i];
    }
  	int ans=0;
  	for(int i=1; i<n-1; i++){
    	if((p[i]<p[i+1]&&p[i]>p[i-1])||(p[i]>p[i+1]&&p[i]<p[i-1])){
        	ans++;
        }
    }
  
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dre_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dre_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int par[150010],r[150010];
void init(){ rep(i,150010){ par[i]=i; r[i]=0; } }
int find(int x){ if(x==par[x])return x; return par[x]=find(par[x]); }
bool same(int x,int y){ return find(x)==find(y); }
void unit(int x,int y){ if(same(x,y))return; x=find(x); y=find(y); if(r[x]<r[y])par[x]=y; else { par[y]=x; if(r[x]==r[y])r[x]++; } }

int main(){
	int n,m;
	int x[10010],y[10010];
	vector<P1> G;
	
	scanf("%d%d",&n,&m);
	rep1(i,n){
		scanf("%d%d",&x[i],&y[i]);
	}
	rep(i,m){
		int p,q;
		scanf("%d%d",&p,&q);
		G.pb(mp1((x[p]-x[q])*(x[p]-x[q])+(y[p]-y[q])*(y[p]-y[q]),p,q));
	}
	
	sor(G);
	rev(G);
	init();
	
	double ret=0.0;
	rep(i,m){
		P1 ed=G[i];
		if(!same(ed.sc.fr,ed.sc.sc)){
			unit(ed.sc.fr,ed.sc.sc);
		}
		else ret+=sqrt((double)ed.fr);
	}
	
	printf("%.3f\n",ret);
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int n;
  cin >> n;
  vi b(n - 1);
  rep (i, n - 1) cin >> b[i];

  vi a(n);
  a[n - 1] = b[n - 2];
  rrep (i, n - 1) {
    if (i == 0) {
      a[i] = b[i];
    }
    else {
      a[i] = min(b[i], b[i - 1]);
    }
  }

  DEBUG_VEC(a);
  int ans = 0;
  rep (i, n) ans += a[i];
  cout << ans << endl;
    
}


Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll N,A[200000];
    std::cin >> N;
    ll sum=0;
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
        A[i]-=i+1;
        sum+=A[i];
    }
    
    sort(A,A+N);
    ll b=A[0];
    ll res=0;
    
    res=sum-N*b;
    
    if(N==1){
        res=0;
    }else if(N==2){
        res=A[1]-A[0];
    }else if(N==3){
        res=A[2]-A[0];
    }else{
        for (int i = 1; i <= N/2; i++) {
            res-=(N-2*i)*(A[i]-A[i-1]);
        }
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ff first
#define se second
#define pb push_back
#define nn 200100
#define mt make_tuple
#define mp make_pair
#define ll long long int
#define db double
#define ldb long double
#define inf 1000000000000000000ll
#define logn 20
#define mod 1000000007ll
#define mod1 mod
#define mod2 100000009ll
#define sqr(a) a*1ll*a
#define nullp mp(-1,-1)
#define set0(a) memset(a,0,sizeof a)
#define init(a) memset(a,-1,sizeof a)
#define cmp 1e-16
 
using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef pair<long double,long double> pdd;
template<class T>
using max_pq = priority_queue<T>;
template<class T>
using min_pq = priority_queue<T,vector<T>,greater<T>>;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> OST;

template<class T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
ll pow(ll a,ll p,ll m=mod)
{ll res=1;while(p>0){if(p&1)res=(res*a)%m;a=(a*a)%m;p>>=1;}
return res;}

const ldb pi=3.141592653589793238462643383;

ll a[nn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll ans=inf,sum=0;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	sum+=a[i];
    }
    ll t=0;
    for(int i=0;i<n-1;i++)
    {
    	t+=a[i];
    	ll tmp = sum - 2*t;
    	if(tmp<0)
    		tmp*=-1;
    	ans = min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n,m,x;
    cin>>n>>m;
    if (n<m){
        int c;
        c=m;
        m=n;
        n=c;
    }
    while(n%m != 0){
        x = n%m;
        n = m;
        m = x;
    }
    cout << m << endl;
}

Measured memory_bytes: 3124
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        boolean honest = false;
        if(a.equals("H")){
            if(b.equals("H")){
                honest = true;
            }
            if(b.equals("D")){
                honest = false;
            }
        }
        if(a.equals("D")){
            if(b.equals("H")){
                honest = false;
            }
            if(b.equals("D")){
                honest = true;
            }
        }
        if(honest){
            System.out.println("H");
            return;
        }
            System.out.println("D");
    }
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[105], ans;

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++){
    cin >> A[i];
    if (i % 2 != 0 && A[i] % 2 != 0) ans++;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3580
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main() {
    val s = readLine()!!
    val t = readLine()!!
    val x = (0 until s.length).count { s[it] != t[it] }
    println(x)
}


Measured memory_bytes: 41172
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
if N > M: N, M = M, N
if N == 1 and (M == 1): print(1)
elif N == 2: print(0)
elif N == 1 and (M == 2): print(0)
elif N == 1: print(max(0, M - 2))
else: print(max(0, (N - 2) * (M - 2)))

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

int main() {
	string s;
	cin >> s;
	string k = "keyence";
	int len = s.size();
	int c[110][110];
	if (s == k) {
		cout << "YES" << endl;
		return 0;
	}
	for (int i = 0; i < len; i++) {
		for (int j = 1; j < len; j++) {
			string ss = "";
			for (int kk = 0; kk < len; kk++) {
				if (i <= kk && kk <= j) continue;
				else ss.push_back(s[kk]);
			}
			if (ss == k) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
def m():
    N = int(input())
    A, B = map(int, input().split())
    P = list(map(int, input().split()))
    tmp = [0] * 3
    for i in P:
        if i <= A:
            tmp[0] += 1
        elif i > A and i <= B:
            tmp[1] += 1
        elif i > B:
            tmp[2] += 1
    return min(tmp)

print(m())

Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
import fractions

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

def yaku(num):
    temp=[]
    for i in range(2,-int(-num**0.5//1)+1):
        if num%i==0:
            temp.append(i)
            temp.append(num//i)
    temp=list(set(temp))
    if num!=2:
        temp.append(num)
    temp.sort()
    return temp

koyaku=fractions.gcd(A,B)

cand=yaku(min(A,B))
#print(cand)

if cand[0]==1:
    print(1)
    exit()

count=0

for i in cand:
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)


Measured memory_bytes: 5984
S['= r'],m[4]['= r'],z,d[4]={0,-2},k,i;f(i){m[k][i]=S[i]+47?0:m[k][i]?:1+f(d[k]-~i);}main(t){for(scanf("%*d%d ",d),d[2]=-*d-2;S[++i-~*d]=~getchar(););for(;--i;z=fmax(z,1-t))for(t=k=4;k--;)t-=f(i-~*d);printf("%d",z);}

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

int main(){

    ll n;
    string s[3];
    cin>>n;
    for(ll i = 0; i < 3; i++){
        cin>>s[i];
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(s[0][i] != s[1][i]){
            ans++;
        }
        if(s[2][i] != s[0][i] && s[2][i] != s[1][i]){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}




//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);


Measured memory_bytes: 256
def test():
    n = int(input())
    h = list(map(int,input().split()))
    ans = h[0]
    for i in range(n-1):
        if h[i] < h[i+1]:
            ans += h[i+1] - h[i]
    print(ans)


if __name__ == "__main__":
    test()


Measured memory_bytes: 38460
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << n/3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
int a[3005][3005];
long long dp[3005][3005][4];
//解説写し
int main() {
	int R,C,K;
	cin>>R>>C>>K;
	rep(i,K){
		int r,c,v;
		cin>>r>>c>>v;
		a[r-1][c-1]=v;
	}
	rep(i,R)rep(j,C){
		for(int k=2;k>=0;k--){
			chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
		}
		rep(k,4){
			chmax(dp[i+1][j][0],dp[i][j][k]);//次の行に行ったら、リセットしてk=0とする
			chmax(dp[i][j+1][k],dp[i][j][k]);
		}
	}
	ll ans=0;
	rep(k,4)chmax(ans,dp[R-1][C-1][k]);
	cout<<ans<<endl;
}
	

Measured memory_bytes: 320472
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int c = 0, n = scn.nextInt();
        for(int i = 0; i < n; i++) {
            c += primeCheck(scn.nextInt());
        }
        System.out.println(c);
    }
    
    private static int primeCheck(int x) {
        int rslt = 1;
        if(x < 2 || x > 3 && x % 2 == 0) {
            rslt = 0;
        }
        for(int i = 3; i <= x / i; i += 2) {
            if(x % i == 0) {
                rslt = 0;
                break;
            }
        }
        return rslt;
    }
}

Measured memory_bytes: 41552
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int x, y, z; cin >> x >> y >> z;

    swap(x,y);
    swap(x,z);

    cout << x << " " << y << " "<< z << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;


const int MAXN = 15;
const int MAXW = 110000;

int dp[MAXN][MAXW];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int W;
    cin >> W;

    vector<int> weight;
    for (int i = 1; i <= W; i *= 6) weight.push_back(i);
    for (int i = 9; i <= W; i *= 9) weight.push_back(i);
    int n = (int)weight.size();

    for (int i = 0; i < MAXN; ++i) for (int w = 0; w < MAXW; ++w) dp[i][w] = INF;
    for (int i = 0; i <= n; ++i) dp[i][0] = 0;

    for (int i = 0; i <n; ++i) {
        for (int w = 0; w <= W; ++w) {
            dp[i + 1][w] = min(dp[i + 1][w], dp[i][w]);
            if (w >= weight[i]) dp[i + 1][w] = min(dp[i + 1][w], dp[i + 1][w - weight[i]] + 1);
        }
    }

    cout << dp[n][W] << endl;

    return 0;
}

Measured memory_bytes: 6656
#include<iostream> 
using namespace std;
int itung=0; 

// A function to check if n is palindrome 
long long isPalindrome(long long n) 
{ 
	// Find reverse of n 
	long long rev = 0; 
	for (long long i = n; i > 0; i /= 10) 
		rev = rev*10 + i%10; 

	// If n and rev are same, then n is palindrome 
	return (n==rev); 
} 

// prints palindrome between min and max 
void countPal(long long min, long long max) 
{ 
	for (long long i = min; i <= max; i++) 
		if (isPalindrome(i))
		itung++;
} 

// Driver program to test above function 
int main() 
{ 
	long long n,m;
	cin >> n >> m;
	countPal(n, m); 
	
	cout << itung << endl;
	return 0; 
} 



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')w=0,ch=getchar();
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
#define ll long long
const int N=2e5+5;
int n;ll a[N],x[N],y[N],L[N],R[N];
int main(){
	n=gi();
	for(int i=1;i<=n;++i){
		a[i]=gi(),x[i]=~a[i]&1,y[i]=a[i]?a[i]&1:2;
		a[i]+=a[i-1],x[i]+=x[i-1],y[i]+=y[i-1];
	}
	ll mn=0;
	for(int i=1;i<=n;++i)mn=min(mn,a[i]-y[i]),L[i]=mn+y[i];
	mn=y[n];
	for(int i=n-1;~i;--i)mn=min(mn,a[n]-a[i]+y[i]),R[i]=mn-y[i];
	ll ans=1ll<<60;mn=1ll<<60;
	for(int i=0;i<=n;++i)mn=min(mn,L[i]-x[i]),ans=min(ans,mn+R[i]+x[i]);
	printf("%lld\n",ans);return 0;
}


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

using namespace std;

int main() {
	// input

	int num; cin >> num;
	vector<int> Height(num);
	for (int i = 0; i < num; ++i)
	{
		cin >> Height[i];
	}


	//compute
	int ans = 0;
	for (int i = 0; i < num; ++i)
	{
		bool is_candidate = true;

		for (int j = 0; j < i; ++j)
		{
			
			if (Height[j] > Height[i])
			{
				is_candidate = false;
				break;
			}

		}


		if (is_candidate)
		{
			++ans;/* code */
		}


	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    vector<string> s(3);
    for (int i = 0; i < 3; i++) cin >> s[i];

    for (int i = 0; i < 3; i++) cout << s[i][i];
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N;
    cin >> N;
    vector<bitset<20>> As(N);
    for (auto &&i: irange(0LL, N)){
        int A;
        cin >> A;
        As.at(i) = bitset<20>(A);
    }
    ll l{0};
    ll r{0};
    bitset<20> state = As.at(0);
    ll count{1};
    while(l < N){
        if ((r+1) < N && !(state & As.at(r+1)).any()){
            state |= As.at(r+1);
            r++;
            count++;
        } else if (l < r){
            state ^= As.at(l);
            count += r-l;
            l++;
        } else if (l == N-1) {
            break;
        } else {
            r++;
            l++;
            state = As.at(l);
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
ll sq(ll x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    ll a;
    cin>>a;
    ll ans=a+(ll)sq(a)+(ll)(sq(a)*a);
    cout<<ans<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3600