akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define int long long
using namespace std;

vector<pair<int,int>> dpsub[1 << 18];
int dpres[1 << 18];

signed main(){
	int N, M;
	cin >> N;
	M = 1 << N;

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

	dpres[0] = 0;
	for(int s = 1; s < M; ++s) {
		vector<pair<int,int>> v;
		v.push_back(make_pair(A[s], s));
		for(int t = 1; t < s; t *= 2) if(s & t) {
			v.insert(v.end(), ALL(dpsub[s & ~t]));
		}
		v.push_back(make_pair(A[0], 0));
		sort(ALL(v));
		reverse(ALL(v));
		/*
		EACH(i, v) {
			cout << "(" << i->first << "," << i->second << ")";
		}
		cout << endl;
		*/
		v.erase(unique(ALL(v)), v.end());
		v.erase(v.begin() + 2, v.end());

		dpres[s] = max(dpres[s-1], v[0].first + v[1].first);
		dpsub[s] = v;

		cout << dpres[s] << endl;
	}

	return 0;
}


Measured memory_bytes: 25600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int n, m, x, y, ta[100], iwa[100];

int main() {
	cin >> n >> m >> x >> y;
	for (int i = 0; i < n; i++) {
		cin >> ta[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> iwa[i];
	}
	if (x >= y) {
		cout << "War" << endl;
		return 0;
	}
	sort(ta, ta + n);
	sort(iwa, iwa + m);
	reverse(ta, ta + n);
	if (ta[0] >= iwa[0]||x>=iwa[0]||ta[0]>=y) {
		cout << "War" << endl;
		return 0;
	}
	cout << "No War" << endl;
	return 0;
}

Measured memory_bytes: 256
X,N = [int(hoge) for hoge in input().split()]
P = [int(hoge) - X for hoge in input().split()]
for d in range(101):
    if (d in P) and (-d in P):
        continue
    elif -d in P:
        print(X + d)
        exit()
    else:
        print(X - d)
        exit()


Measured memory_bytes: 61892
#include<iostream>
using namespace std;
int gcd(int x, int y);


int main() {

	int x, y;

	cin >> x >> y;

	cout << gcd(x, y) << endl ;

	return 0;

}

int gcd(int x, int y) {
	int amari=0;

	if (x <= y) swap(x, y);	//大小関係の入れ替え
	
	while (x%y != 0){
		amari = x % y;
		x = y;
		y = amari;
	}

	return y;
}





Measured memory_bytes: 3124
#include <iostream>
#include <set>
#include <iterator>
using namespace std;
int main(){
    int product_price, my_money, i , j = 0;

    cin >> product_price;

    if(product_price%1000 != 0){
        for(i = 0; i <= (product_price/1000); i++){
        j++;
    }
    my_money = 1000*j;
    cout << my_money - product_price << endl;

    }
    else{
        cout << "0" << endl;
    }


    return 0;
}


Measured memory_bytes: 3632
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return abs(a); }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll m, n, k, l, q;

bool zawiera(pll & a, pll & b){
	return a.f <= b.f and a.s >= b.s;
}

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

	ll a, b, c, d;

	cin >> a >> b >> c >> d >> q;

	pll A = {a - b * q, a + b * q};
	pll B = {c - d * q, c + d * q};

	cout << (zawiera(A, B) ? "YES" : "NO") << '\n';

}

Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


struct Elem
{
	bool tailA;
	bool headB;	//注意有相连的不算
	
	int inCount;	//内部存在的计数个数 
};

int n;
char s[20];
Elem elems[10010];

void checkElem(const char *s, int szS, int i)
{
	elems[i].headB = false;
	elems[i].tailA = false;
	
	if (szS == 1)
	{
		if (s[0] == 'A')
			elems[i].tailA = true;
		else if (s[0] == 'B')
			elems[i].headB = true;
			
		return ;
	}
	
	if (s[0] == 'B')
		elems[i].headB = true;
	if (s[szS - 1] == 'A')
		elems[i].tailA = true;
		
	elems[i].inCount = 0;
	for (int j = 0 ; j < szS - 1 ; j++)
	{
		if ((s[j] == 'A') && (s[j + 1] == 'B'))
			elems[i].inCount++;
	}
}

int main()
{
	scanf("%d\n", &n);
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%s\n", s);
		checkElem(s, strlen(s), i);
	}
	
	int sHeadBCount = 0;
	int sTailACount = 0;
	int bothCount = 0;
	
	int total = 0;
	for (int i = 0 ; i < n ; i++)
	{
		total = total + elems[i].inCount;
		if ((elems[i].tailA == true) && (elems[i].headB == true))
			bothCount++;
		else if (elems[i].tailA == true)
			sTailACount++;
		else if (elems[i].headB == true)
			sHeadBCount++;
	}
	
	if (bothCount > 0)
	{
		total = total + bothCount - 1;
		//头上的B 
		if (sTailACount > 0)
		{
			total++;
			sTailACount--;
		}
		
		if (sHeadBCount > 0)
		{
			total++;
			sHeadBCount--;
		}
	}
	
	if (sTailACount > sHeadBCount)
		total = total + sHeadBCount;
	else
		total = total + sTailACount;
	
	
	printf("%d\n", total);

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  long check[n+1];
  for (long i = 1; i <= n; i++) {
    check[i] = 0;
  }
  long a,b;
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a, &b);
    check[a]++;
    check[b]++;
  }
  for (long i = 1; i <= m; i++) {
    if (check[i]%2 != 0) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");

  return 0;
}

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

using namespace std;

char s[10][10];

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++)
        cin >> s[i];
    
    int ans = 0;
    for(int i = 0; i < (1 << n); i++)
        for(int j = 0; j < (1 << m); j++)
        {
            int black = 0;
            for(int a = 0; a < n; a++)
                for(int b = 0; b < m; b++)
                    if(((i >> a) & 1) == 0 && ((j >> b) & 1) == 0 && s[a][b] == '#')
                        black += 1;
                    
            if(black == k)
                ans++;
        }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {

	long long int n, x;

	cin >> n >> x;

	vector<long long int> a(n);

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

	sort(a.begin(), a.end());

	long long int ans = 0;


	for (long long int i = 0; i < n; i++) {
		if (x >= a[i]) {
			x -= a[i];
			ans++;
		}
		else {
			x = 0;
			break;
		}
	}

	if (x > 0) {
		ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
from collections import *
from math import atan2, pi
from bisect import *
mod = 10**9+7

N = int(input())
S = [int(c == 'B') for c in input()]
if S[0] + S[-1] < 2:
    print(0)
    exit()
for i in range(N):
    S[2*i] ^= 1
if sum(S) != N:
    print(0)
    exit()
cnt, ans = 0, 1
for x in S:
    if x == 0:
        cnt += 1
    else:
        if cnt == 0:
            print(0)
            exit()
        ans = ans * cnt % mod
        cnt -= 1
for i in range(2, N+1):
    ans = ans * i % mod
print(ans)


Measured memory_bytes: 5480
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

#include <numeric>

using namespace std;

typedef unsigned long long LL;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int n;
LL ans;

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            for (int k = 1; k <= n; ++k)
                ans += euclidean_gcd(i, euclidean_gcd(j, k));
    
    cout << ans << endl;
 

}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//実行部
void Main()
{
  ll a, b; cin >> a >> b;
  fin(max(a + b, max(a - b, a * b)))
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <functional>
//#include <utility>

#include <queue>

using namespace std;

void get_map();
void dijkstra(int start);
struct edge
{
  int to;
  int weight;
};

const int INF = INT_MAX/3;
const int MAX_V = 500000;
vector<edge> g[100000];
bool visited[MAX_V];
int dist[MAX_V];
int vertex;
int start;

int main()
{
  get_map();
  dijkstra(start);
  for(int i=0;i<vertex;i++)
    {
      if(visited[i]==false)
	{
	  cout << "INF" << endl;
	}
      else
	{
      cout << dist[i] << endl;
	}
    }
  return 0;
}


bool operator>(edge r1, edge r2)
{
  return r1.weight > r2.weight;
}



void dijkstra(int start)
{
    priority_queue<edge, vector<edge>, greater<edge> > q;
    q.push({start,0});

    while(!q.empty())
      {
	edge r = q.top();
	q.pop();

	if(visited[r.to]==false)
	  {
	    visited[r.to]=true;
	    dist[r.to]=r.weight;

	    for(int i=0;i<g[r.to].size();i++)
	      {
		if(visited[g[r.to][i].to]==false)
		  {
		    q.push({g[r.to][i].to, g[r.to][i].weight+dist[r.to]});
		  }
	      }
	  }
	
      }
}

void get_map()
{
  int edge;
  cin >> vertex >> edge >> start;

  for(int i=0;i<edge;i++)
    {
      int from, to, weight; 
      cin >> from >> to >> weight;
      g[from].push_back({to , weight});
    }
  
  for(int i=0;i<MAX_V;i++)
    {
      dist[i]=INF;
    }
  
}

Measured memory_bytes: 14408
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let n:usize = read();
    let s:Vec<String> = (0..n).map(|_| read()).collect();
    let m:usize = read();
    let t:Vec<String> = (0..m).map(|_| read()).collect();

    let mut ans:i64 = 0;
    for el in s.iter() {
        let mut cnt:i64 = s.iter().filter(|x| &x[..] == &el[..]).count() as i64;
        //debug!(cnt);
        cnt -= t.iter().filter(|x| &x[..] == &el[..]).count() as i64;
        //debug!(cnt);
        ans = max(ans, cnt);
    }

    println!("{}", ans);

}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**5)

v, e = map(int, input().split())
adj_list = {}
for _ in range(e):
    x, y = map(int, input().split())
    adj_list.setdefault(x, []).append(y)
visited = [0] * (v + 1)
dis = [0] * (v + 1)


def dfs(cur):
    global visited
    global dis
    visited[cur] = 1
    if cur in adj_list:
        for item in adj_list[cur]:
            if not visited[item]:
                dfs(item)
            dis[cur] = max(dis[cur], 1+dis[item])


for i in range(v + 1):
    if not visited[i]:
        dfs(i)
print(max(dis))


Measured memory_bytes: 68316
#include<cstdio>
int a,b,i,n,x;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++,x^=a/b)
	{
		scanf("%d%d",&a,&b);
		while(a%b&&a>(long long)b*b)a-=a/b+1;
		if(a%b)while((a-=a%b/(a/b+1)*(a/b+1))%b)a-=a/b+1;
	}
	return 0*puts(x?"Takahashi":"Aoki");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string r;
  cin >> r;
  
  if(r.at(0)=='A'&&r.at(1)=='A'&&r.at(2)=='A')cout << "No" << endl;
  else{
  if(r.at(0)=='B'&&r.at(1)=='B'&&r.at(2)=='B')cout << "No" << endl;
  else cout << "Yes" << endl;
  }
  
}

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

namespace ABC154 {
    public class A {
        public static void Main() {
            var strs = Console.ReadLine().Split(' ');
            var counts = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var select = Console.ReadLine();

            if (strs[0] == select) counts[0]--;
            else counts[1]--;


            Console.WriteLine($"{counts[0]} {counts[1]}");
        }
    }
}


Measured memory_bytes: 13268
h, w = gets.split.map(&:to_i)
s = Array.new(h + 1).map{Array.new(w + 1, 0)}
1.upto(h) do |i|
  c = 0
  l = 1
  b = gets.split('').map(&:to_s)
  1.upto(w) do |j|
    if b[j - 1] == '.'
      l = j if c == 0
      c += 1
    elsif c > 0
      l.upto(j - 1) do |k|
        s[i][k] = c
      end
      c = 0
      s[i][j] = 0
    else
      s[i][j] = 0
    end
    if j == w && c > 0
      l.upto(j) do |k|
        s[i][k] = c
      end
    end
  end
end
1.upto(w) do |j|
  c = 0
  l = 1
  1.upto(h) do |i|
    if (s[i][j] > 0)
      l = i if c == 0
      c += 1
    elsif c > 0
      l.upto(i - 1) do |k|
        s[k][j] += c
      end
      c = 0
    end
    if i == h && c > 0
      l.upto(i) do |k|
        s[k][j] += c
      end
    end
  end
end
ans = 0
1.upto(h) do |i|
  1.upto(w) do |j|
    ans = s[i][j] if ans < s[i][j]
  end
end
puts ans - 1

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

using namespace std;
using ll=long long;
using ld=long double;
template<typename T>
using v=vector<T>;
template<typename T>
using vv=vector<vector<T>>;
template<typename T>
using vvv=vector<vector<vector<T>>>;
template<typename T>
using pql=priority_queue<T,vector<T>,greater<T>>;
template<typename T>
using li=list<T>;
template<typename T>
using fl=forward_list<int>;
template<typename T>
using st=stack<T>;
template<typename T>
using qu=queue<T>;
template<typename T>
using dq=deque<T>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define rbe rbegin()
#define en end()
#define ren rend()
#define sz(x) x.size()
#define all(x) x.be,x.en
#define ral(x) x.rbe,x.ren
#define Vsort(v) sort(v.begin(), v.end());
#define Vrev(v) reverse(v.begin(), v.end());
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)
#define repr(i, n) rep2(i,n,0)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define chmin(mi, val) mi = min(mi, val)
#define chmax(ma, val) ma = max(ma, val)
#define MOD 1e9+7

int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
template<typename T> void In(T &e){cin>>e;}
template<typename T,typename U>void Inparray(T &f,U n){for(U i=0;i<n;i++) cin>>f[i];}
template<typename T,typename U>void Inparray2(T &f,U n){for(U i=0;i<n;i++)for(U j=0;i<n;i++)cin>>f[i][j];}
template<typename T,typename U,typename V>void Inparray3(T &f,U a,V b){for(U i=0;i<a;i++)for(U j=0;i<b;i++)cin>>f[i][j];}
template<typename T> void co(T e){cout<<e;}
template<typename T> void co2(T e){cout<<e<<"\n";}
template<typename T,typename U>void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i]<<"\n";}
template<typename T,typename U>void Printarray2(T f,U n){for(int i=0;i<n;i++){cout<<f[i]<<"\n";}}
template<typename T,typename U,typename V>void Printarray3(T f,U n){for(U i=0;i<n;i++){for(U j=0;j<n;j++){cout<<f[i][j];}cout<<"\n";}}
template<typename T,typename U,typename V>void Printarray4(T f,U a,V b){for(U i=0;i<a;i++){for(U j=0;j<b;j++){cout<<f[i][j];}cout<<"\n";}}
template<typename T>void flagfunc(bool flag,T A,T B){cout<<(flag?A:B)<<"\n";}
void flag2func(bool flag){cout<<(flag?"Yes":"No")<<"\n";}
void flag3func(bool flag){cout<<(flag?"YES":"NO")<<"\n";}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  int hoge=100,huga=1,shake,x;cin>>x;
  bool flag=false;
  while(hoge<=x){
    //cout<<hoge<<endl;
    shake=hoge;
    rep(i,5*huga+1){
      if(shake==x) flag=true;
      shake++;
    }
    if(flag) break;
    huga++;
    hoge+=100;
  }
  cout<<(flag?1:0)<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int k = 0; k < 5; k++)
            {
                var sum = 0;
                var n = ReadInt();
                if (n == 0)
                {
                    return;
                }
                for (int i = 0; i < 9; i++)
                {
                    var a = ReadInt();
                    sum += a;
                }
                WriteLine(n - sum);
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

typedef struct {
int first;
int second;
int third;
}triple;

int main()
{
	int n;
	cin >>n;
	triple happ[n];

	for (int i=0;i<n;i++)	cin >> happ[i].first >>happ[i].second >> happ[i].third ;
	
	int dp[n][3];

	memset(dp,0,sizeof(dp));
	dp[0][0]=happ[0].first;
	dp[0][1]=happ[0].second;
	dp[0][2]=happ[0].third;

	for (int i=1;i<n;i++)
	{	
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+happ[i].first;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+happ[i].second;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+happ[i].third;
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}

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

using namespace std;

int main()
{
	string a="a?";
	string s;
	string t;
	cin>>s>>t;
	int lt=t.size(),ls=s.size();
	int lab=ls;
	for(int i=0;i<=ls-lt;i++)
	{
		bool k=1;
		for(int j=i;j<i+lt;j++)
		if(s[j]!=a[1]&&s[j]!=t[j-i])
		{
		k=0;
		break;}
		if(k==1)
		lab=i;
	}
	if(lab==ls)
	{
		cout<<"UNRESTORABLE";
		return 0;
	}
	for(int j=lab;j<lab+lt;j++)
	s[j]=t[j-lab];
	for(int i=0;i<ls;i++)
	if(s[i]==a[1])
	s[i]=a[0];
	cout<<s;
	return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a; cin>>a;
	bool ok=false;
	for(int i=1;i<=9;i++){
		if(a%i==0){
			if(a/i<10){
				ok=true;
			}
		}
	}
	cout<<(ok ? "Yes":"No");
	
	return 0;
}

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

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

  int ans = 0;
  vector<int> d(n);

  for(int i = 0; i < n; i++){
    cin >> d[i];
  }

  sort(d.begin(), d.end());

  if(n % 2 == 0 && d[n/2] != d[n/2 - 1]){
    ans = d[n/2] - d[n/2 - 1];
  }

  cout << ans << endl;

}


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

int main(){
	int n,tmp[]={512,256,128,64,32,16,8,4,2,1};
	while(cin >> n){
		int cou[10]={0};
		for(int i=0;i<10;i++){
			if(n-tmp[i]>=0){
				n-=tmp[i];
				cou[i]++;
			}
			if(n==0) break;
		}
		int flag = 0;
		for(int i=9;i>=0;i--){
			if(cou[i] == 1){
				if(flag == 1) cout << " ";
				cout << tmp[i];
				flag = 1;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

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

	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		int m = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) {
				m++;
			}
		}
		if (m == 8) {
			ans++;
		}
	}

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


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

const double PI  = 3.141592653589793238463;

int main() {
    map<char, int> m;
    bool t = true;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        m[s[i]]++;
    }
    auto it = m.begin();
    while(it != m.end()){
        if(it->second%2 != 0){
            t = false;
        }
        it++;
    }
    if(t){
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
        
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), f(n);

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

    sorti(a); // shoujunn
    sortd(f); // koujunn

    // max = 10e12;
    ll right = 10e12 + 1;
    ll left = -1;
    ll ans = right;
    while (left + 1 < right) {
        ll mid = (right + left) / 2;
        ll total = 0;
        rep(i, n) {
            ll cost = mid / f[i];
            total += max(0LL, a[i] - cost);
        }

        if (total > k) {
            left = mid;
        } else {
            right = mid;
        }
    }

    cout << right << endl;
}


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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n, 0);
	for(int i=0; i<n; i++)cin >> a[i];
	multiset<int> si;
	si.insert(a[0]);
	for(int i=1; i < n; i++){
		auto it = si.lower_bound(a[i]);
		if(it != si.begin()){
			it--;
			si.erase(it);
		}
		si.insert(a[i]);
	}
	cout << si.size() << "\n";
	
	return 0;
}

Measured memory_bytes: 5376
#!/usr/bin/env python3

def main():
    a,b,c,d = map(int, input().split())
    if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int mypow(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}
int n,k,dp[2005],x,fac[2005],invfac[2005];
int C(int n,int m){return 1ll*fac[n]*invfac[m]%mod*invfac[n-m]%mod;}
int main()
{
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	invfac[n]=mypow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--)invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
	dp[0]=1;
	for(int _=1;_<=k;_++)
	{
		scanf("%d",&x);
		for(int i=n;i>=0;i--)
		{
			dp[i]=1ll*dp[i]*C(n,x)%mod;
			for(int j=1;j<=x&&j<=i;j++)dp[i]=(dp[i]+1ll*dp[i-j]*C(n-j,x-j)%mod*invfac[j])%mod;
		}
	}	
	printf("%lld\n",1ll*dp[n]*fac[n]%mod);
	return 0;
} 

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main () {
  int a[10000], b=0, n, i, j, m=0, z;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++) {
    scanf("%d", &a[i]);
  }

  for(i = 0 ; i < n ; i++) {
    z = (double)sqrt(a[i]);
    for(j = 2 ; j <= z ; j++) {
      if(a[i] % j == 0) {
	b++;
	break;
      } 
    }
    if(b == 0) m++;
    b = 0;
  }

  printf("%d\n", m);
  return 0;
}
   

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

bool judge(int x){
    if(x==2){
        return true;
    }
    if(!(x%2)){
        return false;
    }
    int i=3;
    while(x>=i*i){
        if(!(x%i)){
            return false;
        }
        i+=2;
    }
    return true;
}

int main(void){
    int a;
    cin>>a;
    while(!judge(a)){
        a+=1+(a%2);
    }
    cout<<a;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define NUM_CODE 32
#define BUF_SIZE 20

const char *code_table['Z'+1] = {
	['A']="00000", ['B']="00001", ['C']="00010", ['D']="00011",
	['E']="00100", ['F']="00101", ['G']="00110", ['H']="00111",
	['I']="01000", ['J']="01001", ['K']="01010", ['L']="01011",
	['M']="01100", ['N']="01101", ['O']="01110", ['P']="01111",
	['Q']="10000", ['R']="10001", ['S']="10010", ['T']="10011",
	['U']="10100", ['V']="10101", ['W']="10110", ['X']="10111",
	['Y']="11000", ['Z']="11001", [' ']="11010", ['.']="11011",
	[',']="11100", ['-']="11101", ['\'']="11110", ['?']="11111"
};

const char *decrypt_table[NUM_CODE] = {
	"100101", "10011010", "0101", "0001", "110", "01001", "10011011",
	"010000", "0111", "10011000", "0110", "00100", "10011001",
	"10011110", "00101", "111", "10011111", "1000", "00110", "00111",
	"10011100", "10011101", "000010", "10010010", "10010011", "10010000",
	"101", "000000", "000011", "10010001", "010001", "000001"
};

int main(void) {
	int c, k;
	size_t i, len;
	char buf[BUF_SIZE] = "";

	while (1) {
		c = getchar();
		if (c == '\r') {
			c = getchar();
		}
		if (c == '\n') {
			putchar('\n');
			memset(buf, '\0', BUF_SIZE);
			continue;
		}
		if (c == EOF)
			break;

		strcat(buf, code_table[c]);

		while (1) {
			for (i = 0; i < NUM_CODE; i++) {
				for (k = 0; decrypt_table[i][k]; k++) {
					if (decrypt_table[i][k] != buf[k]) {
						k = -1;
						break;
					}
				}
				if (k >= 0) {
					break;
				}
			}
			if (i >= NUM_CODE)
				break;

			putchar("ABCDEFGHIJKLMNOPQRSTUVWXYZ ',-.?"[i]);

			len = strlen(buf+k);
			memmove(buf, buf+k, len);
			buf[len] = '\0';
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

string s;
stack<char> st;

int main() {
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if (st.empty()) {
            st.push(s[i]);
            continue;
        }
        else if (st.top() != s[i]) {
            st.pop();
        }
        else {
            st.push(s[i]);
        }
    }

    cout << s.size() - st.size() << endl;

    return 0;
}


Measured memory_bytes: 512
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
}

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

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func main() {
	a, b, c, d := nextInt(), nextInt(), nextInt(), nextInt()
	fmt.Println(max(max(a*c, a*d), max(b*c, b*d)))
}


Measured memory_bytes: 1776
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	int cou = 0;
	rep(i, 0, n - 1) {
		if (i + 1 == a[i]) {
			swap(a[i], a[i + 1]);
			cou++;
		}
	}
	if (a[n - 1] == n) {
		swap(a[n - 1], a[n - 2]);
		cou++;
	}
	cout << cou << endl;
	return 0;
}


Measured memory_bytes: 640
function Main(input) {
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);

    var result = A - 2 * B;

    console.log(result < 0 ? 0 : result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

const int M=305;
const int INF=0x3f3f3f3f;
int og[M][M];
int cnt[M][M];
int n,m,l;

void floyd(int g[M][M])
{
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
}

int main()
{
	scanf("%d%d%d",&n,&m,&l);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			og[i][j]=l+1;
	int u,v,c;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d",&u,&v,&c);
		u--; v--;
		og[u][v]=og[v][u]=c;
	}
	floyd(og);
	memset(cnt,INF,sizeof(cnt));
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(og[i][j]<=l) cnt[i][j]=1;
	floyd(cnt);
	// cout<<endl;
	// for(int i=0;i<n;i++)
	// {
	// 	for(int j=0;j<n;j++)
	// 		cout<<cnt[i][j]<<"\t";
	// 	cout<<endl;
	// }
	// cout<<endl;
	int q; scanf("%d",&q);
	for(int i=0;i<q;i++)
	{
		scanf("%d%d",&u,&v);
		u--; v--;
		if(cnt[u][v]<INF) printf("%d\n",cnt[u][v]-1);
		else printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.ArrayList;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        ArrayList<Integer> l = new ArrayList<>();

        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());

        for (int i = 0; i < n * 2; i++) {
            l.add(Integer.parseInt(scanner.next()));
        }

        l.sort(Integer::compareTo);

        int ans = 0;

        for (int i = 0; i < n * 2; i++) {
            if (i % 2 == 0) {
                ans += l.get(i);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26708
// AtCoder ABC051 D - Candidates of No Shortest Paths
// 2020.1.22 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define INF 0x5ffffff
typedef struct { int a, b, c; } E;
E e[1005]; int M;
int N;
int d[105][105];

int main()
{
	int i, ans;
	int a, b, c;
	
	N = in(), M = in();
	for (a = 0; a < N; ++a) {
		d[a][a] = INF;
		for (b = a+1; b < N; ++b) d[a][b] = d[b][a] = INF;
	}
	for (i = 0; i < M; ++i) {
		e[i].a = a = in()-1, e[i].b = b = in()-1, e[i].c = c = in();
		d[a][b] = d[b][a] = c;
	}
	
	for (i = 0; i < N; ++i) {
		for (a = 0; a < N; ++a) for (b = 0; b < N; ++b) if (a != b) {
			int x = d[a][i] + d[i][b];
			if (x < d[a][b]) d[a][b] = x;
		}
	}
	ans = 0;
	for (i = 0; i < M; ++i) {
//		printf("a=%d, b=%d, d=%d, c=%d\n",e[i].a,e[i].b,
//			d[e[i].a][e[i].b], e[i].c);
		if (d[e[i].a][e[i].b] != e[i].c) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    print(max(A + B, A - B, A * B))

    return


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;cin>>n;
    if (n%2==0) cout << 0.5000000;
    else cout << setprecision(8) << fixed << (double) (n/2+1)/n;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define S size()
#define E end()
#define B begin()
#define L length()
 
#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define fi first
#define se second
#define fl float
#define ld long double
#define ll long long
 
#define gcd __gcd
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define all(v) v.B,v.E
#define acc(v) accumulate(all(v), 0)
#define psum partial_sum
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation
#define maxe *max_element
#define mine *min_element
 
#define forl(i,n) for(ll i = 0; i < n; i++)
#define fore(i,m,n) for (ll i = m; i <= n; i++)
#define rforl(i,n) for (ll i = n - 1; i >= 0; i--)
#define rfore(i,m,n) for (ll i = m; i >=n; i--)    
#define iter(s) for(auto it:s)
 
 
#define prec(n) fixed<<setprecision(n)
#define popcnt(n) __builtin_popcountll(n)
#define parity(n) __builtin_parityll(n)
#define clz(n) __builtin_clzll(n)
#define ctz(n) __builtin_ctzll(n)
 
#define sll set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vll vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define msll multiset<ll>
#define msc multiset<char>
#define vvll vector<vector<ll>>
#define rev reverse
 
#define tc ll q;cin>>q;while(q--)
#define pat ll n;cin>>n;
#define pat1 vll a(n);forl(i,n)cin>>a[i];
#define pat2 ll n,k;cin>>n>>k;vll a;forl(i,n) cin>>a[i];
#define pats string s;cin>>s;
#define yesno if(flag)cout<<"YES\n";else cout<<"NO\n";
#define loop forl(i,n)
 
#define p0(a) cout << a << " ";
#define p1(a) cout << a << endl;
#define p2(a,b) cout << a << " " << b << endl;
#define p3(a,b,c) cout << a << " " << b << " " << c << endl;
#define p4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
 
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define mod1 1000000007
#define mod2 998244353
#define PI 3.1415926535897932384626433832
 
//**********************************
 
int main(){
    pat;
    ll a[n],b[n];
    loop{
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    ll ans;
    if(n%2==1){
        ans=b[n/2]-a[n/2]+1;
    }else{
        ans=b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1;
    }
    p1(ans);
}

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

int main(){
    string line;
    getline(cin, line);
    
    for(int i = 0; i < line.size(); i++){
        if(line[i] >= 'a' && line[i] <= 'z') line[i] += 'A' - 'a';
        else if(line[i] >= 'A' && line[i] <= 'Z') line[i] -= 'A' - 'a';
    }
    
    cout << line << endl;
}


Measured memory_bytes: 3168
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    ll a,b;
    cin>>a>>b;
    if(a>0) cout<<"Positive";
    else if(a==0) cout<<"Zero";
    else{
        ll m=min((ll)0,b);
        if(m==0) cout<<"Zero";
        else{
            ll u=b-a+1;
            if(u%2==0) cout<<"Positive";
            else cout<<"Negative";
        }

    }
}

Measured memory_bytes: 256
H,W,M = [int(x) for x in input().split()]
hw = []
hNum = [0]*H
wNum = [0]*W

for i in range(M):
    h,w = [int(x) for x in input().split()]
    hw.append([h,w])
    hNum[h-1]+=1
    wNum[w-1]+=1

hmax = max(hNum)
hMaxList = []
wmax = max(wNum)
wMaxList = []

for i in range(H):
    if(hmax == hNum[i]):
        hMaxList.append(i)
for i in range(W):
    if(wmax == wNum[i]):
        wMaxList.append(i)

ans = wmax + hmax
count = 0
for i in hw:
    if(hNum[i[0]-1] == hmax and wNum[i[1]-1] == wmax):
        count += 1
# if(hNum.count(hmax) * wNum.count(wmax) == count):
if(len(hMaxList) * len(wMaxList) == count):
    ans -= 1
print(ans)


Measured memory_bytes: 82376
// We love golf
#include <bits/stdc++.h>
using namespace std;

int main(){
    int k, a, b;
    cin >> k >> a >> b;

    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3604
/*
	In the name of ALLAH
	Author : Raashid Anwar
*/

#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define MOD 1000000007


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,k,s;
	cin>>n>>k>>s;
	int A[n+1];
	for(int i=1;i<=k;i++)
		A[i]=s;
	for(int i=k+1;i<=n;i++) {
		A[i]=s+1;
		if(s==1e9)
			A[i]=1+(s&1);
	}
	for(int i=1;i<=n;i++)
		cout<<A[i]<<" ";
}



Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

typedef long long LL;

#define REP(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define DREP(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define EREP(i, a) for(register int i = (be[a]); i != -1; i = nxt[i])
#define mem(a, b) memset((a), b, sizeof(a))

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

template <class T>
T read(T sum = 0, T fg = 0)
{
	char c = getchar();
	while(c < '0' || c > '9') { fg |= c == '-'; c = getchar(); }
	while(c >= '0' && c <= '9') { sum = sum * 10 + c - '0'; c = getchar(); }
	return fg ? -sum : sum;
}

const int Size = 100010;

int to[Size << 1], nxt[Size << 1], be[Size], e;

void add(int x, int y) { to[e] = y; nxt[e] = be[x]; be[x] = e; e++; }

void init() { mem(be, -1); e = 0; }

bool flag;
int col[Size];
bool vis[Size];

void dfs(int x, int c)
{
	if(flag) return;
	vis[x] = 1;
	col[x] = c;
	EREP(i, x)
	{
		int y = to[i];
		if(!vis[y]) dfs(y, c ^ 1);
		else if(c == col[y]) { flag = 1; return; }
	}
}

int main()
{
	init();
	int n = read<int>(), m = read<int>();
	REP(i, 1, m)
	{
		int x = read<int>(), y = read<int>();
		add(x, y); add(y, x);
	}
	dfs(1, 0);
	if(flag) printf("%lld\n", 1LL * n * (n - 1) / 2 - m);
	else
	{
		LL b = 0, w = 0;
		REP(i, 1, n)
		{
			b += col[i] == 0;
			w += col[i] == 1;
		}
		printf("%lld\n", 1LL * b * w - m);
	}
	return 0;
}


Measured memory_bytes: 2944
N, P = map(int, input().split())
A = list(map(int, input().split()))

cnt_odd = sum([int((Ai % 2) == 1) for Ai in A])
cnt_evn = N - cnt_odd

ptn_evn = 1 << cnt_evn

tab_ncr = [1]
ncr_tmp = 1
for i in range(cnt_odd):
    ncr_tmp *= (cnt_odd - i)
    ncr_tmp //= (i + 1)
    tab_ncr.append(ncr_tmp)

ans = 0
# print("#", tab_ncr)

for i in range(cnt_odd + 1):
    if i % 2 != P: continue
    #
    ans += (ptn_evn * tab_ncr[i])

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>

typedef long long ll;

using namespace std;

int main()
{string S; cin >> S;
 
 bool alphabet[26] = {false};
 for(int i = 0; i < S.size(); i++){
   alphabet[S[i] - 'a'] = true;}
 
 for(int i = 0; i < 26; i++){
   if(alphabet[i] == false){ char x = i + 'a'; cout << x << endl; return 0;}}
cout << "None" << endl; return 0;}
 

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

int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  rep(i,n){
    if(s[i]!=t[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
  string s;
  int k;
  cin >> s;
  cin >> k;
  vector<string> v;
  REP(i, s.size()){
    REP(j, k){
      string sub = s.substr(i, j + 1);
      v.push_back(sub);
    }
  }
  sort(v.begin(), v.end());
  unique(v.begin(), v.end());
  print(v[k-1]);
}

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

int main() {
  int s=-7,i;
  string n;
  vector<int> m(4);
  char op1='+',op2='+',op3='+';
  cin >> n;
  for(i=0; i<4; i++) {
    m.at(i)=n.at(i)-'0';
    s+=m.at(i);
  }
  s/=2;
  
  if(s==m.at(1))
    op1='-';
  else if(s==m.at(2))
    op2='-';
  else if(s==m.at(3))
    op3='-';
  else if(s==m.at(1)+m.at(2)) {
    op1='-';
    op2='-';
  } else if(s==m.at(2)+m.at(3)) {
    op2='-';
    op3='-';
  } else if(s==m.at(1)+m.at(3)) {
    op1='-';
    op3='-';
  } else if(s==m.at(1)+m.at(2)+m.at(3)) {
    op1='-';
    op2='-';
    op3='-';
  }
  
  cout << n.at(0) << op1 << n.at(1) << op2 << n.at(2) << op3 << n.at(3) << "=7" << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	s := read()
	prev := ""
	var result = ""
	for i := 1; i <= len(s); i++ {
		if prev == s[i-1:i] {
			result ="Bad"
			break
		}
		prev = s[i-1:i]
	}
	if result == "" {
		result = "Good"
	}
	fmt.Println(result)
}

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


Measured memory_bytes: 640
N = int(input())

f = []
for i in range(N):
    x, l = map(int, input().split())
    f.append([x - l, x + l])
f.sort(key=lambda x: x[1])

t = f[0][1]
ans = 1
for i in range(1, N):
    if f[i][0] < t:
        continue
    ans += 1
    t = f[i][1]
print(ans)


Measured memory_bytes: 25528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl ;
  }
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	
	if(s=="SAT")
	cout<<1;
	
	else if(s=="MON")
	cout<<6;
	
	else if(s=="TUE")
	cout<<5;
	
	else if(s=="WED")
	cout<<4;
	
	else if(s=="THU")
	cout<<3;
	
	else if(s=="FRI")
	cout<<2;
	
	else if(s=="SUN")
	cout<<7;
	
	return 0;
}

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

int main(){
	int n, p;
	cin >> n >> p;
	int i1 = 0;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a % 2) i1 = 1;
	}
	if(i1){
		cout << (1LL<<(n-1)) << endl;
	} else if(p == 1){
		cout << 0 << endl;
	} else {
		cout << (1LL<<n) << endl;
	}
}


Measured memory_bytes: 256