akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200005];
int visited[200005];
int curr=0;
int counter=0;
void explore(int v)
    {counter++;
    visited[v]=1;
    for(auto x:adj[v]){if(visited[x]==0){explore(x);}}
    }
int DFS(int n)
    {for(int i=0;i<n;i++){if(visited[i]==0){counter=0;explore(i);curr=max(curr,counter);}}
    return curr;
    }
int main()
    {ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int u,v;
    memset(visited,0,sizeof(visited));
    for(int i=0;i<m;i++)
        {cin>>u>>v;u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
        }
    cout<<DFS(n)<<"\n";
    }

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long x, k, d;
    cin >> x >> k >> d;

    long long change = abs(x) / d;
    if (x < 0) x += min(change, k) * d;
    else x -= min(change, k) * d;
    k -= min(change, k);
    if (k % 2) {
        if (x < 0) x += d;
        else x -= d;
    }
    cout << abs(x) << "\n";

    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
ll inf = 1e10;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i, n) cin >> a[i+1];
  if(n % 2 == 0){
    for(int i = n; i >= 2; i -= 2) cout << a[i] << " " ;
    for(int i = 1; i <= n-1; i += 2) cout << a[i] << " " ;
  }
  else{
    for(int i = n; i >= 1; i -= 2) cout << a[i] << " " ;
    for(int i = 2; i <= n-1; i += 2) cout << a[i] << " " ;
  }
  return 0;
}   

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


int main() {

    int A, B;
    cin >> A >> B;
    if ((A+B) % 2 == 0) {
        cout << (A+B)/2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

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

int main(){
    int N, T;
    cin >> N >> T;
    int min_cost = 1001;
    for (int i = 0; i < N; i++){
        int c, t;
        cin >> c >> t;
        if (c < min_cost && t <= T){
            min_cost = c;
        }
    }
    if (min_cost == 1001){
        cout << "TLE" << endl;
    }
    else{
        cout << min_cost << endl;
    }
}

Measured memory_bytes: 256
def check(mid, b, c1, c2, q1):
  if mid + (b - mid * c1) // c2 < q1:
    return False
  return True

while True:
  s = input()
  if s == "0":
    break
  
  q1, b, c1, c2, q2 = map(int, s.split())
  max_aizu = min(b // c1, q2)
  
  if max_aizu <= 0:
    print("NA")
    continue
  
  if c2 >= c1:
    max_normal = (b - max_aizu * c1) // c2
    if max_aizu + max_normal < q1:
      print("NA")
    else:
      print(max_aizu, max_normal)
    continue
  
  if (b - c1) // c2 + 1 < q1:
    print("NA")
    continue

  left = 0
  right = max_aizu + 1
  while right - left > 1:
    mid = (left + right) // 2
    if check(mid, b, c1, c2, q1):
      left = mid
    else:
      right = mid
  
  print(left, (b - left * c1) // c2)



Measured memory_bytes: 5600
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

template <long long mod>
long long mod_pow(long long a, long long b) {
    if (b == 0) return 1;
    long long ret = mod_pow<mod>(a, b / 2);
    ret = ret * ret % mod;
    if (b % 2 == 1) ret = a * ret % mod;
    return ret;
}

const int MAX_K = 100000;
const ll MOD = TEN(9) + 7;
ll n, k;
ll cnt[MAX_K + 1];

int main() {
    fastio();

    cin >> n >> k;

    ll ans = 0;
    for (ll i = k; i >= 1; i--) {
        ll x = k / i;

        ll temp = mod_pow<MOD>(x, n);

        for (ll j = 2 * i; j <= k; j += i) {
            //cout << "!" << i << endl;
            temp = (temp - cnt[j] + MOD) % MOD;
        }

        //cout << i << " " << temp << endl;

        cnt[i] = temp;

        ans = (ans + temp * i % MOD) % MOD;
    }

    cout << ans % MOD << endl;

    return 0;
}

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

char in[(2*100000) + 1] = {0};

int main(void)
{
	long long counter = 0;
	long long b_count = 0;
	int i = 0;

	scanf("%s", &in[0]);
	for(i = 0; i < (strlen(in)) ; i++) {
		if (in[i] == 'B') {
			b_count++;
		}
		if (in[i] == 'W') {
			counter += b_count;
		}
	}
    printf("%lld\n",counter);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MAX 5001
typedef unsigned long long ull;
ull B=9999973;

int n,m;
string a[12];
ull b[12];

vector<int> G[MAX];
bool dp[MAX][(1<<12)];
string s,tmp;

int main(){
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    for(int i=0;i<MAX;i++)G[i].clear();
    memset(b,0,sizeof(b));
    memset(dp,0,sizeof(dp));
    s="";
    for(int i=0;i<n;i++){
      cin>>a[i];
      for(int j=0;j<(int)a[i].size();j++)
        b[i]=b[i]*B+a[i][j];
    }
    for(int i=0;i<m;i++)cin>>tmp,s+=tmp;

    for(int i=0;i<n;i++){
      int size=a[i].size();
      ull C=1,key=0;
      for(int j=0;j<(int)s.size();j++){
        key=key*B+s[j];
        if(j-size>=0)key-=s[j-size]*C;
        else C*=B;
        if(key==b[i])G[j-size+1].push_back(i);
      }
    }

    ull ans=0;
    for(int i=0;i<(int)s.size();i++){
      dp[i][0]=true;
      for(int S=0;S<(1<<n);S++){
        if(dp[i][S]==false)continue;
        for(int j=0;j<(int)G[i].size();j++){
          int id=G[i][j];
          int size=a[id].size();
          if(S>>id&1)continue;
          dp[i+size][S|(1<<id)]=true;
        }
      }
      ans+=dp[i][(1<<n)-1];
    }
    if(dp[s.size()][(1<<n)-1])ans++;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 21796
fun main(args:Array<String>):Unit {
    readLine()
    val nums = readLine()!!.split(' ').map(String::toInt)
    readLine()
    println( if (readLine()!!.split(' ').map(String::toInt).all{
        nums.binarySearch(it) >= 0
    }) 1 else 0)
}


Measured memory_bytes: 86704
//ehhhhh...... i hate you......

/* optimizations and other useless stuff*/
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e14
#define ull unsigned long long int
using namespace std;
/* TYPE DEFINITIONS */
typedef     long long int   ll;
typedef     vector<ll>      vi;
typedef     pair<ll,ll>     pi;


/* Basic  Math!!! */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll ncr(int n, int k)  
{  
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 

/* MACROS */
#define  all(A)         (A).begin() , (A).end()
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).sbegin()) it = (a).begin(); it != (a).end(); it++)  
void solve()
{
    ll n,c=0;
    cin>>n;
    ll arr[n];
    forn(i,n)cin>>arr[i];
    ll dp[n+1]={0};
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

int main()
{
    FastIO;
    ll c=0;
    ll t=1;
   // cin>>t;
    while(t--)
    {
        //cout<<"Case "<<++c<<": ";
        solve();
    }
}

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

int H, W, M;

int row[300005], col[300005];
vector<pair<int, int> > squares;

struct st
{
	private:int s, e, maximum;
	private:st *left, *right;
	
	public:st(int _s, int _e)
	{
		s = _s;
		e = _e;
		maximum = 0;
		
		if(s == e)
			return;
			
		int mid = s + (e - s) / 2;
		
		left = new st(s, mid);
		right = new st(mid + 1, e);
	}
	
	public:void update(int pos, int val)
	{
		if(pos < s && pos > e)
			return;
		
		if(s == e)
		{
			maximum = val;
			return;
		}
		
		int mid = s + (e - s) / 2;
		if(pos <= mid)
			left -> update(pos, val);
			
		else
			right -> update(pos, val);
			
		maximum = max(left -> maximum, right -> maximum);
	}
	
	public:int query(int qs, int qe)
	{
		if(qs > qe)
			return 0;
			
		if(qs <= s && e <= qe)
			return maximum;
			
		if(e < qs || qe < s)
			return 0;
			
		return max(left -> query(qs, qe), right -> query(qs, qe));
	}
};

st *root;

int currPtr = 0;
int queryRow(int rowNum)
{
	int maximum = 0, start = 1;
	
	while(currPtr < (int)(squares.size()) )
	{
		if(squares[currPtr].first < rowNum)
		{
			currPtr++;
			continue;
		}
		
		if(squares[currPtr].first > rowNum)
			break;

		maximum = max(maximum, col[squares[currPtr].second] - 1);
		maximum = max(maximum, root -> query(start, squares[currPtr].second - 1)); 
		
		//printf("start = %d, end = %d, ans = %d\n", start, squares[currPtr].second - 1, root -> query(start, squares[currPtr].second - 1) );
		
		start = squares[currPtr].second + 1;
		currPtr++;
	}
	
	//printf("start = %d, W = %d, ans = %d\n", start, W, root -> query(start, W));
	//printf("\n");
	maximum = max(maximum, root -> query(start, W));

	return maximum + row[rowNum];
}

int main()
{
	scanf("%d%d%d", &H, &W, &M);
	for(int i = 1; i <= M; i++)
	{
		int hi, wi;
		scanf("%d%d", &hi, &wi);
		
		row[hi]++;
		col[wi]++;
		squares.push_back(make_pair(hi, wi));
	}
	sort(squares.begin(), squares.end());
	
	root = new st(1, W);
	for(int i = 1; i <= W; i++)
	{
		root -> update(i, col[i]);
		//printf("%d ", root -> query(i, i));
	}
	//printf("\n");
	
	int ans = 0;	
	for(int i = 1; i <= H; i++)
		ans = max(ans, queryRow(i));
	printf("%d", ans);
}


Measured memory_bytes: 36164
n,q=map(int,input().split())
s=input()
cnt=[0 for i in range(n+1)]
for i in range(1,n+1):
    if s[i-1:i+1]=="AC":
        cnt[i]+=1
    cnt[i]+=cnt[i-1]
#print(cnt)
for i in range(q):
    a,b=map(int,input().split())
    print(cnt[b-1]-cnt[a-1])

Measured memory_bytes: 7772
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if ((a + b) > (c + d)) cout << "Left" << endl;
  else if ((a + b) < (c + d)) cout << "Right" << endl;
  else cout << "Balanced" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

void Do(int N){
  int i, j, n, m;
  int x[N], y[N];
  double S;
  n = 1;
  for(i = 0;i < N;i++){
    scanf("%d %d", &x[i], &y[i]);
    n *= i + 1;
  }
  m = 2 * n / N;
  S = 0.;
  for(i = 0;i < N;i++) for(j = i + 1;j < N;j++) S += m * sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
  printf("%f\n", S / n);
}

int main(void){
  int N;
  scanf("%d", &N);
  Do(N);
  return 0;
}


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

using namespace std;
using namespace atcoder;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];

    auto c = fenwick_tree<ll>(N);
    for(int i = 0 ; i < N ; i++)
        c.add(i, a[i]);
    for (int i = 0; i < Q; i++) {
        int t;
        cin >> t;
        if (t == 0) {
            int p, x;
            cin >> p >> x;
            c.add(p, x);
        } else {
            int l, r;
            cin >> l >> r;
            cout << c.sum(l, r) << endl;
        }
    }
    // Failed to predict input format
    return 0;
}


Measured memory_bytes: 10152
n,m=map(int,input().split())
dp=[-1 for i in range(n+1)] #dp[i]=はi段目
for i in range(m):
	a=int(input())
	dp[a]=0
dp[0]=1
if dp[1]<0:
	dp[1]=1
for i in range(2,n+1):
	if dp[i]<0:
		dp[i]=(dp[i-1]+dp[i-2])%1000000007
print(dp[n]%1000000007)

Measured memory_bytes: 7056
#include <iostream>
using namespace std;
typedef long long ll;
ll GCD(ll a, ll b) {
    return (a == 0) ? b : GCD(b % a, a);
}
ll LCM(ll a, ll b) {
    if (a > b) {
        a ^= b; b = a xor b; a = a xor b;
    }
    return a*b/GCD(a, b);
}
int main() {
    int a[3], m[3];
    while (1) {
        cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2];
        if (!a[0] && !m[0] && !a[1] && !m[1] && !a[2] && !m[2]) {
            break;
        }
        int move[3];
        for (int i=0; i<3; ++i) {
            int val = 1;
            for (int j=1; j<=m[i]; ++j) {
                val = a[i] * val % m[i];
                if (val == 1) {
                    move[i] = j; break;
                }
            }
        }
        ll ans = LCM(LCM(move[0], move[1]), move[2]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,m;cin>>n>>m;
  int s=0,t=0;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    if(a<n) s+=(n-a),t=max(t,n-a);
  } 
  cout<<s-t<<endl;
  return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

LL f(LL a){
    if(a%2 == 0){
        return a ^ (((a+1)/2)%2);
    }
    else{
        return ((a+1)/2)%2;

    }


}

void Main()
{
    LL a,b;cin>>a>>b;

    cout<<(f(a-1) ^ f(b))<<endl;
    
	return;
}

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

Measured memory_bytes: 3648
n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
sum = arr[0]
i = 1
n = n-1
while n>1:
    if n==2:
        sum += arr[i]
        i += 1
        n -= 2
    else:
        sum += 2*arr[i]
        i += 1
        n -= 2
print(sum)

Measured memory_bytes: 31388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)

int const N = 500;
int n, x[N][N], dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
bool em[N][N];

void go(int a, int b, int c){
	f(i, 0, 4){
		int na = a + dx[i], nb = b + dy[i];
		if (na == -1 || na == n || nb == -1 || nb == n || x[na][nb] <= c)continue;
		x[na][nb] = c;
		go(na, nb, c + !em[na][nb]);
	}
}

int main(){
	scanf("%d", &n);
	f(i, 0, n)f(j, 0, n)x[i][j] = min(min(i, n - 1 - i), min(j, n - 1 - j));
	int an = 0;
	f(i, 0, n * n){
		int t;
		scanf("%d", &t);
		--t;
		int a = t / n, b = t % n;
		an += x[a][b];
		em[a][b] = true;
		go(a, b, x[a][b]);
	}
	printf("%d\n", an);
}

Measured memory_bytes: 20388
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long a, b, d;
        for (long i = 1; i <= 3500; i++) {
            for (long j = 1; j <= 3500; j++) {
                a=4*i*j-N*i-N*j;
                if (a<=0) continue;
                b=N*i*j;
                d = gcd(a,b);
                a/=d;
                b/=d;
                if (a==1) {
                    System.out.println(i + " " + j + " " + b);
                    return;
                }
//                long k = lcm(lcm(i, j), N);
//                long a = k/i;
//                long b = k/j;
//                long c = k/N;
//                if ((a+b+1) == (4*c)) {
//                    System.out.println(i + " " + j + " " + k);
//                    return;
//                }
            }
        }
    }

    private static long gcd(long a, long b) {
        while (b > 0) {
            long temp = b;
            b = a % b; // % is remainder
            a = temp;
        }
        return a;
    }


    private static long lcm(long a, long b) {
        return a * (b / gcd(a, b));
    }
}

Measured memory_bytes: 23124
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll F[100050];
int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);

	F[0] = 1;
	for (i = 1; i <= 100000; i++) F[i] = F[i - 1] * i % MOD;

	int c = 0;
	if (abs(N - M) == 1) c = 1;
	if (abs(N - M) == 0) c = 2;
	return !printf("%lld\n", (c*F[N] * F[M]) % MOD);
}

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int A,B,C;

int main(){
	cin>>A>>B>>C;
	if(C>=A and C<=B){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((ll)(1e18))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> a(N, 0);
	rep (i, N){
		cin >> a[i];
	} // end rep

	vector<ll> csum(N, 0LL);
	csum[0] = a[0];
	for (int i = 1; i < N; ++i){
		csum[i] = csum[i-1] + (ll)a[i];
	} // end for
		
	ll res = INF;
	for (int i = 0; i < N-1; ++i){
		ll x = csum[N-1] - csum[i];
		ll y = csum[i];
		ll curr = abs(x - y);
		res = min(res, curr);
	} // end for

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2560
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    complex<ld>   P;
#define    X   real()
#define    Y   imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf   1000000000000000001
#define    ninf   -1000000000000000001
#define    ima   1000000001
#define    imi   -1000000001
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	
ll ans=0;
ll n;
cin>>n;
for(ll i=1;i<=n;i++)
{
	for(ll j=1;j<=n;j++)
	{
		for(ll k=1;k<=n;k++)
		{
			ll an=gcd(i,j);
			an=gcd(an,k);
			ans+=an;
		}
	}
}
cout<<ans;

}return 0;}

Measured memory_bytes: 3696
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)
	if (B-A)%2 == 0 {
		fmt.Println((B - A) / 2)
		return
	}
	fmt.Println(Min(A-1, N-B) + 1 + (B-A-1)/2)
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}


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

int main() {
  int N,A,B,a,b,c,d,e,cnt=0,s;
  cin >> N >> A >> B;
  for(int i=1; i<=N; i++) {
    a=i/10000;
    b=i%10000/1000;
    c=i%1000/100;
    d=i%100/10;
    e=i%10;
    s=a+b+c+d+e;
    if(s>=A&&s<=B) {
      cnt+=i;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  char a,b;
  cin>>a>>b;
  if(a<b)
  {
    cout<<"<"<<endl;
  }
  else if(a>b)
  {
    cout<<">"<<endl;
  }
  else
  {
    cout<<"="<<endl;
  }

}
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include <iostream>
#include<stdlib.h>
//#include <algorithm>
#include <limits>
#include<string>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
struct DSU{
  ll num;
  ll size;
};
DSU *par;//親の番号
//n要素で初期化
void init(int n){
  rep(i,n){
    par[i].num=i;
    par[i].size=1;
  }
  return;
}
//木の根を求める
ll root(ll x){
  if(par[x].num==x){
    return x;
  }else{
    ll r = root(par[x].num);
    par[x].num=r;
    return r;//経路圧縮
  }
}

//x,yが同じ集合に属するか否か
bool same(ll x,ll y){
  if(root(x)==root(y)){
    return true;
  }else{
    return false;
  }
}
//x,yの属する集合を併合
void unite(ll x,ll y){
  if(same(x,y)==true){
    return;
  }
  par[root(x)].size+=par[root(y)].size;
  par[root(y)].size=par[root(x)].size;
  par[root(y)].num=root(x);
  return;
}
ll size(ll x){
  ll sum = par[root(x)].size;
  return sum;
}
int main(void){
	ll N,M;
  cin >> N >> M;
  par = (DSU*)malloc(sizeof(DSU)*N);
  init(N);
  ll ans[M+1];
  ll Na=1;
  ll Nb=1;
  ll a[M],b[M];
  rep(i,M){
    cin >> a[i] >> b[i];
    a[i]-=1;
    b[i]-=1;
  }
  ans[M]=(N*(N-1))/2;
  for(int i=M-1;i>=1;i--){
    if(same(a[i],b[i])==true){
      Na=0;Nb=0;
      //cout << "same";
      ans[i]=ans[i+1];
      continue;
    }
    Na=size(a[i]);
    Nb=size(b[i]);
      //cout << size(a[i],N) << " " << size(b[i],N) << endl;
      unite(a[i],b[i]);
    ans[i]=ans[i+1]-(ll)(Na*Nb);
  }
  for(ll i=0;i<M;i++){
    cout << ans[i+1] << endl;
  }
	return 0;
}

Measured memory_bytes: 5248
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;
 
int main(void)
{
	long long int x, y;
	long long int res=0, n;

	cin >> x >> y;
	res = 1;
	n = x;
	while (1)
	{
		n *= 2;
		if (n > y)
		{
			break;
		}
		res++;
	}

	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
(N,K)=input().split()
(N,K)=(int(N),int(K))
d=[0 for i in range(K)]
A=[0 for i in range(K)]
M=[]
for i in range(1,N+1):
  M.append(i)
for i in range(K):
  d[i]=int(input())
  A[i]=input().split()
  for j in range(len(A[i])):
    A[i][j]=int(A[i][j])
    if A[i][j] in M:
      M.remove(A[i][j])
print(len(M))

Measured memory_bytes: 67812
import numpy as np
N = int(input())
P = np.array(input().split(), dtype=float)

dp = np.zeros(N + 1, dtype=float)
dp[0] = 1

for p in P:
    newDP = dp * (1-p)
    newDP[1:] += dp[:-1] * p
    dp = newDP

n = (N + 1) // 2
ans = dp[n:].sum()
print(ans)


Measured memory_bytes: 22404
N,K=map(int, input().split())
S=list(input())
Ans=""

if S[K-1]=="A":
  S[K-1]="a"
elif S[K-1]=="B":  
    S[K-1]="b"
elif S[K-1]=="C":  
    S[K-1]="c"

for i in range(N):
  Ans=Ans+S[i]

print(Ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int n, k;
    long long r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    long long pts = 0;
    for (int i = 0; i < k; i++)
    {
        if (t[i] == 'r')
        {
            pts += p;
            t[i] = 'p';
        }
        else if (t[i] == 'p')
        {
            pts += s;
            t[i] = 's';
        }
        else
        {
            pts += r;
            t[i] = 'r';
        }
    }

    for (int i = k; i < n; i++)
    {
        if (t[i] == 'r' && t[i - k] != 'p')
        {
            pts += p;
            t[i] = 'p';
        }
        else if (t[i] == 'p' && t[i - k] != 's')
        {
            pts += s;
            t[i] = 's';
        }
        else if (t[i] == 's' && t[i - k] != 'r')
        {
            pts += r;
            t[i] = 'r';
        }
        else t[i] = '?';
    }

    cout << pts;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show(const T& t) {cout<<t<<LN;}
template<class T> void show(const vector<T>& v) {cout<<joined(v)<<LN;}
void show(bool b) {cout<<(b?"Yes":"No")<<LN;}
void show(double d) {cout<<fixed<<setprecision(12)<<d<<LN;}

bool is_prime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    ll X;
    cin >> X;
    while (!is_prime(X)) {
        X++;
    }
    show(X);
}


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

int main(void)
{
    long long int a,b,c,i,j,k,n;

    cin >> a;

    if(a<1200) cout << "ABC";
    if(a>=1200 && a<2800) cout << "ARC";
    if(a>=2800) cout << "AGC";
    return 0;
}

Measured memory_bytes: 256
// AOJ 0142: Nature of Prime Numbers
// 2017.8.16 bal4u@uu
// 2018.1.24

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int a[10002];
int d[10002];
char f[10002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, i, j, k, b, m;

	while (n = in()) {
		k = n >> 1;
		memset(d, 0, sizeof(d));
		memset(f, 0, sizeof(f));
		for (m = 0, i = 1; i <= k; i++) {
			b = i*i% n;
			if (!f[b]) f[b] = 1, a[m++] = b;
		}
		for (i = 0; i < m; i++) {
			for (j = 0; j < i; j++) {
				if (b = a[i] - a[j]) {
					if (b < 0) b += n;
					if (b > k) b = n - b;
					d[b]++;
				}
			}
		}
		for (i = 1; i <= k; i++) printf("%d\n", d[i]<<1);
	}
	return 0;
}



Measured memory_bytes: 2028
#include<stdio.h>

int main(){
	
	int N,a[3][110],i,j,ans=0,c;
	scanf("%d",&N);
	
	for(i=1;i<=2;i++){
		for(j=1;j<=N;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=1;i<=N;i++){
		c=0;
		for(j=1;j<=i;j++){
			c+=a[1][j];
		}
		for(j=i;j<=N;j++){
			c+=a[2][j];
		}
	if(ans<c){
		ans=c;
	}
	}
	
	printf("\n%d\n",ans);
	
	return 0;
}

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

int n, jumlahsatuan, tetap;

int main (){
	cin>>n;
	tetap=n;
	while(n>0){
		jumlahsatuan+=n%10;
		n/=10;
	}
	if (tetap%jumlahsatuan==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

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

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

#define pow CHANGETHENAMESTUPID

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

char s[100][100];

void load() {
	int n, m; scanf("%d%d", &n, &m);
	FOR(i, n) scanf("%s", s[i]);
	auto bad = [&](int x, int y) {
		return x < 0 || x >= n || y < 0 || y >= m || s[x][y] == '#';
	};
	int dx[] = {1, -1, 0, 0};
	int dy[] = {0, 0, 1, -1};
	int maxi = 0;
	FOR(i, n) FOR(j, m) {
		if (bad(i, j)) continue;
		queue<int> Q;
		Q.push(i); Q.push(j);
		int bio[n][m];
		FOR(x, n) FOR(y, m) bio[x][y] = -1;
		bio[i][j] = 0;
		while (!Q.empty()) {
			int x = Q.front(); Q.pop();
			int y = Q.front(); Q.pop();
			FOR(k, 4) {
				int x_ = x + dx[k];
				int y_ = y + dy[k];
				if (bad(x_, y_)) continue;
				if (bio[x_][y_] == -1) {
					bio[x_][y_] = bio[x][y] + 1;
					maxi = max(maxi, bio[x_][y_]);
					Q.push(x_); Q.push(y_);
				}
			}
		}
	}
	printf("%d\n", maxi);
}

void solve() {

}

int main() {
	load();
	solve();
	return 0;
}


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

using namespace std;

int main()
{
  int n, m;
  float temp =0;
  cin>>n>>m;
  int a[n];
  for(int i=0; i<n; i++)
  {
    cin>>a[i];
    temp += a[i];
  }
  temp = temp /(4.0*m);
  int count =0;
  for(int i=0; i<n; i++)
  {
    if(a[i] >= temp)
      count++;
  }
  if(count >= m)
    cout<<"Yes";
  else
    cout<<"No";
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <math.h>
#include <complex>
using ll = long long;
using namespace std;
int const MOD = 1e9 + 7;
ll const INF = (1LL << 50);
#define rep(i, n) for (int i = 0; i < (n); i++)

using P = pair<ll, ll>;
bool operator<(const P &a, P &b)
{
    if (a.first == b.first)
        return a.second < b.second;
    return a.first < b.first;
}

struct Node
{
    ll to, cost;
};
vector<vector<Node>> G(210);
ll d[210][210];
int N, M, R;

int main(void)
{
    cin >> N >> M >> R;

    vector<ll> r;
    for (int i = 0; i < R; ++i)
    {
        ll a;
        cin >> a;
        a--;
        r.push_back(a);
    }

    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            d[i][j] = 1e9;

    for (int i = 0; i < M; ++i)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    for (int i = 0; i < N; ++i)
    {
        priority_queue<P, vector<P>, greater<P>> que;
        que.push({i, 0}); //地点 最短距離
        d[i][i] = 0;
        while (!que.empty())
        {
            P p = que.top();
            que.pop();

            int v = p.first;
            if (d[i][v] < p.second)
                continue;

            for (int j = 0; j < G[v].size(); ++j)
            {
                Node e = G[v][j]; //j番目 vから次のVへ移る
                if (d[i][e.to] > d[i][v] + e.cost)
                {
                    d[i][e.to] = d[i][v] + e.cost;
                    que.push({e.to, d[i][e.to]});
                }
            }
        }
    }
    // for (int i = 0; i < N; ++i)
    // {
    //     for (int j = 0; j < N; ++j)
    //     {
    //         cout << d[i][j];
    //     }
    //     cout << endl;
    // }
    sort(r.begin(), r.end());
    ll ans = INF;
    do
    {
        ll t = 0;
        for (int i = 1; i < R; ++i)
        {
            t += d[r[i - 1]][r[i]];
        }
        ans = min(ans, t);
    } while (next_permutation(r.begin(), r.end()));

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

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

int main() {
  string sss;
  cin >> sss;
  int ans = 0;
  int a = 0;
  for(int i = 0; i < sss.size(); i++) {
    if(sss.at(i) == 'A' || sss.at(i) =='T' || sss.at(i) == 'G' || sss.at(i) == 'C') {
      a++;
    }
    else {
      ans = max(ans, a);
      a = 0;
    }
    ans = max(ans, a);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

num = len(set(a))
ans = 0

if num <= k:
    print(ans)
    exit()
else:
    dict_a = {}
    for i in a:
        if i not in dict_a:
            dict_a[i] = 1
        else:
            dict_a[i] += 1
    a_values = [v for v in dict_a.values()]
    a_values.sort()
    i = 0
    while num > k:
        ans += a_values[i]
        num -= 1
        i += 1

print(ans)

Measured memory_bytes: 36916
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

void end(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  ll n;
  cin >> n;
  ll t[n+1], x[n+1], y[n+1];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  REP(i,n){
    cin >> t[i+1] >> x[i+1] >> y[i+1];
    if(t[i+1]-t[i]<abs(x[i+1]-x[i])+abs(y[i+1]-y[i])) end();
    if((t[i+1]+x[i+1]+y[i+1])%2!=0) end();
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 2560
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    new = [a[k][j:j+m] for k in range(i, i+m)]
    if new == b:
      print("Yes")
      exit()
print("No")


Measured memory_bytes: 3060
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ii d[MAXn];
ll h[MAXn];

int main()
{
    IOS();
    ll n;
    cin>>n;
    REP(i,n)cin>>d[i].X>>d[i].Y>>h[i];
    for(ll x = 0;x <= 100;x++)
    {
      for(ll y = 0;y <= 100;y++)
      {
        ll mxh = INF;
        ll dth = -1;
        bool fg = 1;
        REP(i,n)
        {
          if(h[i] == 0)
          {
            mxh = min(mxh,abs(d[i].X - x) + abs(d[i].Y - y));
          }
          else{
            ll tmp = h[i] + abs(d[i].X - x) + abs(d[i].Y - y);
            if(dth != -1 && dth != tmp)
            {
              fg = 0;
              break;
            }
            else dth = tmp;
          }
        }
        if(!fg)continue;
        if(dth != -1 && dth <= mxh)
        {
          cout<<x<<" "<<y<<" "<<dth<<endl;
          return 0;
        }
        else if(dth == -1 && mxh != INF && mxh > 0)
        {
          cout<<x<<" "<<y<<" "<<1<<endl;
          return 0;
        }
      }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    String a = scanner.next();
		    
		    if( a.equals("a") || a.equals("i") || a.equals("u") 
		    						|| a.equals("e") || a.equals("o") )
		    {
		    	System.out.println("vowel");
		    }
		    else 
		    {
		    	System.out.println("consonant");
		    }
		    scanner.close(); }
		  }

Measured memory_bytes: 22100
#include<iostream>
#include<vector>
#include<map>

using namespace std;

struct Memo
{

  int count;
  bool flag;

  Memo()
  {
    count = 0;
    flag = false;
  }

};

Memo memo[31][4];

int ProgressNumberOfYears(int step_num, int step_kind)
{

  int kind_count = 0;

  if(step_num == 0) return 1;
  else if(memo[step_num][step_kind].count) return memo[step_num][step_kind].count;

  for(int i = 1; i < 4; ++i) if(step_num - i >= 0)kind_count = kind_count + ProgressNumberOfYears(step_num - i,i);

  memo[step_num][step_kind].count = kind_count;

  return kind_count;

}

int main()
{

  int step_num;

  while(cin >> step_num && step_num != 0) cout << ProgressNumberOfYears(step_num,0)/10/365 + 1<< endl;

  return 0;

}

Measured memory_bytes: 1160
n = gets.to_i
a = gets.split.map(&:to_i)

non_even = a.map{|v| v.even?}.count(false)
four_val = a.map{|v| v % 4 == 0}.count(true)

if four_val >= n/2
  puts 'Yes'
elsif non_even <= four_val
  puts 'Yes'
else
  puts 'No'
end



Measured memory_bytes: 9988
#include<stdio.h>
int main(void)
{
	int i,a[]={2048,1024,512,256,128,64,32,16,8,4,2,1},x[12],m;
	double n,s;
	while(1){
		scanf("%lf",&n);
		if(n<0)break;
		m=n*16;
		n=n*16;
//		printf("%f\n",n);
		if(n-m>0||n>4095){
			printf("NA\n");
		}
		else{
			for(i=0;i<12;i++){
//			printf("%d %d\n",m-a[i],i);
				if(m-a[i]>=0){
					x[i]=1;
					m-=a[i];
				}
				else{
					x[i]=0;
				}
//				printf("%d\n",m);
			}
			for(i=0;i<12;i++){
				if(i==8){
					printf(".");
				}
				printf("%d",x[i]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

struct Player
{
  int num;
  double time;
};

void PlayerSwap( Player* player1, Player* player2 )
{
  Player tmp;
  tmp = *player1;
  *player1 = *player2;
  *player2 = tmp;
}

void PlayerSort( Player* players, int length)
{
  for (int i=1; i<length; i++)
  {
    for (int j=i; j !=0 && players[j].time < players[j-1].time; j--)
    {
      PlayerSwap(&players[j], &players[j-1]);
    }
  }
}

int main()
{
  const int player_length = 24;
  Player players[player_length];
  Player final_players[8];
  for (int i=0; i<player_length; i++)
  {
    cin >> players[i].num >> players[i].time;
  }

  for (int i=0; i<3; i++)
  {
    Player* plr[8];
    for (int j=0; j<8; j++)
    {
      plr[j] = &players[i*8+j];
    }
    PlayerSort( *plr, 8 );
    for (int j=0; j<2; j++)
    {
      final_players[i*2+j] = players[i*8+j];
      players[i*8+j].time = 1000;
    }
  }

  PlayerSort( players, player_length );
  final_players[6] = players[0];
  final_players[7] = players[1];

  for (int i=0; i<8; i++)
  {
    cout << final_players[i].num << ' ' << final_players[i].time << endl;
  }
}

Measured memory_bytes: 1296