akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int dp[100010];
int N;
int h[100010];

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

	cin >> N;
	rep(i, 0, N)cin >> h[i];

	dp[1] = abs(h[0] - h[1]);

	rep(i, 2, N)
	{
		dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
	}

	cout << dp[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 1792
# Comment out -> using bisect ver. method
# import bisect
import math
N, H = map(int, input().split())
swing = []
throw = []
for _ in range(N):
    sw, th = map(int, input().split())
    swing.append(sw)
    throw.append(th)
swing.sort(reverse=True)
throw.sort(reverse=True)
'''
idx = bisect.bisect_right(throw, swing[0])
if idx == len(throw):
    print(math.ceil(H / swing[0]))
'''
if swing[0] >= throw[0]:
    print(math.ceil(H / swing[0]))
else:
    # throw = throw[idx:]
    cnt = 0
    damage_sum = 0
    while cnt < len(throw):
        if throw[cnt] <= swing[0]:
            break
        damage_sum += throw[cnt]
        cnt += 1
        if damage_sum >= H:
            print(cnt)
            exit()
    '''
    for i in reversed(throw):
        cnt += 1
        damage_sum += i
        if damage_sum >= H:
            print(cnt)
            exit()
    '''
    print(math.ceil(cnt + (H - damage_sum) / swing[0]))


Measured memory_bytes: 17076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
ll n;
ll w[1100],s[1100],v[1100];
ll dp[1100][22000];
int main(){
    cin>>n;
    rep(i,n)cin>>w[i]>>s[i]>>v[i];
    vl block;
    rep(i,n)block.pb(i);
    sort(block.begin(),block.end(),[&](int x,int y){
        return s[x]+w[x]<s[y]+w[y];
    });
    for(int i=1;i<=n;i++){
        ll ind=block[i-1];
        for(int j=0;j<220000;j++){
            dp[i][j]=dp[i-1][j];
            if(j-w[ind]<=s[ind]&&j-w[ind]>=0){
                dp[i][j]=max(dp[i][j],dp[i-1][j-w[ind]]+v[ind]);
            }
        }
    }
    ll ans=0;
    rep(i,220000)chmax(ans,dp[n][i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 177040
#include <stdio.h>
int s[10000],n,ans=0;

void linearSearch(int a){
  int j=0;
  while(j<n){
    if(s[j]==a){
      ans++;
      break;
    }
    j++;
  }
}

int main(){
  int q,i,pass;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&pass);
    linearSearch(pass);
  }
  printf("%d\n",ans);
  return 0;
}

  



 



Measured memory_bytes: 2052
#include<stdio.h>
int main(){
  int a,n,i,j,k,v;
  int M[100][100];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      M[i][j] = 0;
    
    }
  }

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

    for(j = 0; j < k; j++){
      scanf("%d",&v);
      M[a-1][v-1] = 1;
      }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n-1; j++){
      printf("%d ", M[i][j]);
      }
    printf("%d", M[i][n-1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll N; cin >> N;
    int ans = 0;
    FOR(i, 2, 100000000) {
        int cur = 0;
        while (N % i == 0) {
            cur++;
            N /= i;
        }
        FOR(j, 1, 10000) {
            if (cur < j) break;
            ans++; cur -= j;
        }
    }
    if (N > 1) ans++;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3668
(defun solve (array e-num spa &optional (pos 0) (result 0))
  (cond ((and (= spa 0) (= e-num 0))
         result)
        ((= spa 0)
         (solve array (1- e-num) spa (1+ pos) (+ result (aref array pos))))
        (t
         (solve array (1- e-num) (1- spa) (1+ pos) result))))

(let* ((Enemy-Numbers (read))
       (Special-Atack (read))
       (Enemy-list (make-array Enemy-Numbers :initial-element 0)))
  (dotimes (x Enemy-Numbers)
    (setf (aref Enemy-list x) (read)))
  (sort Enemy-list #'>)
  (print (if (>= Special-Atack Enemy-Numbers)
             0
             (solve Enemy-list Enemy-Numbers Special-Atack))))


Measured memory_bytes: 59876
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[10];
struct sa
{
    int x,y;
}p[10];
double dis(double x1,double y1,double x2,double y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
    int n,m,len;
    while(cin>>n)
    {
        ll k=1;
        for(int i=1;i<=n;i++)
            a[i]=i,k*=i;
        for(int i=1;i<=n;i++)
            cin>>p[i].x>>p[i].y;
        double ans=0;
        for(int i=1;i<n;i++)
            ans+=dis(p[a[i]].x,p[a[i]].y,p[a[i+1]].x,p[a[i+1]].y);
        while(next_permutation(a+1,a+n+1))
        {
            for(int i=1;i<n;i++)
                ans+=dis(p[a[i]].x,p[a[i]].y,p[a[i+1]].x,p[a[i+1]].y);
        }
        printf("%.10lf\n",ans/k*1.0);
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
int main ()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	int s;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		s = 0;
		int j = i;
		while (j)
		{
			s += j%10;
			j /= 10;
		}
		if (s <= b && s >= a) {
			sum += i;
		}
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

const int inf = numeric_limits<int>::max();


int main(){   
    int n;
    long int w;
    cin>>n>>w;
    long int weights[n+1];
    long long int values[n+1];
    for(long int i= 1;i<=n;i++){
        cin>>weights[i]>>values[i];
    }
    long long int arr[n+1][w+1] = { };
    for(int i  = 1;i<=n;i++){
        for(long int j = 1;j<=w;j++){
            if(weights[i]<=j){
                arr[i][j] = (values[i] + arr[i-1][j-weights[i]]);
            }
            arr[i][j] = max(arr[i][j],arr[i-1][j]);
        }
    }
    cout<<arr[n][w];



}

















Measured memory_bytes: 79104
// g++ -std=gnu++1y -O2 main.cpp

#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1e9;
const long long LINF = 1e18;

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

	bool ret = false;
	if (A == B && A != C)
	{
		ret = true;
	}
	else if (B == C && B != A)
	{
		ret = true;
	}
	else if (C == A && C != B)
	{
		ret = true;
	}

	if (ret)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int width, length;
        string[] str = Console.ReadLine().Split(' ');
        length = int.Parse(str[0]);
        width = int.Parse(str[1]);
        Console.WriteLine(length * width +" " + (2 * length + 2 * width));
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Union Find tree
//-------------------------------------------------
class UnionFind
{
private:
    ::std::vector<int> par;
    ::std::vector<int> rank;
    vector<int> cnt;
public:
    UnionFind(int n):par(n),rank(n),cnt(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            cnt[i] = 1;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        if (rank[rx]>rank[ry]){
            par[ry] = rx;
            cnt[rx] += cnt[ry];
        }else{
            par[rx] = ry;
            cnt[ry] += cnt[rx];
            if (rx==ry) rank[ry]++;
        }
    }
    int weight(int x){return cnt[root(x)];}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k; cin>>n>>m>>k;
    vi ans(n,-1);
    UnionFind uf(n);
    rep(i,m){
        int a,b; cin>>a>>b; a--; b--;
        uf.unite(a,b);
        ans[a]--; ans[b]--;
    }
    rep(i,k){
        int a,b; cin>>a>>b; a--; b--;
        if (uf.same(a,b)){
            ans[a]--; ans[b]--;
        }
    }
    rep(i,n) ans[i]+=uf.weight(i);
    rep(i,n){
        if (i>0) cout<<" ";
        cout<<ans[i];
    }cout<<"\n";
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

double sum = 0, k = 0 , a, c, n = 0;

int main(){
	while (scanf("%lf,%lf", &a, &c) != EOF){
		sum += a*c;
		k += c;
		n++;
	}
	cout << sum << endl;
	cout << (int)(k / n + 0.5) << endl;
}

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

int main(){
	int n;
	cin>>n;
	int res = 1;
	for(int i = 2;i <= n; i++){
		int p = i*i;
		int pprev = 1;
		while(p<=n){
		 pprev = p;
		 p*=i;
		}
		if(pprev<=n) res = max(res,pprev);
	}
	cout<<res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	if(n>99999)
	{
	    cout<<90909;
	    return 0;
	}
	if(n>9999)
	{
		cout<<n-10000+1+909;
		return 0;
	}
	
	if(n>999)
	{
		cout<<909;
		return 0;
	}
	
	if(n>99)
	{
		cout<<n-100+1+9;
		return 0;
	}
	
	if(n>9)
	{
		cout<<9;
		return 0;
	}
	cout<<n;	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef long long ll;
ll n, k;
int main() {
	scanf("%lld%lld", &n, &k);
	ll now = 1ll;
	int cnt = 0;
	while (n >= now) {
		now *= k;
		++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
import sys
import itertools
import numpy as np

input = sys.stdin.readline

n = int(input())
F = [[int(i) for i in input().split()] for _ in range(n)]
P = [[int(i) for i in input().split()] for _ in range(n)]

scores = []
for a in itertools.product(
  *[[0, 1] for _ in range(10)]):
    
    if np.sum(a)==0:
        continue
    
    score = 0
    
    for f, p in zip(F, P):
        m = np.sum([
            int(x==1 and y==1) for x, y 
          in zip(a, f)])
        score += p[m]
    
    scores.append(score)
    
print(np.max(scores))

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

using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll dp[100500];

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

  int N, K;
  cin >> N >> K;

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

  REP(i, N) dp[i] = 1 << 30;

  dp[0] = 0;

  REP(i, N){
    REP(j, K){
      chmin(dp[i+j+1], dp[i] + abs(h[i+j+1]-h[i]));
    }
  }

  cout << dp[N-1] << endl;


  return 0;
}


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

using Heights = std::vector<int>;

int solve(const Heights& heights)
{
  int result = 0;
  for (auto i = 0u; i < heights.size(); ++i) {
    const auto it = std::max_element(heights.begin(), heights.begin() + i);
    if (*it <= heights[i]) ++result;
  }
  return result;
}

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

  Heights heights(n);
  for (auto& h : heights) {
    std::cin >> h;
  }

  std::cout << solve(heights) << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main() {
	long long N;
    scanf("%lld",&N);

	ll ans = 1e15;
	for(ll i=1; i*i<=N; i++){
		if(N%i == 0) {
			ans = min(ans, i+N/i-2);
		}
	}

	cout << ans << endl;

	return 0;
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string S;
  cin >> S;
  int cnt = 0;
  rep(i,S.size()){
    if(S[i] == '2') cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>

using namespace std;
/**
2^60 = 1152921504606846976
 */
long long xor_sum4(int n, long long a[]) {
  long long divider = 1000000007;
  vector<bitset<60>> ba;
  long long ans = 0;
  for(int i=0;i<n;i++) {
    bitset<60> b = a[i];
    ba.push_back(b);
    // cout << b << endl;
  }
  for(int i=0;i<60;i++) {
    long long count_zero = 0;
    long long count_one = 0;
    for(int j=0;j<ba.size();j++) {
      bitset<60> b = ba[j];
      if (b[i] == 0)
	count_zero++;
      else
	count_one++;
      /*
      if ((a[j] >> i) & 1LL) ++count_one;
      else ++count_zero;
      */
    }
    // cout << i << " -> one: " << count_one << ", zero: " << count_zero << endl;
    /*
    long long adder = (count_one * count_zero) * pow(2, i);
    adder = adder % divider;
    ans += adder;
    */
    ans += (((count_one * count_zero) % divider) * ((1LL << i) % divider)) % divider;
    // cout << ans << endl;
  }
  ans = ans % divider;
  return ans;
}

int main() {
  int n;
  cin >> n;
  long long a[n];
  for(int i =0;i<n;i++) {
    cin >> a[i];
  }
  auto ans = xor_sum4(n, a);
  cout << ans;
}


Measured memory_bytes: 8176
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

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

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n := readInt()
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		m[readString()]++
	}
	len := len(m)
	switch len {
	case 3:
		fmt.Println("Three")
	case 4:
		fmt.Println("Four")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  string N;
  cin>>N;
  int n=N.size();
  bool ok=false;
  for(int i=1;i<n;i++){
    if(N[i]!='9'){ok=true;}
  }
  if(ok){
    string t=N.substr(1);
    cout<<N[0]-'0'-1+9*(n-1)<<endl;
  }
  else{
    cout<<N[0]-'0'+9*(n-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust" << endl;
    } else {
        cout <<"win" <<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B, K;
	cin >> A >> B >> K;

	int count = 0;
	for (int i = min(A, B); 0 <= i; i--)
	{
		if (A % i == 0 && B % i == 0)
		{
			count++;
		}

		if (count == K)
		{
			cout << i << endl;
			return;
		}
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a+b==15) {
        cout << '+' << endl;
    }
    else if (a*b==15) {
        cout << '*' << endl;
    }
    else {
        cout << 'x' << endl;
    }
}

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

int h_len[2002][2002];
int w_len[2002][2002];

int main(void) {
	int H, W;
	cin >> H >> W;
	vector <string> S(H+2);
	for (int w = 0; w <= W+1; w++) {
		S[0] += "#";
		S[H+1] += "#";
	}
	for (int h = 1; h <= H; h++) {
		string s;
		cin >> s;
		S[h] = "#" + s + "#";
	}

	int pre_w = 0;
	int cnt = 0;
	for (int h = 0; h <= H+1; h++) {
		for (int w = 0; w <= W+1; w++) {
			if (S[h][w] == '#') {
				w_len[h][w] = 0;
				for (int i = pre_w+1; i < w; i++) {
					w_len[h][i] = cnt;
				}
				pre_w = w;
				cnt = 0;
			} else {
				cnt++;
			}
		}
	}
	int pre_h = 0;
	for (int w = 0; w <= W+1; w++) {
		for (int h = 0; h <= H+1; h++) {
			if (S[h][w] == '#') {
				w_len[h][w] = 0;
				for (int i = pre_h+1; i < h; i++) {
					h_len[i][w] = cnt;
				}
				pre_h = h;
				cnt = 0;
			} else {
				cnt++;
			}
		}
	}
	int ans = 0;
	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			ans = max(ans, h_len[h][w] + w_len[h][w] - 1);
		}
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 39424
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int a, b, h = 0;

  std::cin >> a >> b;

  for (int i = 0; i < b - a; i ++)
    h += i + 1;

  std::cout << h - b << std::endl;

  return 0;
}


Measured memory_bytes: 256
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn main() {
    loop {
        let nums: Vec<usize> = get_line().trim()
            .split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect();
        let (w, h): (usize, usize) = (nums[0], nums[1]);
        if w == 0 && h == 0 {
            break;
        }
        for _ in 0..w {
            println!("{}", "#".repeat(h));
        }
        println!("");
    }
}



Measured memory_bytes: 5020
import java.util.*;

class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int A = Integer.parseInt(sc.next());
      int B = Integer.parseInt(sc.next());
      
      int result = Math.max(0, A - 2*B);
      
      System.out.println(result);
    }

}

Measured memory_bytes: 23252
def main():
    n, k = map(int, input().split())
    d = [None for _ in range(k)]
    a = [None for _ in range(k)]
    for i in range(k):
        d[i] = int(input())
        a[i] = list(map(int, input().split()))

    tricked = [True for _ in range(n)]
    for i in range(k):
        for j in range(d[i]):
            tricked[a[i][j]-1] = False

    ans = 0
    for i in range(n):
        if tricked[i]:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 200005;
int a[N], b[N];
int c[N], d[N];

inline int search(int v, int n){
	if(d[n - 1] < v)return n;
	int l = 0, r = n - 1;
	while(l < r){
		int m = l + (r - l)/2;
		if(v <= d[m])r = m;
		else l = m + 1;
	}
	return l;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	for(int i = 0; i < n; i++){
		cin>>b[i];
	}
	int ans = 0;
	for(int k = 0; k <= 28; k++){
		for(int i = 0; i < n; i++){
			c[i] = a[i]&((1<<(k + 1)) - 1);
			d[i] = b[i]&((1<<(k + 1)) - 1);
		}
		sort(d, d + n);
		ll cnt = 0;
		int x = 1<<k;
		int y = 1<<(k + 1);
		int z = x + y;
		for(int i = 0; i < n; i++){
			cnt += search(y - c[i], n) - search(x - c[i], n) + n - search(z - c[i], n);
		}
		if(cnt&1)ans ^= (1<<k);
	}
	cout<<ans<<'\n';

	return 0;
}

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

int memo[110][110][10];

int n;
int c[110];

void dp(int l, int r){
    if(memo[l][r][0] != -1){
        return;
    }

    if(l == r){
        for(int i = 0;i <= 9;i++){
            memo[l][r][i] = 0;
        }
        memo[l][r][c[l]] = 1;
        return;
    }

    for(int i = l;i < r;i++){
        dp(l,i);
        dp(i+1,r);
    }

    for(int x = 1;x <= 9;x++){
        memo[l][r][x] = 0;
        for(int i = l;i < r;i++){
            if(memo[l][i][x] == 1 && (memo[i+1][r][x] == 1 || memo[i+1][r][0] == 1)){
                memo[l][r][x] = 1;
            }else if((memo[l][i][x] == 1 || memo[l][i][0] == 1) && memo[i+1][r][x] == 1){
                memo[l][r][x] = 1;
            }
        }
    }

    memo[l][r][0] = 0;
    for(int i = l;i < r;i++){
        for(int x = 0;x <= 9;x++){
            if(memo[l][i][x] == 1 && memo[i+1][r][x] == 1){
                memo[l][r][0] = 1;
            }
        }
    }

    return;
}

int main(){
    cin >> n;

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

    memset(memo, -1, sizeof(memo));

    dp(0, n-1);
    if(memo[0][n-1][0] == 1){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a;
  int x;
  while (cin >> x) {
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int prev = 0;
  for (auto i : a) {
    if (prev == i) {
      cout << "NO" << endl;
      return 0;
    }
    prev = i;
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1400
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        HashMap<String, Integer> map1 = new HashMap<>();
        HashMap<String, Integer> map2 = new HashMap<>();

        int n = sc.nextInt();
        for(int i=0; i<n; i++){
            String s = sc.next();
            if(map1.get(s)==null) map1.put(s,0); map2.put(s,0);
            map1.put(s, map1.get(s)+1);
        }
        int m = sc.nextInt();
        for(int i=0; i<m; i++){
            String t = sc.next();
            if(map2.get(t)==null) map2.put(t,0);
            map2.put(t, map2.get(t)+1);
        }
        int max = 0;
        for(String key : map1.keySet()){
            max = Math.max(map1.get(key)-map2.get(key),max);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 22996
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        int n;
        cin >> n;
        vector<double> guz(n);
        for (int i = 0; i < n; ++i) {
            cin >> guz[i];
        }
        sort(all(guz));

        double ans = 0.0;
        for (int i = 0; i + 1 < n; ++i) {
            guz[i + 1] = (guz[i] + guz[i + 1]) / 2.;
        }
        ans = guz.back();
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int K;
  cin >> K;
  int A,B;
  cin >> A >> B;
  srep(k,A,B+1) {
    if(k%K==0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3604
use std::str::FromStr;
use std::io::stdin;
use std::cmp::max;

fn main() {
    let n: usize = read();
    let mut vec: Vec<(usize, usize, usize)> = Vec::new();
    for _ in 0..n {
        let line: Vec<usize> = read_vec();
        vec.push((line[0], line[1], line[2]))
    }
    let mut dp: Vec<Vec<usize>> = Vec::new();
    for i in 0..(n + 1) {
        dp.push(Vec::new());
        for _ in 0..3 { dp[i].push(0); }
    }
    for i in 0..n {
        let (a, b, c) = vec[i];
        dp[i + 1][0] = max(dp[i][1] + a, dp[i][2] + a);
        dp[i + 1][1] = max(dp[i][0] + b, dp[i][2] + b);
        dp[i + 1][2] = max(dp[i][0] + c, dp[i][1] + c);
    }
    let mut mx: usize = 0;
    for i in 0..3 {
        mx = max(mx, dp.last().unwrap()[i])
    }
    println!("{}", mx);
}

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

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


Measured memory_bytes: 14584
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int f(int x) {
    int ans = 0;
    while(x) ans += x % 10, x /= 10;
    return ans;
}
int main() {
    int n;
    scanf("%d", &n);
    int mn = 1e9;
    for(int i = 1; i < n; i++) mn = min(mn, f(i) + f(n - i));
    printf("%d\n", mn);
    return 0;
}

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

int N;
int d = 0;//下1桁

int main() {
/*
  vector<int> data(5);
  for (int i = 0; i < 5; i++) {
    cin >> data.at(i);
  }
*/
cin >> N;

d = N % 10;
if(d==2 || d==4 || d==5 || d==7 || d==9) cout << "hon" << endl;
else if(d==0 || d==1 || d==6 || d==8) cout << "pon" << endl;
else cout << "bon" << endl;

  
}


Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,i,j,k,a,b,c,dp[500000][3],cc[500000][3];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) for (int j=0;j<3;j++) scanf("%d",&cc[i][j]);
	//for (int i=2;i<=n;i++) for (int j=0;j<3;j++) dp[i][j]=9999999999;	
	for (int i=1;i<=n;i++){
		for (int j=0;j<3;j++) for (int k=0;k<3;k++) if (k!=j) dp[i][j]=max(dp[i][j],dp[i-1][k]+cc[i][j]);		
	}
	printf("%d\n",max(dp[n][2],max(dp[n][0],dp[n][1])));
	return 0;
}

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

int main() {

  int N;
  cin >> N;

  int min = 100;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;

    int j = 0;
    while ((A % 2) == 0) {
      A /= 2;
      j++;
    }
    
    if (j == 0)
    {
      min = 0;
      break;
    }
    
    if (min > j) {
      min = j;
    }
  }
  
  cout << min << endl;
}


Measured memory_bytes: 256
n = int(input())
vec = []
for i in range(n):
    vec += [list(map(int, input().split()))]
vec += [vec[0]]
vec += [vec[1]]
Sum = 0
def cross(a, b):
    return a[0]*b[1]-a[1]*b[0]
def ab(a, b):
    c = (b[0]-a[0],b[1]-a[1])
    return c
def check(a, b, c):
    if cross(ab(a, b),ab(a, c)) >= 0:
        return 1
    else:
        return 0
    
for a, b, c in zip(vec[0:-2],vec[1:-1],vec[2:]):
    cnt = check(a,b,c)
    if cnt == 0:
        break
print(cnt)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...
const int maxn = 1e7+1;
int n;
void test_case(){
	cin>>n;
	vector<ll> v(maxn,0);
	for(int i = 1;i<=n;++i){
		for(int j = 1;j*i<=n;++j){
			v[j*i]++;
		}
	}
	ll ans = 0;
	for(int i = 1;i<=n;++i)
		ans += i*v[i];
	
	cout<<ans;
}





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 81348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <sstream>
#include <map>

using namespace std;
typedef long long int lli;

const int INF = 100100100;

int main()
{
    string line, s;
    getline(cin, line);
    istringstream iss(line);

    char c;
    map<char, int> w;
    while (iss >> c) {
        auto itr = w.find(c);
        if( itr != w.end() ) {
            w[c]++;
        } else {
            w[c] = 1;
        }
    }

    bool is_beautiful = true;
    for(auto itr = w.begin(); itr != w.end(); ++itr) {
        if (itr->second % 2 != 0) {
            is_beautiful = false;
            break;
        }
    }

    string ans = (is_beautiful) ? "Yes" : "No";

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

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

using namespace std;

typedef long long ll;

#define FOR(a, b, i) for(int i=a; i<b; i++)
#define RFOR(a, b, i) for(int i=a; i>=b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1e9+7
#define newline cout<<"\n"


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

    string s, t; cin>>s>>t;
    int a = s.length(), b = t.length();

    vector<vector<int> > dp(a+1, vector<int> (b+1, 0));

    FOR(0, a, i)
    {
        FOR(0, b, j)
        {
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            if(s[i]==t[j])
            {
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1);
            }
        }
    }

    string ans = "";

    // FOR(1, a+1, i)
    // {
    //     FOR(1, b+1, j)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     newline;
    // }

    int p = a, q=b;

    while(p>0 && q>0)
    {
        if(dp[p][q-1]==dp[p][q])
        {
            q--;
        }
        else
        {
            if(dp[p-1][q] == dp[p][q])
            {
                p--;
            }
            else
            {
                if(dp[p-1][q-1]<dp[p][q])
                {
                    p--; q--;
                    ans+=s[p];
                }
            }
            
        }
        
        
    }

    reverse(ans.begin(), ans.end());

    cout<<ans;
    newline;


    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	int sum = 0;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	
	if( sum % 10 != 0 ) {
		cout << sum << endl;
		return 0;
	}
	
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if( (sum - a[i]) % 10 != 0 ) {
			ans = max(ans, sum - a[i]);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){

  int A,B,C,D,ans;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  if(B<=C){
    ans = 0;
  }
  if(A<=C && C<=B && B<=D){
    ans = B-C;
    }
    if(A<=C && D<=B){
      ans = D-C;
    }

    if(D<=A){
      ans = 0;
    }
    if(C<=A && A<=D && D<=B){
      ans = D-A;
      }
      if(C<=A && B<=D){
        ans = B-A;
      }
      printf("%d",ans);
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  int a, b;
  cin >> a >> b;
  int answer = 0;

  answer += a-1;

  if(b >= a) answer += 1;

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	double N, X;
	int T;
	cin >> N >> X >> T;

	cout << (int)(ceil(N / X) * T) << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2012;
char s[maxn];int n;
int g[maxn][maxn],vis[maxn];
void pre_dfs(int x,int c){
	if(vis[x]!=-1){
		if(vis[x]!=c){
			puts("-1");
			exit(0);
		}
		return ;
	}
	vis[x] = c;
	for(int i=1;i<=n;i++)
		if(g[x][i])
			pre_dfs(i,c^1);
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=n;j++){
			if(s[j]=='1')g[i][j] = 1;
			else g[i][j] = 0;
		}
	}
	memset(vis,-1,sizeof(vis));
	pre_dfs(1,0);
	int ans = 0;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		if(g[i][j]==0)g[i][j] = 1024;
	for(int k=1;k<=n;k++)
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		g[i][j] = min(g[i][j],g[i][k]+g[k][j]);
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	ans = max(ans,g[i][j]);
	cout << ans+1 << endl;
}

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

int main() {
  long long N,T,A;
  cin >> N >> T >> A;
  long long ans = 0;
  long long mini = 100000000000;
  for (long long i = 0; i < N; i++) {
    long long H;
    cin >> H;
    long long diff;
    diff = T*1000 - H*6 - 1000*A;
    if (diff < 0) diff = -diff;
    if (mini > diff) {
      mini = diff;
      ans = i+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/**/
/*
 * 	Meet me on the battlefield
*/
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const int inf=1e9;
const int mod=1e9+7;
#define dpr(x) cout<<#x<<": "<<x<<endl
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[200005];
int dp[200005][3];
int n;
void solve()
{
	cin>>n;
	int summ=0;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		summ+=a[i];
		if(a[i]==0)
			a[i]--;
	}
	int umax=0;
	for(int i=0; i<=n; i++) {
		dp[i+1][0]=max(dp[i+1][0],a[i+1]-((a[i+1]&1))+dp[i][0]);
		dp[i+1][1]=max(dp[i+1][1],a[i+1]-((a[i+1]&1)==0)+dp[i][1]);
		dp[i+1][1]=max(dp[i+1][1],a[i+1]-((a[i+1]&1)==0)+dp[i][0]);
		dp[i+1][2]=max(dp[i+1][2],a[i+1]-((a[i+1]&1))+dp[i][0]);
		dp[i+1][2]=max(dp[i+1][2],a[i+1]-((a[i+1]&1))+dp[i][1]);
		dp[i+1][2]=max(dp[i+1][2],a[i+1]-((a[i+1]&1))+dp[i][2]);
		for(int j=0; j<3; j++)
			umax=max(umax,dp[i][j]);
	}
	cout<<summ-umax<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}
/**/


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




int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    char a[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];

    rep(i, h) rep(j, w){
        if(a[i][j]=='#')
            break;
        if(j+1==w)
            rep(k, w) a[i][k] = 'x';
    }
    rep(i, w) rep(j, h)
    {
        if (a[j][i] == '#')
            break;
        if (j + 1 == h)
            rep(k, h) a[k][i] = 'x';
    }
    bool q = false;
    rep(i,h){
        rep(j, w) 
            if (a[i][j] != 'x') {
                cout << a[i][j];
                q = true;
            }
        if(q)cout << endl;
        q = false;
    }
        return 0;
}

Measured memory_bytes: 256
pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

fn main(){
    let mut scan = Scanner::new();
    let n = scan.next_string();
    if n[0]=='7' || n[1] == '7' || n[2]=='7'{
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

double p2(double x) {
  return x * x;
}

int main() {
//  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vi x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }
  vd a;
  a.push_back(-M_PI);
  a.push_back(M_PI);
  for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) {
    long double dx = x[j] - x[i], dy = y[j] - y[i];
    a.push_back(atan2(dx, -dy));
    a.push_back(atan2(-dx, dy));
  }
  sort(a.begin(), a.end());
  vd res(n);
  const long double R = 1e13;
  for (int i = 0; i + 1 < a.size(); ++i) {
//    cerr << a[i] << ' ' << a[i+1] << endl;
    long double mid = (a[i] + a[i+1]) / 2;
    long double tx = R * cos(mid), ty = R * sin(mid);
    long double mi = 2 * R * R;
    int best = -1;
    for (int j = 0; j < n; ++j) {
      long double d2 = p2(tx - x[j]) + p2(ty - y[j]);
      if (d2 < mi) {
        mi = d2;
        best = j;
      }
    }
    assert(best >= 0);
    res[best] += (a[i+1] - a[i]) / 2 / M_PI;
  }
  for (int i = 0; i < n; ++i) printf("%.10Lf\n", res[i]);
  return 0;
}

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



 int main(){
    int n,p,q;
    cin>>n>>p>>q;

    vector<int>k(n, 0);
    
    for(int i=0;i<q;i++){
        int x;
        cin>>x;
        k[x-1]++;
    }
   

  for(int i=0;i<n;i++){
    int y=k[i]+p-q;
    if(y>0){
        cout<<"Yes"<<endl;
    }else if(y<=0){
        cout<<"No"<<endl;
    }

    }
    

     

       
 }
    

Measured memory_bytes: 1024
A, B, C = list(map(int, input().split()))
amari = A%B
ptn = [amari]
tmp = amari
while 1:
    tmp = (amari + tmp)%B
    if tmp in ptn:
        if C in ptn:
            print('YES')
            exit()
        else:
            print('NO')
            exit()
    else:
        ptn.append(tmp)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

#define M 1046527
#define L 14

char H[M][L];

int h1(int key) {
  return key % M;
}

int h2(int key) {
  return 1 + (key % (M - 1));
}

int h(int key, int i) {
  return (h1(key) + i * h2(key)) % M;
}

int getChar(char ch) {
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

int getKey(char str[]) {
  int sum = 0;
  int p = 1;
  for (int i = 0; i < strlen(str); i++) {
    sum += p * getChar(str[i]);
    p *= 5;
  }
  return sum;
}

void insert(char str[]) {
  int key;
  int hash;
  int i = 0;
  key = getKey(str);
  while(1) {
    hash = h(key, i++);
    if(strlen(H[hash]) == 0) {
      strcpy(H[hash], str);
      break;
    }
    else if(strcmp(H[hash], str) == 0)
      break;
  }
}

int find(char str[]) {
  int key;
  int hash;
  int i = 0;
  key = getKey(str);
  while(1) {
    hash = h(key, i++);
    if(strlen(H[hash]) == 0)
      return 0;
    else if (strcmp(H[hash], str) == 0)
      return 1;
  }
}

int main(void) {
  int n;
  char command[10];
  char word[L];

  for (int i = 0; i < n; i++)
    H[i][0] = '\0';
  
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", command);
    scanf("%s", word);
    if (command[0] == 'i')
      insert(word);
    else {
      if (find(word))
	printf("yes\n");
      else
	printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 15948