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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

const int N = 55;
vector<LL>vec;
LL n , m , q;
struct DATA{
    LL a,b,c,d;
}ara[N];

LL ans;

LL score(vector<LL>&v)
{
    LL s = 0;
    for(LL i = 1;i <= q;i++){
        LL D = v[ara[i].b - 1] - v[ara[i].a - 1];
        LL C = ara[i].c;
        if(D == C)s += ara[i].d;
    }
    return s;
}
void rec(LL pos,LL pre)
{
    if(pos == n){
        ans = max(ans,score(vec));
        return;
    }
    for(LL i = pre;i <= m;i++){
        vec.push_back(i);
        rec(pos + 1,i);
        vec.pop_back();

    }
}
int main()
{

    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> n >> m >> q;
    FOR(i,1,q)cin >> ara[i].a >> ara[i].b >> ara[i].c >> ara[i].d;
    rec(0,1);
    cout << ans << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 3596
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"--->"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    unordered_map<string,ll> mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    cin>>n;
    string s;
    for(i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }

    cout<<"AC x "<<mp["AC"]<<NL;
    cout<<"WA x "<<mp["WA"]<<NL;
    cout<<"TLE x "<<mp["TLE"]<<NL;
    cout<<"RE x "<<mp["RE"]<<NL;

    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 3680
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    scan(N);
    auto S = readln.chomp.to!(char[]);

    foreach (i ; 0 .. S.length) {
        S[i] = (((S[i] - 'A') + N) % 26 + 'A').to!char;
    }

    writeln(S);
}



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

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

const int maxa = 1e6 + 1;
vector<int> spf(maxa + 1, 0);
vector<bool> can(maxa + 1, true);

int main() {

	iota(spf.begin(), spf.end(), 0);

	for (int i = 2; i * i <= maxa; i++) {
		if (spf[i] == i) {
			for (int j = i * i; j <= maxa; j += i) if (spf[j] == j) spf[j] = i;
		}
	}

	int n; cin >> n;
	int gd = 0;
	vector<int> a(n); for (int i = 0; i <= n - 1; i++) cin >> a[i], gd = gcd(gd, a[i]);

	bool is_setwise = (gd == 1);
	bool is_pairwise = true;


	for (int i = 0; i <= n - 1; i++) {
		int x = a[i];

		while (x != 1) {
			int pfac = spf[x];

			if (can[pfac] == false) {
				is_pairwise = false;
				break;
			}
			can[pfac] = false;

			while (x % pfac == 0) x /= pfac;
		}

		if (!is_pairwise) break;
	}

	if (is_pairwise) cout << "pairwise coprime";
	else if (is_setwise) cout << "setwise coprime";
	else cout << "not coprime";


	return 0;
}

Measured memory_bytes: 11064
'use strict'
function Main(input) {
  input = input.split("\n")
  let line1 = input[0].split(' ')
  let N = parseInt(line1[0])
  let K = parseInt(line1[1])
  let A = input[1].split(' ')
  let ret = 0
  let minPos = -1
  for (let i = 0; i < N; i += 1) {
    if (minPos === -1 || A[minPos] > A[i]) minPos = i
  }
  console.log(Math.floor((N - 1 + K - 2) / (K - 1)))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 16716
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int b = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'E') {
			b++;
		}
	}
	int mini = b;
	int c = b;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'E') {
			c--;
		}
		if (s[i - 1] == 'W') {
			c++;
		}
		mini = min(mini, c);
	}
	cout << mini << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define P1 pair<pair<int,int>,int>
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

vector<vector<int>>warshall_floyd(int n,vector<vector<int>>&d) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
	for (int j = 0; j < n; j++)    // 開始頂点
	  for (int k = 0; k < n; k++)  // 終端
		d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
	return d;
}

signed main(){
	int N,M,L;
	cin >> N >> M >> L;
	vector<vector<int>>d(N,vector<int>(N,INF));
	REP(i,N)d[i][i] = 0;
	REP(i,M){
		int a,b,c;
		cin >> a >> b >> c;
		if(c>L)continue;
		a--;b--;
		d[a][b]=c;
		d[b][a]=c;
	}
	warshall_floyd(N,d);
	vector<vector<int>>dd(N,vector<int>(N,INF));
	REP(i,N){
		REP(j,N){
			if(d[i][j]<=L)dd[i][j]=1;
		}
	}
	warshall_floyd(N,dd);

	int Q;
	cin >> Q;
	vector<int>ans;
	while(Q--){
		int s,t;
		cin >> s >> t;
		s--;t--;
		ans.push_back(dd[s][t]);
	}
	for(auto e:ans){
		if(e==INF)cout<<-1<<endl;
		else cout<<e-1<<endl;
	}
}

Measured memory_bytes: 2832
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>


using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);

}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int d[210];
bool flag = true;
bool fl = true;
struct edge { int to, cost; };
std::vector<edge>v[100];
bool used[210];

int main() {
	ll a, b, c, ans = INF2;
	std::cin >> a >> b >> c;
	ans = min(ans, llabs(a*b*(c / 2) - a*b*(c - (c / 2))));
	ans = min(ans, llabs(a*c*(b / 2) - a*c*(b - (b / 2))));
	ans = min(ans, llabs(b*c*(a / 2) - b*c*(a - (a / 2))));
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h.at(i);
	}

	vector<int> dp(n, inf);
	dp.at(0) = 0;

	// 貰うDP
	/*
	for (int i = 1; i < n; i++)
	{
		dp.at(i) = min(dp.at(i), dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
		if (i - 2 >= 0)
		{
			dp.at(i) = min(dp.at(i), dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
		}
	}
	*/

	// 配るDP
	for (int i = 0; i < n - 1; i++)
	{
		dp.at(i + 1) = min(dp.at(i + 1), dp.at(i) + abs(h.at(i + 1) - h.at(i)));
		if (i + 2 < n)
		{
			dp.at(i + 2) = min(dp.at(i + 2), dp.at(i) + abs(h.at(i + 2) - h.at(i)));
		}
	}
	

	cout << dp.at(n - 1) << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int flag=0;
    int n;
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0 ||i%5==0);
        else sum+=(ll)i;
    }
    printf("%lld",sum);
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define int long long
#define S second
#define F first
#define pb push_back
#define sz size()
using namespace std;
const int N=5e6+7;
int a[N],dp[N] ;
int n,x=1,ans,k ;
vector < int > vec ;
vector < int > pos ;
multiset < int > st ;
main()
{
    cin >> n >> k ;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i] ;
        dp[i]=1e17 ;
    }
    dp[1]=0 ;
    for (int i=2;i<=n;i++)
        for (int j=max(x,i-k);j<i;j++)
            dp[i]=min(dp[i],dp[j]+abs(a[j]-a[i])) ;
    cout << dp[n] ;
}


Measured memory_bytes: 5132
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int d[35][200100];
int main(){
    int n,c; cin>>n>>c;
    rep(i,n){
        int s,t,ch; cin>>s>>t>>ch;
        d[ch][2*s-1]++;
        d[ch][2*t]--;
    }
    int ans=0;
    rep(i,200010){
        int cnt=0;
        rep(ch,35){
            d[ch][i+1]+=d[ch][i];
            if(d[ch][i]>0) cnt++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    string s;

	cin >> s;

	cout << s.substr(0, 4) << " " << s.substr(4) << End;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

template <typename T>
class CumSum1D
{
public:
    CumSum1D(){};
    ~CumSum1D(){};
    void init(vector<T>& arr) {
        m_cum = arr;
        m_N = arr.size();
        FOR(i, 1, m_N) m_cum[i] += m_cum[i - 1];
    }
    // get sum of [l, r]. 0-based.
    T getSum(int l, int r) {
        T ret = m_cum[r];
        if (l != 0) ret -= m_cum[l - 1];
        return ret;
    }
private:
    size_t m_N;
    vector<T> m_cum;
};

int main(void)
{
    cin.sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> As(N);
    REP(n, N) cin >> As[n];

    sort(ALL(As));
    CumSum1D<ll> from_min;
    from_min.init(As);

    reverse(ALL(As));
    CumSum1D<ll> from_max;
    from_max.init(As);
    
    ll best_ans = -1e10;
    ll best_i = -1;
    FOR(i, 1, N) { // plusになる個数
        ll ans1 = from_max.getSum(0, i - 1);
        ll ans2 = from_min.getSum(0, N - i - 1);
        ll ans = ans1 - ans2;
        if (ans > best_ans) {
            best_ans = ans;
            best_i = i;
        }
    }

    cout << best_ans << endl;
    vector<ll> plus;
    vector<ll> minus;
    REP(i, best_i) {
        plus.pb(As[i]);
    }
    reverse(ALL(As));
    REP(i, N - best_i) {
        minus.pb(As[i]);
    }
    
    ll cur = minus[0];
    auto plus_num = SIZE(plus);
    auto minus_num = SIZE(minus);
    REP(i, plus_num - 1) {
        cout << cur << " " << plus[i] << endl;
        cur = cur - plus[i];
    }
    cout << plus.back() << " " << cur << endl;
    cur = plus.back() - cur;

    FOR(i, 1, minus_num) {
        cout << cur << " " << minus[i] << endl;
        cur -= minus[i];
    }

    assert(cur == best_ans);

    return 0;
}


Measured memory_bytes: 5236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int count = 0;
		boolean flag = false;
		for(int i=0;i<n;i++){
			sc.nextLine();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if(a==b){
				count++;
				if(count >= 3){
					flag = true;
					break;
				}
			}else{
				count = 0;
			}
		}
		
		if(flag){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 36152
#include<stdio.h>
int main(void)
{
  int a,b,d,r;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/b;
  printf("%d %d %f\n",d,r,f);
  return 0;
}



Measured memory_bytes: 2056
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

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

signed main() {
  int N;
  cin >> N;
  vector<int> a(N + 2), l(N + 2, 0), r(N + 2, 0);
  for (int i = 1; i <= N; i++) cin >> a[i];

  for (int i = 1; i <= N; i++) l[i] = gcd(l[i - 1], a[i]);
  for (int i = N; i >= 0; i--) r[i] = gcd(r[i + 1], a[i]);

  int ans = 1;
  for (int i = 1; i <= N; i++) ans = max(ans, gcd(l[i - 1], r[i + 1]));

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


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int A[112345];
int ans;
bool flag[112345];

int main(){
	
	cin>>N;
	
	fill( flag, flag+112345, 0 );
	
	REP( i, N ){
		scanf("%d", A+i);
		if( A[i] == (i+1) ){
			flag[i+1] = 1;
		}
	}
	
	int b = 0;
	
	FOR( i, 1, N+1 ){
		if( flag[i] ) b++;
		else{
			b = 0;
		}
		if( b % 2 ) ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
	
}

Measured memory_bytes: 768
#include<stdio.h>

int main()
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a == 1 || b == 1) {
		if (a == 1 && b != 1) printf("Alice\n");
		else if (b == 1 && a != 1)printf("Bob\n");
		else printf("Draw\n");
	}
	else {
		if (a < b) {
			printf("Bob\n");
		}
		else if (b < a) {
			printf("Alice\n");
		}
		else {
			printf("Draw\n");
		}
	}

	return 0;

}

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

using namespace std;

int main()
{
	int t;
	
  int i,j,k,n,m,d;
  
  cin>>n>>d;
  i=0;
  while(n--)
  {
  	
  	double x,y,z;
  	cin>>x>>y;
  	
   z=sqrt(x*x+y*y);
   
   if(z<=(double)d)
    i++;
	
	 	
  	 
  	 
  	
  	
  }
  
  cout<<i<<endl;

}


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

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int N, M;
  char A[50][50], B[50][50];
  cin >> N >> M;

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

  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++)
      cin >> B[i][j];
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i + M - 1 >= N || j + M - 1 >= N) continue;
      
      int match = 1;
      for (int bi = 0; bi < M; bi++) {
        for (int bj = 0; bj < M; bj++) {
          if (A[i + bi][j + bj] != B[bi][bj]) match = 0;
        }
      }
      if (match) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#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 pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#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 vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int k;
    int a, b;
    cin >> k;
    cin >> a >> b;
    bool ok = false;
    for(int i=a;i<=b;i++){
        if(i%k==0) ok = true;
    }

    if(ok) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}

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

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};

int main() {
	int n, m; cin >> n >> m;
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	vector<string> grid(n);
	for(int i = 0; i < n; ++i) {
		cin >> grid[i];
	}
	sx--, sy--, tx--, ty--;
	if(grid[sx][sy] == '#' || grid[tx][ty] == '#') {
		cout << -1 << '\n';
		return 0;
	}
	vector<vector<int>> comp(n, vector<int>(m, -1));
	int c = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			if(grid[i][j] == '.' && comp[i][j] == -1) {
				queue<pair<int,int>> q;
				q.push({i, j});
				comp[i][j] = c;
				while(!q.empty()) {
					int cx = q.front().first;
					int cy = q.front().second;
					q.pop();
					for(int dir = 0; dir < 4; ++dir) {
						int nx = cx + dx[dir];
						int ny = cy + dy[dir];
						if(nx < 0 || nx >= n || ny < 0 || ny >= m || grid[nx][ny] == '#' || comp[nx][ny] != -1) continue;
						comp[nx][ny] = c;
						q.push({nx, ny});
					}
				}
				c++;
			}
		}
	}

	vector<set<int>> adj(c, set<int>());
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			if(grid[i][j] == '.') {
				for(int a = -2; a <= 2; ++a) {
					for(int b = -2; b <= 2; ++b) {
						int nx = i + a;
						int ny = j + b;
						if(nx < 0 || nx >= n || ny < 0 || ny >= m || comp[nx][ny] == -1) continue;
						if(comp[nx][ny] != comp[i][j]) {
							adj[comp[i][j]].insert(comp[nx][ny]);
						}
					}
				}
			}
		}
	}

	int src = comp[sx][sy];
	int tar = comp[tx][ty];
	int ans = -1;

	queue<int> q;
	q.push(src);

	vector<bool> vis(c, false);
	vis[src] = true;

	int steps = 0;
	while(q.size()) {
		int sz = q.size();
		while(sz--) {
			int tp = q.front(); q.pop();
			if(tp == tar) {
				ans = steps;
				break;
			}
			for(auto nxt : adj[tp]) {
				if(!vis[nxt]) {
					vis[nxt] = true;
					q.push(nxt);
				}
			}
		}
		steps++;
		if(ans != -1)
			break;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 33284
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> cou(N);
    REP(_, Q)
    {
        int a;
        cin >> a;
        cou[a - 1]++;
    }
    REP(i, N)
    {
        cout << (K - Q + cou[i] > 0 ? "Yes" : "No") << endl;
    }
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    vvl c(3,vl(3));
    rep(i,3)rep(j,3)cin>>c[i][j];
    vl a(3),b(3);
    rep(i,3)b[i] = c[0][i] - a[0];
    bool check = true;
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    rep(i,3)rep(j,3)if(a[i]+b[j] != c[i][j]){
        out("No");
        return 0;
    }
    out("Yes");
}


Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	lint x; cin>>x;
	cout<< x/500*1000 + (x%500)/5*5<<endl;
    return 0;
}

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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

class Stack{
private:
int m[1000];
int tp;
public:
    Stack(){
    tp=0;
    }
    void push(int x){
        tp++;
        m[tp]=x;
    }
    int pop(){
        tp--;
        return m[tp+1];
    }
}; 
class Queue{
private:
pair<string,int> m[60000];
int head,tail;
public:
    Queue(){
        head=0;
        tail=0;
    }
    bool isEmpty(){
        return head==tail;
    }
    void enqueue(pair<string,int> x){
        m[tail]=x;
        if(tail +1 ==60000)tail=0;
        else tail++;
    }
    pair<string,int> deque(){
        pair<string,int> x=m[head];
        if(head+1==60000)head=0;
        else head++;
        return x;
    } 
};

int main(){
int n;
while(1){
cin>>n;
if(n==0)break;
char vote[n];
pair<char,int> can[26];
pair<char,int> winner;
int wind;
bool tie=false;
bool determine=false;
//65
REP(i,26){
    can[i].first=65+i;
    can[i].second=0;
}

winner=can[0];
REP(i,n)cin>>vote[i];
REP(i,n){

REP(j,26){
if(vote[i]==can[j].first){
can[j].second++;
winner= (can[j].second>winner.second)? can[j]:winner;
if(!determine){
determine=true;
REP(k,26){
    if(winner.first!=can[k].first)if(!(winner.second>can[k].second+n-i-1))determine=false;
}
if(determine)wind=i+1;
}
}
}
}

REP(i,26){
if(winner.first!=can[i].first)if(winner.second==can[i].second)tie=true;
}

if(tie)cout<<"TIE"<<endl;
else cout<<winner.first<<" "<<wind<<endl;
}
}


Measured memory_bytes: 3076
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define si set<int>
#define msi map<string, int>
#define rsz(a) resize(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
int digits(int n) {
  n = abs(n);
  if(n < 10) return 1;
  elif(n < 100) return 2;
  elif(n < 1000) return 3;
  elif(n < 10000) return 4;
  elif(n < 100000) return 5;
  elif(n < 1000000) return 6;
  elif(n < 10000000) return 7;
  elif(n < 100000000) return 8;
  elif(n < 1000000000) return 9;
  else return 10;
}


int main() {
  io();
  
  int n, m;
  cin >> n >> m;
  --n, --m;
  int a = (n * (n + 1))/2;
  int b = (m * (m + 1))/2;
  cout << a + b;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    vector<int> c(N, 0), ans(N, -1);
    vector<P> t(N);

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        c[a]++;
        c[b]++;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, N) {
        t[i] = P(c[i], i);
    }
    sort(all(t));

    rep(i, N) cin >> c[i];
    sort(all(c));

    queue<int> que;
    que.push(t[N - 1].second);
    int cost = N - 1;
    while (!que.empty()) {
        int v = que.front(); que.pop();
        ans[v] = c[cost];
        cost--;
        rep(i, G[v].size()) {
            int to = G[v][i];
            if (ans[to] != -1) continue;
            que.push(to);
        }
    }
/*
    rep(i, N) {
        cout << t[i].second << "  " << t[i].first << endl;
    //    ans[t[i].second] = c[i];
    }
*/
    ll res = 0;
    rep(i, N - 1) res += c[i];

    cout << res << endl;
    rep(i, N - 1) cout << ans[i] << " ";
    cout << ans[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1152
import java.util.Arrays;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int d[] = new int[N];

		for (int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}

		Arrays.sort(d);

		System.out.print(d[N / 2] - d[N / 2 - 1]);
	}
}

Measured memory_bytes: 51328
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(x, y) pb(mp(x, y))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(), (VECTOR).end()

int main(){

	string S;
	cin >> S;
	ll snum = 0, ans = 0;
	for(int i = 0; i < S.size(); i ++){
		if(S[i] == 'T' && snum > 0){
			ans ++;
			snum --;
		}
		if(S[i] == 'S')snum ++;
	}
	cout << S.size() - ans * 2 << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0;
	cin>>n;
	vector<int> b(n);
	for(int i=1;i<n;i++)cin>>b[i];
	vector<int> a(n+1);
	ans+=b[1];
	for(int i=2;i<n;i++)
	{
		ans+=min(b[i-1],b[i]);
	}
	ans+=b[n-1];
	cout<<ans;
	return 0;
}

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

int main()
{
    long long k, a, b;
    cin >> k >> a >> b;
    if (a >= k || b - a <= 2)
    {
        cout << k + 1 << endl;
        return 0;
    }
    k -= a - 1;
    long long ans = (b - a) * (k / 2) + (k % 2) + a;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

using namespace std;

int main(){
  while(int l = getInt()){
    int sum = 0;
    int ans = 12;

    REP(i,12){
      int m = getInt();
      int n = getInt();

      sum += m - n;

      if(sum >= l)
	ans = min(ans, i);
    }

    if(ans == 12) puts("NA");
    else printf("%d\n", ans + 1);
  }
  return 0;
}

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

int main(){
    int a,b,c,f =0;
    cin>>a>>b>>c;
    
    for(int x=a; x<=b; x++){
        if(c%x==0){
            f=f+1;
        }
    
    }
    cout<<f<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	int l[10];
	int v1, v2;
	while (scanf(" ") != EOF)
	{
		for (int i = 0; i < 10; ++i)
			scanf("%d,", l+i);
		if (scanf("%d,%d", &v1, &v2) == EOF)
			break;

		int len = 0;
		for (int i = 0; i < 10; ++i)
			len += l[i];
		double across = (double)v1*len/(v1+v2);
		int t = 0;
		for (int i = 0; i < 10; ++i)
		{
			t += l[i];
			if (across <= t)
			{
				printf("%d\n", i+1);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,s,e) for(int i=s;i<e;i++)
#define endl '\n'
int main(){
    lli A,B,C,K;cin>>A>>B>>C>>K;
    lli res;
    if(K<=A)res=K;
    else if(K<=A+B)res=A;
    else if(K<=A+B+C)res=A-(K-A-B);
    cout<<res<<endl;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;

vector<ll> v;
map<ll, ll> M;

int main(void)
{
	ll n, i, ans = 0;

	scanf("%lld", &n);

	for (i = 2; i * i <= n; i++)
		if (n % i == 0)
		{
			ll tmp = n;
			while (tmp % i == 0)
				tmp /= i;

			if (tmp % i == 1)
			{
				M[i]++;
				v.push_back(i);
			}

			tmp = n;
			while (tmp % (n / i) == 0)
				tmp /= (n / i);

			if (tmp % (n / i) == 1)
			{
				M[n / i]++;
				v.push_back(n / i);
			}
		}
	
	ll cnt = 0;
	for (i = 1; i * i <= n - 1; i++)
		if ((n - 1) % i == 0)
		{
			++cnt;
			M[i]++;
			M[(n - 1) / i]++;
			v.push_back(i);
			v.push_back((n - 1) / i);
		}

	for (i = 0; i < v.size(); i++)
		if (M[v[i]])
		{
			++ans;
			M[v[i]] = 0;
		}
	
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
{- SPDX-License-Identifier: X11
 -
 - Copyright 2020 Elias Yuan <a@jthv.ai>, MIT/X11 License
 -   https://jthv.ai/LICENSE/X11.txt
 -
 - ANU-CPC Observation Workshop - B: Sorted Arrays
 -   2020-05-06
 -}

module Main where

import System.IO (print)

solve :: String -> Int
solve = sol . unDup . strToInts
  where
    strToInts :: String -> [Int]
    strToInts = map (read :: String -> Int) . words

    unDup :: [Int] -> [Int]
    unDup (x:y:ys)
      | x == y    = unDup (y:ys)
      | otherwise = x:unDup (y:ys)
    unDup x = x

    sol :: [Int] -> Int
    sol []  = 0
    sol [_] = 1
    sol (x:y:ys)
      | x < y     = s 1 True (y:ys)
      | x > y     = s 1 False (y:ys)
      | otherwise = error "sol: That shouldn't have been possible"
      where
        s :: Int -> Bool -> [Int] -> Int
        s acc fl (a:b:c:cs)
          | fl && a < b || not fl && a > b = s acc fl (b:c:cs)
          | fl && a > b || not fl && a < b = s (acc + 1) (b < c) (b:c:cs)
          | otherwise                      = error "s: That shouldn't have been possible"

        s acc fl [a,b]
          | fl && a < b || not fl && a > b = acc
          | fl && a > b || not fl && a < b = acc + 1
          | otherwise                      = error "s: That shouldn't have been possible"

        s acc _ _ = acc


main :: IO ()
main = getLine >> getLine >>= \x -> print $ solve x


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

using namespace std;

int main(){
	int dx[8] = { -1, 0, 1, -1, 1, -1,  0,  1 };
	int dy[8] = {  1, 1, 1,  0, 0, -1, -1, -1 };
	int H, W; cin >> H >> W;
	char S[H][W];
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			cin >> S[i][j];
		}
	}
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if(S[i][j] == '.'){
				char count = 48;
				for(int k = 0; k < 8; ++k){
					int nowx = j + dx[k];
					int nowy = i + dy[k];
					if(0 <= nowx && nowx < W && 0 <= nowy && nowy < H && S[nowy][nowx] == '#'){
						count++;
					}
					S[i][j] = count;
				}
			}
		}
	}
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			cout << S[i][j];
		}
		cout << endl;
	}
}

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

int gcd(int a, int b) {
    if (a > b) {
        if (a % b == 0) {
            return b;
        } else {
            return gcd(b, a % b);
        }
    }
    else {
        if (b % a == 0) {
            return a;
        } else {
            return gcd(a, b % a);
        }
    }
}

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

    int L[N] = {0};
    int R[N] = {0};
    for (int i = 0; i < N; ++i) {
        if (i == 0) {
            L[i] = A[i];
            R[i] = A[N-i-1];
        } else {
            L[i] = gcd(L[i-1], A[i]);
            R[i] = gcd(R[i-1], A[N-i-1]);
        }
    }

    int max = 0;
    for (int i = 0; i < N; ++i) {
        if (i == 0) {
            max = std::max(max, R[N-i-2]);
        } else if (i == (N-1)) {
            max = std::max(max, L[i-1]);
        } else {
            max = std::max(max, gcd(L[i-1], R[N-i-2]));
        }
    }
    
    std::cout << max << std::endl;

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

/* ?????????????´??????????????????? */
void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
		/* ??£??\??????????´??????????1????????????????????? */
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

/* ?????\?????????(0??????????????????) */
void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}

Measured memory_bytes: 600
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();

		int cnt=0;
		for (int a=0;a<A+1;a++) {
			for (int b=0;b<B+1;b++) {
				int x = X-a*500-b*100;
				if (x>=0 && x%50==0 && x/50<=C) {
					cnt++;
				}

			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main(){
int H,N;
  cin>>H>>N;
for(int i=0;i<N;i++){
	int A;
	cin>>A;
	H-=A;
}
if(H<=0)
  cout<<"Yes";
else 
  cout<<"No";

return 0;
}


Measured memory_bytes: 3628