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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  map<int, int> pen, ac;
  int cp = 0, ca = 0;
  for (int i = 1; i <= m; i++) {
    int id;
    string s;
    cin >> id >> s;
    if (s == "WA") pen[id]++;
    else if (!ac[id]) {
      ac[id] = 1;
      cp += pen[id];
      ca += 1;
    }
  }
  cout << ca << ' ' << cp << '\n';
}


Measured memory_bytes: 16052
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vi a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    vi c(n), d(n);
    int ret = 0;
    for (int i = 0; i <= 29; ++i) {
        for (int j = 0; j < n; ++j) {
            c[j] = a[j] % (1 << (i + 1));
            d[j] = b[j] % (1 << (i + 1));
        }
        sort(c.begin(), c.end());
        sort(d.begin(), d.end());
        ll count = 0;
        for (int j = 0; j < n; ++j) {
            count += lower_bound(d.begin(), d.end(), (1 << (i + 1)) - c[j]) - d.begin();
            count -= lower_bound(d.begin(), d.end(), (1 << (i)) - c[j]) - d.begin();
            count += lower_bound(d.begin(), d.end(), (1 << (i + 2)) - c[j]) - d.begin();
            count -= lower_bound(d.begin(), d.end(), (1 << (i + 1)) + (1 << (i)) - c[j]) - d.begin();
        }
        if (count % 2 == 1)
            ret += 1 << i;
    }
    cout << ret << "\n";
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, C;
    cin >> A >> B >> C;

    cout << min(B/A, C) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
n,m=map(int,input().split())
path=[[] for i in range(n)]
for i in range(m):
  x,y=map(int,input().split())
  # どこからくるかとういう情報
  path[y-1].append(x-1)

memo = [-1]*n
def dfs(v):
  if memo[v] < 0:
    if len(path[v])==0:
      memo[v]=0
    else:
      memo[v]=max([dfs(p)+1 for p in path[v]])
  return memo[v]

res = 0
for i in range(n):
  tmp = dfs(i)
  if res < tmp:
    res = tmp
print(res)
  

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    int alice = 0, bob = 0;
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    rep(i, n){
        if (i % 2 == 0) alice += a.at(i);
        else bob += a.at(i);
    }
    cout << alice - bob << endl;
}

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

int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  for(i=1;i<=9;i++){
    for(j=i;j<=9;j++){
      if(i*j==n){
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
from statistics import median

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

A_star = [a - (i + 1) for i, a in enumerate(A)]

def calc_score(b):
    score = 0
    for a in A_star:
        score += abs(a - b)
    return score

print(calc_score(int(median(A_star))))

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

using namespace std;

int main() {

	int n;
	cin >> n;

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

	int counter = 0;

	for (int i = 1; i < n-1; i++) {
		if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) {
			counter++;
		}

	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N, A, B;
	ll ans = 0;
	cin >> N >> A >> B;
	for (ll i = 1; i <= N; i++) {
		ll sum = 0;
		ll X = i;
		while (X != 0) {
			sum += X % 10;
			X = X / 10;
		}
		if (A <= sum && sum <= B)
			ans += i;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

struct SegmentTree
{
	int n;
	vector<ll> v;
	SegmentTree(int n0) {
		n = 1;
		while (n < n0) {
			n *= 2;
		}

		v.resize(2 * n - 1);

		v[n] = 1;
		for (int i = n - 2; i >= 0; i--) v[i] = v[i * 2 + 1] + v[i * 2 + 2];
	}

	ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
		//cout << l << " " << r << endl;
		if (r < 0) {
			r = n;
		}

		if ( r <= a|| b <=l) {
			return 0;
		}

		if (a <= l && r <= b) {
			//cout << k << endl;
			return v[k];
		}

		ll ql = query(a, b, 2 * k + 1, l, (l + r) / 2);
		ll qr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		
		return ql + qr;
	}

	void update(int x,int l, int r) {
		int ma = x - l + 1;
		int mi = max(0, x - r);
		//cout << mi << " " << ma << endl;

		x += n - 1;
		v[x] += query(mi, ma);
		v[x] %= MOD;
		while (x > 0) {
			x = (x - 1) / 2;
			v[x] = (v[2 * x + 1] + v[2 * x + 2]) % MOD;
		}
		//cout << x << " " << v[x] << endl;
		
	}
};

int main() {
	int n, k;
	cin >> n >> k;
	vector<pii> v(k);
	for (int i = 0; i < k; i++) {
		int l, r;
		cin >> l >> r;
		v[i] = make_pair(l, r);
	}
	sort(v.begin(), v.end());


	SegmentTree st(n + 1);

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


			int l = v[j].first;
			int r = v[j].second;

			st.update(i, l, r);
		}

		/*

		for (int i = 1; i <= n; i++) {
			cout << st.query(i, i + 1) << " ";
		}
		cout << endl;
		*/
	}

	cout << st.query(n, n + 1) << endl;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> k(m);
    vector<vector<int>> vec(m);
    vector<int> s(n);
    vector<int> p(m);
    int ans=0;
    rep(i,m){
        int tk;cin>>tk;k[i]=tk;
        rep(j,tk){
            int tmp;cin>>tmp;
            vec[i].push_back(tmp-1);
        }
    }
    rep(i,m){
        cin>>p[i];
    }
    for(int bit=0;bit<(1<<n);bit++){
        rep(i,n){
            if(bit&(1<<i)){
                s[i]=1;
            }else{
                s[i]=0;
            }
        }
        
        bool fl=true;
        rep(i,m){
            int sum=0;
            for(auto v:vec[i]){
                if(s[v]==1) sum++;
            }
            if(sum%2!=p[i]){
                fl=false;
                break;
            }
        }
        if(fl) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream& operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T>
inline void printV(vector<T>& a, int n) { for(int i=0; i<n; i++) { cerr<<a[i]<<" "; } cerr<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a) { for(int i=0; i<sz(a); i++) { cerr<<a[i]<<"\n"; } cerr<<"\n"; }
template <typename T>
inline void clearVV(vector<vector<T>>& a) { for(auto &x : a) { x.clear(); } a.clear(); }
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val) { for(int i=0; i<sz(a); i++) { a[i].assign(sz(a[i]), val); } }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	string s;
	cin>>s;
	set<char> st(all(s));
	if(sz(st)!=2) {
		cout<<"No\n";
		return 0;
	}
	char ch = *st.begin();
	int freq = 0;
	for(int i=0; i<sz(s); i++) {
		if(ch==s[i]) freq++;
	}
	if(freq!=2) {
		cout<<"No\n";
	}
	else cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 256
let lcs s1 s2 =
  let l1 = String.length s1 in
  let l2 = String.length s2 in
  let dp = Array.make_matrix (l1+1) (l2+1) 0 in
  let rec iter i j =
    if i = l1 + 1 then dp.(l1).(l2)
    else if j = l2 + 1 then iter (i+1) 1
    else begin
        if s1.[i-1] = s2.[j-1] then
          dp.(i).(j) <- dp.(i-1).(j-1) + 1
        else
          dp.(i).(j) <- max dp.(i-1).(j) dp.(i).(j-1);
        iter i (j+1)
      end
  in iter 1 1
                
let () =
  let n = read_int () in
  let rec iter i =
    if i = 0 then ()
    else
      let s1 = read_line () in
      let s2 = read_line () in
      lcs s1 s2 |> string_of_int |> print_endline;
      iter (i-1)
  in iter n

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

int main(){
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  int L = min(X*Y, K);

  long long A[X], B[Y], C[Z], AB[X*Y], ABC[L*Z];
  for(int i=0; i<X; ++i) cin >> A[i];
  for(int i=0; i<Y; ++i) cin >> B[i];
  for(int i=0; i<Z; ++i) cin >> C[i];

  for(int i=0; i<X; ++i)
  for(int j=0; j<Y; ++j)
    AB[i*Y+j] = A[i] + B[j];

  sort(AB, AB+X*Y, [](const long long& x, const long long& y){ return x>y; });

  for(int i=0; i<L; ++i)
  for(int j=0; j<Z; ++j)
    ABC[i*Z+j] = AB[i] + C[j];

  sort(ABC, ABC+L*Z, [](const long long& x, const long long& y){ return x>y; });

  for(int i=0; i<K; ++i) cout << ABC[i] << endl;

  return 0;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

long long int mod=1e9+9;
const int N=100000;
int t,i,j,cs=0,n,a,b;
string s;

int main()
{
    set<string> st;
    w(t){
        cin>>s;
        st.insert(s);
    }
     cout<<st.size()<<endl;
}




Measured memory_bytes: 19220
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#ifdef _MSC_VER
int getchar_unlocked() { return getchar(); }
#endif
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
#define qp(f) [](auto i){return f;}
using LL=long long;
using VI=vector<int>;
using VL=vector<LL>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;

struct Edge {
	int to, cost;
	Edge(int to, int cost) : to(to), cost(cost) {}
};
const int INF = 1'000'000'000;

int v, e, r;
vector<vector<Edge>> graph;
vector<int> dist;

bool BellmanFord() {
	dist[r] = 0;
	rep(i, v) {
		rep(j, v) {
			rep(k, sz(graph[j])) {
				Edge e = graph[j][k];
				if (dist[j] != INF && dist[e.to] > dist[j] + e.cost) {
					dist[e.to] = dist[j] + e.cost;
					if (i == v - 1)return true;
				}
			}
		}
	}
	return false;
}


int main() {
	cin >> v >> e >> r;
	graph.resize(v);
	dist = vector<int>(v, INF);

	rep(i, e) {
		int s, t, d;
		cin >> s >> t >> d;
		graph[s].pb({ t,d });
	}

	if (BellmanFord()) {
		puts("NEGATIVE CYCLE");
	}
	else {
		rep(i, v) {
			if (dist[i] == INF)puts("INF");
			else cout << dist[i] << endl;
		}
	}
}


Measured memory_bytes: 3156
while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    else:
        if m == -1 or f == -1:
            print("F")
        elif m + f >= 80:
            print("A")
        elif m + f >= 65:
            print("B")
        elif  m + f >= 50:
            print("C")
        elif  m + f >= 30 and r >= 50:
            print("C")
        elif m + f < 30:
            print("F")
        else:
            print("D")

Measured memory_bytes: 7668
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;
long long a[500000];
long long ans;
int main(){
    int n,m=0;
    ans = 0;
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%lld",&a[i]);
    sort(a,a+n);
    ans += a[n-1];
    for (int i=n-2;i>=0;i--){
        if (m+2<=n-2){
            ans += a[i]*2;
            m += 2;
        }
        else{
            if (m+1<=n-2){
                ans += a[i];
                m += 1;
            }
            else break;
        }
    }
    printf("%lld\n",ans);
}

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

int main(){
    int n, k, x, y, sum = 0;
    cin >> n >> k >> x >> y;
    for(int i=1; i <= n;++i){
        if(i<=k){
            sum += x;
        }
        else{
            sum += y;
        }
    }
    cout << sum << endl;
}

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

int main()
{
  string name, type;
  while (cin >> name >> type) {
    if (type == "X")
      break;

    name[0] = tolower(name[0]);
    vector<string> words;
    if (name.find_first_of("_") != string::npos) {
      int s = 0;
      name += "_";
      for (int i = 0; i < name.size(); ++i) {
	if (name[i] == '_') {
	  words.push_back(name.substr(s, i-s));
	  s = i+1;
	}
      }
    } else {
      int s = 0;
      name += "X";
      for (int i = 0; i < name.size(); ++i) {
	if (isupper(name[i])) {
	  words.push_back(name.substr(s, i-s));
	  name[i] = tolower(name[i]);
	  s = i;
	}
      }
    }

    if (type == "D") {
      cout << words[0];
      for (int i = 1; i < words.size(); ++i)
	cout << "_" << words[i];
    } else {
      if (type == "U")
	words[0][0] = toupper(words[0][0]);
      cout << words[0];

      for (int i = 1; i < words.size(); ++i) {
	words[i][0] = toupper(words[i][0]);
	cout << words[i];
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val s = readLine()!!.toCharArray()
    if ((s.contains('N') && s.contains('S').not())
            || (s.contains('S') && s.contains('N').not())
            || (s.contains('E') && s.contains('W').not())
            || (s.contains('W') && s.contains('E').not())){
        println("No")
        return
    }else{
        println("Yes")
    }
}

Measured memory_bytes: 34264
#include <iostream>
#include <vector>

int main(){
  long long N, M;
  std::cin >> N >> M;
  std::vector<long long> A(M);
  for(int i = 0 ; i < (int)A.size() ; i++){
    std::cin >> A[i];
  }

  long long total = 0;
  for(int i = 0 ; i < (int)A.size() ; i++){
    total += A[i];
  }
  if(total <= N){
    std::cout << N - total << std::endl;
  }else{
    std::cout << -1 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3684
# Author: cr4zjh0bp
# Created: Sat Mar 14 10:51:46 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

x, y, z = na()

ans = 0
i = z
while i <= x - z:
    i += y
    if i > x - z:
        break
    i += z
    ans += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    while(b){
        a %= b;
        swap(a,b);
    }
    return a;
}
int main(){
    int n;cin >> n;
    vector<int> a(n);
    int ans;
    cin >> ans;
    for(int i=1;i<n;i++){
        cin >> a[i];
        ans = gcd(ans,a[i]);
    }
    cout << ans << endl;
return 0;
}


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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    auto S = accumulate(A.begin(), A.end(), 0);

    int cnt = 0;
    for (const auto &a: A){
        if (a >= (S + 4 * m - 1) / (4 * m))
            cnt++;
    }
    puts(cnt >= m ? "Yes" : "No");
}

Measured memory_bytes: 256
import bisect
N = int(input())
L = list(map(int, input().split()))

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

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    for (int i=0; i<N; i++)
    {
        cin >> B.at(i);
    }
    int test=A.at(0);
    for(int i=0; i<N; i++)
    {
        test+=B.at(i);
    }
    int max=test;
    for(int i=0; i<N-1; i++)
    {
        test=test-B.at(i)+A.at(i+1);
        if(test>max)
        {
            max=test;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 3548
N = int(input())
A = [list(map(int,input().split())) for _ in range(N-1)]
T = []
for i in range(N-1):
    t = A[i][1]+A[i][0]
    for j in range(i+1,N-1):
        if t<=A[j][1]:
            t = A[j][1]+A[j][0]
        else:
            if t%A[j][2]==0:
                t += A[j][0]
            else:
                t = (t//A[j][2]+1)*A[j][2]+A[j][0]
    T.append(t)
T.append(0)
for i in range(N):
    print(T[i])
    

Measured memory_bytes: 3188
#include<iostream>
#include<vector>

using namespace std;

int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b, a%b);
}

int main(){

    int p, q;
    cin>> p>> q;

    q=q/gcd(p, q);
    vector<int> v;
    for(int i=2; i*i<=q; i++){
        if(q%i==0){
            v.push_back(i);
            while(q%i==0) q/=i;
        }
    }
    int r=1;
    for(int i=0; i<v.size(); i++) r*=v[i];

    cout<< r*q<< endl;

    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int r;cin >> r;
    string ans = "AGC";
    if(r < 2800) ans = "ARC";
    if(r < 1200) ans = "ABC";
    cout << ans << endl;
    return 0;
}


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


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

  int a, b, h;
  std::cin >> a >> b >> h;
  std::cout << (a + b) * h / 2 << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100;

int N;
ll a[MAX_N + 1];

// ford-fulkerson O(FE) F:Flow
// maximum flow problem
// 1. init G[V] by add_edge
// 2. max_flow(s, t) return the max flow

const int MAX_V = MAX_N + 2;

struct edge{int to;ll cap; int rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, ll cap){
  G[from].push_back((edge){to, cap, int(G[to].size())});
  G[to].push_back((edge){from, 0, int(G[from].size() -1)});
}

ll dfs(int v, int t, ll f){
  if(v == t) return f;
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      ll d = dfs(e.to, t, min(f, e.cap));
      if (d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(int s, int t){
  ll flow = 0;
  for(;;){
    memset(used, 0, sizeof(used));
    ll f = dfs(s, t, INFi);
    if(f == 0) return flow;
    flow += f;
  }
}

int main(){
  cin >> N;

  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }

  ll ans = 0;

  int s = 0, t = N + 1;
  for(int i = 1; i <= N; i++) {
    if(a[i] < 0) {
      add_edge(s, i, -a[i]);
    } else {
      ans += a[i];
      add_edge(i, t, a[i]);
    }
    for(int j = 2; i * j <= N; j++) {
      add_edge(i, i * j, 1333333333333);
    }
  }

  ans -= max_flow(s, t);

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

string s;
int main() {
  cin >> s;
  int ans = 0;
  for(int i=1; i<s.size(); i++) {
    if (s[i] != s[i-1]) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <string>
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void){
    int H,W;
    while(1){
        cin >> H;
        cin >> W;
        if(H == 0 && W == 0){
            break;
        }    
        for ( int i = 0; i < H; i++ ){
           for ( int j = 0; j < W; j++ ){
               if(i > 0 && j > 0 && i < H - 1 && j < W - 1){
                cout << ".";
                } else {    
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }    
    return 0;
}


Measured memory_bytes: 3104
N_K = input().split()
N = int(N_K[0])
K = int(N_K[1])
Hs = sorted([int(input()) for i in range(N)])
Hs_diff_K = [Hs[K+i-1] - Hs[i] for i in range(N) if i < N-K+1]
print(min(Hs_diff_K))

Measured memory_bytes: 10840
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
XL=[]
for i in range(n):
    x,l=map(int,input().split())
    XL.append((x,l))

XL.sort()
now=XL[0][0]+XL[0][1]
for i in range(1,n):
    x,l=XL[i]
    if x-l<now:
        count+=1
        now=min(now,x+l)
    else:
        now=x+l
print(n-count)
    
    

Measured memory_bytes: 50012
inp = list(map(int,input().split()))
n=inp[0]
a=inp[1]
b=inp[2]
if(a==0 and b==0):
    print (0)
else:
    k=n//(a+b)
    z=n-(a+b)*k
    if(z<=a):
        print (k*a+z)
    else:
        print ((k+1)*a)

Measured memory_bytes: 3064
def heisei(a)
  if(a[0].to_i<=2019)
    if(a[1].to_i<=4)
      if(a[2].to_i<=30)
        return "Heisei"
      end
    end
  end
  return "TBD"
end
n = gets.chomp
a = n.split("/")
puts(heisei(a))


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

void fill()
{
    int dp[100010];
    dp[0] = 0;
    dp[1] = 1;
    for (int i = 2; i < 1000; i++)
    {
        int prev = dp[i - 1];
        if (dp[i - prev] < prev)
            dp[i] = prev;
        else
            dp[i] = prev + 1;
    }
    for (int i = 1; i <= 100; i++)
    {
        cout << i << " " << dp[i] << endl;
    }
}

int triangle(int x)
{
    return x * (x + 1) / 2;
}
int main()
{
    /*
        dp(x) = y
        dp(x+y+1) = y+1
        .
        .
        dp(x+y+h) = y+h

        dp(x)

        dp(r) = h && h+1+r==x
        1 1 +triangle(0)
        2  1+triangle(1)
        4  1 + traingle(2)
        7
        11
    */
    int x;
    cin >> x;
    for (int i = 0;; i++)
    {
        if (triangle(i) + 1 <= x && x <= triangle(i + 1))
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)






int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(t.compare(s) > 0) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dfs(long long n,long long x)
{
	if(x>n) swap(x,n);
	if(n%x==0) return n/x*2*x-x;
	else return n/x*2*x+dfs(x,n%x);	
}
int main ()
{
	long long n,x;
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",dfs(n-x,x)+n);
	
}

Measured memory_bytes: 256
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 3e5 + 200;
const long long MNN = 5e3 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n;
ullong pw[MNN], h[MNN];
map<ullong, int> mp;
string s;

bool check(llong len){
    mp.clear();
    for(int i = 1; i <= n - len + 1; i++){
        ullong x = h[i + len - 1] - h[i - 1];
        x *= pw[n - i];
        if(mp[x] != 0 && i > mp[x]) return true;
        else if(mp[x] == 0) mp[x] = i + len - 1;
    }
    return false;
}

int main () {
    ios;
    cin >> n;
    cin >> s;
    s = '#' + s;
    pw[0] = 1;
    for(int i = 1; i <= n; i++){
        pw[i] = pw[i - 1] * 37;
        h[i] = (h[i - 1] + (s[i] - 'a' + 1) * pw[i]);
    }
    int l = 1, r = n / 2;
    while(r - l > 1){
        int tm = (r + l) / 2;
        if(check(tm)){
            l = tm;
        }else{
            r = tm;
        }
    }
    if(check(r)){
        cout << r;
    }else if(check(l)){
        cout << l;
    }else{
        cout << 0;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ( (a == 5 && b == 5 && c == 7)
    || (a == 5 && b == 7 && c == 5)
    || (a == 7 && b == 5 && c == 5) )
    cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    ll n,m;
    cin>>n>>m;
    vector<bool> prob(n+5);
    vector<ll> num(n+5);

    rep(i,n+2) 
    {
        prob[i]=false;
        num[i] =1;
    }
    prob[1]=true;

    rep(i,m)
    {
        ll a;
        ll b;
        cin>>a>>b;

        if(prob[a]==true) prob[b] = true;

        num[a] --;
        num[b] ++;
        if(num[a]==0) prob[a] = false;
    }
    ll ans = 0;


    for(ll q=1;q<=n;q++)
    {
        if(prob[q]==true) ans ++;
    }

    cout << ans << endl;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

ll f(ll n, ll x){
    if(n>=0)
        return n/x + 1;
    else
        return 0;
}

int main(){
    ll a, b, c, d;
    cin >> a >> b>>c >> d;
    ll lcm = (c*d)/gcd(c,d);

    ll dc = f(b, c)-f(a-1, c);
    ll dd = f(b, d)-f(a-1, d);
    ll l = f(b, lcm)-f(a-1, lcm);

    cout << (b-a)-(dc+dd-l)+1;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n,m,res=0,ans=0,u,v;
    vector<int>adj[100005];
    int h[100005]={};
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>h[i];
    for(int i=0;i<m;i++){
        cin>>u>>v;
        u--,v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=0;i<n;i++){
            res=0;
        for(auto p:adj[i]){
            if(h[i]>h[p])res++;
        }
    if(res==adj[i].size())ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8712
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int N;
int minCost = INF;
vector<int> length(MAX), group(MAX), use(MAX);
vector<int> target(3);
/* function */
void check(int n) {
    vector<int> L(3), cnt(3, 0);
    for (int i = 0; i < n; i++) {
        L[group[use[i]]] += length[use[i]];
        cnt[group[use[i]]]++;
    }
    bool can = true;
    for (int i = 0; i < 3; i++) if (cnt[i] == 0) can = false;
    if (!can) return;
    int cost = 0;
    sort(L.begin(), L.end());
    for (int i = 0; i < 3; i++) {
        cost += abs(target[i] - L[i]);
        cost += (cnt[i] - 1) * 10;
    }
    minCost = min(cost, minCost);
}
void rec(int n, int l) {
    if (n >= l) {
        check(l);
        return;
    }
    for (int i = 0; i < 3; i++) {
        group[use[n]] = i;
        rec(n + 1, l);
    }
}
/* main */
int main(){
    cin >> N;
    for (int i = 0; i < 3; i++) cin >> target[i];
    sort(target.begin(), target.end());
    for (int i = 0; i < N; i++) cin >> length[i];

    for (int b = 7; b < (1 << N); b++) {
        int l = 0;
        for (int i = 0; i < N; i++) if ((b >> i) & 1) use[l++] = i;
        if (l >= 3) rec(0, l);
    }
    cout << minCost << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    //偶数回出てきた数字は消す
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C), tmpP(A), tmpQ(B), tmpR(C);
    rep(i, A)cin >> p[i];
    rep(i, B)cin >> q[i];
    rep(i, C)cin >> r[i];
    sort(all(p), greater<int>());
    sort(all(q), greater<int>());
    sort(all(r), greater<int>());
    ll ans = 0;
    if(X != A) p.erase(p.begin() + X, p.end());
    if(Y != B) q.erase(q.begin() + Y, q.end());

    p.insert(p.end(), q.begin(), q.end());
    p.insert(p.end(), r.begin(), r.end());
    sort(all(p), greater<int>());
    rep(i, X + Y) ans += p[i];
    cout << ans << endl;

}

Measured memory_bytes: 3960
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		
		int count = 0;
		
		for (int i = 0; i < n; i++) {
			boolean flag = true;
			for (int j = 0; j < i; j++) {
				if (h[j] > h[i]) {
					flag = false;
					break;
				}
			}
			if (flag) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int N[3],x,y,z,ans;
    cin>>N[0]>>N[1]>>N[2];
    sort(N,N+3);
    x=N[2]-N[1];
    y=N[0]+x;
    if((N[2]-y)%2==0){
        ans=(N[2]-y)/2+x;
    }else{
        ans=(N[2]-y)/2+x+2;
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main()
{
  string s; cin >> s;
  int left, right;
  for (int i = 0, len = s.size(); i < len; ++i) {
    if (s[i] == 'A') {
      left = i;
      break;
    }
  }
  for (int i = s.size()-1; i >= 0; --i) {
    if (s[i] == 'Z') {
      right = i;
      break;
    }
  }

  cout << right-left+1;
}

Measured memory_bytes: 640
//2019.8.24 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    int m,d;
    int ans;
    inline void MAIN(){
        m=read(),d=read();
        for(res i=1;i<=m;i++){
            for(res j=1;j<=d;j++){
                if((j%10)*(j/10)==i&&(j%10)>=2&&(j/10)>=2)ans++;
            }
        }
        printf("%d\n",ans);
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	int n, k;
	cin >> n >> k;
	if ((n - 1) % (k - 1) == 0) {
		cout << (n - 1) / (k - 1);
	}else{
		cout << (n - 1) / (k - 1) + 1;
	}
	
return		(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n=s.length(),minn=999;
	for(int i=0;i<n-2;i++){
		int x=100*(s[i]-48)+10*(s[i+1]-48)+s[i+2]-48;
		int y=x-753;
		if(y<0) y=-y;
		if(y<minn) minn=y;
	}
	cout<<minn<<endl;
} 

Measured memory_bytes: 256
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
   input! {
      a:isize,b:isize,c:isize,mut k:isize
   }
   let mut res = 0_isize;
   if k >= a {
      res += a;
      k -= a;
   } else {
      res += k;
      k = 0;
   }

   if k >= b {
      k -= b;
   } else {
      k = 0;
   }

   if k >= c {
      res -= c;
      k -= c;
   } else {
      res -= k;
      k = 0;
   }

   println!("{}", res);
}


Measured memory_bytes: 2156
//https://atcoder.jp/contests/abc134
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e6 + 5;
const double E = 1e-9;

//------------------------------------------------------------------------------

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	int r;
	cin >> r;
	cout << 3 * r*r;
	return 0;
}
//04-08-2020 09:41:53
//------------------------------------------------------------------------------

Measured memory_bytes: 3664
def d_alter_altar():
    N = int(input())
    C = input()

    stone_white_total, stone_red_total = C.count('W'), C.count('R')

    stone_white_left, stone_red_right = [0], [stone_red_total]
    stone_white, stone_red = 0, stone_red_total
    for stone in C:
        if stone == 'W':
            stone_white += 1
        else:
            stone_red -= 1
        stone_white_left.append(stone_white)
        stone_red_right.append(stone_red)

    return min([max(w, r) for w, r in zip(stone_white_left, stone_red_right)])

print(d_alter_altar())

Measured memory_bytes: 20460
#include <stdio.h>
int main()
{
  int n,m,l;
  int i,j,k;
  scanf("%d %d %d",&n,&m,&l);
  int A[n][m];
  int B[m][l];
  long long int C[n][l];


  //input array A
  for(i = 0;i< n;i++)
    {
      for(j = 0;j< m;j++)
        {
          scanf("%d",&A[i][j]);
        }
    }
  //input array B
  for(j = 0;j< m;j++)
    {
      for(k = 0;k< l;k++) //i++ to natteite segementation fault
        {
          scanf("%d",&B[j][k]);
        }
    }
  //calculation
  for(i = 0;i< n;i++)
    {
      for(k = 0;k< l;k++)//i++ to natteite segmentation fault
        {
          C[i][k] = 0;
          for(j = 0; j < m; j++)
            {
              C[i][k] +=A[i][j]*B[j][k];
            }
        }
    }

  //output array C
  for(i = 0;i< n;i++)
    {
      for(k = 0;k< l-1;k++)
        {
          printf("%lld ",C[i][k]);
        }
      printf("%lld\n",C[i][k]);
    }
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	vector<int> b(n);
	rep(i,n) cin >> b[i];
	
	vector<int> c(n-1);
	for(int i = 0; i < n-1;++i) cin >> c[i];
	
	int ans = 0;
	rep(i,n){
		ans += b[i];
		if(i>0 && a[i] == a[i-1]+1){
			ans += c[a[i-1]-1];
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long[] dp;
    
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        dp = new long[Math.max(N,M)+1];
        
        if(Math.abs(N-M) >= 2) {
            System.out.println(0);
            return;
        }
        
        dp[1] = 1;
        for(int i = 2; i <= Math.max(N,M); i++) {
            dp[i] = dp[i-1] * (long)i % 1000000007L;
        }
        
        long dogCount = dp[N];
        long monkeyCount = dp[M];
        
        long d = 1; 
        if(N == M) d *= 2;

        long answer = dogCount * monkeyCount * d % 1000000007L;
        
        System.out.println(answer);
    }
}


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

using namespace std;

int main(int argc, char **argv)
{
  int k, n, a[100001], s, t, p, q, r, j;

  while(1){
    cin >> n >> k;
    if(n == 0 && k == 0){
      break;
    }

    for(int i = 0; i < k; i++){
      cin >> a[i];
    }
    sort(a, a+k);
    for(int i = 0; i < k; i++){
    }

    if(a[0] == 0){
      q = 1;
      while(a[q] == 0 && q < k){
	q++;
      }

      s = q;
      for(int i = q; i < k-1; i++){
	t = 1;
	p = q;
	j = i;
	while(j < k-1){
	  r = a[j+1]-a[j]-1;
	  if(r == 0){
	    t++;
	  } else if(p == r){
	    t += (1+p);
	    p -= r;
	  } else if(p > r){
	    t += r;
	    p -= r;
	  } else {
	    t += p;
	    break;
	  }
	  j++;
	}
	if(s < t){
	  s = t;
	}
      }
    } else {
      t = a[0];
      s = 1;
      for(int i = 1; i < k; i++){
	if(t+1 == a[i]){
	  p = 2;
	  i++;
	  while(a[i] == t+p && i < k){
	    i++;
	    p++;
	  }
	  if(s < p){
	    s = p;
	  }
	  if(i == k){
	    break;
	  }
	}
	t = a[i];
      }
    }
    cout << s << endl;
  }


  return 0;
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VVVVI vector<vector<vector<vector<int>>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VVVVL vector<vector<vector<vector<LL>>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }
inline bool inside(int y, int x, int H, int W) { return 0 <= y and y < H and 0 <= x and x < W; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, 1, 0, -1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

string big(string a, string b) {
    if (a.size() < b.size()) { return b; }
    if (a.size() > b.size()) { return a; }
    return a > b ? a : b;
}

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

    while (true) {
        int W, H;
        cin >> W >> H;
        if (W == 0 and H == 0) { break; }

        vector<vector<int>> field(H, vector<int>(W, -1));
        FOR(i, 0, H) {
            string s;
            cin >> s;
            FOR(j, 0, s.size()) {
                if (s[j] < 'A') {
                    field[i][j] = (s[j] - '0');
                }
            }
        }

        vector<vector<string>> dp(H, vector<string>(W));
        FOR(y, 0, H) {
            FOR(x, 0, W) {
                if (field[y][x] == -1) {
                    continue;
                }

                // 0 startはだめ
                if (dp[y][x].empty() and field[y][x] == 0) {
                    continue;
                }

                // start
                if (dp[y][x].empty()) {
                    dp[y][x] = to_string(field[y][x]);
                }

                if (y + 1 < field.size() and field[y + 1][x] != -1) {
                    string new_c = dp[y][x] + to_string(field[y + 1][x]);
                    dp[y + 1][x] = big(dp[y + 1][x], new_c);
                }
                if (x + 1 < field[0].size() and field[y][x + 1] != -1) {
                    string new_c = dp[y][x] + to_string(field[y][x + 1]);
                    dp[y][x + 1] = big(dp[y][x + 1], new_c);
                }
            }
        }

        string ans = "";
        FOR(y, 0, dp.size()) {
            FOR(x, 0, dp[0].size()) {
                ans = big(ans, dp[y][x]);
            }
        }

        print(ans);
    }

    return 0;
}


Measured memory_bytes: 3392
#include<cstdio>
#include<cstdlib>
#include<algorithm> 
#include<cmath>
#include<cstring>
using namespace std;



int n,m,ans;;
int a[123][123];
int main()
{
  int i,j,k;
  scanf("%d%d",&n,&m);
  for(i=1;i<=n;i++)
    for(j=1;j<=m;j++) scanf("%d",&a[i][j]);
  for(i=1;i<n;i++)
    for(j=i+1;j<=n;j++)
      {
        int sum=0;
	    for(k=1;k<=m;k++) sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
	    int t=sqrt(sum);
	    if(t*t==sum) ans++;
	  }
 printf("%d\n",ans);
} 

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  getline(cin, s);
  rep(i, s.size()) {
    if (isupper(s[i]))
      s[i] = tolower(s[i]);
    else
      s[i] = toupper(s[i]);
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3208