akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
	int s,h,n,i,a[5000];
	while(true) {
		cin >> n;
		if (n==0) break;
		for (i=0;i<n;i++) cin >> a[i];
		s=0; h=-100000;
		for (i=0;i<n;i++) {
			s=(s+a[i]>=a[i]) ? s+a[i] : a[i];
			h=(s > h)  ? s : h;
		}
        cout << h << endl;
	}
	return 0;
	}

Measured memory_bytes: 1176
#include<stdio.h>

static const int N = 1000;

void trac(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int k, i, j,key;
  int A[N+1];
  scanf("%d", &k);

  for ( i = 1; i <=k; i++ ) scanf("%d", &A[i]);
  
  trac(A, k);
  /*

    your code

   */
  for(j=2;j<=k;j++){
    key=A[j];
    i=j-1;
    while(i>=0 && A[i]>key){
      A[i+1]=A[i];
      i=i-1;
    }
    A[i+1]=key;
    trac(A,k);
  }
  return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

class UnionFind {
public:
    vector<int> parent;
    vector<LL> dis;

    UnionFind(int N) {
        parent.resize(N);
        REP(i, N) {
            parent[i] = i;
        }
        dis.resize(N);
        fill(ALL(dis), 0);
    }

    pair<int, LL> root(int x) {
        if(x == parent[x]) {
            return make_pair(x, dis[x]);
        }
        auto p = root(parent[x]);
        parent[x] = p.first;
        dis[x] += p.second;
        auto r = make_pair(parent[x], dis[x]);
        return r;
    }

    bool same(int x, int y) {
        return root(x).first == root(y).first;
    }

    bool unite(int l, int r, LL d) {
        if(same(l, r)) {
            LL dl = root(l).second;
            LL dr = root(r).second;
            return dr - dl == d;
        }
        int R = root(r).first;
        parent[R] = l;
        LL x = d - dis[r];
        dis[R] = d - dis[r];
        return true;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N + 1);
    bool p = true;
    REP(i, M) {
        LL l, r, d;
        cin >> l >> r >> d;
        p = p && uf.unite(l, r, d);
    }

    if(p) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

void funcA() {
  int x;
  for (int i = 0; i < 5; i++) {
    std::cin >> x;
    if (x == 0) {
      std::cout << (i + 1);
      return;
    }
  }
}

int main(void) {
  funcA();
  return 0;
}

Measured memory_bytes: 3140
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

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

	vector <int> A(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
	}

	//前計算
	vector <int> L(N, 0);
	L[1] = A[0];
	for (int ii = 2; ii < N; ++ii){
		L[ii] = gcd(L[ii-1], A[ii-1]);
	}

	vector <int> R(N, 0);
	R[N-2] = A[N-1];
	for (int ii = N-2; ii >= 0; --ii){
		R[ii] = gcd(R[ii+1], A[ii+1]);
	}

	int ans = 1;
	for (int ii = 0; ii < N; ++ii){
		int tmp;
		if (L[ii] == 0){
			tmp = R[ii];
		} else if (R[ii] == 0) {
			tmp = L[ii];
		} else {
			tmp = gcd(L[ii], R[ii]);
		}
		ans = max(ans, tmp);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4504
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    string s;
    int n,ans=0,sz;
    cin >> sz >> s;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='I')n++;
        if(s[i]=='D')n--;
        ans=max(ans,n);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll ans;
ll n, m, c;
ll l[100005];
pll ball[100005];

int main()
{
    cin >> n >> m >> c;
    for (int i = 1; i <= c; i++) {
        cin >> l[i];
    }

    for (int i = 0; i < n; i++) {
        cin >> ball[i].second >> ball[i].first;
    }

    sort(ball, ball + n, greater<pll>());

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (cnt >= m) break;
        
        if (l[ball[i].second] > 0 &&
            ans + ball[i].first > ans) {
            l[ball[i].second]--;
            cnt++;
            ans += ball[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5224
#include <iostream>
#include <math.h>
#include <set>
#include<vector>
#include<string>
#include <algorithm>
#include<queue>
#include<map>
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define per(i,j,k) for(int i = (int)j;i >= (int)k;i --)
#define F(i,k) for(int i=(int)0;i<(int)k;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
const int maxn = 5e3 + 5;
using namespace std;
ll m,n,k;
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int a; string s;
	cin >> a >> s;
	if (a >= 3200)cout << s;
	else cout << "red";
}

/*

*/

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

constexpr double EPS = 1e-10;
bool equals(double a, double b) { return (abs(a - b) < EPS); }

struct V2 {
	double x, y;
	V2(double x = 0, double y = 0) : x(x), y(y) {}
	
	V2 operator + (V2 p) const { return (V2(x + p.x, y + p.y)); }
	V2 operator - (V2 p) const { return (V2(x - p.x, y - p.y)); }
	V2 operator * (double r) const { return (V2(x * r, y * r)); }
	V2 operator / (double r) const { return (V2(x / r, y / r)); }
	
	double norm() const { return (sqrt(sqrNorm())); }
	double sqrNorm() const { return (x*x + y*y); }
	
	bool operator < (const V2 &p) const { 
		return (x != p.x ? x < p.x : y < p.y); 
	}
	bool operator == (const V2 &p) const {
		return (equals(x, p.x) && equals(y, p.y));
	}

	V2 rotate90() const { return (V2(y, -x)); }
	V2 normalized() const { return (*this / norm()); }

	double dot(const V2 &p) const { return (x*p.x + y*p.y); }
	double cross(const V2 &p) const { return (x*p.y - y*p.x); }
	double arg() const { return (atan2(y, x)); }
};
V2 polar(double r, double a) { return (V2(cos(a) * r, sin(a) * r)); }

using Polygon = vector<V2>;
struct Segment {
	V2 p1, p2;
	Segment() {}
	Segment(V2 p1, V2 p2) : p1(p1), p2(p2) {}
};

using Line = Segment;

struct Circle {
	V2 o;
	double r;
	Circle() {}
	Circle(V2 o, double r) : o(o), r(r) {}

	int intersects(const Circle &c) {
		double d = (o-c.o).norm();
		if (d + c.r < r) return (3); //contain on A
		if (d + r < c.r) return (-3); //contain on B
		if (equals(d + c.r, r)) return (1); 
		if (equals(d + r, c.r)) return (-1);
		if (r + c.r < d) return (0);
		if (equals(r + c.r, d)) return (4); 
		return (2);
	}

	vector<V2> crossPoints(const Circle &c) {
		int inter = intersects(c);
		if (abs(inter) == 3 || inter == 0) return (vector<V2>());
		double d = (c.o-o).norm();
		double t = (c.o-o).arg();
		if (abs(inter) == 1 || inter == 4) return ((vector<V2>){o + (c.o-o).normalized() * r});
		double a = acos((r*r + d*d - c.r*c.r) / (2*r*d));
		return ((vector<V2>){o + polar(r, t+a), o + polar(r, t-a)});
	}
};

int main() {
	Circle a, b;
	cin >> a.o.x >> a.o.y >> a.r;
	cin >> b.o.x >> b.o.y >> b.r;
	vector<V2> v = a.crossPoints(b);

	cout << fixed << setprecision(8);
	sort(begin(v), end(v));
	cout << v[0].x << " " << v[0].y << " ";
	if (v.size() == 2) cout << v[1].x << " " << v[1].y << endl;
	else cout << v[0].x << " " << v[0].y << endl;
}



Measured memory_bytes: 3660
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  std::swap(a, b);
  std::swap(a, c);
  printf("%d %d %d\n", a, b, c);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
int32_t main() {
	int a,b;
	cin>>a>>b;
	if(a>0)
	{
		cout<<"Positive\n";
	}
	else if(b<0)
	{
		if((b-a)%2==0)
			cout<<"Negative\n";
		else cout<<"Positive\n";
	}
	else cout<<"Zero\n";
}
						

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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

int main(){
	int a, b, c, K;
	scanf("%d%d%d%d", &a, &b, &c, &K);
	a -= b;
	if (K & 1)
		a = -a;
	printf("%d\n", a);
	return 0;
}


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

int main(){
	int n;
	int a[1000];

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

	sort(a,a+n);
	int sum=a[n-1]-a[0];
	
	cout<<sum<<endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  int n;
  while (cin >> n) {
    string s;
    for (int i = 0; i < n; ++i) {
      char c;
      cin >> c;
      s += c;
    }
    int m = 0;
    char buff[10000];
    while (true) {
      sprintf(buff, "%d", m);
      string t(buff);
      if (s.find(t) == string::npos) {
        cout << t << endl;
        break;
      }
      ++m;
    }
  }
  return 0;
}

Measured memory_bytes: 1252
S = input()
a = int(S[0:2])
b = int(S[2:4])

hoge = (1 <= a <= 12)
fuga = (1 <= b <= 12)
if hoge and fuga:
    print("AMBIGUOUS")
elif not hoge and not fuga:
    print("NA")
elif fuga:
    print("YYMM")
else:
    print("MMYY")

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<queue>
const int INF = 100000000;
using namespace std;
typedef pair<int, int> P;
char a[1005][1005];
int N, M;
int sx, sy;
int gx, gy;
int d[1005][1005];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int bfs()
{
	queue<P> que;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			d[i][j] = INF;
	que.push(P(sx, sy));
	d[sx][sy] = 0;
	while (que.size())
	{
		P p = que.front();
		que.pop();
		if (p.first == gx&&p.second == gy)
			break;
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if (nx >= 0 && nx < N&&ny >= 0 && ny < M&&a[nx][ny] != 'X'&&d[nx][ny] == INF)
			{
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}

	}
	return d[gx][gy];
}
int main(void)
{
	while (cin >> N >> M)
	{
		int n, sum = 0;
		cin >> n;
		for (int i = 0; i < N; i++)
			for (int j = 0; j < M; j++)
				cin >> a[i][j];
		for (int j = 0; j < N; j++)
			for (int k = 0; k < M; k++)
				if (a[j][k] == 'S')
				{
					sx = j;
					sy = k;
				}
		for (int j = 0; j < N; j++)
			for (int k = 0; k < M; k++)
				if (a[j][k] == '1')
				{
					gx = j;
					gy = k;
				}
		sum += bfs();
		for (int i = 0; i < n - 1; i++)
		{
			for (int j = 0; j < N; j++)
				for (int k = 0; k < M; k++)
				{
					if (a[j][k] == (char)(i+49))
					{
						sx = j;
						sy = k;
					}
					if (a[j][k] == (char)(i+50))
					{
						gx = j;
						gy = k;
					}
				}
			sum += bfs();

		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 8032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] array = new long[n];
		int count=0;

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

		for(long buff:array) {
			if(judge(buff)) count++;
		}
		System.out.println(count);

	}

	public static boolean judge(long input) {
		if(input == 2) {
			return true;
		}
		if(input <= 1 || input%2 ==0) {
			return false;
		}

		for(int i=3;i<=Math.sqrt(input);i+=2) {
			if(input % i == 0) return false;
		}
		return true;
	}
}



Measured memory_bytes: 41728
s = input()

targets = []
if len(s) % 2 == 0:
    tmp_1 = ''
    tmp_2 = ''
    for i in range(len(s)//2):
        tmp_1 += '10'
        tmp_2 += '01'
    targets.append(tmp_1)
    targets.append(tmp_2)
else:
    tmp_1 = ''
    tmp_2 = ''
    for i in range(len(s)//2):
        tmp_1 += '10'
        tmp_2 += '01'
    tmp_1 += '1'
    tmp_2 += '0'
    targets.append(tmp_1)
    targets.append(tmp_2)

res = len(s)
for target in targets:
    count = 0
    for i in range(len(target)):
        if target[i] != s[i]:
            count += 1
    res = min(res, count)

print(res)

Measured memory_bytes: 3444
fun main(array: Array<String>) {
    val n = readLine()!!.toInt()
    val t = readLine()!!.split(" ").map { it.toInt() }
    val m = readLine()!!.toInt()
    repeat(m) {
        val list = t.toList().toMutableList()
        val (idx, time) = readLine()!!.split(" ").map { it.toInt() }
        list[idx-1] = time
        println(list.sum())
    }
}

Measured memory_bytes: 38060
abc = list(map(int, input().split()))
abc.sort()
max_n = abc[2]
mid_n = abc[1]
min_n = abc[0]

cnt = max_n - mid_n
if (max_n - min_n - cnt)%2 == 1:
    cnt += (max_n - min_n - cnt)//2 + 2
else:
    cnt += (max_n - min_n - cnt)//2
print(cnt)

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

int main() {
  string str;
  cin >> str;

  int zen = stoi(str.substr(0, 2));
  int kou = stoi(str.substr(2, 2));

  // 00→YY確定

  if (zen > 12 && kou == 0 || zen == 0 && kou > 12 || zen > 12 && kou > 12) {
    cout << "NA" << endl;
  } else if (zen > 0 && kou > 0 && zen <= 12 && kou <= 12) {
    cout << "AMBIGUOUS" << endl;
  } else if (zen <= 12 && zen > 0) {
    cout << "MMYY" << endl;
  } else if (kou > 0 && kou <= 12) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        mut s:chars,
        t:chars,
    }
    let mut index = None;
    for j in 0..s.len()-t.len()+1 {
        if (0..t.len()).all(|k| s[j+k] == t[k] || s[j+k] == '?') {
            index = Some(j);
        }
    }
    let ans = match index {
        Some(index) => {
            for j in 0..t.len() {
                s[index+j] = t[j];
            }
            s.into_iter().map(|c| if c == '?' {'a'} else {c})
            .collect::<String>()
        }
        None => "UNRESTORABLE".to_string(),
    };
    println!("{}",ans);
}


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

using ld = long double ;
int n, m;
vector<int> a[605];
ld dp[605];

ld calc (int x) {
    dp[n] = 0 ;
    for (int cur = n - 1 ; cur >= 1; -- cur) {
        ld sum = 0.0;
        ld ma = numeric_limits<ld>::min();
        for (int j : a[cur]) {
            sum += dp[j];
            ma = max(ma, dp[j]);
        }
        if (cur == x && (int)a[cur].size() >= 2) {
            sum -= ma;
            sum /= (ld) (a[cur].size() - 1);
        }
        else sum /= (ld) (a[cur].size());
        dp[cur] = sum + 1;
    }
    return dp[1];

}

int main () {
    scanf("%d %d", &n, &m);
    for (int i = 1 ; i <= m ; ++ i) {
        int from , to ;
        scanf("%d %d", &from, &to);
        a[from].emplace_back(to);
    }
    ld ans = numeric_limits<ld>::max();
    for (int i = 0 ; i < n ; ++ i) {
        ans = min(ans, calc(i));
    }
    cout << fixed << setprecision(10) << ans << '\n';
}


Measured memory_bytes: 1408
#include<stdio.h>

#define N 100

int main(){

  int n, p[N + 1], m[N + 1][N + 1];
  int i, j, k, l;
  
  scanf("%d", &n);
  
  for(i = 1; i <= n; i++){
    scanf("%d", &p[i - 1]);
    scanf("%d", &p[i]);
  }
  
  for(i = 0; i <= n; i++){
    m[i][i] = 0;
  }
  
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      int j = i + l - 1;
      m[i][j] = 1410065408;
      
      for(k = i; k <= j - 1; k++){
        if( m[i][j] < m[i][k] + m[k + 1][j] + p[i - 1]*p[k]*p[j]){
          m[i][j] = m[i][j] ;
        } else {
          m[i][j] = m[i][k] + m[k + 1][j] + p[i - 1]*p[k]*p[j];
        }
      }
    }
  }
  
  printf("%d\n", m[1][n]);
  
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
 
using namespace std;
 
int main() {
	int n;
	cin >> n;
    long long sum =0;
    int maxsofar = 0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(a > maxsofar){
            maxsofar = a;
        }else if(a < maxsofar){
            sum += maxsofar -a;
        }
    }
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3604
//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5;
int n,a[maxn],xr[maxn],dp[(1<<16)],cal[maxn],re;
bool ok[16];
vector<int> v;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    rep(i,1,n)
    {
        int x,y,w;
        cin>>x>>y>>w;
        xr[x]^=w;
        xr[y]^=w;
    }
    rep(i,0,n)
    {
        if(xr[i]==0)
        {
            re++;
        }
        else if(ok[xr[i]])
        {
            ok[xr[i]]=0;
            re++;
        }
        else
        {
            ok[xr[i]]=1;
        }
    }
    rep(i,1,16)if(ok[i])
    {
        v.pb(i);
        //cout<<v.back()<<' ';
    }
    //cout<<endl;
    int l=v.size();
    rep(i,1,(1<<l))
    {
        int j=0;
        while(!(i&(1<<j)))j++;
        cal[i]=cal[i^(1<<j)]^v[j];
    }
    rep(i,1,(1<<l))if(cal[i]==0)
    {
        dp[i]=1;
        for(int sub=i;sub>0;sub=(sub-1)&i)if(cal[sub]==0)
        {
            dp[i]=max(dp[i],dp[i^sub]+1);
        }
    }
    re+=dp[(1<<l)-1];
    cout<<n-re;
    return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int N;
vector<string> S;
vector<int> homon;
bool isOK = true;
void dfs(int v){
  REP(i, N){
    if(S[v][i] == '0') continue;
    if(homon[v] == homon[i]){
      isOK = false;
      return;
    }
    if(homon[i] != -1) continue;
    homon[i] = (homon[v]+1) % 2;
    dfs(i);
  }
}
int main(){
  cin >> N;
  S.resize(N);
  REP(i, N){
    cin >> S[i];
  }
  homon.resize(N, -1);
  homon[0] = 0;
  dfs(0);
  if(!isOK){
    cout << -1 << endl;
    return 0;
  }
  vector<vector<int>> dist(N, vector<int>(N, INF));
  REP(i, N){
    REP(j, N){
      if(i==j){
        dist[i][j] = 0;
      }
      if(S[i][j] == '1'){
        dist[i][j] = 1;
      }
    }
  }
  REP(k, N){
    REP(i, N){
      REP(j, N){
        if(dist[i][j] > dist[i][k] + dist[k][j]){
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }
  int ans = 0;
  REP(i, N){
    REP(j, N){
      if(dist[i][j] == INF) continue;
      ans =max(ans, dist[i][j]);
    }
  }
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 3856
#include<cstdio>
#include <algorithm>
using namespace std;
const int MAXN=201000;
int n,k;
int a[MAXN];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int tmp;
		scanf("%d",&tmp);
		a[tmp]++;
	}
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=n;i>=max(n-k+1,1);i--)
		ans+=a[i];
	printf("%d",n-ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//constexpr ll MOD = 1e9 + 7;
constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  priority_queue<ll> P, Q, R;
  for (ll i = 0; i < A; i++)
  {
    ll p;
    cin >> p;
    P.push(p);
  }
  for (ll i = 0; i < B; i++)
  {
    ll p;
    cin >> p;
    Q.push(p);
  }
  for (ll i = 0; i < C; i++)
  {
    ll p;
    cin >> p;
    R.push(p);
  }

  ll ans = 0;
  ll cnt = X + Y;
  while (cnt > 0)
  {
    ll p = -1, q = -1, r = -1;
    if (X > 0 && !P.empty())
      p = P.top();
    if (Y > 0 && !Q.empty())
      q = Q.top();
    if (!R.empty())
      r = R.top();

    ll m = max({p, q, r});

    if (m == r)
    {
      R.pop();
      cnt--, ans += r;
    }
    else if (m == p)
    {
      P.pop();
      X--, cnt--, ans += p;
    }
    else if (m == q)
    {
      Q.pop();
      Y--, cnt--, ans += q;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main() 
{
    int x,y;
    cin>>x>>y;
    bool ispossible=false;
    int least=x*2;
    for(int i=0;i<=x;i++)
    {
        if(least==y)
        {
            ispossible=true;
            break;
        }
        least+=2;
    }
    if(ispossible)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3576
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define MAX(a,b) (a>b?a:b)
using namespace std;

int main(){
  int N ,K;
  cin >> N >> K;
  int ans = 1;
  rep(i,N){
    if(2*ans<ans+K)
      ans *= 2;
    else
      ans += K;
  }
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979
#define NIL -1
#define MAX 50

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

int main(void) {
	string s;
	int p, q;
	int count = 0;

	cin >> s;
	p = 0;
	q = s.size() - 1;

	while (1) {
		if (s[p] == s[q]) {
			p++;
			q--;
		}
		else if (s[p] == 'x') {
			p++;
			count++;
		}
		else if (s[q] == 'x') {
			q--;
			count++;
		}
		else {
			count = -1;
			break;
		}
		if(p>q){
			break;
		}
	}

	cout << count << endl;


	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,m,i,p,wa[100005]={},acn=0,pen=0;
  bool ac[100005]={false};
  string s;
  
  cin >> n >> m;
  for (i=0;i<m;i++){
    cin >> p >> s;
    if (s=="AC" && !ac[p]){
      acn++;
      pen+=wa[p];
      ac[p]=true;
    }else{
      wa[p]++;
    }
  }
  
  cout << acn << ' ' << pen << endl;
  
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
using pii = pair<int, int>;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<int> a(N);
  int nim = 0;
  int ans = 0;
  map<int, int> mp;
  rep(i, 0, N) {
    cin >> a[i];
    nim ^= a[i];
    mp[log2(a[i]&(-a[i]))]++;
    dump(nim);
  }
  dump(mp);
  rrep(j, 0, 31) {
    dump(nim);
    if (nim >> j & 1) {
      if (mp[j]) {
        mp[j]--;
        nim ^= (1 << (j + 1)) - 1;
        ans++;
      }
    }
  }

  if (nim == 0) {
    cout << ans << endl;

  } else
    cout << -1 << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

int a[200050],b[200050];
int main()
{
   // ios::sync_with_stdio(false);
   // cin.tie(0);
   // cout.tie(0);
    int n;
    cin >> n;
    int x;
    int state=1;
    for(int i=0;i<n;i++)
    {
        cin >> x;
        if(x%2==0){
            if(x%3!=0&&x%5!=0)
                state=0;
        }
    }
    if(state)
        cout << "APPROVED";
    else
        cout << "DENIED";
    return 0;
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::string S;
  std::cin >> N >> S;

  std::map<char, std::vector<int>> cnt;
  cnt['R'] = std::vector<int>(N + 1, 0);
  cnt['G'] = std::vector<int>(N + 1, 0);
  cnt['B'] = std::vector<int>(N + 1, 0);
  for(int i = 1; i <= N; ++i) {
    for(char c : "RGB.") {
      if(c == '.') break;
      cnt[c][i] = cnt[c][i - 1];
    }
    ++cnt[S[i - 1]][i];
  }

  ll ans = 0;
  for(int i = 0; i < N; ++i) {
    for(int j = i + 1; j < N; ++j) {
      if(S[i] == S[j]) continue;
      for(char c : "RGB.") {
        if(c == '.') break;
        if(S[i] == c || S[j] == c) continue;
        int x = j + j - i;
        if(x < N) {
          ans += cnt[c][x] - cnt[c][j + 1];
          ans += cnt[c][N] - cnt[c][x + 1];
        } else {
          ans += cnt[c][N] - cnt[c][j + 1];
        }
      }
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 3692
<?php
 
$input = trim(fgets(STDIN));

$inputs = explode(' ',trim(fgets(STDIN)));
rsort($inputs);
$half = $input / 2;

if($inputs[$half] === $inputs[$half - 1]){
  print 0;
}else{
  print $inputs[$half - 1] - $inputs[$half];
}

Measured memory_bytes: 12792
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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 MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi H(n);
  VIN(H)
  bool flg = false;
  bool all0 = false;
  while(true){
    all0 = true;
    flg = false;
    REP(i,n){
      if(H[i]==0 && flg){
        x++;
        flg = false;
      } else if(H[i] != 0){
        flg = true;
        all0 = false;
        H[i]--;
      }
    }
    if(flg){
      x++;
    }
    if(all0) break;
  }
  OUT(x);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define G 1000000007
long long check(long long N)
{
    long long R=1;
    for(long i=2;i<=N;i++)
    {
        R*=i;
        R%=G;
    }
    return R;
}
int main()
{
    //ifstream cin("input.in");
   // ofstream cout("output2.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long long N,M;
    cin>>N>>M;
    if(abs(N-M)>1)
        cout<<0;
    else
    {
        if(N<M)
        {
            long temp=N;
            N=M;
            M=temp;
        }
        if(N==M+1)
            cout<<(check(N)*check(M))%G;
        else
            cout<<(check(N)*check(M)*2)%G;
    }
}

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

int main(){
  ll N,K,Q;
  cin >>N>>K>>Q;
  
  vector<ll> sum(N,K);
  vector<ll> A(Q);
  rep(i,0,Q){
    cin >>A[i];
    sum[A[i]-1]++;
  }
  
  string ans;
  rep(i,0,N){
    (sum[i]-Q)>0 ? ans = "Yes" : ans = "No"; 
    cout <<ans<< endl;
  }
}

Measured memory_bytes: 2176
N = int(input())
A = [int(j) for j in input().split()]
from collections import Counter

A_C =Counter(A)
A_C = sorted(A_C.items(),key=lambda x:-x[0])

if 0 == A_C[-1][0]:
    print(0)
    exit()
    
result = 1
for a in A_C:
    result*=(a[0]**a[1])

    if result >10**18:
        print(-1)
        exit()

print(result)

Measured memory_bytes: 30564
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
# define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int k;
    cin >> k;
    if (k % 2 == 0)cout << k * k / 4 << endl;
    else cout << (k / 2)*(k / 2 + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
        System.out.println(Math.min(a, b) + Math.min(c, d));
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(1);
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  //for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 2000005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;


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

  vector<int> v;
  rep(i,N){
    int c;
    cin >> c;
    v.push_back(c);
  }
  sort(ALLOF(v));

  mint ret(0);
  rep(i,N){
    int a = i;
    int b = N-i-1;
    if(b>0){
      ret += mutil.pow(2,a) * mint(v[i]) * (mutil.pow(2,b) + mutil.pow(2,b-1) * mint(b));
    }else{
      ret += mutil.pow(2,a) * mint(v[i]) * mutil.pow(2,b);
    }
  }
  
  ret *= mutil.pow(2, N);

  cout << ret << endl;
  
  return 0;
}



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

using p = pair<long long, long long>;
long long n, m;
vector<p> memo[2];

int main() {
  while(1) {
    cin >> n >> m;
    if(n + m == 0) break;
    memo[0].assign(n, {0, 0});
    memo[1].assign(n, {0, 0});
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < 2; ++j) memo[j][i].second = i;
    for(int i = 0; i < m; ++i) {
      long long s, k;
      cin >> s >> k;
      for(int j = 0; j < k; ++j) {
        long long c;
        cin >> c;
        --c;
        memo[0][c].first += s;
        if(k == 1) memo[1][c].first += s;
      }
    }
    sort(memo[0].begin(), memo[0].end(), greater<p>());
    sort(memo[1].begin(), memo[1].end());
    if(memo[0][0].second != memo[1][0].second)
      cout << memo[0][0].first - memo[1][0].first + 1
           << endl;
    else
      cout << max(memo[0][1].first - memo[1][0].first,
                  memo[0][0].first - memo[1][1].first) +
                  1
           << endl;
  }
  return 0;
}


Measured memory_bytes: 3348
#include<iostream>
#include<vector>
#include<string>
#include<set>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<string> S(N);
    for (auto& s : S) {
        cin >> s;
    }
    set<string> cnt;
    rep(i, 0, N) {
        cnt.insert(S[i]);
    }
    cout << cnt.size() << endl;
    return 0;
}

Measured memory_bytes: 25056
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  co(N / 3);
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

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

	int H, W;
	cin >> H >> W;

	vector<string> grid(H);
	vector<vector<int>> used(H, vector<int>(W, INF));
	int black = 0;
	string tmp;
	for (int i = 0; i < H; i++) {
		cin >> tmp;
		grid[i] = tmp;
		for (int j = 0; j < W; j++) black += tmp[j] == '#';
	}

	vector<int> dx{ 1,0,-1,0 }, dy{ 0,1,0,-1 };
	used[0][0] = 1;
	auto ok = [&](int x, int y) { return 0 <= x && x < H && 0 <= y && y < W && grid[x][y] == '.'; };

	auto dfs = [&](auto &&f, int x, int y) -> bool {
		
		bool flag = (x == H - 1 && y == W - 1);

		for (int i = 0; i < 4; i++) {
			int xto = x + dx[i], yto = y + dy[i];
			if (ok(xto, yto) && used[xto][yto] > used[x][y] + 1) {
				used[xto][yto] = used[x][y] + 1;
				flag |= f(f, x + dx[i], y + dy[i]);
			}
		}

		return flag;

	};

	if(dfs(dfs,0,0))cout << H * W - black - used.back().back() << "\n";
	else cout << "-1\n";

	return 0;
}

Measured memory_bytes: 384
while(<>){
	chomp;
	if($. == 1){
		$n = $_;
	}else{
		@s = split(/ /, $_);
	}
}

$r = 0;

for $i (0 .. $#s){
	for $p (1 .. $#s){
		next if(($p < $i) or ($p == $i));
		$r += ($s[$p] * $s[$i]);
	}
}

print "$r\n";


Measured memory_bytes: 512
N=int(input())
A=input()
B=input()
C=[]
count=1
for i in range(N-1):
  if A[i]!=A[i+1]:
    C.append(count)
    count=1
  else:
    count+=1
if N==1:
  print(3)
  exit()
  
if A[-1]==A[-2]:
  C.append(2)
else:
  C.append(1)

ans=3
if C[0]==2:
  ans*=2
d=len(C)
for i in range(1,d):
  if C[i]==1 and C[i-1]==2:
    ans*=1
    ans%=10**9+7
  elif C[i]==2 and C[i-1]==2:
    ans*=3
    ans%=10**9+7
  else:
    ans*=2
    ans%=10**9+7
print(ans%(10**9+7))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<sstream>
using namespace  std;
vector<string> split(const string &s,char delimiter)
{
	vector<string> ret;
	size_t now = 0, find;
	while ((find = s.find_first_of(delimiter, now)) != string::npos)
	{
		ret.push_back(string(s, now, find - now));
		now = find + 1;
	}
	ret.push_back(string(s, now, s.size() - now));
	return ret;
}
int main()
{
	string s;
	int b = 0, c = 0;
	while (cin >> s)
	{
		vector<string> sv = split(s, ',');
		int a[3];
		for (int i = 0; i < sv.size(); i++)
		{
			stringstream ss;
			ss << sv[i];
			ss >> a[i];
		}
		if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])b++;
		else if(a[2] >= a[0] && a[2] >= a[1]) c++;
	}
	cout << b << endl;
	cout << c << endl;
	return 0;
}

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


void solve(long long N, std::vector<long long> P){
    map<int, int> mp;
    for(int i = 0; i < N; i++) {
        mp[P[i]] = i;
    }

    vector<int> q(N + 1, 0);
    for(int i = 0; i < N; i++) {
        if(i < mp[P[i] + 1]) q[P[i]] += q[P[i] - 1] + 1;
    }

    int ans = 0;
    for(auto e: q) ans = max(e, ans);
    cout << N - ans - 1 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
        P[i];
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,m,f[110][110];
char s[110][110];
int main()
{
	read(n),read(m);
	for(res i=1;i<=n;++i) scanf("%s",s[i]+1);
	memset(f,0x3f,sizeof(f)),f[1][1]=s[1][1]=='#';
	for(res i=1;i<=n;++i)
	  for(res j=1;j<=m;++j) {
	  	/*
	  	if(i<n) {
	  		chkmin(f[i+1][j],f[i][j]);	
		}
		if(j<m) {
			chkmin(f[i][j+1],f[i][j]);
		}
		*/
		if(i<n) {
			if(s[i][j]=='.'&&s[i+1][j]=='#') chkmin(f[i+1][j],f[i][j]+1);
			else chkmin(f[i+1][j],f[i][j]);
		}
		if(j<m) {
			if(s[i][j]=='.'&&s[i][j+1]=='#') chkmin(f[i][j+1],f[i][j]+1);
			else chkmin(f[i][j+1],f[i][j]);			
		}
	  }
	print(f[n][m],'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

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


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

    string s; cin  >> s;
    int n = s.size();
    int a,b,c;
    a = 0;b = 0;c = 0;
    for(int i = 0;i < n;i ++){
        if(s.at(i) == 'a') a ++;
        else if(s.at(i) == 'b') b ++;
        else c ++;
    }

    int m = (n+2) / 3;

    if(a <= m && b <= m && c <= m) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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


MY_NAMESPACE(sandbox)
ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);
	if (a % b == 0)
		return b;
	return gcd(b, a % b);
}

ll modpow(ll base, ll exponent, ll mod)
{
	ll retval = 1;
	while (exponent > 0)
	{
		if (exponent % 2)
			retval = (retval * base) % mod;
		exponent /= 2;
		base = (base * base) % mod;
	}
	return retval;
}

struct HashPair {

	static size_t m_hash_pair_random;

	template<class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const {

		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);

		size_t seed = 0;
		seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= m_hash_pair_random + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		return seed;
	}
};

size_t HashPair::m_hash_pair_random = (size_t)random_device()();

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

	ll modval = 1000000007;

	int n;
	cin >> n;
	//map<pll, int> cnt;
	unordered_map<pll, int, HashPair> cnt;
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		if (a != 0 && b != 0)
		{
			if (a < 0)
			{
				a *= -1;
				b *= -1;
			}
			ll g = gcd(abs(a), abs(b));
			cnt[{a / g, b / g}]++;
		}
		else if (a == 0 && b == 0)
			cnt[{0, 0}]++;
		else if (a == 0)
			cnt[{0, 1}]++;
		else  // b == 0
			cnt[{1, 0}]++;
	}

	ll num00 = 1;
	if (cnt[{0, 0}] == 0)
		num00 = 0;
	else
		num00 = cnt[{0, 0}];
	cnt.erase(make_pair(0,0));

	ll num = 1;
	while (!cnt.empty())
	{
		auto this_item = *cnt.begin();
		cnt.erase(cnt.begin());
		pll this_pair = this_item.first;
		pll anti_pair = { this_pair.second, -this_pair.first };
		if (anti_pair.first < 0)
			anti_pair = { -this_pair.second, this_pair.first };
		else if (anti_pair.first == 0)
			anti_pair = { 0, 1 };
		if (cnt.find(anti_pair) == cnt.end())
			cnt[anti_pair] = 0;
		auto anti_item = cnt.find(anti_pair);

		num = num * (modpow(2, this_item.second, modval) - 1 + modpow(2, anti_item->second, modval) - 1 + 1) % modval;
		cnt.erase(anti_item);
	}
	ll retval = (num + modval - 1) % modval;
	cout << (retval + num00) % modval << "\n";
		
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 14656