akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

struct mint {
    // Preparation: MOD is already defined.
    ll value;

    mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(mint m) const {
        return pow(m.value);
    }

    mint inv() const {
        ll a = value, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        return u;
    }

    mint &operator+=(const mint a) {
        if ((value += a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((value += MOD - a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (value *= a.value) %= MOD;
        return *this;
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    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 operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

mint dp[220000];
int main() {
    int n, m;
    cin >> n >> m;
    vi a(m);
    vector<bool> ok(n + 1, true);
    rep(i, m) {
        cin >> a[i];
        ok[a[i]] = false;
    }

    dp[0] = 1;
    rep(i, n) {
        repeat(j, i + 1, min(n, i + 2) + 1) {
            if (ok[j])
                dp[j] += dp[i];
        }
    }

    out(dp[n].value);
}


Measured memory_bytes: 2304
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
    int n;
    scanf("%d", &n);
    int aa[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", aa + i);
    }
    int c = 0;
    while (true) {
        for (int i = 0; i < n; i++) {
            int a = aa[i];
            if (a & 1) goto end;
            aa[i] = a >> 1;
        }
        c++;
    }
end:
    printf("%d\n", c);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = "Good";
		for(int i = 0 ; i < s.length() - 1 ; i++) {
			if(s.charAt(i) == s.charAt(i + 1))
				ans = "Bad";
		}
		sc.close();
		System.out.println(ans);

	}
}



Measured memory_bytes: 35592
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  vector <int> a;
  a.push_back(0);
  int p = 0;
  int q = 0;
  int vl = 0, vr = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      p++;
      q++;
    } else if (s[i] == '1') {
      p--;
      q--;
    } else {
      p--;
      q++;
    }
    vl = min(vl, p);
    vr = min(vr, q);
  }
  const int inf = 1e9 + 7;
  auto f = [&] (int x, string s) {
    int q = 0;
    vector <int> st;
    bool bad = false;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        q++;
      } else if (s[i] == '1') {
        q--;
      } else {
        st.push_back(i + 1);
        s[i] = '1';
        q--;
      }
      while (q < x && !st.empty()) {
        int i = st.back();
        st.pop_back();
        s[i - 1] = '0';
        q += 2;
      }
      if (q < x) {
        bad = true;
      }
    }
    q = 0;
    vector <int> a = {0};
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        q++;
      } else {
        q--;
      }
      a.push_back(q);
    }
    return *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end());
  };
  int ans = 1e9;
  if (n <= 10000) for (int i = vl; i <= vr; i++) ans = min(ans, f(i, s));
  auto ok = [&] (int y) {
    int me = f(y, s);
    for (int lg = (1 << 20); lg > 0; lg /= 3) {
      bool ch = true;
      while (ch) {
        ch = false;
        int go = f(y + lg, s);
        if (go < me) {
          ch = true;
          me = go;
          y += lg;
        }
        go = f(y - lg, s);
        if (go < me) {
          ch = true;
          me = go;
          y -= lg;
        }
      }
    }
    ans = min(ans, me);
  };
  ok(vl);
  ok(vr);
  while (clock() / (double) CLOCKS_PER_SEC <= 1.9) {
    ans = min(ans, f(vl, s));
    vl++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 17136
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split().Select(int.Parse).ToArray();
        var segtree = new SegmentTree<int>(A, 0, GCD);
        var ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans = Max(ans, GCD(segtree.Query(0, i), segtree.Query(i + 1, N)));
        }
        WriteLine(ans);
    }

    static int GCD(int a, int b)
    {
        while (b != 0)
        {
            var c = a;
            a = b;
            b = c % b;
        }
        return a;
    }
}

public class SegmentTree<T>//Tがstring以外の参照型だとEの扱いが･･･単位元に対する書き換えは起こらない保証ある･･･？
{
    T[] buffer;
    int N;
    T IE;
    Func<T, T, T> Op;//デリゲート遅そう　

    public SegmentTree(T[] init, T E, Func<T, T, T> op)
    {
        N = init.Length;
        buffer = new T[N * 2 - 1];
        Array.Copy(init, 0, buffer, N - 1, init.Length);
        for (int i = N - 2; i >= 0; i--)
        {
            buffer[i] = op(buffer[i * 2 + 1], buffer[i * 2 + 2]);
        }
        Op = op;
        IE = E;
    }

    public void Update(int index, T value)//[0, N)アクセス可
    {
        index += N - 1;
        buffer[index] = value;
        while (index > 0)
        {
            index = (index - 1) / 2;
            buffer[index] = Op(buffer[index * 2 + 1], buffer[index * 2 + 2]);
        }
    }

    public T this[int index]
    {
        set//setの式形式はC#7.0以降
        {
            Update(index, value);
        }
        get
        {
            return buffer[index + N - 1];
        }
    }

    public T Query(int l, int r)
    {
        var lv = IE;
        var rv = IE;
        l += N - 1;
        r += N - 1;
        while (l < r)
        {
            if ((l & 1) == 0)
            {
                lv = Op(lv, buffer[l]);
            }
            if ((r & 1) == 0)
            {
                rv = Op(buffer[r - 1], rv);
            }
            l /= 2;
            r = (r - 1) / 2;
        }
        return Op(lv, rv);
    }
}


Measured memory_bytes: 26972
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        int cnt = 0;
        for (int i = 0; i < S.length()/2; i++){
            if (S.charAt(i) != S.charAt(S.length()-i-1)){
                cnt ++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=200010;
//const ll mod=1e9+7;
const ll mod=998244353;

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(){
  int n,s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }

  vector<vector<vector<mint>>> dp(3010, vector<vector<mint>>(3010, vector<mint>(3,0)));
  dp[0][0][0]=1;
  rep(i,n)rep(j,s+1){
    dp[i+1][j][0] += dp[i][j][0];
    dp[i+1][j][1] += dp[i][j][1];
    dp[i+1][j][2] += dp[i][j][2];
    if(j+a[i]<=s){
      dp[i+1][j+a[i]][1] += dp[i][j][0] * (i+1);
      dp[i+1][j+a[i]][2] += dp[i][j][0] * (i+1) * (n-i);
      dp[i+1][j+a[i]][1] += dp[i][j][1];
      dp[i+1][j+a[i]][2] += dp[i][j][1] * (n-i);
    }
  }
  ll ans = dp[n][s][2].x;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 496000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  int ans=0;
    for(int i=0;i<3;i++){
    if(s.at(i)=='R'){
      ans++;
      break;
    }
  }
  for(int i=0;i<2;i++){
    if(s.at(i)=='R' && s.at(i+1)=='R'){
      ans++;
      break;
    }
  }
    if(s.at(0)=='R' && s.at(1)=='R'&&s.at(2)=='R'){
      ans++;
  }
  cout << ans;
}

Measured memory_bytes: 3600
n = int(input())
t, a = input().split()
t = int(t)
a = int(a)
h = []
h = input().split()
for i in range(n):
    h[i] = int(h[i])
realans = 0
diff = abs(t- (h[0]* 0.006)-a)
temp = 0
for i in range(n):
    temp = t- (h[i]* 0.006)
    if diff >= abs(temp-a):
        diff = abs(temp-a)
        realans = i + 1
    
print(realans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define all(x) (x).begin(), (x).end()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N;
int O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
int ans = 0;
map<char, char> beats = {{'r', 'p'}, {'s', 'r'}, {'p', 's'}};
map<char, int> hands;
string t;
vector<char> memo;

void process(int i) {
    memo[i] = t[i];
    ans += hands[beats[t[i]]];
}

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

	cin >> N >> K >> hands['r'] >> hands['s'] >> hands['p'] >> t;
    memo.resize(N);
    
    rep(i, N) {
        if (i < K) {
            process(i);
        } else if (t[i] != memo[i-K]) {
            process(i);
        }
    }

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

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

ll sa(ll a, ll b, ll c) {
	return (max(a, max(b, c)) - min(a, min(b, c)));
}


int main(void) {
	
	ll H, W; cin >> H>> W;

	ll ans = 1<<31-1;

	//最初横、次縦

	for (ll i = 1; i <= H - 1; i++) {

		ll Sa = W*i;
		ll Sb = (H - i)*(W / 2);
		ll Sc = (H - i)*(W - W / 2);

		ans = min(ans, sa(Sa, Sb, Sc));
	}

	//最初横、次も横
	for (ll i = 1; i <= H - 2; i++) {

		ll Sa = W*i;

		ll Hs = (H - i);

		ll Sb = Hs/ 2 * W;
		ll Sc = (Hs - Hs / 2)*W;

		ans = min(ans, sa(Sa, Sb, Sc));
	}


	swap(H, W);
	//最初横、次縦


	for (ll i = 1; i <= H - 1; i++) {

		ll Sa = W*i;
		ll Sb = (H - i)*(W / 2);
		ll Sc = (H - i)*(W - W / 2);

		ans = min(ans, sa(Sa, Sb, Sc));
	}

	//最初横、次も横
	for (ll i = 1; i <= H - 2; i++) {

		ll Sa = W*i;

		ll Hs = (H - i);

		ll Sb = Hs / 2 * W;
		ll Sc = (Hs - Hs / 2)*W;

		ans = min(ans, sa(Sa, Sb, Sc));
	}


	cout << ans << endl;

	return 0;
}

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

struct node{
	int num;
	node* next;
	node* prev;
};

int main(){
	
	int order_num;
	char order[10];
	int val;
	node* p = (node*)malloc(sizeof(node));
	node* origin = p;
	origin->next = NULL;
	origin->prev = NULL;
	origin->num = 0;
	cin >> order_num;
	const int test = order_num;

	for(int i = 0; i < test; i++){
		cin >> order;
		//cout << i << "/" << test << ":" << order << endl;
		if(order[0] == 'i'){
			cin >> val;
			p->num = val;
			p->next = (node*)malloc(sizeof(node)); 
			p->next->prev = p;
			p->next->next = NULL;
			p->next->num = 0;
			p = p->next;
		}else if(order[6] == 'F'){
			if(p->prev == origin){
				free(origin);
				origin = p;
				p->prev = NULL;
			}else{
				p->prev = p->prev->prev;
				free(p->prev->next);
				p->prev->next = p;
			}
		}else if(order[6] == 'L'){
			origin = origin->next;
			free(origin->prev);
			origin->prev = NULL;
		}else{
			cin >> val;
			node* p2 = p;
			do{
				p2 = p2->prev;
				if(p2->num == val){
					if(p2->prev == NULL){
						origin = origin->next;
						free(origin->prev);
						origin -> prev = NULL;
					}else{
						p2->next->prev = p2->prev;
						p2->prev->next = p2->next;
						free(p2);
					}
					break;
				}
			}while(p2->prev != NULL);
		}

		
	
	}


	if(p != origin){
		p = p->prev;
		while(p->prev != NULL){
			free(p->next);
			cout << p->num << " ";
			p = p->prev;
		}
		cout << p->num << endl;
	}
	free(p);
	
	return 0;
}

Measured memory_bytes: 32444
n=int(input())
a=list(map(int,input().split()))
dp=[0]*n
i,j,k=1,1,0
p=n//2
dp[p]=a[0]
if n%2==0:
  while i+j-1!=n:
    if k%2==0:
      dp[p-i]=a[i+j-1]
      i+=1
      k=1
    else:
      dp[p+j]=a[i+j-1]
      j+=1
      k=0
  print(*dp)
else:
  while i+j-1!=n:
    if k%2==0:
      dp[p+i]=a[i+j-1]
      i+=1
      k=1
    else:
      dp[p-j]=a[i+j-1]
      j+=1
      k=0
  print(*dp)

Measured memory_bytes: 30984
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, a[N], dp[N], K;
	cin >> n >> K;
	dp[1] = 0;
	for (int i=1; i<=n; i++) {
        cin >> a[i];
        if (i == 1) {
            continue;
        }
        dp[i] = 1e9;
        for (int j=i-1; j>=max(i-K, 1); j--)
            dp[i] = min(dp[i], dp[j] + abs(a[i]-a[j]));
	}
	cout << dp[n];
    return 0;
}


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


void bubbleSort(int A[], int N) {
	bool flag = true;

	int counter = 0;
	while(flag) {
		flag = false;
		for(int j=N-1;j>=0;j--) {
			if(A[j] < A[j-1]) {
				int tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				flag = true;
				counter++;
			}
		}
	}

	for(int i=0;i<N;i++) {
		cout << A[i];
		if(i!=N-1) {
			cout << " ";
		}
	}
	cout << endl;
	cout << counter << endl;

}


int main(void) {

	int n;
	cin >> n;

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

	bubbleSort(a, n);


	return 0;
}

Measured memory_bytes: 1160
a,b=map(int,input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)
  
ans=1+len(prime_factorize(a)&prime_factorize(b))
print(ans)

Measured memory_bytes: 38512
import sys
import random
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n, k = map(int,input().split())
s = input().rstrip()
ans = []
if s[0] == "0":
    ans.append(0)
    mae = "0"
else:
    mae = "1"
b = 0
for i in range(n):
    if s[i] == mae:
        b += 1
    else:
        ans.append(b)
        if mae == "0":
            mae = "1"
        else:
            mae = "0"
        b = 1
else:
    if b:
        ans.append(b)
rui = [0]*(len(ans)+1)
for i in range(len(ans)):
    rui[i+1] = ans[i] + rui[i]
MAX = 0
if len(ans[1::2]) <= k:
    print(n)
    exit()
for i in range(len(ans)+1):
    try:
        if i %2 == 0:
            MAX = max(rui[i+2*k+1]-rui[i],MAX)
        else:
            pass
    except:
        if i %2 == 0:
            MAX = max(rui[len(ans)]-rui[i],MAX)    
print(MAX)

Measured memory_bytes: 8772
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
    long long N, M, a[51], b[51], c[51], d[51], i, j, k, min=1e11;

    cin >> N >> M;

    for(i=1; i<=N; i++){
        cin >> a[i] >> b[i];
    }

    for(i=1; i<=M; i++){
        cin >> c[i] >> d[i];
    }

    for(i=1; i<=N; i++){ // 学生
        min = 1e11;
        
        for(j=1; j<=M; j++){
            if(abs(a[i]-c[j])+abs(b[i]-d[j]) < min){
                min = abs(a[i]-c[j])+abs(b[i]-d[j]);

                k = j;
            }
        }

        cout << k << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC diagnostic ignored "-Wunused-result"
#define NDEBUG

#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstdio>
#include <vector>

#ifdef NDEBUG
#  define debug(...)
#else
#  define debug(...)                                \
  do {                                              \
    fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
    fprintf(stderr, __VA_ARGS__);                   \
    fputc('\n', stderr);                            \
  } while (false)
#endif

using namespace std;

int main() {
  int K;
  scanf("%d", &K);
  printf("%d\n", (K/2) * ((K+1)/2));
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    long long int n,a,c=0;
    scanf("%lld",&n);
    for(a=1;a<=n;a++)
    {
    if(a%3==0 || a%5==0)
    {
        c=c+0;
    }
    else
        {
            c=c+a;
        }
    }
        printf("%lld\n",c);
    c=0;
    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>

int selectionSort(int A[], int N) {
  int i, j, swap_medium, swap_cnt = 0, minj;
  for (i = 0; i < N - 1; i++) {
    // iからN-1までの、はじめに見つかる最小値の位置minjを得る
    minj = i;
    for (j = i; j < N; j++) {
      if (A[j] < A[minj]) minj = j;
    }
    // 最小のminjと端のiの値を交換する
    swap_medium = A[i]; A[i] = A[minj]; A[minj] = swap_medium;
    // minj = iでなければ交換があるので記録する
    if (minj != i) swap_cnt++;
  }
  return swap_cnt;
}

int main() {
  // 宣言 & 入力
  int N, i, swap_cnt;
  scanf("%d", &N);
  int A[N];
  for (i = 0; i < N; i++) scanf("%d", &A[i]);
  // 実行
  swap_cnt = selectionSort(A, N);
  //出力
  for (i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", swap_cnt);

  return 0;
}



Measured memory_bytes: 2076
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,m,dis[5010],l[5010],r[5010];ll sumd[5010],val[5010][210],sum[5010][5010];
int s[5010],top=0;
int main(){
	n=read();m=read();int i,j;ll ans=0;
	for(i=1;i<n;i++) dis[i]=read(),sumd[i+1]=sumd[i]+dis[i];
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++) val[i][j]=read();
	}
	for(j=1;j<=m;j++){
		for(i=1;i<=n;i++){
			while(top&&val[s[top]][j]<=val[i][j]) r[s[top]]=i,s[top--]=0;
			s[++top]=i;
		}
		while(top) r[s[top]]=n+1,s[top--]=0;
		for(i=n;i>=1;i--){
			while(top&&val[s[top]][j]<val[i][j]) l[s[top]]=i,s[top--]=0;
			s[++top]=i;
		}
		while(top) l[s[top]]=0,s[top--]=0;
//		for(i=1;i<=n;i++) cout<<i<<' '<<j<<' '<<l[i]<<' '<<r[i]<<'\n';
		for(i=1;i<=n;i++){
			//matrix([l+1,i],[i,r-1])
//			cout<<"add matirx "<<l[i]+1<<' '<<i<<' '<<i<<' '<<r[i]-1<<'\n';
			sum[l[i]+1][i]+=val[i][j];
			sum[i+1][i]-=val[i][j];
			sum[l[i]+1][r[i]]-=val[i][j];
			sum[i+1][r[i]]+=val[i][j];
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
//			cout<<i<<' '<<j<<' '<<sum[i][j]<<'\n';
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+sum[i][j];
//			if(i<=j) cout<<i<<' '<<j<<' '<<sum[i][j]<<'\n';
		}
	}
	for(i=1;i<=n;i++){
		for(j=i;j<=n;j++){
			ans=max(ans,sum[i][j]-sumd[j]+sumd[i]);
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 204672
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  pr((ll)pow(n,3));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
  int N, M, count = 0, countR = 0, temp = 0, result;
 
//blue
  cin >> N;
  vector<string> blue(N);
  vector<string> word;
  vector<int> Wcount;
  for (int i = 0; i < N; i++) {
    cin >> blue[i];
  }

  int flag = 0;
  for (int i = 0; i < N; i++) {
    for (int k = 0; k < word.size(); k++) {
      if (blue[i] == word[k])
        flag = 1;
    }
    if (flag == 1) {
      flag = 0;
      continue;
    }
    for (int j = 0; j < N; j++) {
      if (blue[i] == blue[j]) {
        count++;
      }
    }
    word.push_back(blue[i]);
    Wcount.push_back(count);
    count = 0;
  }
 //cout << word[1] << Wcount[1] << endl;
 
//Red
  cin >> M;
  //cout << M << endl;
  vector<string> red(M);
  vector<string> wordR;
  vector<int> WcountR;
  for (int i = 0; i < M; i++) {
    cin >> red[i];
  }
  //cout << red[0] << endl;
  int flagR = 0;
  for (int i = 0; i < M; i++) {
    for (int k = 0; k < wordR.size(); k++) {
      if (red[i] == wordR[k])
        flagR = 1;
    }
    if (flagR == 1) {
      flagR = 0;
      continue;
    }
    for (int j = 0; j < M; j++) {
      if (red[i] == red[j]) {
        countR++;
      }
    }
    wordR.push_back(red[i]);
    WcountR.push_back(countR);
    countR = 0;
    //cout << wordR[i] << endl;
  }
 //cout << wordR[0] << WcountR[0] << endl;

  
  
  //cout << word.size() << wordR.size() << endl;
  for (int i = 0; i < word.size(); i++){
    for (int j = 0; j < wordR.size(); j++){
      if (word[i] == wordR[j]){
       	 result = Wcount[i] - WcountR[j];
         //cout << result << endl;
         if (result <= 0){
           Wcount[i] = 0;
           //cout << Wcount[i] << endl;
         }else{
          Wcount[i] = result; 
         }
      }
    }
  }
  
  if (Wcount.size() < 2)
    cout << Wcount[0] << endl;
  else{
    for (int i = 0; i < Wcount.size(); i++){
      if (Wcount[i] > temp){
        temp = Wcount[i];
        //cout << temp << endl;
      }
  	}
  
    cout << temp << endl;
  }

}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main(void){
    char a[1001],b[1001];
    int n,i,j;
    scanf("%s%d",a,&n);
    
    for(i=0;i<n;i++){
        char x[10];
        int y,z;
        scanf("%s%d%d",x,&y,&z);
        if(x[2]=='i'){
            for(j=y;j<=z;j++)
            printf("%c",a[j]);
            
            printf("\n");
        }else if(x[2]=='v'){
            strcpy(b,a);
            for(j=y;j<=z;j++){
                a[j]=b[z-j+y];
            }
        }else{
            char p[z-y+2];
            scanf("%s",p);
            for(j=y;j<=z;j++){
                a[j]=p[j-y];
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


ll dp[3005][6005];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,t;cin >> n >> t;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<P> v(n);
  rep(i,n){
    ll a,b;cin >>a >> b;
    v[i] = mp(a,b);
  }
  sort(all(v));
  rep(i,n){
    a[i] = v[i].first;
    b[i] = v[i].second;
  }
  rep(i,3005){
    rep(j,6000){
      dp[i][j] = -LINF;
    }
  }
  dp[0][0] = 0;
  rep(i,n){
    rep(j,t){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      dp[i+1][j+a[i]] = max(dp[i+1][j+a[i]], dp[i][j] + b[i]);
    }
    FOR(j,t,6000){
      dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
    }
  }
  ll ans = 0;
  rep(j,6000){
    ans = max(ans, dp[n][j]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  string s;
  cin >>s;
  ll ss=s.size(),ans1=0,ans2=0;
  for(ll i=0;i<ss;i++){
   if(i%2==0){
     if(s[i]=='0') ans1++;
   }
   else{
     if(s[i]=='1') ans1++;
   }
  }
  for(ll i=0;i<ss;i++){
    if(i%2==1){
      if(s[i]=='0') ans2++;
    }
    else{
      if(s[i]=='1') ans2++;
    }
  }
  cout <<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, X, Y, x, y):
    mx = max(x)
    my = min(y)

    error_print(mx, my)
    if mx < my and (my > X and mx < Y):
        return 'No War'
    return 'War'


def main():
    N, M, X, Y = read_int_n()
    x = read_int_n()
    y = read_int_n()
    print(slv(N, M, X, Y, x, y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7740
package main

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

var mod = pow(10, 9) + 7
var A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z int
var ans int = 0

func main() {
	fmt.Scan(&N)
	d := make([]int, N)

	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)

	for i := 0; i < N; i++ {
		reader.Scan()
		d[i], _ = strconv.Atoi(reader.Text())
	}
	sort.Ints(d)

	var cnt int
	if len(d)%2 == 0 {
		if d[(len(d)/2)-1] == d[len(d)/2] {
			cnt = 0
		} else {
			cnt = d[(len(d)/2)] - d[len(d)/2-1]
		}
	} else {
		cnt = 0
	}
	fmt.Println(cnt)
}

/*  ----------------------------------------  */

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans, cnt int = 1, 0
	for cnt < y {
		ans *= (x - cnt)
		cnt++
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] > a[j] }


Measured memory_bytes: 2048
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		sc.close();

		//処理
		long ans = 0;
		if(2*n >  m) ans = m/2;
		else ans = n + (m-2*n)/4;

		//出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 左側A[:k] (N<=k<=2*N)までの最大値を求める
# 同様に右側も求める
N = ir()
A = lr()
left_sum = [0] * (N+1)
right_sum = [0] * (N+1)
left = A[:N]; heapify(left)
right = A[-N:]
right = [-x for x in right]
heapify(right)
cur = sum(left)
left_sum[0] = cur
center = A[N:-N]
for i in range(N):
    heappush(left, center[i])
    l = heappop(left)
    cur = cur - l + center[i]
    left_sum[i+1] = cur

cur = sum(right)
right_sum[N] = cur
for i in range(N):
    heappush(right, -center[N-1-i])
    r = heappop(right)
    cur = cur - r + (-center[N-1-i])
    right_sum[N-1-i] = cur

answer = -10 ** 15
for i in range(N+1):
    temp = left_sum[i] + right_sum[i]
    if temp > answer:
        answer = temp

print(answer)
# 05


Measured memory_bytes: 37212
#include <stdio.h>

int n, A[50];

int solve(int i, int m)
{
    if (m == 0)
        return 1;
    if (i >= n)
        return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

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

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

    scanf("%d", &q);
    for (i = 0; i < q; i++)
    {
        scanf("%d", &M);
        if (solve(0, M))
            printf("yes\n");
        else
            printf("no\n");
    }

    return 0;
}


Measured memory_bytes: 2612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int arr[] = new int[n];
        int dp[] = new int[n];
        int k = 0;

        for (String s: input){
            arr[k++] = Integer.parseInt(s);
        }
        dp[1] = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(Math.abs(arr[i - 1] - arr[i]) + dp[i - 1],Math.abs(arr[i - 2] - arr[i]) + dp[i - 2]);
        }
        System.out.println(dp[n- 1]);
    }
}


Measured memory_bytes: 35872
# ABC066 B - ss
S = input()
N = len(S)
ans = 0
for i in range(1,N):
    ss = S[0:N-i]
    if len(ss)%2 == 1:
        continue
    n = len(ss)//2
    sf = ss[0:n]
    st = ss[n:N+1]
    if sf == st:
        ans = max(ans,len(ss))

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>

const long long INF = 1LL<<60;
const int inf = 1 << 30;
const int mod = 1e9+7;


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


int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int> (m));

  rep(i, 0, n){
    cin >> c[i];
    rep(j, 0, m){
      cin >> a[i][j];
    }
  }
  long long ans = INF;
  for (int bit=0; bit<(1<<n); ++bit){
    vector<int> s(m, 0);
    long long cost = 0;

    for(int i=0; i<n; i++){
      if(bit & (1 << i)){
        cost += c[i];
        for(int j=0; j<m; j++){
          s[j] += a[i][j];
        }
      }
    }
    bool flag = true;
    for(int i=0; i<m; i++){
      if(s[i] < x) flag = false;
    }
    if(flag){
      ans = min(ans, cost);
    }
  }
  if(ans != INF){
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }
  
}

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

using namespace std;

const int maxn = 90, maxl = 2 * maxn * maxn;
int a[maxn][maxn], n, m;
bool dp[maxn][maxn][maxl];

int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
    for (int i = 1; i <= n; i++)
        for (int j = 1, u; j <= m; j++)
            cin >> u, a[i][j] = abs(a[i][j] - u);

    dp[1][1][a[1][1]] = true;
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= m; j++)
            for (int k = 0; k <= maxn * maxn; k++)
            {
                dp[i + 1][j][k + a[i + 1][j]] |= dp[i][j][k];
                dp[i + 1][j][abs(k - a[i + 1][j])] |= dp[i][j][k];
                dp[i][j + 1][k + a[i][j + 1]] |= dp[i][j][k];
                dp[i][j + 1][abs(k - a[i][j + 1])] |= dp[i][j][k];
            }

    for (int i = 0; i < maxl; i++)
        if (dp[n][m][i])
            return cout << i, 0;

    return 0;
}

Measured memory_bytes: 116480
use io::*;
use std::*;

fn solve(S: String) {
    let ans = if S == "ABC" {"ARC"} else {"ABC"};
    println!("{}",ans);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut S: String;
    S = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(S)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 2204
from scipy import ndimage
import numpy as np
import sys
input = sys.stdin.readline

H, W = map(int, input().split())

A_array = np.array(
    [[0 if s == "#" else 1 for s in input()[:-1]] for i in range(H)])
# print(A_array)


# print(A_array)
b = ndimage.morphology.distance_transform_cdt(
    A_array, metric="taxicab")
print(np.max(b))


Measured memory_bytes: 45412
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	long long N;
	scanf("%lld", &N);
	if (N % 2) printf("0");
	else {
		long long ans = 0;
		for (long long i = 5; i <= 1000000000000000000LL; i *= 5) ans += N / (i * 2);
		printf("%lld", ans);
	}
	return 0;
}

Measured memory_bytes: 128
n,k=map(int,input().split())
p=list(map(int,input().split()))

for i in range(len(p)):
  p[i]+=1

tmp=0
for i in range(k):
  tmp+=p[i]
  
ans=tmp
for i in range(n-k):
  tmp-=p[i]
  tmp+=p[i+k]
  ans=max(ans,tmp)
  
print(ans/2)

Measured memory_bytes: 71792
#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 maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#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 bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
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;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

vector<bool> sieve_of_eratosthenes(int n) {
  vector<bool> is_prime(n + 1, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i * i <= n; ++i)
    if (is_prime[i])
      for (int k = 2 * i; k <= n; k += i)
        is_prime[k] = false;
  return is_prime;
}
  
int main() {
  v(bool) primes = sieve_of_eratosthenes(100000);
  v(bool) primes2(100001,false);
  for(int i =1; i < 100001;i+=2) {
    if(primes[i] && primes[(i + 1) / 2]) {
      primes2[i] = true;
    }
  }
  vi sum(100001,0);
  rep(i,100000) {
    sum[i+1] = sum[i];
    if(primes2[i+1]) sum[i+1]++;
  }
  int q;
  cin >> q;
  vi ans(q);
  rep(i,q) {
    int l,r;
    cin >> l >> r;
    ans[i] =  sum[r] - sum[l-1];
  }
  rep(i,q) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
import fractions

def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))


n, k = rli()
a = rli()
if(max(a) < k):
    print("IMPOSSIBLE")
else:
    g = a[0]
    for i in a[1:]:
        g = fractions.gcd(g, i)
    if(k % g == 0):
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


Measured memory_bytes: 16304
W, H, N = map(int, input().split())
a_list =[] 
for i in range(N):
  a_list.append(list(map(int, input().split())))
a1_list = [i[0] for i in a_list if i[2] == 1 ]
a2_list = [i[0] for i in a_list if i[2] == 2 ]
a3_list = [i[1] for i in a_list if i[2] == 3 ]
a4_list = [i[1] for i in a_list if i[2] == 4 ]
if a1_list == []:
  a1_max = 0
else:
  a1_max = max(a1_list)
if a2_list == []:
  a2_min = W
else:
  a2_min = min(a2_list)
if a3_list ==[]:
  a3_max = 0
else:
  a3_max = max(a3_list)
if a4_list == []:
  a4_min = H
else:
  a4_min = min(a4_list)
S = (a2_min - a1_max)*(a4_min - a3_max)
if (a2_min - a1_max) >= 0 and (a4_min - a3_max) >= 0:
  print(S)
else:
  print(0)

Measured memory_bytes: 3064
n=int(input())
arr=list(map(int,input().split()))
from collections import defaultdict
dd=defaultdict(int)
for a in arr:
    dd[a-1]+=1
    dd[a]+=1
    dd[a+1]+=1
ans=0
for k in dd.keys():
    ans=max(ans,dd[k])
print(ans)


Measured memory_bytes: 19916
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	n := len(s)

	const m = 1000000007

	dp := make([][]int, n + 1, n + 1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, 13, 13)
		for j := 0; j < 13; j++ {
			dp[i][j] = 0
		}
	}
	
	for i := 1; i <= n; i++ {
		c := s[i - 1]

		if i == 1 {
			if c == '?' {
				for j := 0; j <= 9; j++ {
					dp[1][j] = 1
				}
			} else {
				dp[1][c - '0'] = 1
			}
		} else {			
			if c == '?' {
				for j := 0; j <= 12; j++ {
					for k := 0; k <= 9; k++ {
						dp[i][(j * 10 + k) % 13] += dp[i - 1][j]
						dp[i][(j * 10 + k) % 13] %= m
					}
				}
			} else {
				k := c - '0'
				for j := 0; j <= 12; j++ {
					dp[i][(j * 10 + int(k)) % 13] = dp[i - 1][j]
				}
			}
		}
	}

	fmt.Println(dp[n][5])
}


Measured memory_bytes: 14592
#include <stdio.h> 
 #include <string.h> 
 
 
 int main(){ 
     int m, h; 
     char cards[256], temp[256], result[256]; 
     int i, j=0, len; 
 
 
     while(1){ 
         scanf("%s", cards); 
         len=strlen(cards); 
         if(strcmp(cards, "-")==0&&len==1)break; 
         scanf("%d", &m); 
         for(;m>0;m--){ 
            scanf("%d", &h); 
             strcpy(temp, cards); 
             for(i=0;i<h;i++){ 
                 cards[len-h+i]=temp[i]; 
             } 
             for(i=0;i<len-h;i++){ 
                 cards[i]=temp[i+h]; 
             } 
         } 
         for(i=0;i<len;i++){ 
             result[j++]=cards[i]; 
         } 
         result[j++]='\n'; 
     } 
     result[j]='\0'; 
     printf("%s", result); 
 
 
     return 0; 
 } 



Measured memory_bytes: 2128
s = input()
for i in range(len(s)-1, 0, -1):
	if i % 2 != 0:
		continue
	_i = int(i/2)
	_s1 = s[:_i]
	_s2 = s[_i:i]
	if _s1 == _s2:
		print(i)
		break


Measured memory_bytes: 2940
import java.util.ArrayList

fun main(args: Array<String>) {
    val (n) = readLine()!!.split(' ').map(String::toInt)
    val xs = readLine()!!.split(' ').map(String::toInt).toMutableList()
    xs.add(0, -1)
    val result = IntArray(n+2){-1}
    fun calc(i: Int): Int{
        if(result[i] != -1) return result[i]
        if(i * 2 > n) {
            result[i] = xs[i]
            return result[i]
        }
        val upper = (i * 2..n step i).sumBy { it: Int -> calc(it)} % 2
        val ret = if(xs[i] == upper) 0 else 1
        result[i] = ret
        return ret
    }
    calc(1)

    val r = (1..n).filter {it: Int -> result[it] == 1 }

    if (r.isEmpty()) {
        print(0)
    } else {


        println(r.size)
        for (i in r.indices) {
            print(r[i])
            if (i != r.size - 1)
                print(" ")
        }
    }
}

Measured memory_bytes: 67844
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define scout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	unordered_set<int> us;
    rep(i,4){
        us.insert(s[i]);
    }
    if(us.size() == 2 && count(s.begin(), s.end(), s[0]) == 2){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
n = int(input())
s = list(input())
alphabet_list = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
alphabet_indexes = []
for s_index in range(len(s)):
    for alphabet_index in range(len(alphabet_list)):
        if s[s_index] == alphabet_list[alphabet_index]:
            s_alphabet_index = (alphabet_index + n)%26
    alphabet_indexes.append(s_alphabet_index)
alphabets = []
for alphabet_index in alphabet_indexes:
    alphabets.append(alphabet_list[alphabet_index])

print("".join(map(str, alphabets)))

Measured memory_bytes: 41712
using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

class program{
  static void Main(string[] args){
    program p= new program();
      p.Run();
  }
  void Run(){
    int n=Readint()[0];
    Tuple<string,int,int>[] lin = new Tuple<string,int,int>[n];
    for(int i=1;i<n+1;i++){
      string[] inp=ReadLine().Split();
      lin[i-1]=Tuple.Create(inp[0],100-int.Parse(inp[1]),i);
    }
    Array.Sort(lin);
    for(int k=0;k<n;k++) WriteLine(lin[k].Item3.ToString());     
  }
  int[] Readint(){
    string[] inp= ReadLine().Split();
    int n=inp.Length;
    int[] res=new int[n];
    for(int i=0;i<n;i++){
      res[i]=int.Parse(inp[i]);
    }
    return res;
  }
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
using namespace std;
int m(int a1, int a2, int a3) {
	if (a1 > a2) {
		swap(a1, a2);
	}
	if (a2 > a3) {
		swap(a2, a3);
	}
	if (a1 > a2) {
		swap(a1, a2);
	}
	return a3-a1;
}
int f(int H, int W) {
	int r = 10000000;
	int k = H / 3;
	if (k != 0) {
		r = min(r, m(k * W, (H - k)*(W / 2), (H - k)*(W - (W / 2))));
	}
	r = min(r, m((k + 1) * W, (H - k - 1)*(W / 2), (H - k - 1)*(W - (W / 2))));
return r;
}
int main(){
	int H, W;
	cin >> H >> W;
	int res = H;

	if (H % 3 == 0 || W % 3 == 0) {
		res = 0;
		cout << 0 << endl;
		return 0;
	}
	res = min(H, W);
	res = min(res, f(H, W));
	res = min(res, f(W, H));
	cout << res << endl;
  return 0;
}


Measured memory_bytes: 256