akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 2e5+10;

//head

int n;
int a[N];
ll zero, one, two, fin = LINF;
ll kk;

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

  rep(i, n) {
    ll two_ = min({two + (a[i]?(a[i]&1):2), zero + (a[i]&1)});
    kk = min(kk+(a[i]?(a[i]&1):2), one+!a[i]);
    ll one_ = min({zero, one+(~a[i]&1), two+!a[i]});
    ll zero_ = zero + a[i];
    ll fin_ = min({fin+a[i], zero_, one_, two_, kk});
    two = two_;
    one = one_;
    zero = zero_;
    fin = fin_;
  }

  cout << fin << endl;
}

Measured memory_bytes: 4440
import sys
import math

'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
N=int(input())
li0= [int(x) for x in input().split()]
count=0
for i in range(N-2):
  if (li0[i+1]>li0[i] and li0[i+1]<li0[i+2]):
    count+=1
  if(li0[i+1]<li0[i] and li0[i+1]>li0[i+2]):
    count+=1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  int count = 1;
  int p = 29;
  cout << p;
  int tmp;
  bool prime;
  while(count < n){
    p+= 30;
    tmp = 7;
    prime = true;
    while(tmp < p){
      if(p%tmp == 0){
        prime = false;
        break;
      }
      tmp += 2;
    }
    if(prime){
      cout << " " << p;
      count++;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n;
	while(scanf("%d", &n) != EOF){
		int *arr = new int[n + 1];
		
		for(int i = 2; i <= n; i++){
			if(arr[i] == 0){
				for(int j = 2*i; j <= n; j += i){
					arr[j] = 1;
				}
			}
		}
		
		int cnt = 0;
		for(int i = 2; i <= n; i++){
			if(arr[i] == 0){
				cnt++;
			}
		}
		delete [] arr;
		
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int a,b;
  cin>>a>>b;

  cout<< ( a%3==0 or b%3==0 or (a+b)%3==0 ? "Possible" : "Impossible" )<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s == "Sunny") cout << "Cloudy" << endl;
	if(s == "Cloudy") cout << "Rainy" << endl;
	if(s == "Rainy") cout << "Sunny" << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#include <cmath>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans=0;
  int pre=0;
  rep(i,3){
    if(s[i]=='R'){
      ans++;
      if(ans==1){
        pre=1;
      }
      else if(ans==2){
        pre =2;
      }
    }
    else{
      ans =0;
    }
  }
  if(ans>=pre){
    cout << ans<<endl;
  }
  else{
    cout << pre<<endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

int N;
int M;
long long MOD = 1000000007;

int A[1000];
int B[1000];
bool in_A[1000000];
bool in_B[1000000];

int main(){
    bool no_ans = false;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(in_A[A[i] - 1]){
            no_ans = true;
            break;
        }
        in_A[A[i] - 1] = true;
    }
    sort(A, A + N);
    for(int i = 0; i < M; i++){
        cin >> B[i];
        if(in_B[B[i] - 1]){
            no_ans = true;
            break;
        }
        in_B[B[i] - 1] = true;
    }
    sort(B, B + M);

    if(no_ans){
        cout << 0 << endl;
        return 0;
    }

    long long ans = 1;
    for(int i = M * N; i > 0; i--){
        if(in_A[i -1] && in_B[i - 1]){
            continue;
        } else if(in_A[i - 1]){
            auto it = upper_bound(B, B + M, i);
            ans = (ans * ((long long) M - (long long) (it - B))) % MOD;
        } else if(in_B[i - 1]){
            auto it = upper_bound(A, A + N, i);
            ans = (ans * ((long long) N - (long long) (it - A))) % MOD;
        } else {
            auto it1 = upper_bound(B, B + M, i);
            auto it2 = upper_bound(A, A + N, i);
            long long candidate_pos = ((long long) M - (long long) (it1 - B)) * ((long long) N - (long long) (it2 - A));
            long long left_pos = candidate_pos - (N * M - i);
            ans = (ans * left_pos) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int n = 0;
bool isPrime[55560];
int cnt = 0;
int arr[55500];

void init() {
    isPrime[0] = false;
    isPrime[1] = false;
    isPrime[2] = true;
    for(int i = 2; i <= 55555; i++) {
        if(isPrime[i]) {
            for(int j = 2 * i; j <= 55555; j+=i) {
                isPrime[j] = false;
            }
        }
    }
    for(int i = 2; i <= 55555; i++) {
        if(isPrime[i] && i % 10 == 1) arr[cnt++] = i;
    }
}

int main() {
    fill(isPrime, isPrime + 55556, 1);
    init();
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    return 0;
}


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

int main()
{
  int H,W,D;
  cin >> H >> W >> D;
  int A[H][W];
  int x[H*W];
  int y[H*W];
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> A[i][j];
      x[A[i][j]-1] = i;
      y[A[i][j]-1] = j;
    }
  }
  
  int dis[H*W];
  int Dis[H*W];
  for(int i=0;i<H*W-D;i++){
    dis[i] = abs(x[i+D]-x[i]) + abs(y[i+D]-y[i]);
  }
  for(int i=0;i<H*W;i++){
    if(i<D){
      Dis[i] = 0;
    }
    else{
      Dis[i] = Dis[i-D] + dis[i-D];
    }
  }//for

  int Q;
  cin >> Q;
  int L[Q];
  int R[Q];
  int cost[Q];
  for(int i=0;i<Q;i++){
    cin >> L[i] >> R[i];
    cost[i] = Dis[R[i]-1] - Dis[L[i]-1];
    cout << cost[i] << endl;
  }
}


Measured memory_bytes: 4096
from collections import Counter

# N = 3
# ARR = ["apple", "orange", "apple"]
# BRR = ["grape"]

N = int(input())
ARR = []

for i in range(N):
    ARR.append(input())

M = int(input())
BRR = []

for j in range(M):
    BRR.append(input())


def calculate(a, b):
    result = {}

    for i in a:
        if result.get(i) == None:
            result.__setitem__(i, 1)
        else:
            result.__setitem__(i, result.get(i) + 1)

    for i in b:
        if result.get(i) == None:
            result.__setitem__(i, -1)
        else:
            result.__setitem__(i, result.get(i) - 1)

    print(max(0,max(result.values())))


calculate(ARR, BRR)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 10000
#define MAXK 9

int a,b,c,d;
int main(int argc,char const* argv[])
{
  cin >> a >> b >> c >> d;
  if((a+b)>(c+d))
    {
      cout << "Left" << endl;
    }
  else if((a+b)==(c+d))
    {
      cout << "Balanced" << endl;
    }
  else
    {
      cout << "Right" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
K = int(input())
x_list = [int(i) for i in input().split()]

distance_sum = 0
for x in x_list :
    if (abs(K - x) > x) :
        distance_sum += x*2
    else :
        distance_sum += abs(K-x)*2

print(distance_sum)

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

string prime(int n){
  int i,j;
  string p = "001";
  while((int)p.size()<=n)p+="10";
  i = 3;
  while(i*i<n){
    for(j=3*i;j<n;j+=2*i)p[j] = '0';
    do{i+=2;}while(p[i]-'1');
  }
  return p;
}

int main(){
  int n,c;
  string p;

  p = prime(300000);

  while(1){
    cin >> n;
    if(!n)break;

    c = 0;
    for(int i=n+1;i<=2*n;i++){
      if(p[i] == '1'){
	c++;
      }
    }
    
    cout << c << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
	int i,N,K,ans=1,cnt=0,len=0;
	char S[100001];
	scanf("%d",&N);
	scanf("%d",&K);
	scanf("%s",S);
 
	for(i=0;i<N;++i){
		if(S[i]=='0'){
			if(i==0 || S[i-1]=='1'){
				cnt++;
			}
		}
		if(cnt>K){
			while(S[len]=='1'){
				len++;
			}
			while(S[len]=='0'){
				len++;
			}
			cnt--;
		}
		if(ans<i-len+1)ans=i-len+1;
	}


	printf("%d\n",ans);
}

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

pairs = [set() for i in range(N + 1)]
appeared = set()

for i in range(M):
	x, y, z = map(int, input().strip().split(" "))
	
	pairs[x].add(y)
	pairs[y].add(x)
	
	appeared.add(x)
	appeared.add(y)

count_not_appeared = N - len(appeared)

group_count = 0
while appeared:
	cur = appeared.pop()
	queue = [cur]
	while queue:
		cur = queue.pop()
		for n in pairs[cur]:
			if n in appeared:
				appeared.remove(n)
				queue.append(n)
	group_count += 1

print(count_not_appeared + group_count)



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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  bool A= false;
  if(e-a<=k){
    A=true;
  }
  if(A){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}

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

const int DIM = 1e3 + 5;

long long dst[DIM][DIM];

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= n; i ++ )
    for( int j = 1; j <= n; j ++ )
        if( i != j )
            dst[i][j] = numeric_limits<long long> :: min() / 2;
    
    for( int i = 1; i <= m; i ++ ) {
        int x, y, z;
        cin >> x >> y >> z;
        
        dst[x][y] = z;
    }
    
    for( int k = 1; k <= n; k ++ )
    for( int i = 1; i <= n; i ++ )
    for( int j = 1; j <= n; j ++ )
        dst[i][j] = max( dst[i][j], dst[i][k] + dst[k][j] );
    
    if( dst[1][1] > 0 )
        cout << "inf" << endl;
    else
        cout << dst[1][n] << endl;
        
    return 0;
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MSIZE = 100200;

const long long mod = 1e9 + 7;

long long dp[2][MSIZE];
long long pref[MSIZE];

long long Get(int l, int r) {
    l = max(0, l);
    return (mod + pref[r] - (l ? pref[l - 1] : 0LL)) % mod;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, 0, sizeof dp);
    int n, k;
    cin >> n >> k;
    dp[0][0] = 1;
    long long answer = 1;
    
    int * arr = new int[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }

    for (int i = 1; i <= n; i++) {
        memcpy(pref, dp[(i & 1) ^ 1], sizeof pref);
        for (int u = 1; u <= k; u++) {
            pref[u] += pref[u - 1];
            pref[u] %= mod;
        }
        for (int u = 0; u <= k; u++) {
            dp[i & 1][u] = Get(u - arr[i], u);       
        }
    }
    cout << dp[n & 1][k] << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(){
	int n,i,tmp;
	long long int sum=0,max=-1000000,min=1000000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&tmp);
		if(max<tmp) max=tmp;
		if(min>tmp) min=tmp;
		sum+=tmp;
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}


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

#define int long long
#define x first
#define y second

int n, d;
vector<vector<int>> points;

bool isSq(int x) {
	int y = round(sqrt(x));
	return (y * y == x);
}

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

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

	int cnt = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int D = 0;
			for(int k = 0; k < d; k++)
				D += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);
			if(isSq(D)) cnt++;
		}
	}

	cout << cnt << endl;
}




















































Measured memory_bytes: 256
#include <stdio.h>

int f(int n){

	int ret=0;

	while(n>0){
	ret+=n%10;
	n/=10;
	}
	return ret;
}

int main(){

	int N;

	scanf("%d",&N);

	if(N%f(N)==0){printf("Yes\n");}
	else{printf("No\n");}

	return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1e6+10;
int b[N],r[N];
bool a[N];
int t;
inline int gcd(int x,int y){
	if(!y)
		return x;
	if(x<y)
		swap(x,y);
	return gcd(y,x%y);
}
inline void fj(int x){
	for(int i=1;x!=1&&i<=t;i++)
		if(!a[x]){
			b[x]++;
			return ;
		}
		else if(x%r[i]==0){
			if(x%r[i]==0)
				b[r[i]]++;
			while(x%r[i]==0)
				x/=r[i];
		}
}
int main(){
	a[0]=a[1]=true;
	for(int i=2;i<N;i++)
		if(!a[i]){
			r[++t]=i;
			for(int j=2;j*i<N;j++)
				a[i*j]=true;
		}
	int n;
	cin>>n;
	int x;
	scanf("%d",&x);
	fj(x);
	int k=x;
	for(int i=1;i<n;i++){
		scanf("%d",&x);
		fj(x);
		k=gcd(k,x);
	}
	if(k!=1){
		cout<<"not coprime\n";
		return 0;
	}
	for(int i=1;i<=t;i++)
		if(b[r[i]]>1){
			cout<<"setwise coprime\n";
			return 0;
		}
	cout<<"pairwise coprime\n";
}


Measured memory_bytes: 8876
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

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

    if (A[A.size() - 1] == B[0] and B[B.size() - 1] == C[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3624
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize,
        m: usize,
    }

    let mut dsu = DSU::new(n + 1);
    for _ in 0..m {
        input!{a: Usize1, b: Usize1}
        dsu.merge(a, b);
    }
    let mut h = std::collections::HashSet::new();
    for i in 0..n {
        h.insert(dsu.top(i));
    }
    println!("{}", h.len() - 1);
}

struct DSU {
    n: usize,
    parent: Vec<Option<usize>>,
    rank: Vec<usize>,
}

impl DSU {
    fn new(n: usize) -> Self {
        Self {
            n,
            parent: vec![None; n],
            rank: vec![1; n],
        }
    }

    fn merge(&mut self, u: usize, v: usize) {
        assert!(u < self.n);
        assert!(v < self.n);

        let (up, vp) = (self.top(u), self.top(v));
        if up != vp {
            let (p, c) = if self.rank[up] > self.rank[vp] { (up, vp) } else { (vp, up) };
            self.rank[p] += self.rank[c];
            self.rank[c] = 0;
            self.parent[c] = Some(p);
        }
    }

    #[allow(unused)]
    fn same(&mut self, u: usize, v: usize) -> bool {
        assert!(u < self.n);
        assert!(v < self.n);

        self.top(u) == self.top(v)
    }

    fn top(&mut self, u: usize) -> usize {
        assert!(u < self.n);

        if let Some(p) = self.parent[u] {
            let p = self.top(p);
            self.parent[u] = Some(p);
            p
        } else {
            u
        }
    }
}


Measured memory_bytes: 6160
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(){
    string s1 = "";
    string s2 = "";
    cin >> s1>>s2;
    int cnt = 0;
    for(int i =0;i < 3; i++){
        if(s1[i] == s2[i])cnt++;
    }
    cout << cnt<<"\n";
    return 0;
}


Measured memory_bytes: 256
/**
ID: albert.28
LANG: C++14
PROB: poetry
**/

/// Time:

#include <bits/stdc++.h>

/**
Mod operations in O(lg n)
Source: Benjamin Qi, https://github.com/bqi343/USACO/blob/master/Implementations/11%20-20(4)/Operators/modOp.cpp?fbclid=IwAR0m2afS-1xVg9kgeF8q8EJIeP9TP3Lct8dYb_hPJuI5gqHP1Utp5EkiOQ8
**/

using namespace std;

#define MAXN 2005
#define MOD 1000000007

#define FOR(g,i,n) for(int i = g; i < n; i++)
#define FORD(g,i,n) for(int i = g; i >= n; i--)

#define apple() ios_base::sync_with_stdio(0)
#define hentai() cin.tie(); cout.tie()

#define mp make_pair
#define pb push_back
#define	ll long long
// #define int ll
#define INF (1e9*1)+5
#define LL_INF (1e18*1)+5
#define bitinc(s) (s&-s)
#define endl '\n'

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mi;
#define f first
#define s second
typedef vector<pii> vii;
typedef set<pii> sii;
typedef map<pii, pii> mii;

void fileio(char* in, char* out)
{
	freopen(in, "r", stdin);
	freopen(out, "w", stdout);
}

namespace modOp
{
    int ad(int a, int b, int mod = MOD) { return (a+b)%mod; }
    int sub(int a, int b, int mod = MOD) { return (a-b+mod)%mod; }
    int mul(int a, int b, int mod = MOD) { return (ll)a*b%mod; }

    int AD(int& a, int b, int mod = MOD) { return a = ad(a,b,mod); }
    int SUB(int& a, int b, int mod = MOD) { return a = sub(a,b,mod); }
    int MUL(int& a, int b, int mod = MOD) { return a = mul(a,b,mod); }

    int po (int b, int p, int mod = MOD) { return !p?1:mul(po(mul(b,b,mod),p/2,mod),p&1?b:1,mod); }
    int inv (int b, int mod = MOD) { return po(b,mod-2,mod); }

    int invGeneral(int a, int b) { // 0 < a < b, gcd(a,b) = 1
        if (a == 0) return b == 1 ? 0 : -1;
        int x = invGeneral(b%a,a);
        return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;
    }
}

using namespace modOp;

int n,m;
bool grid[MAXN][MAXN];
int dp[4][MAXN][MAXN]; // 0->u, 1->l, 2->d, 3->r
int main()
{
	apple();
	hentai();
	cin >> n >> m;
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++)
	{
		char c;
		cin >> c;
		grid[i][j] = c=='.';
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(grid[i][j])
			{
				if(i==0) dp[0][i][j] = 1;
				else dp[0][i][j] = dp[0][i-1][j]+1;
				if(j==0) dp[1][i][j] = 1;
				else dp[1][i][j] = dp[1][i][j-1]+1;
			}
		}
	}
	for(int i = n-1; i >= 0; i--)
	{
		for(int j = m-1; j >= 0; j--)
		{
			if(grid[i][j])
			{
				if(i==n-1) dp[2][i][j] = 1;
				else dp[2][i][j] = dp[2][i+1][j]+1;
				if(j==m-1) dp[3][i][j] = 1;
				else dp[3][i][j] = dp[3][i][j+1]+1;
			}
		}
	}
	int w = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			int our_sum = 0;
			for(int k = 0; k < 4; k++) our_sum += dp[k][i][j];
			w = max(w, our_sum);
		}
	}
	cout << w-3 << endl;
}


Measured memory_bytes: 66944
#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n,a,b; cin >> n >> a >> b;
  int ans = 0;
  for(int i = 0; i <= n; i++){
    int res = 0, j = i;
    while(j > 0){
      res += j%10;
      j /= 10;
    }
    if(a <= res && res <= b) ans += i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
(let* ((n (read))
       (k (read))
       (s 0)
       (l (make-array n)))
      (dotimes (i n)
        (setf (aref l i) (read)))
      (if (<= n k)
          (princ 0)
          (let ()
               (setf l (sort l #'<))
               (dotimes (i (- n k))
                 (incf s (aref l i)))
               (princ s))))

Measured memory_bytes: 69348
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	int len, i = 0, k;
	string s;
	cin >> len >> s >> k;
	k--;
	for (; i < len; i++) {
		if (s[i] == s[k])
			cout << s[i];
		else
			cout << "*";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)










vector<vector<ll>> g;
ll xorsum = 0;
 
ll dfs(ll now, ll par){
    ll res = 0;
    for(auto &child : g[now]){
        if(child == par) continue;
        res ^= dfs(child, now) + 1;
    }
    return res;
}
 
 
 
int main(){
    ll n;
    cin >> n;
    g.resize(n);
    REP(i, n - 1){
        ll x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    cout << (dfs(0, -1)? "Alice" : "Bob") << endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n;
	cin>>n;
	int b[n-1];
	for(int i=0;i<n;i++) cin>>b[i];
	ll sum=0;
	vector<int>a(n);
	a[0]=b[0];
	a[n-1]=b[n-2];
	for(int i=1;i<n-1;i++){
		a[i]=min(b[i-1],b[i]);
	}
	for(int i=0;i<n;i++) sum+=a[i];
	cout<<sum<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 100
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?
typedef long long ll;
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)

int main() {
    int N, i;
    ll K;
    scanf("%d %lld", &N, &K);
    int *A = array(N, int);
    char *visit = array(N, char);
    int *way = array(N, int);

    rep(i, N) {
        scanf("%d", A + i);
        A[i]--;
    }

    int head = -1, r = -1, loop = 0;
    way[0] = 0;
    visit[0]++;
    for (i = 1; i < N; i++) {
        head = way[i] = A[way[i - 1]];
        if (++visit[head] > 1) break;
    }
    free(A);
    free(visit);
    rep(i, N) {
        if (way[i] == head) {
            if (r == -1) r = i;
            else {
                loop = i - r;
                break;
            }
        }
    }
    if (K < i) printf("%d\n", way[K] + 1);
    else printf("%d\n", way[r + (K - r) % loop] + 1);
    free(way);
    return 0;
}

void printa_int(int *a, int size) {
    int i;
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("\n");
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int x=101;
    int sum=0;
    for (int i=0;i<n;i++){
        int s;
        cin>>s;
        sum+=s;
        if(s%10!=0&&x>s) x=s;
    }
    
    int ans;
    if (sum%10!=0) ans=sum;
    else if(x!=101) ans=sum-x;
    else ans=0;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { cout << -1 << '\n'; exit(0); }
// const int INF  = 1<<30;
const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll x, k, d; cin >> x >> k >> d;

  x = abs(x);


  ll ans = INFll;
  if (k <= x / d) {
    chmin(ans, x - k * d);
    cout << ans << '\n';
    return 0;
  }

  if (k % 2 == x / d % 2) chmin(ans, x % d);
  else chmin(ans, abs(x % d - d));
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3576
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int m, d;
	while(cin >> m >> d && m)
	{
		int month[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

		rep(i, m-1)
			d += month[i];

		switch(d%7)
		{
		case 1:
			cout << "Thursday" << endl;
			break;
		case 2:
			cout << "Friday" << endl;
			break;
		case 3:
			cout << "Saturday" << endl;
			break;
		case 4:
			cout << "Sunday" << endl;
			break;
		case 5:
			cout << "Monday" << endl;
			break;
		case 6:
			cout << "Tuesday" << endl;
			break;
		case 0:
			cout << "Wednesday" << endl;
			break;
		}
	}
}

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

#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define int long long int
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define INF 200001
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    double a, b;
    cin >> a >> b;
    if (sqrt(a * a + b * b) <= d)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

int solve(int N, std::vector<int> D)
{
    N++;
    D.emplace_back(0);
    
    if (N > 24) {
        return 0;
    }
    
    std::vector<int> cnt(13);
    for (int i = 0; i < N; i++) {
        cnt[D[i]]++;
        if (cnt[D[i]] == 3) {
            return 0;
        }
    }

    if (N > 12) {
        return 1;
    }
    
    int ret = 0;
    for (int i = 0; i < (1 << N); i++) {
        std::vector<int> d(N, 0);
        for (int j = 0; j < N; j++) {
            if (i >> j & 1) {
                d[j] = D[j] % 24;
            } else {
                d[j] = (24 - D[j]) % 24;
            }
        }
        
        int score = 10000000;
        for (int j = 0; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                int min, max;
                std::tie(min, max) = std::minmax(d[j], d[k]);
                
                int diff = std::min((max - min) % 24, (24 - (max - min)) % 24);
                
                score = std::max(0, std::min(score, diff));
            }
        }

        
        ret = std::max(ret, score);
    }
    
    return ret;
}

int main()
{
    int N;
    std::cin >> N;
    
    std::vector<int> D(N);
    for (int i = 0; i < N; i++) {
        std::cin >> D[i];
    }
    
    std::cout << solve(N, D) << std::endl;

    return 0;
}


Measured memory_bytes: 384
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif

int rohan, papa;
cin>>rohan>>papa;
int arr[1+rohan*2];
int x=rohan+rohan-1;
int first=papa-rohan+1;
for(int i=0;i<x;i++){
	cout<<first<<" ";
	first++;
}




	

return 0;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

  vector<mint> nums(K, 0);
  for(ll i = K; i > 0; i--) {
    mint l = mint(int(K / i));
    l = l.pow(N);
    
    for (ll j = 2 * i; j <= K; j += i) {
      l -= nums[j - 1];
    }
    nums[i - 1] = l;
  }
  mint ans = mint(0);
  for (ll i = 0; i < K; i++) ans += mint(i + 1) * nums[i];
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x*res);
    x=(x*x);    
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}

void solve(){  
    int n,m;
    cin>>n>>m;
    int h[n+1];
    
    forn(i,1,n+1)
    cin>>h[i];
    
    set<int> st[n+1];
    forn(i,0,m){
        int u,v;
        cin>>u>>v;
        st[u].insert(v);
        st[v].insert(u);
    }
    int ans=0;
    forn(i,1,n+1){
        bool flag=true;
        for(auto u:st[i]){
            if(h[u]>=h[i]){
                flag=false;
                break;
            }
        }
        if(flag)
        ans++;
    }
    cout<<ans;
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
   
   while(test--)
   solve();
}

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/



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

int main(){
  int n,w;
  cin>>n>>w;
  vector<ll>weight(n);
  vector<ll>value(n);
  for(int i=0;i<n;i++){
    cin>>weight[i]>>value[i];
  }
  vector<ll>dp(w+1);
  for(int i=0;i<n;i++){
   	for(int j=w-weight[i];j>=0;j--){
    	dp[weight[i]+j]=max(dp[weight[i]+j],dp[j]+value[i]); 
    }
  }
  ll maxa=0;
  for(int i=0;i<w+1;i++){
    maxa=max(dp[i],maxa);
  }
  cout<<maxa<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <queue>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;


int main() {

  int N, A, B;

  cin >> N;

  if (N == 1) {
    cout << "Hello World" << endl;
  }
  else {
    cin >> A >> B;
    cout << A + B << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N = int(input())
D, X = list(map(int, input().split()))
A = [0]*(N+1)
for i in range(1, N+1):
    A[i] = int(input())
ans = X
for i in range(1, N+1):
    day = 1
    while day <= D:
        ans += 1
        day += A[i]
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
int main(){
    int n,i,j,q,p,tmp;
    int g[101][101]={};
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&q,&p);
        for(j=0;j<p;j++){
            scanf("%d",&tmp);
            g[q][tmp]=1;
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            if(j-1) printf(" ");
            printf("%d",g[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define ld long double
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
int dp[100005];
int main()
{
	//dp[0]=0;
	int n,k;
	cin>>n>>k;
	int a[n+1];
	fr(i,1,n)
	{
		cin>>a[i];
	}
	fr(i,0,k)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[j]<=i&&dp[i-a[j]]==0)
			{
				dp[i]=1;
			}
		}
	}
	if(dp[k])
	cout<<"First";
	else
	cout<<"Second";
	return 0;
}





Measured memory_bytes: 4048
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	int A, B;
	cin >> A >> B;


	if (A == B) {
		for (int i = 0; i < A; i++) {
			cout << B;
		}
	}
	else if (A > B) {
		for (int i = 0; i < A; i++) {
			cout << B;
		}
	}
	else {
		for (int i = 0; i < B; i++) {
			cout << A;
		}
	}




}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] P = new int[N];
    for (int i = 0; i < N; i++) P[i] = sc.nextInt();
    int ans = 0;
    for (int i = 1; i + 1 < N; i++) {
      if (P[i] > P[i - 1] && P[i] < P[i + 1] || P[i] < P[i - 1] && P[i] > P[i + 1]) ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
A, B, C, D = map(int, input().split())

while A or C > 0:
    aoki_hitpoint = C - B
    if aoki_hitpoint <= 0:
        C = 0
        print("Yes")
        exit()
    else:
        C = aoki_hitpoint

    takahashi_hitpoint = A - D
    if takahashi_hitpoint <= 0:
        print("No")
        A = 0
        exit()
    else:
        A = takahashi_hitpoint

Measured memory_bytes: 9188
#include <iostream>

using namespace std;

const int NMAX=100*100,L=100;
int nbLig,nbCol,nbCouleurs,nbCases[NMAX],terrain[L][L];

int main(){
    int lig=0,col=0,couleur=0,dCol=1;
    cin >> nbLig >> nbCol >> nbCouleurs;
    for(int i=0;i<nbCouleurs;i++){
        cin >> nbCases[i];
    }

    while(nbLig>lig){
        if(col>=nbCol || 0>col){
            lig++;
            if(lig%2==0){
                col=0;
                dCol=1;
            }
            else{
                col=nbCol-1;
                dCol=-1;
            }
        }
        else{
            terrain[lig][col]=couleur+1;
            nbCases[couleur]--;
            if(nbCases[couleur]==0){
                couleur++;
            }
            col+=dCol;
        }
    }

    for(int i=0;i<nbLig;i++){
        for(int j=0;j<nbCol;j++){
            cout << terrain[i][j] << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
/* All men have limits. They learn what they are and learn
   not to exceed them, I ignore mine. -Batman           */

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


int main(){

	int i,j;
	long long sum;
	int n;
	while(scanf("%d", &n) != EOF){
		i = 0;
		sum = 0;
		while( i != 600){
			sum += n*i*i;
			i += n;
		}
		printf("%lld\n", sum);
	}

return 0;
}

Measured memory_bytes: 3164
s = input().strip()
len_s = len(s)

# odd: white
rep1 = 0
for i in range(len_s):
    if (i % 2 == 0):
        if (s[i] == "0"):
            rep1 += 1
    else:
        if (s[i] == "1"):
            rep1 += 1

# even: white
rep2 = 0
for i in range(len_s):
    if (i % 2 == 0):
        if (s[i] == "1"):
            rep2 += 1
    else:
        if (s[i] == "0"):
            rep2 += 1

print(min(rep1, rep2))


Measured memory_bytes: 40432
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
const int N=2010,O=1000000007;
int f[N];
int main(){
	int n=ni,m=ni,d=ni;
	f[0]=1;
	lint ans=0;
	for(int i=1,ti=(n+m-1)/(d-1);i<=ti;i++){
		for(int j=min((d-1)*i,n),tj=max((d-1)*i-(m-1),0);j>=tj;j--){
			lint tmp=0;
			for(int k=min(d-1,j);k;k--){
				tmp+=f[j-k];
			}
			if((n-j)%(d-1)==0){
				ans+=tmp%O;
			}
			f[j]=(f[j]+tmp)%O;
		}
	}
	printf("%lld\n",ans%O);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define vvv(type, c, m, n, l, i) vector<vector<vector<type>>> c(m, vector<vector<type>>(n, vector<type>(l, i)));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n; cin >> n;
	int b, f, r, v;
	vvv(int, a, 5, 4, 11, 0);
	rep(i, 0, n) {
		cin >> b >> f >> r >> v;
		a[b][f][r] += v;
	}
	rep(i, 1, 5) {
		rep(j, 1, 4) {
			rep(k, 1, 11) {
				cout << " " << a[i][j][k];
			}
			P("");
		}
		if (i < 4) P("####################");
	}
	return 0;
}

Measured memory_bytes: 3216