akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 1e5 + 5, NO_OF_ENDINGS = 4, WITH_MULTIPLIER = 0, WITHOUT_MULTIPLIER = 1;
long long sum_till[MAX_N][NO_OF_ENDINGS];

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

    vector <long long> A(no_of_elements + 1);
    for(int i = 1; i <= no_of_elements; i++)
        cin >> A[i];

    sum_till[1][WITHOUT_MULTIPLIER] = A[1], sum_till[1][WITH_MULTIPLIER] = A[1];
    sum_till[2][WITH_MULTIPLIER] = -A[1] - A[2], sum_till[2][WITHOUT_MULTIPLIER] = A[1] + A[2];
    for(int i = 3; i <= no_of_elements; i++)
    {
        long long max_without_last_2 = max(sum_till[i - 2][WITHOUT_MULTIPLIER], sum_till[i - 2][WITH_MULTIPLIER]);

        sum_till[i][WITHOUT_MULTIPLIER] = A[i] + max(A[i - 1] + max_without_last_2, sum_till[i - 1][WITH_MULTIPLIER]);

        sum_till[i][WITH_MULTIPLIER] = -A[i] + max(-A[i - 1] + max_without_last_2, sum_till[i - 1][WITH_MULTIPLIER] + 2*A[i - 1]);

        //cout << "f(" << i << "+) = " << sum_till[i][WITHOUT_MULTIPLIER] << " f(" << i << "-) = " << sum_till[i][WITH_MULTIPLIER] << endl;
    }

    long long answer = max(sum_till[no_of_elements][WITH_MULTIPLIER], sum_till[no_of_elements][WITHOUT_MULTIPLIER]);
    cout << answer;

    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int n; string s; cin >> n >> s;
    rep(i, s.size()) {
        int a = (int)s[i] + n;
        if(a > 'Z') a = a - 'Z' + 'A' - 1;
        s[i] = (char)a;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int h, w, n, sr, sc;
string s, t;

int main() {
  cin >> h >> w >> n >> sr >> sc >> s >> t;

  int L = 1, R = w, U = 1, D = h;
  for(int i = n-1; i >= 0; --i) {
    if(t[i] == 'R') {
      if(1 < L && L < w) --L;
    }
    if(t[i] == 'L') {
      if(1 < R && R < w) ++R;
    }

    if(s[i] == 'R') --R;
    if(s[i] == 'L') ++L;
  }
  if(L > sc || sc > R) { cout << "NO"; return 0; }

  for(int i = n-1; i >= 0; --i) {
    if(t[i] == 'D') {
      if(1 < U && U < h) --U;
    }
    if(t[i] == 'U') {
      if(1 < D && D < h) ++D;
    }

    if(s[i] == 'D') --D;
    if(s[i] == 'U') ++U;
  }
  if(U > sr || sr > D) { cout << "NO"; return 0; }

  cout << "YES";
  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

int main ()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	cout << (r <= x && r <= y && x <= W - r && y <= H - r ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100000;
const double eps = 1e-6;
const double PI = acos(-1.0);

int N;
int cnt[8];

bool check(int x) {
	int num = 0;
	for(int i = 0; i < 5; i++)
		if(x & (1 << i) )
			num++;
	if(num == 3) return true;
	else return false;
}

int main()
{
	while(scanf("%d", &N) != EOF)
	{
		memset(cnt, 0, sizeof(cnt));
		for(int i = 1; i <= N; i++) {
			string s;
			cin >> s;
			if(s[0] == 'M') cnt[0]++;
			else if(s[0] == 'A') cnt[1]++;
			else if(s[0] == 'R') cnt[2]++;
			else if(s[0] == 'C') cnt[3]++;
			else if(s[0] == 'H') cnt[4]++;
		}
		LL ans = 0LL;
		for(int i = 0; i < (1 << 5); i++) {
			if(check(i) ){
				LL res = 1LL;
				for(int j = 0; j < 5; j++) {
					if(i & (1 << j))
						res = res * cnt[j];
				}
				ans += res;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

//字符串转换成字符
int getChar (char ch){
	if	   (ch=='A')return 1;
	else if(ch=='C')return 2;
	else if(ch=='G')return 3;
	else if(ch=='T')return 4;
	else return 0;
} 

//将字符串转换成数值并生成key
long long getKey(char str[]){
	long long sum=0,p=1,i;
	for(int i=0;i<strlen(str);i++){
		sum+=p*(getChar(str[i]));
		p*=5;
	}
	return sum;
} 

int h1(int x){
	return x%M;
}
int h2(int x){
	return 1+(x%(M-1));
}

int find(char str[]){
	long long x,i,h;
	x=getKey(str);
	for(i=0;;i++){
		h=(h1(x)+i*h2(x))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0)return 0;
	}
	return 0;
}

int insert(char str[]){
	long long x,i,h;
	x=getKey(str);
	for(i=0;;i++){
		h=(h1(x)+i*h2(x))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0) {
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i,n,h;
	char str[L],com[9];
	//for(i=0;i<M;i++) H[i][0]=='\n';
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",com,str);
		
		if(com[0]=='i'){
			insert(str);
		}
		else {
			if(find(str))printf("yes\n");
			else printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 15996
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n, m = na()
  if n * 2 > m:
    print(m // 2)
  else:
    print(n + (m - n * 2) // 4)

main()

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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	int n, a[20], x[20][20], y[20][20], ans = 0;
	bool valid;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		for (int j = 0; j < a[i]; j++) {
			scanf("%d %d", &x[i][j], &y[i][j]);
			x[i][j]--;
		}
	}
	for (int i = 0; i < (1 << n); i++) {
		valid = true;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j))
				for (int k = 0; k < a[j]; k++) {
					if ((y[j][k] == 0) && (i & (1 << x[j][k]))) {
						valid = false;
						break;
					}
					if (y[j][k] == 1) {
						if (i & (1 << x[j][k]))
							continue;
						valid = false;
						break;
					}
				}
			if (!valid)
				break;
		}
		if (valid)
			ans = max(ans, __builtin_popcount(i));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int K = sc.nextInt();
  if(N%K==0){
    System.out.println(0);
  }else{
    System.out.println(1);
  }

}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

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

// Z_pでのaの逆元を計算 O(log p)
// depend:pow_mod
long long int inv_mod(long long int a, long long int p) {
    return pow_mod(a, p - 2, p);
}

// 階乗テーブルを作ってコンビネーションをキビキビ計算する
// depend:inv_mod
struct combination_mod {
    using lint = long long int;
    int sz;
    vector<lint> data;
    lint mod;
    combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
        data.assign(sz + 1, 1);
        for (int i = 1; i <= sz; i++) data[i] = (data[i - 1] * i) % mod;
    }
    // nCrを計算 O(log mod)
    lint query(int n, int r) {
        lint res = 1;
        res = (res * data[n]) % mod;
        res = (res * inv_mod(data[r], mod)) % mod;
        res = (res * inv_mod(data[n - r], mod)) % mod;
        return res;
    }
};

int main() {
    lint mod = 998244353;
    lint n, a, b, k;
    cin >> n >> a >> b >> k;
    combination_mod cm(n, mod);
    lint ans = 0;
    // Aでi箇所塗る
    for (int i = 0; i <= n; i++) {
        // m:Bの数
        lint rem = k - a * i;
        lint m = rem / b;
        if (rem < 0 || rem % b != 0 || m > n) continue;
        lint temp = cm.query(n, i) * cm.query(n, m);
        temp %= mod;
        ans += temp;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	reverse(s.begin(),s.end());
	reverse(t.begin(),t.end());
	for (int i=0;i+t.size()-1<s.size();i++){
		string tmp=s;
		int j=0;
		for (j=i;j<i+t.size();j++){
			if (tmp[j]=='?') tmp[j]=t[j-i];
			if (tmp[j]!=t[j-i]) break;
		}
		j-=i;
		if (j==t.size()){
			for (int j=0;j<tmp.size();j++)
				if (tmp[j]=='?')
					tmp[j]='a';
			reverse(tmp.begin(),tmp.end());
			cout<<tmp<<endl;
			return 0;
		}
	}
	cout<<"UNRESTORABLE"<<endl;
	return 0;
}

Measured memory_bytes: 256
h,w = map(int, input().split())
s = [input() for _ in range(h)]

def check():
    for i in range(h):
        for j in range(w):
            if s[i][j] == '.':
                continue
            ok = False
            for x,y in [(i-1,j), (i+1,j), (i,j+1), (i,j-1)]:
                if x<0 or x>=h or y<0 or y>=w :
                    continue
                if s[x][y] == '#':
                    ok = True
            if not ok:
                return False
    return True


print("Yes" if check() else "No")


Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int n, c, i, j, k, s, t, ans = 0;
  scanf("%d%d", &n, &c);
  int a[c][100010];
  for(i = 0; i < c; ++i) for(j = 0; j < 100010; ++j) a[i][j] = 0;
  for(i = 0; i < n; ++i) {
    scanf("%d%d%d", &s, &t, &k);
    a[--k][s]++, a[k][t + 1]--;
  }
  for(i = 0; i < c; ++i) for(j = 1; j < 100010; ++j) {
    a[i][j] += a[i][j - 1];
    if(a[i][j] == 2) a[i][j] = 1, a[i][j + 1]++;
  }
  for(i = 0; i < 100010; ++i) {
    int cnt = 0;
    for(j = 0; j < c; ++j) cnt += a[j][i];
    if(cnt > ans) ans = cnt;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 11904
#include<iostream>
#include<string>
using namespace std;
int main() {
	int d; cin >> d;
	string ans;
	if (d == 25) ans = "Christmas";
	else if (d == 24) ans = "Christmas Eve";
	else if (d == 23)ans = "Christmas Eve Eve";
	else if (d == 22)ans = "Christmas Eve Eve Eve";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()

N = int(s.split()[0])
M = int(s.split()[1])

H = input().split()

tenbo = list(range(1,N+1))
bad_tenbo = []

for i in range(M):
  road = input().split()
  A = int(road[0])
  B = int(road[1])
  HA = int(H[A-1])
  HB = int(H[B-1])
  if HA > HB:
    bad_tenbo.append(B)
  elif HA == HB:
    bad_tenbo.append(A)
    bad_tenbo.append(B)
  elif HA < HB:
    bad_tenbo.append(A)
    
result = list(set(tenbo) - set(bad_tenbo))
    
print(len(result))

Measured memory_bytes: 33024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
using namespace std;

long long n;
long long ans = 0;

void dfs(string s) {
    
    if (s.length() > 1 && stoll(s) > n) {
        return;
    }

    if (s.find("7") != string::npos) {
        if (s.find("5") != string::npos) {
            if (s.find("3") != string::npos) {
                ans += 1;
            }
        }
    }
    
    dfs("7" + s);
    dfs("5" + s);
    dfs("3" + s);
    
    return;
}

int main(){

    cin >> n;
    dfs("");

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
int n;
int dp[100005],cnt[100005];
char s[100005],t[100005];
int main()
{
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  cnt[s[0]-'a']=1;
  for(int i=1;i<n;i++){
    (dp[i]+=cnt[t[i]-'a'])%=MOD;
    (cnt[s[i]-'a']+=dp[i])%=MOD;
  }
  cout<<dp[n-1]<<endl;
  return 0;
}



Measured memory_bytes: 3700
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	mid := m + m%2
	l, r := 1, mid
	for l < r {
		fmt.Println(l, r)
		l++
		r--
	}
	l, r = mid+1, 2*m+1
	for l < r {
		fmt.Println(l, r)
		l++
		r--
	}

}


Measured memory_bytes: 3264
#include<stdio.h>
int main(){
  int a,b=0,c=1e9,n;
  scanf("%d",&n);
  while(n--){
    scanf("%d",&a);
    if(b<a)b=a;
    if(c>a)c=a;
  }
  printf("%d\n",b-c);
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 55;
int dp[9][N];
string s1, s2;
void solve(){
	int n;
	cin >> n;
	cin >> s1 >> s2;
	s1 = '0' + s1;
	s2 = '0' + s2;
	fr(i, 0, 2){
		fr(j, 0, 2){
			if(i == j && s1[1] == s2[1]){
				dp[i * 3 + j][1] = 1;
			}
			else if(i != j && s1[1] != s2[1]){
				dp[i * 3 + j][2] = 1;
			}
		}
	}
	fr(i, 1, n - 1){
		fr(p, 0, 2){
			fr(q, 0, 2){
				int mask = p * 3 + q;
				fr(a, 0, 2){
					fr(b, 0, 2){
						int nmask = a * 3 + b;
						if(p == a || q == b) continue;
						if(a == b && s1[i + 1] == s2[i + 1]){
							dp[nmask][i + 1] += dp[mask][i];
							dp[nmask][i + 1] %= mod;
						}
						else if(a != b && s1[i + 1] != s2[i + 1]){
							dp[nmask][i + 2] += dp[mask][i];
							dp[nmask][i + 1] %= mod;
						}
					}
				}
			}
		}
	}
	int ans = 0;
	fr(mask, 0, 8){
		ans += dp[mask][n];
		ans %= mod;
	}
	cout << ans;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  int s,w;
  cin >> s >> w;
  if(s<=w) cout << "unsafe" << endl;
  else cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x, y;
    cin >> x >> y;
    if ((y - 2 * x) >= 0 && (y - 2 * x) % 2 == 0 && (y - 2 * x) / 2 <= x)
    {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<sstream>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;


int main(){
    string s;
    cin >> s;

    if (s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * (n + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;

ld ans = -1;
ld L;

int main(void) {
    cin >> L;

    printf("%0.10Lf\n", (L/3)*(L/3)*(L/3));

	return 0;
}


Measured memory_bytes: 256
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    n = int(input())
    c = str(input())

    #output
    #Rがr個、Wがw個あるとする。
    #最終的にはRRRR...WWWW...の状態にすれば良い。
    #もとの状態と比べた時、RとWが一致していないものを考える。
    #WRの個数とRWの個数をそれぞれx, yとすると、求める操作の回数はmax(x, y)となる。
    w, r = 0, 0
    for i in range(n):
        if c[i] == "W":
            w += 1
        else:
            r += 1
    x, y = 0, 0
    for j in range(r):
        if c[j] == "W":
            x += 1
    for k in range(r+1, r+w):
        if c[k] == "R":
            y += 1
    print(max(x, y))

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); 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 rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int a[100100];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    ll ans = 0;
    rep(i, M) {
        int p;
        string S;
        cin >> p >> S;
        if (a[p] >= 0) {
            if (S == "WA") {
                a[p]++;
            } else {
                ans += a[p];
                a[p] = -1;
            }
        }
    }
    ll ans2 = 0;
    rep(i, 100100) {
        if (a[i] == -1) {
            ans2++;
        }
    }
    cout << ans2 << ' ' << ans << endl;
}

Measured memory_bytes: 640
module ABC140

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_A

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! variables for this <subroutine>
    integer(INT32) :: N

    ! STEP.01
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*) N

    ! STEP.02
    ! output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') N ** 3_INT32

    ! STEP.END
    return

  end subroutine task_A

end module ABC140


program main

  ! <module>s to import
  use, non_intrinsic :: ABC140

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 768
/* minimum_weight_cycle.cpp
    グラフの最小の重みの閉路を求める
*/

#include <bits/stdc++.h>
using namespace std;

template <typename T>
struct Edge {
    int to;
    T cost;
};
using Graph = vector<vector<Edge<long long>>>;  // 距離/コストの型 T を指定する
const long long INF = (1LL << 60);              // 型 T のINF (完全な最大値は取らないように)

/* dijkstra(G,s)
    入力：グラフ G, 開始点 s, 距離を格納する dist, 最短経路の前の点を記録するpre
    計算量：O(|E|log|V|)
    副作用：dist, preが書き換えられる
*/
template <typename T>
void dijkstra(const Graph &G, int s, vector<T> &dis, vector<int> &prev) {
    using P = pair<T, int>;
    int N = G.size();
    dis.resize(N, INF);
    prev.resize(N, -1);
    priority_queue<P, vector<P>, greater<P>> pq;  // the least element is top. first:cost, second: node
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();  // the least element
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {
            continue;
        }
        for (auto &e : G[v]) {
            if (dis[e.to] > dis[v] + e.cost) {
                dis[e.to] = dis[v] + e.cost;
                prev[e.to] = v;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}

/* get_path(pre, t)
    入力：得た pre, ゴール t
    出力： t への最短路のパス
*/
vector<int> get_path(const vector<int> &pre, int t) {
    vector<int> path;
    for (int cur = t; cur != -1; cur = pre[cur]) {
        path.push_back(cur);
    }
    reverse(path.begin(), path.end());
    return path;
}

vector<int> min_cyle;
template <typename T>
T minimum_weight_cycle(Graph &G) {
    int V = (int)G.size();
    T ans = INF;
    for (int v = 0; v < V; v++) {
        for (int i = 0; i < (int)G[v].size(); i++) {
            Edge<T> e = G[v][i];
            G[v].erase(G[v].begin() + i);  // e を消す
            vector<T> dist;
            vector<int> pre;
            dijkstra<T>(G, e.to, dist, pre);
            if (ans > dist[v] + e.cost) {
                ans = dist[v] + e.cost;
                min_cyle = get_path(pre, v);
            }
            G[v].insert((G[v].begin() + i), e);  // e を戻す
        }
    }
    return ans;
}

int main() {
    int V, E;
    cin >> V >> E;
    if (E == 0) {
        cout << -1 << endl;
        return 0;
    }
    Graph G(V);
    for (int i = 0; i < E; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back({b, 1LL});
        // G[b].push_back({a});
    }

    long long ans = minimum_weight_cycle<long long>(G);

    if (ans == INF) {
        cout << -1 << endl;
        return 0;
    } else {
        cout << ans << "\n";
        for (auto i : min_cyle) {
            cout << i + 1 << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>

extern const double eps;
bool eql(const double &a, const double &b) {
    return fabs(a - b) < eps;
}

struct Vector {
    double x = 0, y = 0;
    Vector(int _x, int _y) : x(_x), y(_y) {}
    Vector(double _x, double _y) : x(_x), y(_y) {}

    double dot(const Vector &r) const {
        return x * r.x + y * r.y;
    }
    
    double cross(const Vector &r) const {
        return x * r.y - y * r.x;
    }

    double length() const {
        return sqrt(x * x + y * y);
    }

    Vector  operator +  (const Vector &r) const {
        return Vector(x + r.x, y + r.y);
    }
    Vector& operator += (const Vector &r) {
        x += r.x, y += r.y;
        return *this;
    }

    Vector  operator -  () const {
        return Vector(-x, -y);
    }

    Vector  operator -  (const Vector &r) const {
        return *this + -r;
    }
    Vector& operator -= (const Vector &r) {
        x -= r.x, y -= r.y;
        return *this;
    }

    Vector  operator *  (double k) const {
        Vector tmp = *this;
        tmp.x *= k, tmp.y *= k;
        return tmp;
    }

    Vector& operator *= (double k) {
        x *= k, y *= k;
        return *this;
    }

    // 向量单位化
    void unitise() {
        double len = length();
        x /= len, y /= len;
    }
};
typedef Vector Point;
struct Line {
    Point p;
    // 规定方向向量取单位向量
    Vector dir;

    Line(Point _p, Vector _dir) : p(_p), dir(_dir) {
        dir.unitise();
    }

};

// 向量数乘
Vector operator * (double k, const Vector & r) {
    return r * k;
}

// 点到直线的投影点
Point projection(const Point &p, const Line &l) {
    double d = Vector(p - l.p).dot(l.dir);
    return l.p + d * l.dir;
}
// 点关于直线的对称点
Point reflection(const Point &p, const Line &l) {
    Point pro = projection(p, l);
    return p + 2 * (pro - p);
}
using namespace std;
const double eps = 1e-8;


int main() {
    // freopen("in", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int xp1, yp1, xp2, yp2, q, xp, yp;
    cin >> xp1 >> yp1 >> xp2 >> yp2 >> q;
    // Line L(Point(xp1, yp1), Vector(xp2 - xp1, yp2 - yp1));
    Vector p12(xp2 - xp1, yp2 - yp1);
    while (q--) {
        cin >> xp >> yp;
        Vector p1p(xp - xp1, yp - yp1);
        double cro = p12.cross(p1p);
        double inp = p12.dot(p1p);
        if (cro > eps) {
            cout << "COUNTER_CLOCKWISE\n";
        } else if (cro < -eps) {
            cout << "CLOCKWISE\n";
        } else {
            if (inp < -eps) {
                cout << "ONLINE_BACK\n";
            } else {
                if (fabs(xp) <= fabs(xp2) && fabs(yp) <= fabs(yp2)) {
                    cout << "ON_SEGMENT\n";
                } else {
                    cout << "ONLINE_FRONT\n";
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3212
// 2020.1.26 #153 B
#include <iostream>
#include <cmath>
using namespace std;

#define N_MAX 100000

int main(int argc, char const* argv[])
{
	unsigned H, N, A[N_MAX];
	int		 i = 0;
	unsigned damage_sum = 0;

	scanf("%d %d\n", &H, &N);
	while(i++ < N)
	{
		cin >> A[i];
		damage_sum += A[i];
	}
	if(damage_sum >= H)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    map<int, int> m;
    int tmp = a;

    while(true){
        if(m[tmp % b] == 1) break;

        m[tmp % b] = 1;
        tmp += a;
    }

    cout << (m[c] == 1 ? "YES" : "NO") << endl;
    


    return 0;
}
/*
|S|が小さいので全探索
*/

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define REP1(i,n) for(int (i)=(1);(i)<(n);++i)
#define ll long long

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

    if(a>12)ans=b;
    else if(a>5)ans = b/2;
    else ans = 0;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cstdio>
using namespace std;
int main(){
	while(1){
		long long a,b;
		cin>>a>>b;
		long temp;
		if(a<b){temp=a;a=b;b=temp;}
		if(cin.eof()) {break;}
		long q,r;
		while(a%b!=0){
			q=(long long)a/b;		
			r=(long long)a%b;
			a=b;
			b=r;
		}
		cout<<b<<endl;		
	}
	return 0;	
}

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

int main(void){
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }

    int dp[2][100010] = {};

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

    int j = 0;
    for(int i = 0; i < n; i++){
        while(1){
            if(a[i] < b[j]){
                dp[0][i] = n - j;
                break;
            }
            if(j == n-1){
                i = n-1;
                break;
            }
            j++;
        }
    }

    j = 0;
    long long sum = 0;
    for(int i = 0; i < n; i++){
        while(1){
            if(b[i] < c[j]){
                dp[1][i] = n - j;
                sum += dp[1][i];
                break;
            }
            if(j == n-1){
                i = n-1;
                break;
            }
            j++;
        }
        
    }

    long long D[100010] = {};

    for(int i = n; i >= 0; i--){
        D[i] = sum;
        sum -= dp[1][n-i];
    }

    long long temp;
    long long ans = 0;
    for(int i = 0; i < n; i++){
        ans += D[ dp[0][i] ];
    }

    /*for(int i = 0; i <= n; i++) cout << D[i] << " ";
    cout << endl;
    */
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

void bomb(int *field, int bx, int by){
	if(bx>=1 && by>=1 && bx<=8 && by<=8)
	if(field[8*(by-1)+bx-1] == 1){
		field[8*(by-1)+bx-1] = 0;
		for(int i=-3;i<=3;++i){
			bomb(field,bx+i,by);
			bomb(field,bx,by+i);
		}
		
	}
}

int main() {
	int n,sx,sy,field[64];
	
	cin>>n;
	for(int i=0;i<n;++i){
		getchar();
		getchar();
		char c;
		
		for(int y=0;y<8;++y){
			for(int x=0;x<8;++x){
				c=getchar();
				field[8*y+x] = (c=='0'?0:1);
			}
			getchar();
		}
		cin>>sx>>sy;
		
		bomb(field,sx,sy);
		
		cout<<"Data "<<i+1<<":"<<endl;
		for(int y=0;y<8;++y){
			for(int x=0;x<8;++x){
				cout<<field[8*y+x];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#define loop(n) for(int i = 0; i < n; i++)
#define FOR(x,y,z) for(int x = y; x < z; x++)
#define INF 999999999;
#define VEC vector<int>
#define in push_back
#define ans(x) cout<<x<<endl
#define ll long long int 

using namespace std;

int main()
{
	int n, k, x;
	cin >> n >> k >> x;
	ans((n + k)*x / 2);
}

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

int main() {
    pair<string, int> S, T;
    
    cin >> S.first >> T.first;
    cin >> S.second >> T.second;
    
    string U;
    cin >> U;
    if (U==S.first) S.second--;
    if (U==T.first) T.second--;
    cout << S.second << " " << T.second << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
	return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

// Verified: CF302B
vector<int> BFS(const vector<vector<Edge>>& graph, int s) {
  int n = graph.size();

  deque<int> queue;
  queue.push_back(s);
  vector<int> ds(n, INT_MAX);
  ds[s] = 0;
  while (!queue.empty()) {
    int v = queue.front();
    queue.pop_front();
    for (const auto& e : graph[v]) {
      if (ds[e.to] < INT_MAX) continue;
      ds[e.to] = ds[v] + 1;
      queue.push_back(e.to);
    }
  }
  return ds;
}

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

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

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

  int h, w;
  cin >> h >> w;
  vector<string> board(h);
  for (int r = 0; r < h; r++) {
    cin >> board[r];
  }

  auto encode_v_fn = [&](int r, int c) {
    return r * w + c;
  };
  vector<vector<Edge>> graph(h * w);
  for (int r = 0; r < h; r++) {
    for (int c = 0; c < w; c++) {
      if (board[r][c] == '#') continue;
      int v = encode_v_fn(r, c);
      if (c + 1 < w && board[r][c + 1] == '.') graph[v].emplace_back(v, encode_v_fn(r, c + 1));
      if (c - 1 >= 0 && board[r][c - 1] == '.') graph[v].emplace_back(v, encode_v_fn(r, c - 1));
      if (r + 1 < h && board[r + 1][c] == '.') graph[v].emplace_back(v, encode_v_fn(r + 1, c));
      if (r - 1 >= 0 && board[r - 1][c] == '.') graph[v].emplace_back(v, encode_v_fn(r - 1, c));
    }
  }

  int ans = 0;
  for (int r = 0; r < h; r++) {
    for (int c = 0; c < w; c++) {
      if (board[r][c] == '#') continue;
      int s = encode_v_fn(r, c);
      auto ds = BFS(graph, s);
      for (int d : ds) {
        if (d == INT_MAX) continue;
        UpdateMax(ans, d);
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
    vector<string> bd(3);
    while (cin >> bd[0], bd[0] != "0") {
        for (int i=1; i<3; ++i) cin >> bd[i];
        string res = "NA";
        for (int k=0; k<3; ++k) {
            if (bd[0][k] != '+' && bd[0][k] == bd[1][k] && bd[1][k] == bd[2][k]) res = bd[0][k];
            if (bd[k][0] != '+' && bd[k][0] == bd[k][1] && bd[k][1] == bd[k][2]) res = bd[k][0];
        }
        if (bd[0][0] != '+' && bd[0][0] == bd[1][1] && bd[1][1] == bd[2][2]) res = bd[0][0];
        if (bd[2][0] != '+' && bd[2][0] == bd[1][1] && bd[1][1] == bd[0][2]) res = bd[2][0];
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>

using namespace std;

void print_grade(int m, int f, int r) {
    int sum = m + f;

    if (m == -1 || f == -1) {
        cout << "F";
    } else if (sum >= 80) {
        cout << "A";
    } else if (sum >= 65) {
        cout << "B";
    } else if (sum >= 50) {
        cout << "C";
    } else if (sum >= 30) {
        if (r >= 50) {
            cout << "C";
        } else {
            cout << "D";
        }
    } else {
        cout << "F";
    }
    cout << endl;
}

int main() {
    int m,f,r;
    while(true) {
        cin >> m >> f >> r;

        if (m == -1 && f == -1 && r == -1)
            break;

        print_grade(m,f,r);
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   
   sort(arr,arr+n);
   ll sum = 0;
   rep(k)
        sum+=arr[i];
   
   cout<<sum;        
   
   
   return 0;        
}  
  
          
   

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
int main(){
    ios;
    ld a, b; cin >> a >> b;
    ull ans = a *b;
    cout << ans;
    return 0;
}



Measured memory_bytes: 3740
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
f(a::Tuple{Int,Int},b::Tuple{Int,Int}) = abs(a[1]-b[1])+abs(a[2]-b[2])

function main()
	h,w,d = readline() |> split |> parseMap
	a = zeros(Int,h,w)
	b = Tuple{Int,Int}[(0,0) for i in 1:h*w]
	for i in 1:h
		x = readline() |> split |> parseMap
		for j in 1:w
			b[x[j]] = (i,j)
		end
	end
	s = 0
	c = zeros(Int,h*w)
	for i in 1:h*w
		if i+d<=h*w
			c[i+d]=c[i]+f(b[i],b[i+d])
		end
	end
	q = readline() |> parseInt
	for i in 1:q
		l,r = readline() |> split |> parseMap
		println(c[r]-c[l])
	end
end

main()

Measured memory_bytes: 154508
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
constexpr int N = 500;
constexpr int MAX = 16 * N;
constexpr int NUM = 2 * N - 1;
bool isprime[16 * N];
ll p1[N][N], p2[N][N], ans[N][N];
std::mt19937 mt{std::random_device{}()};
bool check(const int N)
{
    std::set<ll> st;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            st.insert(ans[i][j]);
            if (ans[i][j] < 1 and ans[i][j] > 1000000000000000LL) { return false; }
        }
    }
    return st.size() == N * N;
}

int main()
{
    std::fill(isprime, isprime + MAX, true);
    std::vector<ll> prime;
    for (int i = 2; i < MAX; i++) {
        if (not isprime[i]) { continue; }
        prime.push_back(i);
        if (prime.size() == NUM) { break; }
        for (int j = 2; i * j < MAX; j++) { isprime[i * j] = false; }
    }
    for (int i = 0; i < 2 * N; i += 2) {
        for (int y = 0; y < N; y++) {
            const int x = i - y;
            if (x < 0 or N <= x) { continue; }
            p1[y][x] = prime[i / 2];
        }
    }
    for (int i = N - 2; i >= -N + 2; i -= 2) {
        for (int y = 0; y < N; y++) {
            const int x = y + i;
            if (x < 0 or N <= x) { continue; }
            p2[y][x] = prime[(i + N - 2) / 2 + N];
        }
    }

    auto get = [&](const int y, const int x) { return y >= 0 and y < N and x >= 0 and x < N ? std::pair<ll, ll>{p1[y][x], p2[y][x]} : std::pair<ll, ll>{1LL, 1LL}; };
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i % 2 == j % 2) {
                ans[i][j] = p1[i][j] * p2[i][j];
            } else {
                std::set<ll> p;
                p.insert({get(i - 1, j).first,
                          get(i - 1, j).second,
                          get(i + 1, j).first,
                          get(i + 1, j).second,
                          get(i, j - 1).first,
                          get(i, j - 1).second,
                          get(i, j + 1).first,
                          get(i, j + 1).second});
                ans[i][j] = 1;
                for (const ll P : p) { ans[i][j] *= P; }
                ans[i][j]++;
            }
        }
    }
    assert(check(N));
    int N;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            std::cout << ans[i][j] << " ";
        }
        std::cout << std::endl;
    }
    return 0;
}


Measured memory_bytes: 20736
l = input().split()
W = int(l[0])
H = int(l[1])
x = int(l[2])
y = int(l[3])
r = int(l[4])

if (x-r) < 0:
    print("No")
elif (x+r) > W:
    print("No")
elif (y-r) <0:
    print("No")
elif (y+r) >H:
    print("No")
else:
    print("Yes")


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int a = 0;
  int b = 0;
  int F = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] == '(') ++a;
    if (S[i] == ')') ++b;
    if (a < b) {
      ++F;
      ++a;
    }
  }
  a = F;
  b = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] == '(') ++a;
    if (S[i] == ')') ++b;
  }
  int B = a - b;
  
  for (int i = 0; i < F; ++i) cout << "(";
  cout << S;
  for (int i = 0; i < B; ++i) cout << ")";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
if n < 10
  puts n
elsif n < 100
  puts 9
elsif n < 1000
  puts (n - 99) + 9
elsif n < 10000
  puts 909
elsif n < 100000
  puts (n - 9999) + 909
else
  puts 90909
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
// vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
// int modInverse(int n){ 
// return p(n, MOD-2); 
// }  
// int nCrModPFermat(int n, int r){   
//     if(r == 0)  return 1; 
//     return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
// } 
signed main(){
    fast();
    int n;
    cin >> n;
    bool flag = false;
    for(int i=0, f; i<n; i++){
        cin >> f;
        if(f%2 == 0){
            if(f%3 != 0 && f%5 != 0){
                flag = true;
            }
        }
    }
    if(flag)    cout << "DENIED" << endl;
    else cout << "APPROVED" << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,m;
    cin>n>m;
    vi dp(n+1);
    set<int> a;
    REP(i,m){
        int b;
        cin>b;
        a.insert(b);
    }
    dp[0]=1;
    REP(i,1,n+1){
        if(a.count(i))continue;
        dp[i]+=dp[i-1];
        dp[i]%=MOD;
        if(i>1)dp[i]+=dp[i-2];
        dp[i]%=MOD;
    }
    cout<dp[n]<endl;
    return 0;
}


Measured memory_bytes: 5376
def ABC129C_TypicalStairs():
    mod_num = 1000000007
    
    N, M = list(map(int, input().strip().split()))
    brk = [int(input())  for i in range(M)]
    # 0段目は1通り？2段目は1段目からの1通り，3段目は1段目から＋2段目からなので p[1] + p[2] になる？

    dp = [0] * (N + 1)
    for i in range(M):
        dp[brk[i]] = -1

    dp[0] = 1
    if dp[1] != -1:
        dp[1] = 1

    for i in range(2, N + 1):
        if(dp[i] == -1):
            continue
        if(dp[i - 1] != -1):
            dp[i] += dp[i - 1]
            dp[i] %= mod_num
        if(dp[i - 2] != -1):
            dp[i] += dp[i - 2]
            dp[i] %= mod_num


    print(dp[N])

def main():
    ABC129C_TypicalStairs()

if __name__ == "__main__":
    main()

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

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
                int r=0;
                for(int i=0; i<3; i++){
                    if(line.charAt(i) == 'o')r++;
                }
                System.out.println(700 + 100*r);
            }
        }
    }
}

Measured memory_bytes: 22484