akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n;
vector<int>a[214514];
int d[214514];
bool used[214514], flag;
int memo;
int far(int x) {
	used[x] = true;
	rep(i, a[x].size()) {
		if (!used[a[x][i]]) {
			d[a[x][i]] = d[x] + 1;
			far(a[x][i]);
		}
	}
	if (x == 0 && flag == false) {
		int max_ = 0;
		rep(i, n) {
			if (max_ < d[i]) {
				max_ = d[i];
				memo = i;
			}
		}
		fill(d, d + n, 0);
		fill(used, used + n, 0);
		flag = true;
		return far(memo);
	}
	else if (x == memo && flag) {
		int res = 0;
		rep(i, n) {
			res = max(res, d[i]);
		}
		return res;
	}
	return 0;
}
signed main() {
	cin >> n;
	rep(i, n - 1) {
		int x, y; cin >> x >> y; x--; y--;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	if (far(0) % 3 == 1)cout << "Second" << endl;
	else cout << "First" << endl;
}


Measured memory_bytes: 22656
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];

    int m = 0, ans = 0;
    REP(i, n) {
        if (m <= h[i]) {
            ans++;
            m = h[i];
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;


void main() {
    int n, q;
    scan(n, q);

    auto sd = SqrtDecomp(n);

    foreach (_ ; 0 .. q) {
        auto line = readln.split.to!(int[]);
        if (line[0] == 0) {
            sd.add(line[1] - 1, line[2]);
        }
        else {
            writeln(sd.sum(line[1] - 1, line[2]));
        }
    }
}

struct SqrtDecomp {
    private {
        int N, K;
        enum sqrtN = 512;
        int[] bucketSum;
        int[] data;
    }

    this(int n) {
        N = n;
        K = (N + sqrtN - 1) / sqrtN;
        bucketSum = new int[](K);
        data = new int[](K * sqrtN);
    }

    void add(int i, int x) {
        int k = i / sqrtN;
        data[i] += x;
        bucketSum[k] += x;
    }

    int sum(int l, int r) {
        int res;
        foreach (k ; 0 .. K) {
            int bl = k * sqrtN, br = (k + 1) * sqrtN;
            if (r <= bl || br <= l) continue;
            if (l <= bl && br <= r) {
                res += bucketSum[k];
            }
            else {
                foreach (i ; max(l, bl) .. min(r, br)) {
                    res += data[i];
                }
            }
        }
        return res;
    }
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  int count = 0;
  cin >> A >> B;
  for(int i = A;i < B+1;i++){
    int p,q,r,s,t = 0;
    p = i /10000;
    q = (i - p*10000) / 1000;
    r = (i - p*10000 - q*1000) / 100;
    s = (i - p*10000 - q*1000 - r*100 ) / 10;
    t = i - p*10000 - q*1000 - r*100 - s*10;
    if (p == t && q == s){
      count ++;
    }
  }
  cout << count <<endl;
}

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

string str;
int alp[26];

int main(void) {
    cin >> str;
    for (char c = 'a'; c <= 'z'; c++)
        alp[c] = 0;
    for (int i = 0; i < str.size(); i++)
        alp[str[i]]++;
    for (char c = 'a'; c <= 'z'; c++) {
        if (alp[c] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        } 
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main()
{
    string S;
    cin >> S;
    for(int i=0; i<S.size(); i++){
        for(int j=i+1; j<S.size(); j++){
            if(S[i] == S[j]){
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
    return 0;
}


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

using ll = long long;

constexpr int INF = (1 << 30) - 1;
constexpr int MOD = 1000000000 + 7;

int N, W;
vector<int> v, w;

int dp[101][10001];

int main() {
  cin >> N >> W;
  v.resize(N);
  w.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i] >> w[i];
  }

  for (int i = 0; i <= W; i++) {
    for (int j = 0; j < N; j++) {
      if (i < w[j]) {
        dp[j + 1][i] = dp[j][i];
      } else {
        dp[j + 1][i] = max(dp[j][i], dp[j][i - w[j]] + v[j]);
      }
    }
  }

  cout << dp[N][W] << endl;
}


Measured memory_bytes: 7020
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
cc=Counter()
cnt=0
for i in a:
    if i<=399:
        cc['gray']+=1
    elif i<=799:
        cc['brown']+=1
    elif i<=1199:
        cc['green']+=1
    elif i<=1599:
        cc['cyan']+=1
    elif i<=1999:
        cc['blue']+=1
    elif i<=2399:
        cc['yellow']+=1
    elif i<=2799:
        cc['orange']+=1
    elif i<=3199:
        cc['red']+=1
    else:
        cnt+=1
mini=len(cc)
if len(cc)==0:
    mini=1
else:
    mini=len(cc)
maxi=len(cc)+cnt
print(mini,maxi)




Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> p[100010];
int vis[100010];
long long s[100010];
void dfs(int x,long long y)
{
    int i,j;
    long long k;
    for(i=0;i<p[x].size();i=i+2)
    {
        j=p[x][i];
        k=p[x][i+1];
        if(vis[j]==0)
        {
            vis[j]=1;
            s[j]=y+k;
            dfs(j,y+k);
        }
    }
}
int main()
{
    int n,i,j,k,x,y,z,q;
    long long s1,s2,sum;
    scanf("%d",&n);
    memset(s,0,sizeof(s));
    for(i=1;i<n;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        p[x].push_back(y);
        p[x].push_back(z);
        p[y].push_back(x);
        p[y].push_back(z);
    }
    scanf("%d%d",&q,&k);
    memset(vis,0,sizeof(vis));
    vis[k]=1;
    dfs(k,0);
    while(q--)
    {
        scanf("%d%d",&x,&y);
        s1=s[x];
        s2=s[y];
        sum=s1+s2;
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, X, x;
  cin >> A >> B;
  X = A * B;
  x = X % 2;
  if (x == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

    vl rui(n+1);
    rep(i, n) {
        ll a;
        cin >> a;
        a--;
        rui[i+1] = (rui[i] + a)%k;
    }

    map<ll, ll> mp;
    queue<ll> Q;
    ll ans = 0;
    rep(i, n+1) {
        if(Q.size() == k) {
            mp[Q.front()]--;
            Q.pop();
        }
        Q.push(rui[i]);
        ans += mp[rui[i]];
        mp[rui[i]]++;
    }
    
    out(ans);
    re0;
}

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



int main(){
    ll A,B,K;
    cin >> A >> B >> K;
    if(K<A){
        cout << A-K << " " << B << endl;
    }
    else if(K<A + B){
        cout << 0 << " " << A+B-K << endl;
    }
    else{
        cout << 0 << " " << 0 << endl;
    }
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N, 0);

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

	int min = 1000000000;
	int cnt;
	for (int i = 0; i < N; i++)
	{
		cnt = 0;

		while (true)
		{
			if (A[i] % 2 == 0)
			{
				cnt++;
				A[i] /= 2;
			}
			else
			{
				break;
			}
		}

		if (min > cnt)
		{
			min = cnt;
		}

	}

	cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int q,a,b,c,i;
  scanf("%d\n",&q);
  for(i=0;i<q;i++){
    scanf("%d %d %d\n",&a,&b,&c);
    int ans=0,d;
    ans=min(a,b);
    ans=min(ans,c);
    a-=ans,b-=ans,c-=ans;
    d=a/2;
    d=min(d,b);
    ans+=d;
    a-=d*2;
    ans+=a/3;
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

ll modPow(long long a, long long n, long long p) {//0でバグる
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	rrep(i, p + 1) {
		a = (a * (n - i + 1)) % mod;
		b = (b * i) % mod;
	}
	return a * (modPow(b, mod - 2, mod)) % mod;
}

ll fact(ll a) {
	ll res = 1;
	for (int i = 1; i <= a; ++i) (res *= i) %= mod;
	return res % mod;
}

ll perm(ll a, ll b) {
	if (a < 0 || a < b) return 0;
	return comb(a, b) * fact(b) % mod;
}

ll n, k;
vector<int> g[100005];
ll ans;
bool vi[100005];

void dfs(int v, int p = -1) {
	for (auto& c : g[v]) {
		if (c == p) continue;
		dfs(c, v);
	}
	ll pp = 0;
	if (v == 0) pp += perm(k - 1, g[v].size());
	else pp += perm(k - 2, g[v].size() - 1);
	(ans *= pp) %= mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ans = k;
	dfs(0);
	printf("%lld\n", ans );
	return 0;
}


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

int main(){
  int H,N;
  cin>>H>>N;
  vector<int> vec(N);
  int S=0;
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  S+=vec.at(i);
}
  if(S>=H){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
#pragma warning (disable: 4996)

int N, A[1 << 18], C[3];
long long sum = 1;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];

	for (int i = 1; i <= N; i++) {
		long long cnt = 0, id = -1;
		if (A[i] == C[0]) { cnt++; id = 0; }
		if (A[i] == C[1]) { cnt++; id = 1; }
		if (A[i] == C[2]) { cnt++; id = 2; }
		if (id == -1) {
			cout << "0" << endl;
			return 0;
		}
		sum *= cnt; C[id]++;
		sum %= 1000000007;
	}
	cout << sum << endl;
	return 0;
}


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

int main(){
  int m, f, r;
  vector<char> v;
  while(cin >> m >> f >> r){
    if(m == -1 && f == -1 && r == -1) break;
    if(m == -1 || f == -1) {v.push_back('F'); continue;}
    int sum = m + f;
    if(sum >= 80)v.push_back('A');
    else if(sum >= 65)v.push_back('B');
    else if(sum >= 50)v.push_back('C');
    else if(sum >= 30 && r >= 50)v.push_back('C');
    else if(sum >= 30)v.push_back('D');
    else v.push_back('F');
  }

  for(int i=0;i<v.size();i++){
    cout << v[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int a[55];
bool comp(int a,int b)
{
	return a>b;
}
int main()
{
	int n,k,s=0;
	cin>>n>>k;
	for (int i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+n+1,comp);
	for (int i=1;i<=k;++i) s+=a[i];
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
import bisect


a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
  
#それぞれソートする
a.sort()
b.sort()
c.sort()

ans = 0
for num_b in b:
  cnt_a = bisect.bisect_left(a,num_b)
  cnt_c = len(b) - bisect.bisect_right(c,num_b)
  ans += cnt_a * cnt_c
  
print(ans)


Measured memory_bytes: 23360
(defvar N (read))
(defvar s (read-line))
(defvar a (make-array N))
(defvar b (make-array N))

(defun if-W (i)
  (if (eq (char s i) #\W) 1 0))
(defun if-E (i)
  (if (eq (char s i) #\E) 1 0))

(setf (aref a 0) (if-E 0))
(setf (aref b (1- N)) (if-W (1- N)))

(loop for i from 1 below n
      do (setf (aref a i)
            (+ (aref a (1- i))
               (if-E i))))

(loop for i from (- N 2) downto 0
      do (setf (aref b i)
            (+ (aref b (1+ i))
               (if-W i))))

(format t "~A~%" (- N (loop for i below n maximize (+ (aref a i) (aref b i)))))

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  string st; cin>>st;
  int f = 0, f2 = 0;
  rep(i,0,3) if(st[i] == 'A') f=1;
  rep(i,0,3) if(st[i] == 'B') f2=1;
  if(f&&f2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 256
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

void solve(){
	int i,j;
	int ans=INT_MAX;

	string a,b;cin >>a >> b;

	int n=a.size(),m=b.size();

	for (int i = 0; i < n-m+1; ++i)
	{
		int cnt=0;
		for (int j = 0; j < m; ++j)
		{
			if(a[i+j]!=b[j])cnt++;
		}
		ans=min(cnt,ans);
	}

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

}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
string S;
  cin >>S;
  cout <<"ABC"<<S<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

int next(int x) {
	string s = to_string(x);
	int n = (int)s.size();
	for (int i = n - 1; i >= 0; i--) {
		int v = s[i] - '0';
		for (int nv = v + 1; nv < 10; nv++) {
			int ok = 1;
			if (i + 1 < n) ok &= (abs((s[i + 1] - '0') - nv) <= 1);
			// cerr << abs((s[i - 1] - '0') - nv) << endl;
			if (i > 0)  ok &= (abs((s[i - 1] - '0') - nv) <= 1);
			if (ok) {
				s[i] = nv + '0';
				for (int j = i + 1; j < n; j++) {
					s[j] = max('0', (char)(s[j - 1] - 1));
				}
				return stoll(s);
			}
		}
	}
	n++;
	string ns = "1";
	for (int i = 1; i < n; i++) {
		ns.push_back('0');
	}
	return stoll(ns);
}

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

	int n;
	cin >> n;
	int x = 1;
	for (int i = 1; i < n; i++) x = next(x);
	cout << x << endl;
	// cout << next(12) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var k = cin.nextInt();
            var x = cin.ArrayLong(n);

            long ans = long.MaxValue;
            for (int i = 0; i <= n - k; i++)
            {
                var l = x[i];
                var r = x[i + k - 1];

                var a = Math.Abs(l) + Math.Abs(r - l);
                var b = Math.Abs(r - l) + Math.Abs(r);
                ans = Math.Min(ans, a);
                ans = Math.Min(ans, b);
            }        

            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 20704
#include "bits/stdc++.h"
using namespace std;

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vi h(n);
	rep(i, 0, n)cin >> h[i];
	const ll N_MAX = 100000 + 1;
	ll dp[N_MAX] = { 0 };
	for (ll i = n - 2; i >= 0; i--) {
		if (h[i] >= h[i + 1])
			dp[i] = dp[i + 1] + 1;
	}
	ll m = INFMIN;
	rep(i, 0, n) {
		if (m < dp[i])
			m = dp[i];
	}
	cout << m << endl;

	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i));
            var n = input.ElementAt(0);
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (i * 4 + j * 7 == n)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268
def main():
    N = int(input())
    S1 = input()
    S2 = input()

    mod_ = 1000000007
    n = N
    if S1[0] == S2[0]:
        fill = 3
        i = 1
    else:
        fill = 6
        i = 2

    while i < N:
        if S1[i] == S2[i]:
            if S1[i-1] == S2[i-1]:
                fill *= 2
            i += 1
        else:
            if S1[i-1] == S2[i-1]:
                fill *= 2
            else:
                fill *= 3
            i += 2

    print(fill % mod_)

main()


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i=0;
		String[] s = new String[1000];
		int[] count = new int[1000];
		Scanner sc = new Scanner(System.in);
		
		while( sc.hasNext() ){
			boolean flag=true;
			String tmp = sc.next();
			
			if(i==0){
				s[i]=tmp;
				count[i]=1;
				i++;
				continue;
			}
			
			for(int j=0; j<i; j++) {
				if(s[j].equals(tmp)){
					count[j]++;
					flag=false;
					break;
				}
			}
			
			if(flag){
				s[i]=tmp;
				count[i]=1;
				i++;
			}
		}
		
		int max = count[0];
		int length = s[0].length();
		String str = s[0];
		String str2 = s[0];
		for(int j=0; j<i; j++) {
			//System.out.println("count[" + j + "] = "+count[j]);
			//System.out.println("s[" + j + "] = "+s[j]);
		
		
			if(max<count[j]) {
				max = count[j];
				str = s[j];
			}
			if(s[j].length()>length){
				length = s[j].length();
				str2 = s[j];
			}
		}
		
		System.out.println(str + " " + str2);
			
		
	}
}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && a!=c) cout<<"Yes";
	else if(b==c && b!=a) cout<<"Yes";
	else if(a==c && a!=b) cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long gcd(long a, long b) {
  while(true) {
    if(a < b) swap(a, b);
    if(!b) return a;
    a %= b;
  }
}

int main(void) {
  long N;
  cin >> N;
  vector<long> A(N);
  rep (i, N) cin >> A[i];

  long all_used = A[0];
  unordered_set<long> an_unused;
  an_unused.insert(A[1]);

  for (long i = 1; i < N; i++) {
    unordered_set<long> next_an_unused;
    next_an_unused.insert(all_used);
    all_used = gcd(all_used, A[i]);
    for (long l: an_unused) next_an_unused.insert(gcd(l, A[i]));
    an_unused = next_an_unused;
  }

  long max = *(an_unused.begin());
  for (long l: an_unused) if (max < l) max = l;
  cout << max << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
    }

Measured memory_bytes: 3556
from itertools import permutations
k = int(input())


# 8*8行の間で何行目に何があるか
start_exists = [[] for _ in range(8)]
exists_rows = []
for _ in range(k):
    r, c = map(int, input().split())
    exists_rows.append(r)
    start_exists[r].append(c)

# print(start_exists)


def check_valid_positions(exist_positions):
    valid = True
    for start_position in exist_positions:
        for check_position in exist_positions:
            if start_position == check_position:
                continue
            if start_position[0] == check_position[0]:
                valid = False
            if start_position[1] == check_position[1]:
                valid = False
            if (start_position[0] - start_position[1]) == (check_position[0] - check_position[1]):
                valid = False
            if (start_position[0] + start_position[1]) == (check_position[0] + check_position[1]):
                valid = False
    return valid


# これですでに存在している行は除く
# [(7, 6, 5, 2, 1, 3, 4, 0), (7, 6, 5, 2, 1, 4, 0, 3)....]
queens_row_permutations = permutations(range(8))
ans = []
for queens_row_permutation in queens_row_permutations:
    exist_positions = []
    for i, row in enumerate(queens_row_permutation):
        if i in exists_rows:
            exist_positions.append([i, start_exists[i][0]])
        else:
            exist_positions.append([i, row])
    # print(exist_positions)
    # print(check_valid_positions(exist_positions))
    if check_valid_positions(exist_positions):
        ans = exist_positions
        break
    # squares = [[0 for _ in range(8)] for _ in range(8)]
    # for i, row in enumerate(queens_row_permutation):
    #     if i in exists_rows:
    #         squares[i][start_exists[i][1]] = 1
    #     else:
    #         squares[i][row] = 1
    # for j in range(8):
for position in ans:
    print(
        ''.join(['Q' if position[1] == i else '.' for i in range(8)]))



Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    vector<ll>dp(500010,0);
    REP(i,500005)
        dp[i+1]=dp[i]+i+1;
    string s;cin>>s;
    ll ans=0;
    vector<ll>x;
    ll tem=1;
    REP(i,s.size()-1){
        if(s[i]!=s[i+1]){x.push_back(tem);ans+=dp[tem];tem=1;}
        else tem++;
    }x.push_back(tem);ans+=dp[tem];
    //for(auto it:x)cout<<it<<endl;cout<<endl<<ans<<endl;


    if(s[0]=='>')x.erase(x.begin());
    if(s[s.size()-1]=='<')x.erase(x.end()-1);
    if(x.size()>=2)for(ll j=0;j<x.size()-1;j+=2)
    {
        ans-=min(x[j],x[j+1]);
    }
    //for(auto it:x)cout<<it<<endl;
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 7192
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (mut ai, ao, _, mut aj, mut ak, _, _) = (v[0], v[1], v[2], v[3], v[4], v[5], v[6]);

    let mut ans = 0;

    for i in 0..2 {
        let mut temp = ao;
        if i == 1 && ai > 0 && aj > 0 && ak > 0 {
            ai -= 1;
            aj -= 1;
            ak -= 1;
            temp += 3;
        }
        for a in &[ai, aj, ak] {
            temp += (a / 2) * 2;
        }
        ans = max(ans, temp);
    }
    println!("{}", ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
[n, k] = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

l = len(bin(k)) - 2
num = []
for i in range(l):
    temp = 0
    for j in range(n):
        if ((a[j] >> i) % 2 == 0):
            temp += 1
    if (temp >= n / 2):
        num.append([1, temp])
    else:
        num.append([0, n - temp])

ind = 0
t = sum([num[i][0] * 2 ** i for i in range(l)])
for i in range(l):
    if ((k - (k >> (l - i)) * 2 ** (l - i)) >= t):
        ind = l - i
        break
    t -= num[l - i - 1][0] * 2 ** (l - i - 1)

t1 = t + ((k >> ind) << ind)
t2 = t + sum([num[i][0] * 2 ** i for i in range(ind, l - 1)])

sum1 = sum([a[i] ^ t1 for i in range(n)])
sum2 = sum([a[i] ^ t2 for i in range(n)])
    
print(sum1 if sum1 > sum2 else sum2)


Measured memory_bytes: 14620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

long long int ans = 0;
string S;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> S;
	long long int len = S.size();
	int cnt = 0,lookup = 0;
	bool flag = false;
	REP(i,len){
		if(S[i] == 'B'){
			flag = true;
			cnt++;
		}else{
			if(flag){
				if(S[i] == 'W'){
					ans += i - lookup++;
				}
			}else{
				lookup++;
			}
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long 
using namespace std;

signed main() {
	int N,M;
	cin >> N >> M;
	vector<pair<int,int>> A(N);
	vector<pair<int,int>> B(M);
	for(int i = 0;i < N;i++) {
		int C,D;
		cin >> C >> D;
		A.at(i) = make_pair(C,D);
	}
	for(int i = 0;i < M;i++) {
		int C,D;
		cin >> C >> D;
		B.at(i) = make_pair(C,D);
	}
	for(int i = 0;i < N;i++) {
		int count = 1e12;
		int answer;
		for(int j = 0;j < M;j++) {
			if(count > abs(A[i].first - B[j].first) + abs(A[i].second - B[j].second)) {
				count = abs(A[i].first - B[j].first) + abs(A[i].second - B[j].second);
				answer = j + 1;
			}
		}
		cout << answer << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll ans = 0;
    vi abc(3, 0);
    cin >> abc[0] >> abc[1] >> abc[2];
    sort(all(abc));
    if(abc[0]%2 != 0 && abc[1]%2 != 0 && abc[2]%2 != 0) ans = abc[0] * abc[1];
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1000000000;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    vector<int> vec(3);
    for(int i = 0;i < 3;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    cout << vec.at(2) - vec.at(0) << endl;
}

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 ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int N, M, C; cin >> N >> M >> C;
	int B[20]; rep(i, M) cin >> B[i];
	int ans = 0;
	rep(i, N) {
		int sum = 0;
		rep(j, M) {
			int tmp; cin >> tmp;
			sum += tmp * B[j];
		}
		sum += C;
		if (sum > 0) ans++;
	}
	cout << ans << endl;
}

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

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

    if(x == 1 || x == 2*n-1){
        cout << "No" << endl;
        return 0;
    }

    if(n == 2){
        if(x == 2){
            cout << "Yes" << endl << 1 << endl << 2 << endl << 3 << endl;
        }else{
            cout << "No" << endl;
        }
        return 0;
    }

    cout << "Yes" << endl;

    deque<int> ans;

    if(x != 2*n-1-1){
        ans.push_back(x);
        ans.push_front(x-1);
        ans.push_back(x+1);
        ans.push_front(x+2);
        int now = 1;
        for(int i = 0; i < n-3; i++){
            if(now == x-1)  now = x+3;
            ans.push_front(now++);
        }
        for(int i = 0; i < n-2; i++){
            if(now == x-1)  now = x+3;
            ans.push_back(now++);
        }
    }else{
        ans.push_back(x);
        ans.push_front(x-1);
        ans.push_back(x+1);
        ans.push_back(x-2);
        int now = 1;
        for(int i = 0; i < n-2; i++){
            if(now == x-2)  now = x+2;
            ans.push_front(now++);
        }
        for(int i = 0; i < n-3; i++){
            if(now == x-2)  now = x+2;
            ans.push_back(now++);
        }
    }

    while(!ans.empty()){
        cout << ans.front() << endl;
        ans.pop_front();
    }

    return 0;
}

Measured memory_bytes: 2304
import sys,math
if sys.version_info[0]>=3: raw_input=input
N=int(raw_input())
for i in range(N):
	x1,y1,x2,y2,x3,y3=[float(e) for e in raw_input().split()]
	a1=2*x2-2*x1
	b1=2*y2-2*y1
	c1=x1*x1-x2*x2+y1*y1-y2*y2
	a2=2*x3-2*x1
	b2=2*y3-2*y1
	c2=x1*x1-x3*x3+y1*y1-y3*y3
	x=(b1*c2-b2*c1)/(a1*b2-a2*b1)
	y=(c1*a2-c2*a1)/(a1*b2-a2*b1)
	print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))

Measured memory_bytes: 4408
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
	int n,m;
	scanf("%d",&n);
	int flag4=0;
	int flag2=0;
	int flag=0;
	int flag0=0;
	for(int i=0;i<n;i++)
	{
        cin>>m;
        if(m%4==0)
		flag4++;
		else
		{
			if(m%2==0)
			{
				flag2++;
				flag=1;
			}
			else
			{
				flag0++;
			}
		}	
	}
	if(flag4>=flag2+flag0-1)
	cout<<"Yes"<<endl;
	else
	{
		if(flag&&flag4>=flag0)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl; 
	} 
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>

using namespace std;

int main()
{
  int n,q,c,t,x;
  vector<stack<int> > a;

  scanf("%d", &n);
  scanf("%d", &q);


  for (int i = 0; i < n; i++) {
    a.emplace_back();
  }


  for (int i = 0; i < q; i++) {
    scanf("%d", &c);
    scanf("%d", &t);
    if (c == 0){
      scanf("%d", &x);
      a[t].push(x);
    }else if (c == 1){
      if (a[t].empty()==0){ //空：１　
        printf("%d\n",a[t].top());
      }
    }else if (c == 2){
      if (a[t].empty()==0){ //空：１　
        a[t].pop();
      }
    }

  }
  return 0;
}



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

using namespace std;

int main(){
	int n,i,a,j,ia,ja,f,c;
	string s[301];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	c=0;
	for(a=0;a<n;a++){
		f=0;
		for(i=0;i<n;i++){
			ia=i+a;
			if(ia>=n){
				ia-=n;
			}
			for(j=i+1;j<n;j++){
				ja=j+a;
				if(ja>=n){
					ja-=n;
				}
				if(s[ia][j]!=s[ja][i]){
					f=1;
					break;
				}
			}
			if(f==1){
				break;
			}
		}
		if(f==0){
			c+=1;
		}
	}
	cout << c*n;
	return 0;
}


Measured memory_bytes: 384
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
-- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Monad.Primitive
import           Control.Applicative
import           Debug.Trace
import           Text.Printf

main = do
  (n,k) <- getInt2Tuple
  ps <- getIntVector
  print $ solve ps k

solve ps k = VU.sum $ VU.take k $ VU.fromList $ sort $ VU.toList ps

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons
getInt = readLn :: IO Int
getInt2Tuple = (\vec -> (vec VU.! 0, vec VU.! 1)) <$> getIntVector
getInt3Tuple = (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2)) <$> getIntVector


Measured memory_bytes: 4712
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

int dp[510][510];
string s;

bool rec(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(l > r) return dp[l][r] = true;
    bool res = false;
    if(s[l] != 'm' || s[r] != 'w') return dp[l][r] = false;
    rep(i, l + 1, r){
        if(s[i] == 'e'){
            res |= (rec(l + 1, i - 1) && rec(i + 1, r - 1));
        }
    }
    return dp[l][r] = res;
}

signed main(){
    cin >> s;
    memset(dp, -1, sizeof(dp));
    cout << (rec(0, s.size() - 1) ? "Cat" : "Rabbit") << endl;
}

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000000;

int main(){
  int N;
  cin >> N;
  map<string, int> vote;
  rep(i, N){
    string key;
    cin >> key;
    if(vote.count(key)) vote.at(key)++;
    if(!vote.count(key)) vote[key] = 1;
  }
  int max_cnt = 0;
  for(auto i : vote){
    if(i.second > max_cnt){
      max_cnt = i.second;
    }
  }
  for(auto i : vote){
    if(i.second == max_cnt) cout << i.first <<endl;
  }
}
       
      

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

using namespace std;

int main()
{
  int n,m;
  cin >> n >> m ;
  int a[m],b[m];
  int c[n] = {0} ;  
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i] ;
  }     
  
  for(int i=0;i<m;i++){
    c[a[i]-1]++;
    c[b[i]-1]++;
  }  

  for(int i=0;i<n;i++){
    cout << c[i] << endl ;
    }    
 }


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
using namespace std;

int SelectSort(vector<int>& nums)
{
	int cnt = 0;
	for(unsigned int i = 0; i < nums.size()-1; ++i) {
		unsigned int k = i;
		for(unsigned int j = i+1; j < nums.size(); ++j) {
			if(nums[j] < nums[k]) {
				k = j;
			}
		}
		if(k != i) {
			int t = nums[k]; nums[k] = nums[i]; nums[i] = t;
			++cnt;
		}
	}
	return cnt;
}

int main()
{
	int n; scanf("%d",&n);
	vector<int> nums(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d",&nums[i]);
	}
	int cnt = SelectSort(nums);
	for(int i = 0; i < n; ++i) {
		if(i) {
			putchar(' '); 
		}
		printf("%d",nums[i]);
	}
	putchar('\n');
	printf("%d\n",cnt);
	return 0;
}



Measured memory_bytes: 2732
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        // if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/


signed main()
{
    fast;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    if(x[a-1]==b)cout<<1<<endl;
    else cout<<0<<endl;
}   


Measured memory_bytes: 3644
#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>;

int main(){
    int n,m;
    cin >> n >> m;
    vector <int> a(n+1,1);
    int aa;
    rep(i,m){
        cin >> aa;
        a[aa]=0;
    }
    vector <ll> ans(n+1);

    ans[0]=1;
    if(a[1]==0){
        ans[1]=0;
    }
    else{
        ans[1]=1;
    }
    rep(i,n-1){
        ans[i+2]=ans[i+1]+ans[i];
        if(a[i+2]==0){
            ans[i+2]=0;
        }
        ans[i+2]=ans[i+2]%1000000007;
    }

    cout << ans[n] << endl;
    

    return 0;
}

Measured memory_bytes: 1408
def powmod(b,r,mod)
  a = 1
  while r > 0
    if r%2 == 1
      a = a * b % mod
    end
    b = b * b % mod
    r /= 2
  end
  a
end

def invmod(f, mod)
  powmod(f, mod-2, mod)
end

require "prime"
N,*A = `dd`.split.map &:to_i
Mod = 10**9 + 7
qs = {}
A.each{ |a|
  a.prime_division.each{ |q,d| qs[q] = [qs[q] || 0, d].max }
}
LCM = qs.map{ |q,d| powmod(q,d,Mod) }.reduce(1){ |a,b| a * b % Mod }
p A.reduce(0){ |s,a|
  (s + (LCM * invmod(a,Mod))) % Mod
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    const int INF = 1000000000;
    int h, n;
    cin >> h >> n;
    int a[n], b[n];
    rep(i, n) cin >> a[i] >> b[i];
    int dp[n+1][20001];
    rep(i, n + 1)rep(j, 20001) dp[i][j] = INF;
    rep(i, n + 1) dp[i][0] = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= 20000; j++){
            if (a[i-1] <= j){
                dp[i][j] = min(dp[i-1][j], dp[i][j-a[i-1]] + b[i-1]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    int ans = INF;
    for (int i = h; i < 20001; i++){
        ans = min(ans, dp[n][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 78464
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;
 
    vl x(n), y(n);
    vl vx, vy;
    rep(i, n) {
        cin >> x[i] >> y[i];
        vx.pb(x[i]);
        vy.pb(y[i]);
    }
    sort(all(vx));
    sort(all(vy));
 
    ll ans = (vx[n-1] - vx[0])*(vy[n-1] - vy[0]);
    exrep(i1, 0, n-2) {
        exrep(i2, i1+1, n-1) {
            exrep(j1, 0, n-2) {
                exrep(j2, j1+1, n-1) {
                    ll cnt = 0;
                    rep(k1, n) {
                        if(vx[i1] <= x[k1] && x[k1] <= vx[i2] && vy[j1] <= y[k1] && y[k1] <= vy[j2]) {
                            cnt++;
                        }
                    } 
                    if(cnt >= k) {
                        chmin(ans, (vx[i2] - vx[i1])*(vy[j2] - vy[j1]));
                    }
                }
            }
        }
    }
 
    out(ans);
    re0;
}

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

int main(void){
    int h,a;
    cin >> h >> a;
    if(h % a == 0) cout << h / a << endl;
    else cout << (h / a) + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256