akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();
    let xs: Vec<usize> = sc.vec(n);
    let mut cx = std::collections::HashMap::<usize, usize>::new();
    cx.insert(0, 1);
    let mut size = 0;
    let mut ans = 0;
    {
        let mut ac = 0;
        let mut ys: Vec<usize> = vec![0; n + 1];
        for i in 0..n {
            let x = xs[i];
            ac += x - 1; ac %= k;
            ys[i + 1] = ac;
            (*cx.entry(ac).or_insert(0)) += 1;
            size += 1;
            if size >= k {
                let pre = ys[i + 1 - k];
                (*cx.entry(pre).or_insert(1)) -= 1;
                size -= 1;
            }
            ans += cx[&ac] - 1;
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 24224
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  vi a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(all(a));
  if(a[0]==5&&a[1]==5&&a[2]==7)
    cout<<"YES"<<endl;
  else 
    cout<<"NO"<<endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k,ans=0;cin>>k;
  for(ll a=1;a<=k;++a)for(ll b=1;b<=k;++b)for(ll c=1;c<=k;++c) ans+=__gcd(a,__gcd(b,c));
  print(ans);
  return 0;
}

Measured memory_bytes: 3620
X = int(input())
if X <=599:
    ans = 8
elif X >= 600 and X <= 799:
    ans = 7
elif X >= 800 and X <= 999:
    ans = 6
elif X >= 1000 and X <= 1199:
    ans = 5
elif X >= 1200 and X <= 1399:
    ans = 4
elif X >= 1400 and X <= 1599:
    ans = 3
elif X >= 1600 and X <= 1799:
    ans = 2
else:
    ans = 1

print(ans)

Measured memory_bytes: 9208
/*
	0216:Cutting Down Water Bills
*/
#include	<iostream>

using namespace std;

int main(void) {
	int t[7];
	
	for(int i = 0; i < 7; i++) {
		int a, b;
		cin >> a >> b;
		
		t[i] = a - b;
	}
	
	for(int i = 0; i < 7; i++) {
		cout << t[i] << endl;
	}
	return 0;
}

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

using namespace std;

void kumiawase(vector<int> &nums,vector<string> &ss) {
	string stmp;
	do {
		stmp = "";
		for (int i = 0; i < nums.size(); i++) {
//			cout << nums[i];
			stmp.push_back((char)(nums[i] + 48));
		}
//		cout << endl;
		ss.push_back(stmp);
	} while (next_permutation(nums.begin(), nums.end()));

}

int main(void){

	int n;
	cin >> n;

	vector<int> p(n);
	vector<int> q(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> q[i];
	}

	vector<int> nums;
	vector<string> ss;

	for (int i = 1; i <= n; i++) {
		nums.push_back(i);
	}

	kumiawase(nums, ss);

	int pp, qq;
	for (int i = 0; i < ss.size(); i++) {
		bool brkflg = false;
		for (int j = 0; j < n; j++) {
			if (ss[i][j] != (char)(p[j]+48)) {
				brkflg = true;
				break;
			}
		}
		if (brkflg == false) {
			pp = i;
			break;
		}
	}
	for (int i = 0; i < ss.size(); i++) {
		bool brkflg = false;
		for (int j = 0; j < n; j++) {
			if (ss[i][j] != (char)(q[j] + 48)) {
				brkflg = true;
				break;
			}
		}
		if (brkflg == false) {
			qq = i;
			break;
		}
	}

	cout << abs(pp - qq) << endl;

	return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;


int main(){
	ll n;
	cin>>n;
	ll h[n];
	rep(i,0,n)cin>>h[i];
	bool p=true;
	irep(i,n-1,1){
		if((-h[i]+h[i-1])>=2){p=false;break;}
		else if(-h[i]+h[i-1]==1){h[i-1]--;}
	}
	if(p)cout<<"Yes";
	else cout<<"No";
	
}

Measured memory_bytes: 1024
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define M 1000000007

/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		ll n;
		cin>>n;
		string s;
		cin>>s;
		map<char,ll> mp;
		ll i,j,ans=1;
		
		rep(i,0,n-1){
			if(!mp[s[i]])
			mp[s[i]]=1;
			else
			mp[s[i]]++;
		}
		for(auto i:mp){
			ans=((ans%M)*(i.S+1)%M)%M;
		}
		ans-=1;
		cout<<ans<<'\n';
	}
	
	return 0;
}

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

using namespace std;
#define ll long long
#define mod 1000000007

ll dp[3001][3001];
vector<ll> v, pre;

ll f(ll l, ll r) {
    if (l > r) return 0;
    else if (l == r) return v[l];

    if (dp[l][r] != -1) return dp[l][r];

    ll score1 = v[l] + pre[r] - pre[l] - f(l + 1, r);
    ll score2 = v[r] + pre[r - 1] - (l ? pre[l - 1] : 0) - f(l, r - 1);

    dp[l][r] = max(score1, score2);
    return dp[l][r];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, -1, sizeof(dp));

    ll n;
    cin >> n;

    v.resize(n);
    pre.resize(n);

    for (auto &i : v) {
        cin >> i;
    }

    pre[0] = v[0];
    for (ll i = 1; i < n; i++) {
        pre[i] = pre[i - 1] + v[i];
    }

    cout << 2 * f(0, n - 1) - pre[n - 1];
}


Measured memory_bytes: 74248
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn = 1<<20, mod = 924844033;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int a, b, c;
	cin >> a >> b;
	if(a <= 0 && b >= 0) cout << "Zero";
	else if(a > 0 || abs(a-min(b, -1)+1)%2 == 0) cout << "Positive";
	else cout << "Negative";
}


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

int main(){
    bool flag[100001];
    int c[100002] = {};
    int Q, L, R;
    
    for(int i=2; i<=100000; i++)if(!flag[i])for(int j=i+i; j<=100000; j+=i)flag[j]=true;
    for(int i=3; i<=100000; i+=2)if(!flag[i] && !flag[(i+1)/2])c[i]++;
    for(int i=3; i<=100000; i++)c[i] += c[i-1];

    cin >> Q;
    while(Q--){
        cin >> L >> R;
        printf("%d\n", c[R]-c[L-1]);
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define db long double
#define mp make_pair
#define X first
#define Y second
#define vi vector<int>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<(a).size();++i)
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
#define gc getchar
inline ll rd()
{
	ll x=0,w=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();
	if(c=='-')c=gc(),w=-1;while(isdigit(c))x=x*10+c-48,c=gc();return x*w;
}
const int N=1e7+5,P=1e9+7;
int n,m,ans,fac[N],ifac[N],iv[N];
inline int C(int a,int b){return a<b||b<0?0:1ll*fac[a]*ifac[b]%P*ifac[a-b]%P;}
inline int D(int a,int b,int c){return 1ll*fac[a+b+c]*a%P*iv[a+c]%P;}
int main()
{
	fac[0]=1;rep0(i,1,N)fac[i]=1ll*fac[i-1]*i%P;
	iv[1]=1;rep0(i,2,N)iv[i]=1ll*(P-P/i)*iv[P%i]%P;
	ifac[0]=1;rep0(i,1,N)ifac[i]=1ll*ifac[i-1]*iv[i]%P;
	n=rd();m=rd();
	rep(i,1,m+1)rep(j,0,i-1)
		ans=(ans+1ll*(j&1?P-1:1)*C(i-1,j)%P*D(i-1-j,max(0,m-i),n-m))%P;
	printf("%d\n",ans);return 0;
}


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


int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    int b = 0;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
        int now = mp[s];
        b = max(b,now);
    }
    for(auto a = mp.begin(); a!=mp.end(); a++){
        if(a->second==b){
            cout << a->first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19232
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int n;
  cin >> n;
  vector<int> d(n);
  REP(i,n) cin >> d[i];
  map<int,bool> ex;
  REP(i,n){
    int tmp=0;
    REP(j,7){
      if(i+j>=n) break;
      tmp+=d[i+j];
      ex[tmp]=true;
      tmp*=10;
    }
  }
  int answer=0;
  while(ex[answer]) ++answer;
  cout << answer << endl;
}

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef vector<vi> vii;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  int x; cin>>x;
  if(x >= 400 && x <= 599) cout<<8<<endl;
  else if(x >= 600 && x <= 799) cout<<7<<endl;
  else if(x >= 800 && x <= 999) cout<<6<<endl;
  else if(x >= 1000 && x <= 1199) cout<<5<<endl;
  else if(x >= 1200 && x <= 1399) cout<<4<<endl;
  else if(x >= 1400 && x <= 1599) cout<<3<<endl;
  else if(x >= 1600 && x <= 1799) cout<<2<<endl;
  else if(x >= 1800 && x <= 1999) cout<<1<<endl;
  return 0;
}

Measured memory_bytes: 3652
n = int(input())
l = [[] for i in range(n)]
retval=[10**10 for i in range(n)]



for i in range(n):
    _input = [int(j) - 1 for j in input().split(" ")]
    u = _input[0]
    k = _input[1] + 1
    node = sorted(_input[2::])
    if u in node:
        node.remove(u)
    l[u] = node

retval[0]=0
for step in range(n+1):
    for i ,d in enumerate(retval):
        if d==step:
            for node in l[i]:
                retval[node]=min(retval[node],step+1)

for i,d in enumerate(retval):
    if d==10**10:
        print(i+1,-1)
    else:
        print(i+1,d)



Measured memory_bytes: 5624
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint n;
lint mod = 1e9 + 7;

// a^n mod pを計算　O(log n)
long long pow_mod(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n & 1) return pow_mod(a, n - 1, p) * a % p;
    long long temp = pow_mod(a, n / 2, p);
    return temp * temp % p;
}

int main() {
    cin >> n;
    lint all = pow_mod(10, n, mod);
    lint a = pow_mod(9, n, mod);
    lint b = pow_mod(9, n, mod);
    lint c = pow_mod(8, n, mod);
    lint ans = (all - (a + b - c)) % mod;
    if (ans < 0) {
        ans = (ans + mod) % mod;
    }
    cout << ans << endl;
}

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

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

  int a, b;
  cin >> a >> b;
  int ans = 0, c = 1;
  while (c < b) {
    c += a - 1;
    ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
s=input()
import string
ans=float("inf")
for i in string.ascii_lowercase:#a-zまでを全探索
    t=list(s)
    while not all(j== i for j in t):#入力値sが全部iでなければ
        for k in range(len(t)):
            if i in t[k:k+2]:
                t[k]=i
        t.pop()
    ans=min(ans,len(s)-len(t))
print(ans)


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;

#define FILENAME ""


int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //  freopen(FILENAME ".in", "r", stdin);
    //  freopen(FILENAME ".out", "w", stdout);
    ll a, b;
    cin >> a >> b;
    ll ans = (a + b);
    if (ans % 2 == 0) {
        cout << ans/2;
    }
    else {
        cout << "IMPOSSIBLE";
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define RALL(a) (a).rbegin(), (a).rend()
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll fact(ll i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll modpow(ll a, ll n, ll mod) {
    ll hi = 1;
    while (n > 0) {
        if (n & 1) hi = hi * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return hi;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
/*signed*/int main(void) {
    int n, m; 
    cin >> n >> m;
    vector<pair<int, int>> p(m);
    rep(i, m) {
        int s, c; 
        cin >> s >> c;
        s--;
        p[i] = make_pair(s, c);
    }
    rep(i, 1000) {
        string s = to_string(i);
        if (s.size() == n) {
            bool ans = true;
            rep(j, m) {
                if ((s[p[j].first] - '0') != p[j].second)ans = false;
            }
            if (ans) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3680
from math import sqrt
n,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        sum = 0
        for k in range(d):
            tmp = abs(a[i][k]-a[j][k])
            sum+=tmp**2
        sum = sqrt(sum)
        if sum%1==0: cnt+=1
print(cnt)
        

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < n; i++)
ll dp[101][4][4][4];

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


    dp[0][3][3][3] = 1;


    rep(i, n){
        rep(j, 4){
            rep(k, 4){
                rep(l, 4){
                    if(dp[i][j][k][l] == 0) continue;
                    rep(m, 4){
                        if(m == 2 && j == 1 && k == 0) continue;
                        if(m == 2 && j == 0 && k == 1) continue;
                        if(m == 1 && j == 2 && k == 0) continue;
                        if(m == 2 && j == 1 && l == 0) continue;
                        if(m == 2 && k == 1 && l == 0) continue;

                        dp[i+1][m][j][k] += dp[i][j][k][l];
                        dp[i+1][m][j][k] %= 1000000007;
                    }
                }
            }
        }
    }

    ll ans = 0;
    rep(i, 4){
        rep(j, 4){
            rep(k, 4){
                ans += dp[n][i][j][k];
                ans %= 1000000007;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int n, k, c1, c2;

int main(){
	scanf("%d%d", &n, &k);
	c1=n/k;
	if (!(k&1)) c2=(n+(k>>1))/k;
	printf("%lld\n", 1ll*c1*c1*c1+1ll*c2*c2*c2);
	return 0;
}

Measured memory_bytes: 128
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:break
    else:
        for i in range(1,h+1):
            for j in range(1,w+1):
                if i==1 or i==h or j==1 or j==w:
                    print("#",end="")
                else:
                    print(".",end="")
            print()
        print()


Measured memory_bytes: 7000
#include<cstdio>

int X,A,B;

int main(){
	scanf("%d %d %d",&X,&A,&B);
	
	int c = A - B;
	
	if(c >= 0) printf("delicious\n");
	else if(X  + c>= 0) printf("safe\n");
	else printf("dangerous\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];

void dfs(ll v,ll sum,ll p){
    sum += x[v];
    y[v] = sum;
    for(int i=0;i<G[v].size();i++){
        ll nv = G[v][i];
        if(nv == p)continue;
        dfs(nv, sum, v);
    }
    return;
}

int main(){
    cin >> n >> k;
    for(i=0;i<n-1;i++){
        cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for(i=0;i<k;i++){
        cin >> a >> b;
        x[a] += b; 
    }
    dfs(1,0,-1);
    for(i=1;i<=n;i++){
        p(y[i]);
    }
    return 0;
}






Measured memory_bytes: 43520
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<pair<int, int>> A;

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) {
        int a; cin >> a;
        A.push_back({a, 0});
    }
    rep(i, N) {
        int b; cin >> b;
        A.push_back({b, 1});
    }
    sort(A.begin(), A.end());
    int ans = 1;
    int size = 0;
    bool stateA = false;
    rep(i, N * 2) {
        //cout << "*" << stateA << " " << A[i].second << endl;
        if (size == 0) {
            size++;
            if (A[i].second == 0) stateA = true;
            else stateA = false;
        }
        else if ((stateA && A[i].second == 0) || (!stateA && A[i].second == 1)) size++;
        else {
            ans = (ans * size) % mod;
            size--;
        } 
        //cout << ans << " " << size << endl;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
ll n;
void dfs(ll num, ll use, ll &count){
  if(num > n) return;
  if(use == 0b111) count++;
  
  dfs(num*10 + 3, use|0b001, count);
  dfs(num*10 + 5, use|0b010, count);
  dfs(num*10 + 7, use|0b100, count);
}

int main() {
  cin >> n;
  ll ans = 0;
  dfs(0, 0, ans);
  cout << ans;
  
  
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }

    vector<int> a(N), b(N);
    for(int i = 0; i < N; i++){
        a[i] = x[i] + y[i];
        b[i] = -x[i] + y[i];
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int ans = max(a[N - 1] - a[0], b[N - 1] - b[0]);

    cout << ans << endl;

    return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  string s;
  cin >> s;
  const int max_size = 1e5;
  int a[max_size+1];
  int size = s.length();

  for(int i = 0; i < size; i++){
    a[i] = 0;
  }

  bool flag = 0;
  int now = 0;
  for(int i = 1; i < size; i++){
    if(s[i] == 'L' && flag == 0){
      flag = 1;
      for(int j = now; j < i; j++){
        if((i-j)%2 == 1) a[i-1] += 1;
        else a[i] += 1;
      }
      if(i == size - 1){
        a[size-1] ++;
      }
      now = i;
    }else if((s[i] == 'R' && flag == 1) || i == size - 1){
      flag = 0;
      for(int j = now; j < i; j++){
        if((j - now)%2 == 0) a[now] += 1;
        else a[now-1] += 1;
        if(j+1 == size - 1){
          if((size-1 - now)%2 == 0) a[now] += 1;
          else a[now-1] += 1;
        }
      }
      now = i;
    }
  }
  for(int i = 0; i < size; i++){
    if(i != size - 1) cout << a[i] << " ";
    else cout << a[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 4144
#include<stdio.h>

int main(){
    int x,y,z,pocket;
    scanf("%d%d%d",&x,&y,&z);    

    if(x > y){
        pocket = x;
        x = y;
        y = pocket;
    }

    if(y > z){
        pocket = y;
        y = z;
        z = pocket;

        if(x > y){
            pocket = x;
            x = y;
            y = pocket;
        }
    }

    printf("%d %d %d\n",x,y,z);
    return 0;
}


Measured memory_bytes: 2112
{-
 - `chebyshev n' returns the number of primes between n+1 and 2n.
 - e.g.:
 -   chebyshev 10 == 4    -- 11, 13, 17, 19
 -   chebyshev 13 == 3    -- 17, 19, 23
 -}

import Control.Monad  -- when

chebyshev :: Int -> Int
chebyshev n = length [x | x<-[n+1 .. 2*n], prime x]
 
prime :: Int -> Bool
prime n | n >= 2 = [x | x<-fs, n`mod`x == 0] == []
  where fs = takeWhile (\x->x*x <= n) ([2] ++ [3,5..])
                         -- x*x is faster than x^2

main :: IO ()
main = do n <- readLn
          when (n /= 0) $ do
            print (chebyshev n)
            main

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

using namespace std;

const int maxn=2e5+5;

int a[maxn];

bool cmp(int i,int j){
    return a[i]<a[j];
}

int main(){
    int n;
    cin>>n;
    int index[n];
    for(int i=0;i<n;i++){
        index[i]=i;
        cin>>a[i];
    }
    sort(index,index+n,cmp);
    for(int i=0;i<n;i++){
        if(a[i]>=a[index[n/2]]){
            cout<<a[index[n/2-1]]<<endl;
        }
        else{
            cout<<a[index[n/2]]<<endl;
        }
    }
    return 0;
}

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

using namespace std;

int main() 
{
    int n, m, a, b, c;
    scanf("%d", &n);
    
    vector<int> v;
    
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &m);
        v.push_back(m);
    }
    
    scanf("%d", &m);
    
    for(int i = 0; i < m; i++)
    {
        scanf("%d %d %d", &a, &b, &c);
        
        int MAX = -1000000000, MIN = 1000000000;
        
        if(a == 0)
        {
            for(int j = c-1; j >= b; j--)
                if(v[j] < MIN)
                    MIN = v[j];
                    
            printf("%d\n", MIN);
        }
        else if(a == 1)
        {
            for(int j = c-1; j >= b; j--)
                if(v[j] > MAX)
                    MAX = v[j];
                    
            printf("%d\n", MAX);
        }
    }
    
    return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cout << #x << " = " << (x) << "\n"
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

int n;
VI manysize;

void solve() {
	int num = n / 3;
	LL size1 = 0, size2 = 0, size3 = 0;
	for ( int i = 0; i < num; i++ ) {
		size1 += manysize[ i ];
	}
	for ( int i = 0; i < num; i++ ) {
		size2 += manysize[ i + num ];
	}
	for ( int j = num * 2; j < n; j++ ) {
		size3 += manysize[ j ];
	}
	LL ans = min( size1, min( size2, size3 ) );
	int now1 = num, now2 = num * 2, now3 = 0;
	set < pair<int, PII> > s;
	while ( !s.count( MP( now1, MP( now2, now3 ) ) ) ) {
		s.insert( MP( now1, MP( now2, now3 ) ) );
		if ( size3 == min( size1, min( size2, size3 ) ) ) {
			ans = max( ans, size3 );
			size3 += manysize[ now3 ];
			size1 -= manysize[ now3 ];
			now3++;
			now3 %= n;
		}
		else if ( size2 == min( size1, min( size2, size3 ) ) ) {
			ans = max( ans, size2 );
			size2 += manysize[ now2 ];
			size3 -= manysize[ now2 ];
			now2++;
			now2 %= n;
		}
		else {
			ans = max( ans, size1 );
			size1 += manysize[ now1 ];
			size2 -= manysize[ now1 ];
			now1++;
			now1 %= n;
		}
	}
	cout << ans << "\n";
}

int main() {
	ios::sync_with_stdio( false );
	cin.tie( 0 );
#ifdef WIN32
	
#endif
	cin >> n;
	manysize.resize( n );
	for ( int i = 0; i < n; i++ ) {
		cin >> manysize[ i ];
	}
	solve();
	return 0;
}

Measured memory_bytes: 20276
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S seconnd
#define int ll
#define PB push_back

int n;
int va[110000],vb[110000];


signed main(){
  cin>>n;

  rep(i,n){
    int a;
    cin>>a;
    if(i%2){
      va[a]++;
    }
    else{
      vb[a]++;
    }
  }

  vector<P> a,b;

  rep(i,100010){
    a.PB(P(va[i],i));
    b.PB(P(vb[i],i));
  }

  sort(all(a));
  sort(all(b));
  reverse(all(a));
  reverse(all(b));
  if(a[0].second!=b[0].second){
    cout<<n-a[0].first-b[0].first<<endl;
 } 
  else if(a[0].first+b[1].first>a[1].first+b[0].first){
    cout<<n-a[0].first-b[1].first<<endl;
  }
  else{
    cout<<n-a[1].first-b[0].first<<endl;
  }

}


Measured memory_bytes: 5220
#include <iostream>

using namespace std;

int fib(int n) {
    int a = 1;
    int b = 1;

    for (int i = 0; i < n-1; ++i) {
        int tmp = a;
        a = b;
        b += tmp;
    }
    return b;
}

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

    cout << fib(n) << endl;

    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;

const int mx=200010;
const ll mod=1e9+7;

int n,m;
int a;
ll dp[mx];
bool dpflag[mx]={true};

int main(){
  cin >> n >> m;
  for(int i=0; i<=n; i++){ dpflag[i]=true; }
  for(int i=0; i<m; i++){
    cin >> a;
    dpflag[a]=false;
  }

  dp[0]=1;
  if(dpflag[1]){dp[1]=1;}
  for(int next=1; next<=n; next++){
      if(dpflag[next+1]){
        dp[next+1] = dp[next] + dp[next-1];
        dp[next+1] %= mod;
      }
  }

  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
int main() {
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> board(H);
	rep(i,0,H) cin >> board[i];
	int si = -1, sj = -1;
	rep(i,0,H) rep(j,0,W) if (board[i][j] == 'S') si = i, sj = j;
	queue<pii> q;
	q.push(pii(si, sj));
	vector<vi> dists(H, vi(W, -1));
	dists[si][sj] = 0;
 
	vector<pii> onestep;
 
	while (!q.empty()) {
		pii pa = q.front();
		q.pop();
		int di = dists[pa.first][pa.second];
		if (di <= K) onestep.push_back(pa);
		rep(d,0,4) {
			pii pa2 = pa;
			if (d == 0) pa2.first++;
			if (d == 1) pa2.second++;
			if (d == 2) pa2.first--;
			if (d == 3) pa2.second--;
			if (pa2.first < 0 || pa2.second < 0 || pa2.first >= H || pa2.second >= W) continue;
			if (board[pa2.first][pa2.second] == '#') continue;
			if (dists[pa2.first][pa2.second] != -1) continue;
			dists[pa2.first][pa2.second] = di+1;
			q.push(pa2);
		}
	}
 
	dists.assign(H, vi(W, -1));
	trav(pa, onestep) {
		q.push(pa);
		dists[pa.first][pa.second] = 0;
	}
 
	while (!q.empty()) {
		pii pa = q.front();
		q.pop();
		int di = dists[pa.first][pa.second];
		rep(d,0,4) 
		{
			pii pa2 = pa;
			if (d == 0) pa2.first++;
			if (d == 1) pa2.second++;
			if (d == 2) pa2.first--;
			if (d == 3) pa2.second--;
			if (pa2.first < 0 || pa2.second < 0 || pa2.first >= H || pa2.second >= W) continue;
			// if (board[pa2.first][pa2.second] == '#') continue;
			if (dists[pa2.first][pa2.second] != -1) continue;
			dists[pa2.first][pa2.second] = di+1;
			q.push(pa2);
		}
	}
 
	int res = INT_MAX;
	rep(i,0,H) rep(j,0,W) {
		if (i == 0 || j == 0 || i == H-1 || j == W-1) {
			res = min(res, dists[i][j]);
		}
	}
 
	cout << (res + K-1) / K + 1 << endl;
 
	exit(0);
}


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

int main() {

    int N, M;
    cin >> N >> M;

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

    vector<vector<int> > adj(N, vector<int>());
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    int ans = 0;

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

        bool good = true;

        for (int j = 0; j < adj[i].size(); j++) {
            if (H[i] <= H[adj[i][j]]) {
                good = false;
                break;
            }
        }

        if (good) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

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

  int N;
  cin >> N;
  int A[N];
  int ans = 0;
  rep(i, N){
    cin >> A[i];
    ans += A[i];
  }
  sort(A, A+N);
  if(ans % 10 != 0){
    cout << ans << endl;
    return 0;
  }
  else{
    for(int i=0;i<N;i++){
      if(A[i] % 10 != 0){
        ans -= A[i];
        break;
      }
      if(i == N-1){
        ans = 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
  a = input()
  
  flg = "YES"
  index = 0
  while True:
    if index == len(a):
      break
    
    if a.find("dreameraser", index) == index:
      index += len("dreameraser")
    elif a.find("dreamerase", index) == index:
      index += len("dreamerase")
    elif a.find("dreamer", index) == index:
      index += len("dreamer")
    elif a.find("dream", index) == index:
      index += len("dream")
    elif a.find("eraser", index) == index:
      index += len("eraser")
    elif a.find("erase", index) == index:
      index += len("erase")
    else:
      flg = "NO"
      break
      
  print(flg)
  
main()

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
    int i;
    scanf("%d", &i);
    if (i % 10 == 7)
    {
        printf("Yes\n");
        return 0;
    }
    i = i / 10;
    if (i % 10 == 7)
    {
        printf("Yes\n");
        return 0;
    }
    i = i / 10;
    if (i % 10 == 7)
    {
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1620
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cerr << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
		int t;
		cin >> t;
		
		map<string , int> m;
		while(t--){
			string s;
			cin >> s;
			
			m[s]++;
		}
		
			cout <<	"AC x " << m["AC"] << "\n";
			cout <<	"WA x " << m["WA"] << "\n";
			cout <<	"TLE x " << m["TLE"] << "\n";
			cout <<	"RE x " << m["RE"] << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int INF=-2000000000;

int main() {
  ll h;
  cin >> h;
  vector<ll> dp(50);
  dp[0]=1;
  ll sum=0;
  ll cnt;
  for(int i=1; i<50; i++){
    dp[i]=dp[i-1]*2+1;
  }
  for(int i=0; i<=40; i++){
    ll pre=sum;
    ll num=pow(2,i);
    sum+=num;
    if(pre<h&&h<=sum) cnt=i;
  }
  cout << dp[cnt] << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, a, b ] <- readInts
	print $ min ( n * a ) b

Measured memory_bytes: 380
import sys
input = sys.stdin.readline
print = sys.stdout.write
x, y = [int(_) for _ in input().split()]
a = [4, 6, 9, 11]
if x == 2 or y == 2:
    ans = "No"
elif x in a and y in a:
    ans = "Yes"
elif not x in a and not y in a:
    ans = "Yes"
else:
    ans = "No"

print(ans)

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

int main(){
	long long s;
	cin>>s;
	
	const int v=1000000000;
	int p = s%v;
	int x=(v-p)%v;
	int y=(s+x)/v;
	
	cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = V[0]
for l in range(min(K, N)+1):
    for r in range(min(K, N)-l+1):
        v = V[:l] + V[N-r:]
        rest = K - (l + r)
        v.sort()
        tmp = 0
        for x in v:
            if rest and x < 0:
                rest -= 1
            else:
                tmp += x
        if ans < tmp:
            ans = tmp
print(ans)

Measured memory_bytes: 9196
// Problem : E - Balanced Path
// Contest : AtCoder - AtCoder Beginner Contest 147
// URL : https://atcoder.jp/contests/abc147/tasks/abc147_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 82

//Solution

int n,m,dp[N][N][2*N*N];
int a[N][N], b[N][N];

void solve(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cin>>a[i][j];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cin>>b[i][j];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(i == 0 && j == 0) dp[i][j][abs(a[i][j]-b[i][j])] = 1;
            for(int k=0;k<2*N*N;k++){
                if(i+1 < n){
                    if(k+abs(a[i+1][j]-b[i+1][j]) < 2*N*N)
                        dp[i+1][j][k+abs(a[i+1][j]-b[i+1][j])] |= dp[i][j][k];
                    if(abs(k-abs(a[i+1][j]-b[i+1][j])) < 2*N*N)
                        dp[i+1][j][abs(k-abs(a[i+1][j]-b[i+1][j]))] |= dp[i][j][k];
                }
                if(j+1 < m){
                    if(k+abs(a[i][j+1]-b[i][j+1]) < 2*N*N)
                        dp[i][j+1][k+abs(a[i][j+1]-b[i][j+1])] |= dp[i][j][k];
                    if(abs(k-abs(a[i][j+1]-b[i][j+1])) < 2*N*N)
                        dp[i][j+1][abs(k-abs(a[i][j+1]-b[i][j+1]))] |= dp[i][j][k];
                }
            }
        }
    }
    for(int k=0;k<2*N*N;k++){
        if(dp[n-1][m-1][k]){
            cout<<k<<endl;
            return;
        }
    }
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 676288
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N, x;
    cin >> N >> x;

    if (x == 1 || x == 2 * N - 1) cout << "No" << endl;
    else if (N == 2) {
        cout << "Yes" << endl;
        cout << 1 << endl;
        cout << 2 << endl;
        cout << 3 << endl;
    } else {
        cout << "Yes" << endl;
        vector<bool> used(2 * N, false);
        vector<int> ans(2 * N, 0);
        ans[N] = x; used[x] = true;
        if (x > 2) {
            ans[N + 1] = x + 1; used[x + 1] = true;
            ans[N - 1] = x - 1; used[x - 1] = true;
            ans[N + 2] = x - 2; used[x - 2] = true;
        } else {
            ans[N + 1] = x - 1; used[x - 1] = true;
            ans[N - 1] = x + 1; used[x + 1] = true;
            ans[N + 2] = x + 2; used[x + 2] = true;
        }
        int now = 1;
        for (int i = 1; i <= 2 * N - 1; i++) {
            if (ans[i] > 0) continue;
            while (used[now]) now++;
            ans[i] = now; used[now] = true;
        }
        for (int i = 1; i <= 2 * N - 1; i++) {
            cout << ans[i] << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 2304
program sum_of_divisors
  implicit none
  integer :: n, i, j
  integer(8) :: f(10000000) = 0, x = 0
  read(*,*) n
  do i = 1, n
    do j = i, n, i
      f(j) = f(j) + 1
    end do
  end do
  do i = 1, n
    x = x + f(i) * i
  end do
  write(*,'(i0)') x
end program sum_of_divisors

Measured memory_bytes: 80992
#include <iostream>
#include <cstdio>
using namespace std;
 
int A[500000], S = 0;
 
int merge(int l, int m, int r){
    int n1 = m - l, n2 = r - m, i, j;
    int L[n1 + 1], R[n2 + 1];
    for(i = 0;i < n1;i++)L[i] = A[i + l];
    for(i = 0;i < n2;i++)R[i] = A[i + m];
    i = j = 0;
    for(int k = 0;k < r - l;k++, S++){
        if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
        else A[k + l] = R[j++];
    }
}

int mergeSort(int l, int r){
    if(l + 1 < r){
        int m = (l + r) / 2;
        mergeSort(l, m);
        mergeSort(m, r);
        merge(l, m, r);
    }
}
 
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0;i < n;i++)scanf("%d", &A[i]);
    mergeSort(0, n);
    for(int i = 0;i < n;i++){
        if(i)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", S);
     
    return 0;
}

Measured memory_bytes: 7032