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

int main() {
    int A[3][3];
    bool ok[3][3];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> A[i][j];
            ok[i][j] = false;
        }
    }
    int N;
    cin >> N;
    vector<int>b(N);
    for(int i = 0; i < N; i++) {
        cin >> b[i];
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(b[i] == A[j][k]) {
                    ok[j][k] = true;
                }
            }
        }
    }
    if(ok[0][0]) {
        if(ok[0][1]) {
            if(ok[0][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[1][0]) {
        if(ok[1][1]) {
            if(ok[1][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[2][0]) {
        if(ok[2][1]) {
            if(ok[2][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][0]) {
        if(ok[1][0]) {
            if(ok[2][0]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][1]) {
        if(ok[1][1]) {
            if(ok[2][1]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][2]) {
        if(ok[1][2]) {
            if(ok[2][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][0]) {
        if(ok[1][1]) {
            if(ok[2][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][2]) {
        if(ok[1][1]) {
            if(ok[2][0]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}



int main2() {
  int N = nextInt();
  vector<int> h(N);
  REP(i, N) h[i] = nextInt();

  const int INF = 1001001001;
  vector<int> dp(N, INF);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    if (i + 1 < N) chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    if (i + 2 < N) chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
  }
  cout << dp[N-1] << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 1024
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def all_pattern(l):
    global n
    ans=0
    for ds in make_divisors(l)[1:]:
        k=n
        while k%ds==0:
            k//=ds
        ans+=(k%ds==1)
    return ans

n=int(input())
print(all_pattern(n)+all_pattern(n-1))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))

map<string, ll> m1;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n;
    	for(int i=0;i<n;i++)
    	{
    		string s;
    		cin>>s;
    		m1[s]++;
    	}
    	cout<<m1.size()<<endl;
    }
    return 0;
}

Measured memory_bytes: 19244
#include<stdio.h>
int main(){
int x,y,t;
while(scanf("%d %d",&x,&y)){
	if(x==0 && y==0){
		break;
	}
if(y<x){
t=x;
x=y;
y=t;
}
	printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 600
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	X := ReadInt()
	if X >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int a[112345];
int ans[112345];

int main()
{
    int n;

    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
    }
    ll sum = 0;

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

    REP(i,n){
        cout << ans[i] << endl;
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  ll n,k;
  cin >> n >> k;
  vector<ll> msk(50,0);
  rep(i,n){
    ll x;cin >> x;
    rep(j,50)msk[j] += (x >> j & 1);
  }
  vector<vector<ll>> dp(50,vector<ll>(2,-1));
  dp[44][1] = 0;
  for(int i = 43;i >= 0;i--){
    if(dp[i+1][0] >= 0)dp[i][0] = max(dp[i][0],dp[i+1][0]+max(n-msk[i],msk[i])*(1ll << i));
    if(dp[i+1][1] >= 0){
      if(k >> i & 1){
        dp[i][1] = max(dp[i][1],dp[i+1][1]+(n-msk[i])*(1ll << i));
        dp[i][0] = max(dp[i][0],dp[i+1][1]+msk[i]*(1ll << i));
      }else{
        dp[i][1] = max(dp[i][1],dp[i+1][1]+msk[i]*(1ll << i));
      }
    }
  }
  ll res = 0;
  res = max({res,dp[0][0],dp[0][1]});
  cout << res << endl;




  return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main() {
    string s;
    ll k;
    cin >> s >> k;
    int n = s.size();
    vector<ll>cnt(n);
    ll sum = 0;
    rep(i, 0, n){
        cnt[i] = (26-(s[i]-'a'))%26;
        sum += (26-(s[i]-'a'))%26;
    }
    //cout << sum << endl;
    if(sum >= k){
        string t;
        rep(i, 0, n-1){
            if(k-cnt[i]<0||cnt[i]==0){
                t += s[i];
                continue;
                //cout << k << endl;
            }
            k -= cnt[i];
            t += 'a';
            //cout << k << endl;
        }
        t += ((s[n-1]-'a')+k)%26 + 'a';
        cout << t << endl;
        return 0;
    }else{
        //aから何個進むか
        ll add = (k-sum)%26;
        string t;
        rep(i, 0, n)t += 'a';
        //t += ((s[n-1]-'a')+add)%26 + 'a';
        //cout << add << endl;
        while(add>0){
            if(t[n-1]=='z')t[n-1]='a';
            else t[n-1]++;
            add--;
        }
        cout << t << endl;
        return 0;
    }
}

Measured memory_bytes: 4316
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#define N 401
#define MIN(a,b) (((a)<(b))?(a):(b))
#define INF 0xFFFFFFFFFFFFFFFF
long long a[N];
long long s[N];

int main() {
	int n;
	std::cin>>n;
	memset(a,0,sizeof(a));
	memset(s,0,sizeof(s));
	unsigned long long dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	for (int i = 1; i <= n; ++i) {
		std::cin>>a[i];
		s[i] = s[i-1] + a[i];
	}
	if (n == 1) {
		printf("%lld\n", s[1]);
		return 0;
	}
	if (n == 2) {
		printf("%lld\n", s[2]);
		return 0;
	}
	for (int len = 2; len <= n; len++)
		for (int i = 1; i <= n - len + 1; i++){
			int j = i + len - 1 ;
			dp[i][j] = INF;
			for (int k = i; k < j; k++) dp[i][j] = std::min(dp[i][j], dp[i][k] + dp[k + 1][j] + s[j] - s[i - 1]) ;
	}
	printf("%llu\n", dp[1][n]);

	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(ll i = a; i < b; i++)
#define DB( x ) cout << #x << " = " << x << endl;
#define sz(s) ((int)((s).size()))
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef pair<int, pii> tri;
typedef vector <vector <ll>> matrix;
typedef pair<string, string> pss;

const ll mod = (ll)1e9 + 7;
const int MAX = (int)1e3 + 100;

const int oo = 0x3f3f3f3f;

char mat[MAX][MAX];

int n, m;

ll dp[MAX][MAX];

ll Solve(int i, int j){
    if(i > n || j > m)
        return 0;
    if(i == n && j == m)
        return 1LL;

    if(dp[i][j] != -1)
        return dp[i][j];

    ll ans = 0;

    int x = i + 1, y = j;

    if(mat[x][y] == '.')
        ans = (ans + Solve(x, y)) % mod;

    x = i, y = j + 1;

    if(mat[x][y] == '.')
        ans = (ans + Solve(x, y)) % mod;

    return dp[i][j] = ans;
}

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

    cin >> n >> m;

    for(int i = 1;i <= n;++i){
        string s; cin >> s;
        for(int j = 1;j <= m;++j)
            mat[i][j] = s[j - 1];
    }

    memset(dp, -1, sizeof(dp));

    cout << Solve(1, 1) << endl;
}


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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

int main()
{
    int q;
    cin >> q;
    list<ll> li;

    rep(i, 0, q)
    {
        string s;
        int a;
        cin >> s;
        if (s == "insert")
        {
            scanf("%d", &a);
            li.push_front(a);
        }
        else if (s == "deleteFirst")
        {
            li.pop_front();
        }
        else if (s == "deleteLast")
        {
            li.pop_back();
        }
        else if (s == "delete")
        {
            scanf("%d", &a);
            for (list_itr it = li.begin(); it != li.end(); it++)
            {
                if (*it == a)
                {
                    li.erase(it);
                    break;
                }
            }
        }
    }

    for (list_itr it = li.begin(); it != li.end(); it++)
    {
        if (it != li.begin() && it != li.end())
        {
            cout << " ";
        }
        cout << *it;
    }
    cout << endl;
}


Measured memory_bytes: 34364
n, k = map(int, input().split())
r, s, p = map(int, input().split())

rsp = {'r':0, 's':1, 'p':2}
t = [rsp[c] for c in input()]
point = [p, r, s]

dp = [[0] * n for _ in range(3)] # 0:r, 1:s, 2:p
if n <= k:
    ans = sum(point[i] for i in t)
else:
    for i in range(k):
        dp[t[i]][i] = point[t[i]]
    for i in range(k, n):
        for j in range(3):
            dp[j][i] = max(dp[(j+1) % 3][i-k], dp[(j+2) % 3][i-k])
            if j == t[i]:
                dp[j][i] += point[j]
    ans = 0
    for i in range(k):
        ans += max(dp[j][-1-i] for j in range(3))
print(ans)


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

int main() {
  string s;
  int gc = 0,pc = 0,ans = 0;
  cin >> s;
  rep(i,0,s.size()){
    if(s[i] == 'g'){
      if(pc < gc){pc++;ans++;}
      else gc++;
    }
    else{
      if(pc < gc) pc++;
      else{gc++;ans--;}
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include <limits.h>

int A[500001], n;
int parent(int i){
	return i / 2;
}

int left(int i){
	return 2 * i;
}

int right(int i){
	return 2 * i + 1;
}

void maxHeapify(int i){
	int largest,tmp;
	int l = left(i);
	int r = right(i);
	if (l <= n && A[l] > A[i])
		largest = l;
	else{
		largest = i;
	}
	if (r <= n && A[r] > A[largest])
		largest = r;
	if (largest != i){
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeapify(largest);

	}
}

void buildMaxHeap(){
	int i;
	for (i = n / 2; i >= 1; i--)
		maxHeapify(i);
}

int main(){
	
	int i,max=INT_MIN;
	
	for (i = 0; i < 500000; i++){
		A[i]= INT_MAX;
	}

	scanf("%d",&n);
	for (i = 1; i <= n; i++){
		scanf("%d",&A[i]);
		if (max < A[i]){ max = A[i]; }
	}

	maxHeapify(max);
	buildMaxHeap();
	for (i = 1; i <= n; i++){
		printf(" %d",A[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2552
k=int(input())
l=list(map(int, input().split(' ')))
a=l[0]
b=l[1]

if (b-a)+1>=k:
    print('OK')
else:
    maybe=(a//k)*k
    ans=False
    while maybe<=b:
        if maybe>=a:
            ans=True
            break
        else:
            maybe+=k
    if ans:
        print('OK')
    else:
        print('NG')


Measured memory_bytes: 9124
#include <bits/stdc++.h>//nCrを高速に求める関数　前処理でCOMinit()を行い、COM(n,k)を使用する
using namespace std;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    long long w,h; cin >> w >> h;
    COMinit();
    long long x,y;
    x = 2*w-h;
    y = 2*h-w;
    if(x%3==0 && y%3==0){
        cout << COM((x+y)/3,x/3) << endl;
    }
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 23680
#include <cstdio>
#include <map>
#define I(M,A) for(i=0;i<M;i++)scanf("%d",&x),A[i+1]=A[i]+x;
using namespace std;int main(){for(int n[1501], m[1501],o,a,b,i,j,x;scanf("%d%d",&a,&b),a;printf("%d\n",o)){map<int,int>z;n[0]=m[0]=o=0;I(a,n)I(b,m)for(i=0;i<=a;i++)for(j=0;j<=b;j++)z[n[i]+m[j]]++;for(map<int,int>::iterator p=z.begin();p!=z.end();p++)o+=(p->second)*((p->second)-1)/2;}}

Measured memory_bytes: 18000
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb emplace_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define add(x) (x > MOD ? x-MOD :(x<0 ? x+MOD:x))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 1e5 + 5;
vector<tuple<int, int, int>> g[N];
vector<tuple<int, int, int, int>> vc[N];
int n, m, a, b, c, d, x, y, u, v;
int anc[N][18], deep[N], len[N], ans[N];
int cur_cnt[N], cur_sum[N];
void dfs(int u, int o) {
  deep[u] = deep[o] + 1;
  anc[u][0] = o;
  for (int i = 1; i < 18; ++i)
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
  for (auto t : g[u]) {
    int v = get<0>(t), w = get<2>(t);
    if (v != o) {
      len[v] = len[u] + w;
      dfs(v, u);
    }
  }
}
void DFS(int u, int o) {
  for (int i = 0; i < vc[u].size(); ++i) {
    auto t = vc[u][i];
    int id = get<0>(t), c = get<1>(t), w = get<2>(t), f = get<3>(t);
    ans[id] -= f * cur_sum[c];
    ans[id] += f * cur_cnt[c] * w;
  }
  for (auto t : g[u]) {
    int v = get<0>(t), c = get<1>(t), w = get<2>(t);
    if (v != o) {
      cur_cnt[c]++;
      cur_sum[c] += w;
      DFS(v, u);
      cur_cnt[c]--;
      cur_sum[c] -= w;
    }
  }
}
inline int lca(int u, int v) {
  if (deep[u] < deep[v])
    swap(u, v);
  for (int i = 17; i >= 0; --i)
    if (deep[anc[u][i]] >= deep[v])
      u = anc[u][i];
  if (u == v)
    return u;
  for (int i = 17; i >= 0; --i)
    if (anc[u][i] != anc[v][i])
      u = anc[u][i], v = anc[v][i];
  return anc[u][0];
}
int main() {
//  freopen("input.in", "rt", stdin);
  scanf("%d %d", &n, &m);
  for (int i = 1; i < n; ++i)
    scanf("%d %d %d %d", &a, &b, &c, &d), g[a].pb(b, c, d), g[b].pb(a, c, d);
  dfs(1, 1);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d %d %d", &x, &y, &u, &v);
    int a = lca(u, v);
    ans[i] = len[u] + len[v] - 2 * len[a];
    vc[u].pb(i, x, y, 1);
    vc[v].pb(i, x, y, 1);
    vc[a].pb(i, x, y, -2);
  }
  DFS(1, 1);
  for (int i = 1; i <= m; ++i)
    printf("%d\n", ans[i]);
  return 0;
}


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

int main(int argc, char** argv)
{
	int num, sum = 0, buf;
	std::cin >> num;
	for (int i = 1; i <= num; i++)
	{
		for (int j = i; j <= num; j++)
		{
			for (int k = j; k <= num; k++)
			{
				if (i == j && j == k)
				{
					sum += i;
					break;
				}
				else if ((i == j || i==k || j==k )||(i!=j&&i!=k&&j!=k))
				{
					buf = i < j ? j : i;
					buf = buf < k ? k : buf;
					for (int l = buf; l > 0; l--)
					{
						if (i % l == 0 && j % l == 0 && k % l == 0)
						{
							sum += l*6;
							break;
						}
					}
				}
			}
		}
	}
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 3636
import qualified Data.Map.Strict as MP
import qualified Data.ByteString.Char8 as BC
import qualified Data.Vector.Unboxed as VU
import Data.Char
import Data.List

type Count = MP.Map Int Int

step :: (Count, Count) -> (Int,Int) -> (Count, Count)
step (emp,omp) (i,e)
    | even i = (emp', omp)
    | odd i = (emp, omp')
    where
        emp' = MP.adjust (+1) e emp
        omp' = MP.adjust (+1) e omp

solve :: Count -> Count -> Int -> Int
solve emp omp n
    | ek1 == ok1 = min (n-ev1-ov2) (n-ev2-ov1)
    | otherwise = n-ev1-ov1
    where
        ((ev1,ek1):(ev2,ek2):[]) = take 2 $ getList emp
        ((ov1,ok1):(ov2,ok2):[]) = take 2 $ getList omp

        getList :: Count -> [(Int, Int)]
        getList mp = sortBy (flip compare) $ MP.foldlWithKey (\acc k v  -> (v,k):acc) [] mp

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (BC.readInt . BC.dropWhile isSpace) <$> BC.getLine
    
    let
        base = VU.foldl' (\m k -> MP.insert k 0 m) MP.empty $ VU.fromList [1..10^5]
        (emp,omp) = VU.foldl' step (base, base) $ VU.zip (VU.fromList [1..n]) xs
        res = solve emp omp n
    
    print res

Measured memory_bytes: 39292
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
from functools import reduce
S=reduce(lambda x,y:(x+y)%mod,A)
B=[]
for i in range(n):
    S=(S-A[i])%mod
    B.append(S)
N=0
for i in range(n):
    N=(N+A[i]*B[i])%mod
print(N)

Measured memory_bytes: 102676
from collections import deque


def is_inside(x, y, W, H, G):
    return (x <= H-1 and y <= W-1 and
            x >= 0 and y >= 0 and
            G[x][y] != "#")


def main():
    H, W = map(int, input().split())
    Cx, Cy = map(int, input().split())
    Dx, Dy = map(int, input().split())

    G = [list(input()) for _ in range(H)]
    INF = int(1e9)
    q = deque()
    q.append((Cx-1, Cy-1, -INF, Cx-1, Cy-1))
    warps = [[INF] * W for _ in range(H)]
    while q:
        x, y, warp, prev_x, prev_y = q.popleft()

        if warps[x][y] != INF:
            continue

        num_warps = warps[prev_x][prev_y] + warp
        warps[x][y] = num_warps

        for step_x in range(-2, 3):
            for step_y in range(-2, 3):
                x_, y_ = x+step_x, y+step_y
                if is_inside(x_, y_, W, H, G) and warps[x_][y_] == INF:
                    if ((max(abs(step_x), abs(step_y)) == 1) and
                            (min(abs(step_x), abs(step_y)) == 0)):

                        q.appendleft((x_, y_, 0, x, y))
                    else:
                        q.append((x_, y_, 1, x, y))

    ans = warps[Dx-1][Dy-1]
    if ans == INF:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 239072
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define maxn 100005
#define inf 0x3f3f3f3f
using namespace std;

int n ,ERROR, info[maxn] , Prev[maxn * 2] , to[maxn * 2] , cnt_e , val[maxn] , sta[maxn] , rfa[maxn] , pt[maxn] , Min[maxn] , Max[maxn];
inline void Node(int u,int v){ Prev[++cnt_e] = info[u] , info[u] =cnt_e,to[cnt_e] = v; }

void dfs(int now,int ff)
{
    Min[now] = -inf , Max[now] = inf;
    if(val[now]!=0x3f3f3f3f) Min[now] = Max[now] = val[now];
	for(int i=info[now];i;i=Prev[i])
		if(to[i]!=ff)
		{
			dfs(to[i],now);
			Min[now] = max(Min[now] , Min[to[i]] - 1);
            Max[now] = min(Max[now] , Max[to[i]] + 1);
		}
	if(Min[now] > Max[now]) ERROR=1;
}

void ser(int now,int ff)
{
	if(ff) Min[now] = max(Min[now] , Min[ff] - 1) ,Max[now] = min(Max[now] , Max[ff] + 1);
	for(int i=info[now];i;i=Prev[i])
		if(to[i]!=ff)
			ser(to[i] , now);
}

void check(int now,int ff,int dist)
{
    if(val[now]!=0x3f3f3f3f && (val[now] % 2)!=dist) ERROR=1;
    for(int i=info[now];i;i=Prev[i])
		if(to[i]!=ff)
			check(to[i] , now , dist ^ 1);
}

int main()
{

	memset(val,0x3f,sizeof val);

	int u,v;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		Node(u,v),Node(v,u);
	}
	int k;
	scanf("%d",&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d%d",&u,&v);
		val[u] = v;
		pt[i] = u;
	}

	if(k==0)
        val[u = 1] = 10;

	check(u , 0 , val[u] % 2);
	dfs(u , 0);
	if(ERROR) puts("No");
	else
	{
		puts("Yes");
        ser(u , 0);
        for(int i=1;i<=n;i++)
			printf("%d\n",Min[i]);
	}
}


Measured memory_bytes: 8704
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); 
		int m = sc.nextInt();
		if(n > m ) System.out.println(n-1); 
		else System.out.println(n);
	}
}

Measured memory_bytes: 21712
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))




n=str(input1())

if "7" in n:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9176
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

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

int main()
{
  int h, w;
  cin >> h >> w;
  string s[110];
  for (int i = 0; i < h; i++)
  {
    cin >> s[i];
  }
  char ans[110][110];
  for (int i = 0; i < 110; i++)
  {
    for (int j = 0; j < 110; j++)
    {
      ans[i][j] = '#';
    }
  }
  for (int i = 1; i <= h; i++)
  {
    for (int j = 1; j <= w; j++)
    {
      ans[i][j] = s[i - 1][j - 1];
    }
  }
  for (int i = 0; i < h + 2; i++)
  {
    for (int j = 0; j < w + 2; j++)
    {
      cout << ans[i][j];
    }
    cout << "\n";
  }
}

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

long long INF = 1e9 + 7;

long long sum(long long left, long long right) {
	return (left + right) * (right - left + 1) / 2.0;
}

int main(void) {
	int N, K; cin >> N >> K;
	long long ans = 0;
	for (int i = K; i <= N + 1; i++) {
		long long left = sum(0, i - 1);
		long long right = sum(N - i + 1, N);
		ans += right - left + 1;
	}
	cout << ans % INF << endl;

	return 0;
}

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

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

const int INF = 1e9 + 7;

using namespace std;

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

	int h, w, n;
	cin >> h >> w >> n;

	vector<int> a(n);
	vector<vector<int>> ar(h, vector<int>(w, 0));
	rep (i, 0, n)
		cin >> a[i];

	int i = 0, j = 0, k = 0;
	int count = 0;
	while (i < h) {
		ar[i][j] = k + 1;
		if (++count == a[k]) {
			k++;
			count = 0;
		}

		if (i & 1) {
			if (j > 0)
				j--;
			else
				i++;
		} else {
			if (j < w - 1)
				j++;
			else
				i++;
		}
	}

	rep (i, 0, h) {
		rep (j, 0, w) {
			cout << ar[i][j] << " ";
		}
		cout << "\n";
	}


	return 0;
}


Measured memory_bytes: 384
n, t = map(int, input().split())
a = list(map(int, input().split()))

# print(a)

minv = a[0]

value = [0] * n
for i, v in enumerate(a[1:], 1):
    if minv >= v:
        value[i] = 0
        minv = v
    else:
        value[i] = v - minv

maxv = max(value)
# print(maxv)
print(value.count(maxv))


Measured memory_bytes: 15020
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res = "NA";
	string S; cin >> S;
	long ue = stol(S.substr(0, 2));
	long shita = stol(S.substr(2, 2));
	if (ue <= 12 && ue != 0) res = "MMYY";
	if (shita <= 12 && shita != 0) res = "YYMM";
	if (ue <= 12 && ue != 0) if (shita <= 12 && shita != 0) res = "AMBIGUOUS";

	cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

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

    long long count = 0;
    string s;
    map<string, long long> m;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        sort(s.begin(), s.end());

        if (m.find(s) != m.end()) {
            count += m[s];
            ++m[s];
        } else {
            m[s] = 1;
        }
    }
    cout << count << '\n';
}


Measured memory_bytes: 11136
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        p = L[i]+L[j]
        k = bisect.bisect_left(L[j+1:], p)
        ans += k

print(ans)




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

#ifdef DONLINE_JUDGE
//freopen("a.in", "r", stdin);
//freopen("a.out","w",stdout); // console output is better (in most cases)
#else
// add i/o method of specific testing system
#endif

using namespace std;

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

    int m, n;
    cin >> m >> n;
    int a[m][n], b[n];

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

    for(int j = 0; j < n; j++)
        cin >> b[j];

    for (int i = 0; i < m; ++i)
    {
        int sum = 0;
        for(int j = 0; j < n; j++)
        {
            sum += a[i][j] * b[j];
        }
        cout << sum << endl;
    }


    return 0;
}


Measured memory_bytes: 3204
H, W = map(int, input().split())
A = [input() for _ in range(H)]

grid = [['#'] * (W + 2) for _ in range(H + 2)]
for i in range(H + 2):
    for j in range(W + 2):
        if 1 <= i <= H and 1 <= j <= W:
            grid[i][j] = A[i - 1][j - 1]

for i in range(H + 2):
    print(*grid[i], sep='')


Measured memory_bytes: 4468
// AOJ 1201: Lattice Practices
// 2017.12.17 bal4u@uu

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

char a[10][6], b[10][6];
char *h[5], *v[5];
int same[10];
int ans;
void vset(int k, int s);

int check(int j)
{
	int i, k;
	for (i = 0; i <= j; i++) for (k = 0; k <= j; k++) if (h[i][k] == v[k][i]) return 0;
	return 1;
}

void hset(int k, int s)
{
	int i, bit;

	if (k == 5) { ans++; return; }
	for (bit = 1, i = 0; i < 10; i++, bit <<= 1) {
		if (s & bit) continue;
		h[k] = a[i];
		vset(k, s | bit);
		if (same[i]) continue;
		h[k] = b[i];
		vset(k, s | bit);
	}
}

void vset(int k, int s)
{
	int i, bit;

	for (bit = 1, i = 0; i < 10; i++, bit <<= 1) {
		if (s & bit) continue;
		v[k] = a[i];
		if (check(k)) hset(k+1, s | bit);
		if (same[i]) continue;
		v[k] = b[i];
		if (check(k)) hset(k+1, s | bit);
	}
}

int main()
{
	int i, j;

	while(scanf("%s", a[0]) && a[0][0] != 'E') {
		for (i = 1; i < 10; i++) scanf("%s", a[i]);
		for (i = 0; i < 10; i++) {
			for (j = 0; j < 5; j++) b[i][j] = a[i][4-j];
			same[i] = (memcmp(a[i], b[i], 5) == 0);
		}
		ans = 0;
		hset(0, 0);
		printf("%d\n", ans >> 3);
	}
	return 0;
}

Measured memory_bytes: 1772
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayDeque<Integer> stack = new ArrayDeque<Integer>();
		Scanner scan = new Scanner(System.in);

		while(scan.hasNext()) {
			Integer input = scan.nextInt();
			if(input == 0) {
				System.out.println(stack.pop());
			} else {
				stack.push(input);
			}
		}

		scan.close();

	}

}


Measured memory_bytes: 26048
# E - Roadwork
from bisect import bisect_left
from operator import itemgetter


def main():
    N, Q, *STXD = map(int, open(0).read().split())
    D = STXD[3 * N :]
    ans = [-1] * Q
    road = [-1] * Q  # (road[i] = x) := if -1: open / else: closed until x
    for s, t, x in sorted(zip(*[iter(STXD[: 3 * N])] * 3), key=itemgetter(2)):
        l, r = bisect_left(D, s - x), bisect_left(D, t - x)
        while l < r:
            if road[l] == -1:
                ans[l] = x
                road[l] = r
                l += 1
            else:
                l = road[l]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 93748
import java.util.*;

public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveB();
    }
    
    private void solveA() {
	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	System.out.println(A <= B ? A: A-1);
    }

    private void solveB() {
	Scanner sc = new Scanner(System.in);
	int[] n = new int[3];
	for(int i=0; i < 3; i++){
	    n[i] = sc.nextInt();	    
	}
	Arrays.sort(n);

	int k = sc.nextInt();

	for(int i=0; i < k; i++){
	    n[2] = n[2] * 2;	    
	}

	System.out.println(n[0] + n[1] + n[2]);
    }
}

Measured memory_bytes: 21844
n = int(input())
s = {}
for i in range(n):
    w = input()
    if w in s.keys():
        s[w] = s[w] + 1
    else:
        s[w] = 1
m = max(s.values())
r = [k for k, v in s.items() if v == m]
r.sort()
for i in r:
    print(i)

Measured memory_bytes: 32096
N = int(input())
A_list = [int(x) for x in input().split()]

now_i = 1
num = 0
for a_i in A_list:
    if a_i == now_i:
        now_i += 1
    else:
        num += 1
if now_i == 1:
    print(-1)
else:
    print(num)

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

int main(){
    int h,w,k; cin >> h >> w >> k;
    vector<vector<char> > c(h,vector<char>(w));
    vector<int> ch(h),cw(w);
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
            if(c[i][j]=='#'){
                ch[i]++;
                cw[j]++;
            }
        }
    }
    ll ans = 0;
    int cnt = 0;
    for(int bh=0;bh<(1<<h);bh++){
        for(int bw=0;bw<(1<<w);bw++){
            for(int i=0;i<h;i++){
                if(bh&(1<<i)) continue;
                for(int j=0;j<w;j++){
                    if(bw&(1<<j)) continue;
                    if(c[i][j]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
            cnt=0;
        }
    }
    cout << ans << endl;
}

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

int check(int p, int number){
    for(int i=0;i<1000;i++){
        if(pow(i+p,4) + pow(i+p,3) * i + pow(i+p,2) * pow(i,2) + pow(i+p,1) * pow(i,3) + pow(i,4) == number){
            return i ;
        }
    }
    for(int i=0;i > -1000;i--){
        if(pow(i+p,4) + pow(i+p,3) * i + pow(i+p,2) * pow(i,2) + pow(i+p,1) * pow(i,3) + pow(i,4) == number){
            return i ;
        }
    }
    return 10e6;
}

int main(){
    int X ;
    cin >> X ;
    vector<int> keep;
    int k = 1 ;
    int x = X ;
    while(k * k <= X ){
        if(x % k == 0 ) {
            keep.push_back(k);
            keep.push_back(-k);
            keep.push_back(X/k);
            keep.push_back(-X/k);
        }
        k ++ ;
    }
    //(a - b )(a^4 + a^3b + a^2b^2 + ab^3 + b^4)
    
    for(int i: keep){
        int number = X / i ;
        int ans = check(i,number) ;
        if(ans != 10e6 ) {
            cout << ans + i << " " << ans << endl ;
            return 0 ;
        }
    }

}

Measured memory_bytes: 4176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i, m) cin >> x[i];
  int ans = 0;
  vector<int> d(m - 1);

  sort(x.begin(), x.end());

  for(int i = 1; i < m; ++i) {
    d[i - 1] = abs(x[i] - x[i - 1]);
    
  }
  sort(d.begin(), d.end());

  for (int i = 0; i < m - n; ++i) {
    ans += d[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int a, b;
    cin >> a >> b;
    cout << (6 / a / b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int N;
    cin >> N;
    long long int D;
    cin >> D;
    long long int X[N];
    long long int Y[N];
    for(int i=0;i<N;i++){
        cin >> X[i] >> Y[i];
    }
    long long int Ans =0;
    for(int i=0;i<N;i++){
        if(X[i]*X[i]+Y[i]*Y[i]<=D*D){
            Ans++;
        }
    }
    cout << Ans << endl;
}


Measured memory_bytes: 6760
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;
}

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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  LL n, k, sum = 0;
  cin >> n >> k;
  vector<LL> f (n);
  for (auto &it : f) cin >> it;
  sort(f.begin(), f.end());
  for (int i = 0; i < n-k; i++) {
    sum += f[i];
  }
  cout << sum << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 4772
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Golden Apple
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, d;
  scanf("%d%d", &n, &d);

  int k = d * 2 + 1;
  printf("%d\n", (n + k - 1) / k);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var XY = Sarray();
            var diff = Abs(XY[0] - XY[1]);
            if (diff == 0 || diff == 1)
                WriteLine("Brown");
            else
                WriteLine("Alice");
        }
    }
}

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

int K, N;
vector<int> A(200000);

void solve(){
    int ans = A[N] -  A[1];
    for(int i = 1; i <= N - 1; ++i){
        ans = min(ans, A[i] + K - A[i + 1]);
    }
    cout << ans;
}
int main(){
    cin >> K >> N;
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		int count = 1;
		int sunny = 0;
		for(int i = 0; i < s.length(); i++) {
			if(i > 0 && s.charAt(i - 1) == 'R' && s.charAt(i) == 'R') {
				count++;
			}
			
			if(s.charAt(i) == 'S') {
				sunny++;
			}
		}
		
		if(sunny == s.length()) {
			count = 0;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 26984
using System;
using System.Collections.Generic;

namespace P0093_LeapYear
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var leap = new List<int>();

            for (int i = 1; i < 3000; i++) 
            {
                if (i % 4 == 0 ) 
                {
                    if (i % 100 != 0)
                    {
                        leap.Add(i);
                    }
                    else if (i % 400 == 0) 
                    {
                        leap.Add(i);
                    }

                }                 
            }

            var inputs = new List<string[]>();

            while (true)
            {

                var line = Console.ReadLine();
                if (line == "0 0") break;

                inputs.Add(line.Split(' '));

            }

            for (int j = 0; j < inputs.Count; j++ ) 
            {
                bool exist = false;

                for (int i = int.Parse(inputs[j][0]); i <= int.Parse(inputs[j][1]); i++)
                {
                    if (leap.Contains(i))
                    {
                        exist = true;
                        Console.WriteLine(i);
                    }
                }

                if (!exist) Console.WriteLine("NA");

                if (j != inputs.Count - 1) Console.WriteLine("");
            }

        }
    }
}

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

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))	
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)	
#define FloorN(x, n)	((x)-(x)%(n))			
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long			ll;
typedef unsigned long long	ull;
typedef pair<ll, ll>		P;
typedef vector<ll>			VLL;
typedef vector<VLL>			VVLL;
typedef vector<VVLL>		VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N;
	
	cin >> N;
	cout << Ceil(N, 2) << endl;
	return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double a, b, c;
    cin >> a >> b >> c;
    long double d = 2.000 * sqrt(a * b);
    if (a + b + d < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

//??\?????????
void swap(int *a, int *b){
	int temp = *a;
	*a = *b;
	*b = temp;
}

int main(){
	int str,mt[10];
	int i;
	
	for(i=0;i<10;i++){
		cin >> str;
		mt[i] = str;
	}
	
	// sort
	int num = 1;
	while(num<=3){
		str = mt[num-1];
		for(i=num;i<10;i++){
			if(str<mt[i]){
				str = mt[i];
				swap(mt[num-1],mt[i]);
			}
		}
		cout << mt[num-1] << "\n";
		num++;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import math

a,b,x=map(int,input().split())

if a*a*b==x:
    print(0)
elif (b*a*a)/2>=x:
    t=((2*x)/(a*b))
    print(math.degrees(math.atan(b/t)))
else:
    s=(2*((a*a*b)-x))/(a**2)
    print(math.degrees(math.atan(s/a)))

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

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

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { for (auto& _e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } pre__;

template< typename Monoid >
struct SegmentTree
{
	using F = function< Monoid(Monoid, Monoid) >;

	int sz;
	vector< Monoid > seg;

	const F f;
	const Monoid M1;

	SegmentTree(int n, const F f, const Monoid& M1) : f(f), M1(M1)
	{
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid& x)
	{
		seg[k + sz] = x;
	}

	void build()
	{
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid& x)
	{
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(ll a, ll b)
	{
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid operator[](const int& k) const
	{
		return seg[k + sz];
	}
};

//区間max
SegmentTree< pair<ll, int> > seg(1000100, [](pair<ll, int> a, pair<ll, int> b) { return a.first == b.first ? (a.second > b.second ? b : a) : (a.first > b.first ? a : b); }, make_pair(numeric_limits<ll>::min(), -1));


int main(void) {
	ll N, Q;
	cin >> N >> Q;
	vec<ll> A(Q), V(Q);
	vec<int> S(N);
	for (int i = 0; i < Q; ++i) {
		cin >> A[i] >> V[i];
		--A[i];
		S[A[i]] += V[i];
		seg.update(A[i], { S[A[i]], A[i] });
		auto s = seg.query(0, N);
		cout << s.second + 1 << " " << s.first << endl;
	}


	return 0;
}


Measured memory_bytes: 40976