akhauriyash/Code-Regression huggingface dataset:
from bisect import*
class BTreeNode:
    def __init__(self):self.key,self.child=[],[]
class BTree:
    def __init__(self):self.root=BTreeNode()
    def search_higher(self,key):
        ptr=self.root
        ret=None
        while ptr.child:
            i=bisect(ptr.key,key)
            if i!=len(ptr.key):ret=ptr.key[i]
            ptr=ptr.child[i]
        i=bisect(ptr.key,key)
        if i!=len(ptr.key):ret=ptr.key[i]
        return ret
    def search_lower(self,key):
        ptr=self.root
        ret=None
        while ptr.child:
            i=bisect_left(ptr.key,key)
            if i:ret=ptr.key[i-1]
            ptr=ptr.child[i]
        i=bisect_left(ptr.key,key)
        if i:ret=ptr.key[i-1]
        return ret
    def insert(self,key):
        def insert_rec(ptr):
            b_size=512
            if not ptr.child:
                insort(ptr.key,key)
                if len(ptr.key)==b_size*2-1:
                    ret=BTreeNode()
                    ret.key=ptr.key[:b_size]
                    ptr.key=ptr.key[b_size:]
                    return ret
            else:
                i=bisect(ptr.key,key)
                tmp=insert_rec(ptr.child[i])
                if tmp:
                    ptr.key.insert(i,tmp.key.pop())
                    ptr.child.insert(i,tmp)
                    if len(ptr.child)==b_size*2:
                        ret=BTreeNode()
                        ret.child=ptr.child[:b_size]
                        ptr.child=ptr.child[b_size:]
                        ret.key=ptr.key[:b_size]
                        ptr.key=ptr.key[b_size:]
                        return ret
        tmp=insert_rec(self.root)
        if tmp:
            root=BTreeNode()
            root.key=[tmp.key.pop()]
            root.child=[tmp,self.root]
            self.root=root
def main():
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    t=BTree()
    t.insert(0)
    t.insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(t.search_higher(v)-v)*(v-t.search_lower(v))*i
        t.insert(v)
    print(c)
main()

Measured memory_bytes: 25884
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("Sunny")){
            System.out.println("Cloudy");
        }else if(s.equals("Cloudy")){
            System.out.println("Rainy");
        }else{
            System.out.println("Sunny");
        }
        sc.close();
    }
}

Measured memory_bytes: 20820
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 510;

vector<vector<ll>> table(n_max, vector<ll>(n_max, 0));
void dfs(vector<ll> elem, ll cl) {
    int sz = elem.size();
    if(sz == 1)return ;
    vector<ll> left(sz/2), right(sz - sz/2);
    auto itr = elem.begin();
    itr += sz/2;
    copy(elem.begin(), itr, left.begin());
    copy(itr, elem.end(), right.begin());
    for(auto l : left){
        for(auto r : right){
            table[l][r] = cl;
            table[r][l] = cl;
        }
    }
    dfs(left, cl + 1);
    dfs(right, cl + 1);
}

int main(){
    ll n; cin >> n;
    vector<ll> vec(n);
    iota(vec.begin(), vec.end(), 0);
    dfs(vec, 1);
    rep(i,n-1){
        for(int j = i+1; j < n; j++)cout << table[i][j] << " ";
        cout << "\n";
    }
}

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

using namespace std;

const long long INF = 1e18;
const int N = 3e5;
const int MOD = 998244353;
const double EPS = 1e-9;

const double PI = acos(-1);

int cntr[3], cntl[3];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    for (char &c : s) {
        if (c == 'R') c = 0;
        if (c == 'G') c = 1;
        if (c == 'B') c = 2;
    }
    for (int i = 1; i < s.size(); i++)
        cntr[s[i]]++;
    cntl[s[0]]++;
    long long ans = 0;
    for (int i = 1; i < s.size() - 1; i++) {
        cntr[s[i]]--;
        if (s[i] == 0)
            ans += cntl[1] * cntr[2] + cntl[2] * cntr[1];
        if (s[i] == 1)
            ans += cntl[0] * cntr[2] + cntl[2] * cntr[0];
        if (s[i] == 2)
            ans += cntl[0] * cntr[1] + cntl[1] * cntr[0];
        int rng = min(i, n - i - 1);
        for (int j = 1; j <= rng; j++) {
            if (s[i - j] != s[i] && s[i - j] != s[i + j] && s[i] != s[i + j])
                ans--;
        }
        cntl[s[i]]++;
    }
    cout << ans;
}

Measured memory_bytes: 3652
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

void solve(long long n, long long M, std::vector<long long> a) {

  rep(i, n) {
    if (a[i] & 1) {
      cout << 0 << endl;
      return;
    }
    a[i] /= 2;
  }
  lli lcm = 1;
  rep(i, n) {
    lcm = a[i] / __gcd(lcm, a[i]) * lcm;
    if (lcm > M) {
      cout << 0 << endl;
      return;
    }
  }
  rep(i, n) {
    lli g = lcm / a[i];
    if ((g % 2) == 0) {
      cout << 0 << endl;
      return;
    }
  }
  lli p = M / lcm;
  if (p & 1)
    p++;
  cout << p / 2 << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, M, std::move(a));
  return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict

def main():
    MOD = 10**9+7
    n = int(input())
    A = list(map(int,input().split()))

    A.sort()
    T = A[-1]+1

    dp = [True] * T

    d = defaultdict(int)

    for a in A:
        d[a] += 1
        if dp[a]:
            for j in range(2*a,T,a):
                dp[j] = False

    ans = 0
    
    for a in A:
        if d[a] == 1 and dp[a] == True:
            ans += 1

    print(ans)

main()

Measured memory_bytes: 43328
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()
 
int main()
{
	int n;
	cin>>n;
	vi v(n);
	vi c(n);
	rep(i,n){
		cin>>v.at(i);
	}
	rep(i,n){
		cin>>c.at(i);
	}
	vi d(n);
	rep(i,n){
		d.at(i)=v.at(i)-c.at(i);
	}
	int ans=0;
	rep(i,n){
		if(d.at(i)>0){
			ans+=d.at(i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
char s[287];
int n;
int main()
{
	RD(n,s);
	int c = 0, k = 0;
	RP(i,n) {
		if (s[i] == '(') {
			++c;
		} else {
			if (c)
				--c;
			else
				++k;
		}
	}
	while (k--)
		PT('(');
	PT(s);
	while (c--)
		PT(')');
	PL();
}


Measured memory_bytes: 256
K = int(input())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
ans = 0
for a in range(K):
    a += 1
    if a == 1:
        ans += K*K
        continue
    for b in range(K):
        b += 1
        if b == 1:
            ans += K
            continue
        tmp = gcd(a, b)
        if tmp == 1:
            ans += K
            continue
        for c in range(K):
            c += 1
            if c == 1:
                ans += 1
                continue
            dada = gcd(tmp, c)
            ans += dada
            # print(dada)

print(ans)


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	if(h%a == 0 && w%b == 0){
		print("No")
	}
	else{
		print("Yes")
		ll x = (h/a)*(w/b)+1;
		rep(i, 1, h){
			rep(j, 1, w){
				if(i%a == 0 && j%b == 0){
					cout << -(x*(a*b-1)+1);
				}
				else{
					cout << x;
				}
				
				if(j < w){
					cout << " ";
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2048
<?php

// 標準入力を一行ずつ配列に代入します
fscanf(STDIN,'%d', $n);
$na = rtrim(fgets(STDIN) , PHP_EOL);
$na = explode(" ", $na);

$can_exec = true;
$exec_cnt = 0;
while($can_exec) {
	for($i = 0; $i < $n; $i++) {
		if ($na[$i] % 2 === 1 || $na[$i] === 1) {
			$can_exec = false;
			break;
		} else {
			$na[$i] /= 2;
		}
	}



	if ($can_exec === true) {
		$exec_cnt++;
	}
}

echo $exec_cnt;


Measured memory_bytes: 5112
N = int(input())
A = list(map(int,input().split()))
p,n = 0,0
Positive,Negative = [],[]
ans = []
for i in range(N):
    if A[i] >= 0:
        p += 1
        Positive.append(A[i])
    else:
        n += 1
        Negative.append(A[i])
Positive.sort()
Negative.sort()
if n == 0:
    now = Positive[0]
    for i in range(1,N-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
    ans.append((Positive[N-1],now))
    Positive[N-1] -= now
    print(Positive[N-1])
    for i in range(len(ans)):
        print(*ans[i])
elif n >= 1 and p >= 1:
    now = Negative[0]
    for i in range(p-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
    bigM = now
    now = Positive[-1]
    for i in range(1,n):
        ans.append((now,Negative[i]))
        now -= Negative[i]
    bigP = now
    ans.append((bigP,bigM))
    bigP -= bigM
    print(bigP)
    for i in range(len(ans)):
        print(*ans[i])
else:
    now = Negative[-1]
    for i in range(N-1):
        ans.append((now,Negative[i]))
        now -= Negative[i]
    print(now)
    for i in range(len(ans)):
        print(*ans[i])

Measured memory_bytes: 100024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    long long start; cin >> start;
    long long cur = 0;
    long long turn = 0;
    vector<long long> v(2*m+2, 0);
    vector<long long> plus(2*m+2, 0);
    for (int i = 1; i < n; i++) {
        long long p; cin >> p;
        p = (p + m - start) % m; 
        if (cur > p) {
            turn++; p += m;
        }
        v[cur+1] -= (cur+1);
        v[p+1] += (cur+1);
        plus[cur+1]++;
        plus[p+1]--;
        cur = p % m;
    }
    long long all = 0;
    for (int i = 0; i <= 2*m; i++) {
        v[i+1] += v[i];
        plus[i+1] += plus[i];
        all += plus[i];
    }
    for (int i = 0; i <= 2*m; i++) {
        plus[i] *= (long long) i;
        plus[i] += v[i];
        if (i >= m) plus[i%m] += plus[i];
    }
    long long ans = 1e18;
    for (int i = 0; i <= m; i++) {
        ans = min(ans, all-plus[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
/*const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
const int mod=1000000007;*/
using namespace std;
int main()
{
    int n;
    cin>>n;
    while(n)
    {
        int num=n%10;
        n/=10;
        if(num==7)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,a[200005];
map<int,int> mp;
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	int ans=0;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
		ans+=it->second*(it->second-1)/2;
	for(int i=1;i<=n;i++)
		cout<<ans-mp[a[i]]+1<<endl;
	return 0;
}


Measured memory_bytes: 11136
#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;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define EPS (1e-7)
#define INF (1e9 + 10)
#define PI (acos(-1))
#define MOD (1000000007)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
template<class T>string watch(T &v){string res="";for(auto f:v)res+=(to_string(f)+" ");return res;}
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; }
template <typename T>
auto to_bin_str(T n) {
    int cc = 0;
    while (n > 0) {
        cc++;
        n >>= 1;
    }
    return cc;
}

int main() {
    int N; cin >> N;
    VI A(N, 0);
    REP(i, N) {
        cin >> A[i];
    }
    sort(ALL(A));
    int cc = 0;
    while (!A.empty()){
        int a = A.back();A.pop_back();
        int d = to_bin_str(a);
        int se = pow(2,d) - a;
        auto lb = lower_bound(ALL(A), se);
        if (lb != A.end() and *lb == se){
            A.erase(lb);
            cc += 1;
        }
    }
    cout << cc << endl;
}

Measured memory_bytes: 1024
use std::i64;
use std::cmp;

// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main(){
    input! {
        n: usize,
        v: [(i64, i64, i64); n],
    }

    let mut dp = vec![vec![0; n]; 3];
    dp[0][0] = v[0].0;
    dp[1][0] = v[0].1;
    dp[2][0] = v[0].2;
    for i in 0 .. n-1 {
        dp[0][i+1] = cmp::max(dp[1][i], dp[2][i]) + v[i+1].0;
        dp[1][i+1] = cmp::max(dp[0][i], dp[2][i]) + v[i+1].1;
        dp[2][i+1] = cmp::max(dp[0][i], dp[1][i]) + v[i+1].2;
    }
    let ans = cmp::max(dp[0][n-1], cmp::max(dp[1][n-1], dp[2][n-1]));
    println!("{}", ans);
}




Measured memory_bytes: 12540
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
 
int main(){
  int N, M; cin >> N >> M;
  
  int ans = 0;
  ans += (N * (N - 1)) / 2;
  ans += (M * (M - 1)) / 2;  
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s;
  cin >> s;
  switch(s){
    case 'A': cout << 'T' << endl; break;
    case 'T': cout << 'A' << endl; break;
    case 'G': cout << 'C' << endl; break;
    case 'C': cout << 'G' << endl; break;
  }
}

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

int main()
{
	int32_t N;

	cin >> N;

	int32_t _time = 0, prev_x = 0, prev_y = 0;

	string res = "Yes";
	for (int32_t i = 0; i < N; i++) {
		int32_t t, x, y;
		cin >> t >> x >> y;

		int32_t duration = t - _time;
		int32_t distance = abs(prev_x - x) + abs(prev_y - y);
		if (distance > duration || (duration - distance) % 2 != 0) {
			res = "No";
			break;
		}

		_time = t;
		prev_x = x;
		prev_y = y;
	}

	cout << res << endl;

	return 0;
}

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

const int INF = 1e9;

int main() {
    int a,b;
    cin>>a>>b;

    if (a>=13) {
        cout<<b<<endl;
    } else if (a >= 6) {
        cout<<b/2<<endl;
    } else {
        cout<<0<<endl;
    }

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  s[k - 1] = std::tolower(s[k - 1]);
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
  int A, B, C;
  long long X, Y, ans = 0;
  cin >> A >> B >> C >> X >> Y;
  if(A+B > C * 2){
    ans += C * min(X, Y) * 2;
  }
  else{
    ans += (A + B) * min(X, Y);
  }
  if(X > Y){
    ans += min(A * (max(X, Y) - min(X, Y)), C * (max(X, Y) - min(X, Y)) * 2);
  }
  else{
    ans += min(B * (max(X, Y) - min(X, Y)), C * (max(X, Y) - min(X, Y)) * 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s, t, u;
  cin >> s >> t >> u;
  char dif = 'A' - 'a';
  cout << char(s[0]+dif) << char(t[0]+dif) << char(u[0]+dif) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int N, K; cin >> N >> K;
    vector<int> a;
    rep(i, N){
        int t; cin >> t;
        if(t<K) a.push_back(t);
    }
    sort(a.begin(), a.end());
    N=a.size();
    vector<vector<bool>> dpl(N+5, vector<bool>(K+5, false)), dpr(N+5, vector<bool>(K+5, false));
    dpl[0][0]=true;
    rep(i, N) rep(j, K+1){
        dpl[i+1][j] = dpl[i+1][j] | dpl[i][j];
        if(j-a[i]>=0) dpl[i+1][j] = dpl[i+1][j] | dpl[i][j-a[i]];
    }
    dpr[N+1][0]=true;
    reprev(i, N) rep(j, K+1){
        dpr[i+1][j] = dpr[i+1][j] | dpr[i+2][j];
        if(j-a[i]>=0) dpr[i+1][j] = dpr[i+1][j] | dpr[i+2][j-a[i]];
    }

    int ans=0;
    repr(i, 1, N+1){
        vector<int> L, R;
        rep(j, K+1){
            if(dpl[i-1][j]) L.push_back(j);
            if(dpr[i+1][j]) R.push_back(j);
        }
        // rep(j, L.size()) cout << L[j] << ' ';
        // cout << endl;
        // rep(j, R.size()) cout << R[j] << ' ';
        // cout << endl;
        bool flg=true;
        rep(j, (int)L.size()){
            int left=L[j];
            if( lower_bound(R.begin(), R.end(), K-left) - lower_bound(R.begin(), R.end(), K-a[i-1]-left) > 0 ){
                flg=false; break;
                
            }
        }
        if(flg) ++ans;
    }
    cout << ans << endl;

    
    return 0;
}


Measured memory_bytes: 7040
require 'pp'
m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
aa = a.group_by(&:itself).map{|k,v|v.size}.sort.reverse
# p aa
# p k
cnt = 0
until aa.size <= k
  ap = aa.pop
  cnt += ap
end
p cnt


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

int main(){

    int A,B,C,K;
    cin >> A >> B >> C >> K;

    if(K<=A){
        cout << K << endl;
    }else if(K<=(A+B)){
        cout << A << endl;
    }else if(K<=(A+B+C)){
        cout << A-(K-A-B) <<endl;
    }else{
        cout << A-C <<endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n; i >= 0; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    ll N, Q; cin >> N >> Q;
    vl A(N+1, 0); rep(i, N) cin >> A[i+1];
    
    vl sum(N+1, 0), ssum(N+1, 0);
    FOR(i, 1, N+1){
        sum[i] = sum[i-1] + A[i];
        ssum[i] = A[i];
        if(i-2>0) ssum[i] += ssum[i-2];
    }
    
    rep(_, Q){
        ll x; cin >> x;
        ll ng = 0, ok = N;
        while(ok-ng > 1){
            ll mid = (ng+ok)/2;
            if(A[mid] < x){
                ng = mid;
            }
            else{
                ll upper = N-mid+1;
                auto l_it = lower_bound(A.begin(), A.end(), max(2*x-A[mid], 1ll));
                ll lower = mid - (l_it - A.begin()) + 1;
                if(upper > lower) ng = mid;
                else ok = mid;
            }
        }
        ll res = sum[N] - sum[ok-1];
        ll lidx = N-2*(N-ok+1);
        if(lidx >= 0) res += ssum[lidx];
        cout << res << endstr;
    }
    return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int i,j,t;
  t = 0;
  for(i = 1;i <= 9; i++){
    for(j = i; j <= 9; j++){
      if(i*j == n){
        t = 1;
        break;
      }
    }
  }
  if(t == 1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),M=in();
	ll sum = 0;
	priority_queue<ll,vector<ll>> Q;
	REP(i,N){
		ll v = in();
		Q.push(v);
		sum += v;
	}
	REP(i,M){
		auto V = Q.top();
		Q.pop();
		sum -= V;
		V /= 2;
		Q.push(V);
		sum += V;
	}
	
	out(sum);
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001;
const ll INF=1LL<<60;

int main(){
    
    int L;cin>>L;
    ll dp[L+1][5];
    vector<int> A(L);
    for(int i=0;i<L+1;i++){
        if(i) cin>>A[i-1];
        for(int j=0;j<5;j++){
            if(i) dp[i][j]=INF;
            else dp[i][j]=0;
        }
    }
    
    for(int i=1;i<=L;i++){
        
        if(A[i-1]==0){
            dp[i][0]=dp[i-1][0];
            dp[i][1]=min(dp[i][0],dp[i-1][1]+2);
            dp[i][2]=min(dp[i][1],dp[i-1][2]+1);
            dp[i][3]=min(dp[i][2],dp[i-1][3]+2);
            dp[i][4]=min(dp[i][3],dp[i-1][4]);
        }else{
            dp[i][0]=dp[i-1][0]+A[i-1];
            dp[i][1]=min(dp[i][0],dp[i-1][1]+A[i-1]%2);
            dp[i][2]=min(dp[i][1],dp[i-1][2]+(A[i-1]+1)%2);
            dp[i][3]=min(dp[i][2],dp[i-1][3]+A[i-1]%2);
            dp[i][4]=min(dp[i][3],dp[i-1][4]+A[i-1]);
        }
        
    }
    
    cout<<dp[L][4]<<endl;
    
}



Measured memory_bytes: 8832
#include <stdio.h> 
#define NILL -1

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum=0;
  int M[MAX][MAX];
  int d[MAX],p[MAX],v[MAX];
  int a,point=0;
 
  
  

  scanf("%d", &n);
  
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for(i = 0; i < n; i++){
    v[i] = 0; 
    d[i] = INFTY;
    p[i] = NILL;
  }
  
  d[0] = 0;
  
  while(1){
    a = NILL;
    point = INFTY;
    
    for(i = 0; i < n; i++){

      if(d[i] < point && !v[i]){
      a = i;
      point = d[i];
      }
    }
    
    if(a == NILL){
      break;
    }
    
    v[a] = 1;
  
    for(j = 0; j < n; j++){
     
      if(M[a][j] < d[j] && !v[j]){
	p[j] = a;
	d[j] = M[a][j];
      }
    }
  }
  
  
  //   sum = 0;
  
  for(i = 0; i < n; i++){
    if(p[i] != NILL){
      sum += M[i][p[i]];
    }
  }
  
  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 808
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

def main():
    N,M = cin.mapInt()
    P = []
    for i in range(M):
        p,y = cin.mapInt()
        P.append([p,y,i,""])
    P.sort(key=lambda x:(x[1],x[0],x[2]))
    pref = [1] * (N + 1)
    for i in range(M):
        a = pref[P[i][0]]
        pref[P[i][0]] = a + 1
        id = str(P[i][0]).zfill(6) + str(a).zfill(6)
        P[i][3] = id
    P.sort(key=lambda x : (x[2]))
    for i in P:
        print(i[3])
    return
if __name__ == "__main__":
    main()


Measured memory_bytes: 87644
//g++  7.4.0

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll T = 1;
    while(T--)
    {
        ll N; cin>>N;
        map<ll,ll> mp;
        
        for(ll i=1;i<=sqrt(N);++i)
        {
            for(ll j=1;j<=sqrt(N);++j)
            {
                for(ll k=1;k<=sqrt(N);++k)
                {
                    ll val = i*i + j*j + k*k + i*j + j*k + i*k;
                    mp[val]++;
                }
            }
        }
        
        for(ll i=1;i<=N;++i)
            cout<<mp[i]<<endl;
        
    }
}

Measured memory_bytes: 5952
s = input()
k = int(input())
ans = ''
for i,v in enumerate(s):
    if (ord('a') - ord(v))%26 <= k:
        k -= (ord('a') - ord(v))%26
        ans += 'a'
    else:
        ans += v
k %= 26
last = chr(ord('a')+(ord(ans[-1])-ord('a')+k)%26)

print(ans[:-1]+last)



Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define true 1
#define false 0



int main(void){

	int i;
	int n;
	int a,b;
	int aa=0,bb=0;
	char *s;
	scanf("%d%d%d",&n,&a,&b);
	s = calloc(sizeof(char),n+1);
	scanf("%s",s);
	for(i=0;i<n;i++){
		if(s[i] == 'a'){
			if(aa+bb<a+b){
				aa++;
				printf("Yes\n");
				continue;
			}
		}else if(s[i]=='b'){
			if(aa+bb<a+b&&bb<b){
				bb++;
				printf("Yes\n");
				continue;
			}
		}
		printf("No\n");
	}



	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
 
int main(void)
{
  int N;
  scanf("%d",&N);
  int A[N],judgea=0,judgeb=0;
  
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
    if(A[i]%2==0){   
      judgea+=1;
      if(A[i]%3==0||A[i]%5==0)
        judgeb+=1;
        
    }
  }
  if(judgea==judgeb)
    printf("APPROVED");
  else
    printf("DENIED");
 
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,T,min=1001;
    cin>>N>>T;
    int c[N],t[N];
    for(int i=0;i<N;++i) cin>>c[i]>>t[i];
    for(int i=0;i<N;++i){
        if(t[i]<=T&&c[i]<min) min=c[i];
    }
    if(min==1001) cout<<"TLE";
    else cout<<min;
}


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

#define MAX 100

void print_array(int A[], int n) {
  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << A[i];
    if (i == n - 1) cout << endl;
  }
}

int main() {
  int n;
  int A[MAX];

  cin >> n;

  // 入力
  for (int i = 0; i < n; i++) { cin >> A[i]; }

  int j, v;
  for (int i = 0; i < n; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    print_array(A, n);
  }
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <set>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void tenka1_2019_b(vector<vector<string>> v) {

    int n = atoi(v[0][0].c_str());
    string s = v[1][0];
    int k = atoi(v[2][0].c_str());

    string stemp = s.substr(k - 1, 1);

//    cout << stemp << endl;

    string result = "";

    for (int i = 0; i < n; i++) {

        if (s.substr(i, 1) != stemp) {
            result += "*";
        } else {
            result += stemp;
        }
    }

    cout << result << endl;



}

int main() {

    vector<vector < string>> vec_arr_result;
    //    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata();

    tenka1_2019_b(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x, a, b;
  cin >> x >> a >> b;
  if (a >= b) {
    cout << "delicious" << endl;
  } else if (a + x >= b) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
XY = [[int(i) for i in input().split()] for _ in range(N)]

if len(set([(X + Y) % 2 for X, Y in XY])) != 1 :
    print(-1)
    
else :
    d = []
    for i in range(32, -1, -1) :
        d.append(1 << i)
    
    if (XY[0][0] + XY[0][1]) % 2 == 0 :
        d.append(1)
    
    print(len(d))
    print(*d)
    
    for X, Y in XY :
        ret = ''
        cx, cy = 0, 0
        for i in range(len(d)) :
            mj, mv = 0, float('inf')
            diff = [(d[i], 0), (-d[i], 0), (0, d[i]), (0, -d[i])]
            for j, (dx, dy) in enumerate(diff) :
                if (cx + dx - X) ** 2 + (cy + dy - Y) ** 2 < mv:
                    mj = j
                    mv = (cx + dx - X) ** 2 + (cy + dy - Y) ** 2
            
            if mj == 0 :
                ret += 'R'
                cx += d[i]
            elif mj == 1 :
                ret += 'L'
                cx -= d[i]
            elif mj == 2 :
                ret += 'U'
                cy += d[i]
            else :
                ret += 'D'
                cy -= d[i]
                
        print(ret)

Measured memory_bytes: 53080
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (long long i = x; i < n; i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
// using ll = long long;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    bitset<8> s;

    int ex = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a / 400 >= 8)
            ex++;
        else
            s.set(a / 400);
    }

    if (s.count() == 0)
        cout << 1 << " ";
    else
        cout << s.count() << " ";
    cout << s.count() + ex << endl;
}

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

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;

  vector<int> v(N + 1);
  unordered_map<int, vector<int>> m;

  for(int i = 0; i < M; i++)
  {
    int A, B;
    cin >> A >> B;
    m[A].push_back(B);
    m[B].push_back(A);
  }

  queue<int> q;
  q.push(1);
  v[1] = 1;

  while(!q.empty())
  {
    int cr = q.front();
    q.pop();
    for(int i = 0; i < m[cr].size(); i++)
    {
      if(!v[m[cr][i]])
      {
        v[m[cr][i]] = cr;
        q.push(m[cr][i]);
      }
    }
  }

  bool flag = true;
  for(int i = 2; i < v.size(); i++)
  {
    if(!v[i])
    {
      flag = false;
      break;
    }
  }

  if(!flag)
  {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  for(int i = 2; i < v.size(); i++)
    cout << v[i] << endl;

  return 0;
}


Measured memory_bytes: 13460
import heapq
import sys
def input():
	return sys.stdin.readline()[:-1]

MOD = 10**9+7
class DijkstraList():
	#隣接リスト版
	#同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ
	def __init__(self, adj, start):
		self.list = adj
		self.start = start
		self.size = len(adj)

	def solve(self):
		self.dist = [float("inf") for _ in range(self.size)]
		self.dist[self.start] = 0
		self.dp = [0 for _ in range(self.size)]
		self.dp[self.start] = 1
		#self.prev = [-1 for _ in range(self.size)]
		self.q = []
		self.cnt = 0

		heapq.heappush(self.q, (0, self.start))

		while self.q and self.cnt < self.size:
			u_dist, u = heapq.heappop(self.q)
			if self.dist[u] < u_dist:
				continue
			for v, w in self.list[u]:
				if self.dist[v] > u_dist + w:
					self.dist[v] = u_dist + w
					self.dp[v] = self.dp[u]
					#self.prev[v] = u
					heapq.heappush(self.q, (self.dist[v], v))
				elif self.dist[v] == u_dist + w:
					self.dp[v] += self.dp[u]
					self.dp[v] %= MOD

			self.cnt += 1
		#print(self.dp)
		return

	def distance(self, goal):
		return self.dist[goal]

	def get_dp(self, x):
		return self.dp[x]

n, m = map(int, input().split())
s, t = map(int, input().split())
s, t = s-1, t-1
adj = [[] for _ in range(n)]
for _ in range(m):
	u, v, d = map(int, input().split())
	adj[u-1].append([v-1, d])
	adj[v-1].append([u-1, d])
S, T = DijkstraList(adj, s), DijkstraList(adj, t)
S.solve()
T.solve()
ans = pow(S.get_dp(t), 2, MOD)
goal = S.distance(t)
#print(ans, goal)

for i in range(n):
	SI, TI = S.distance(i), T.distance(i)
	if SI + TI != goal:
		continue
	if SI*2 == goal:
		ans -= S.get_dp(i) * T.get_dp(i) * S.get_dp(i) * T.get_dp(i)
		ans %= MOD

	else:
		for j, d in adj[i]:
			if i>j:
				continue
			SJ, TJ = S.distance(j), T.distance(j)
			if SJ + TJ != goal or abs(SI - SJ) != d:
				continue
			if SI*2 < goal < SJ*2:
				#print(i, j, SI, SJ)
				ans -= S.get_dp(i) * T.get_dp(j) * S.get_dp(i) * T.get_dp(j)
				ans %= MOD
			elif SJ*2 < goal < SI*2:
				#print(i, j, SI, SJ)
				ans -= S.get_dp(j) * T.get_dp(i) * S.get_dp(j) * T.get_dp(i)
				ans %= MOD

print(ans)

Measured memory_bytes: 145688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<string> s(n); rep (i, n) cin >> s[i];
    int count = 0;
    rep (ofs, n) {
        bool flg = true;
        rep (i, n) {
            eprintf("%s\n", s[(i + ofs) % n].c_str());
            rep (j, n) {
                if (s[(i + ofs) % n][j] != s[(j + ofs) % n][i]) flg = false;
            }
        }
        if (flg) count++;
        eprintf("\n");
    }
    cout << count * n << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(void)
{
    int n;
    bool flag=false;
    cin >> n;
    for(int i=0;i<=n/4;i++)
        if((n-(i*4))%7==0)
            flag=true;
    if(flag==true)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	vector<ll> sum(n + 1);
	rep(i,n) sum.at(i + 1) += sum.at(i) + a.at(i);
	ll ans = 1e10;
	for(int i = 1; i < n; i++){
		ans = min(ans, abs(sum.at(i) - (sum.at(n) - sum.at(i))));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3456