akhauriyash/Code-Regression huggingface dataset:
/* SmartCoder Mar 31, 2019 */
#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end();i++)
#define present(c,x)  ( (c).find(x) !=(c).end())
#define cpresent(c,x) (find(all(c),x)!= (c).end() )
#define minei(x)  min_element(x.begin(),x.end())-(x).begin()
#define maxei(x)  max_element(x.begin(),x.end())-(x).begin()

#define uns(v)     sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define acusum(x)  accumulate(x.begin(),x.end(),0)
#define acumul(x)  accumulate(x.begin(),x.end(),1, multiplies<int>());
#define bits(x)     __builtin_popcount( x )
#define oo INT_MAX
#define inf 1000000000

const double pi = acos(-1.0);
const double eps = 1e-11;
#define MAXN 100007
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
void fastIO() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int dp[MAXN][3];
int data[3];
int main() {
	fastIO();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> data[j];
			dp[i][j] = -inf;
		}
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k)
					continue;
				dp[i][j] = i == 0 ? data[j] : max(dp[i][j], data[j] + dp[i - 1][k]);
			}
		}
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
	return 0;
}


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

import javax.lang.model.element.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionC(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N = nextInt();
		N=N%10;
		if(N==2||N==4||N==5||N==7||N==9){
			pw.println("hon");
		}else if(N==0||N==1||N==6||N==8){
			pw.println("pon");
		}else{
			pw.println("bon");
		}


	}
	public static void solutionB(String[] args) throws Exception{

		int K=nextInt();
		String S = nextString();
		if(S.length()<=K){
			pw.println(S);
		}else{
			pw.println(S.substring(0,K)+"...");
		}


	}

	public static void solutionC(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();
		int H = nextInt();
		int M = nextInt();

		double r = clockAngle(H,M);
		System.out.printf("%.12f\n",Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(r))));
	}

	public static double clockAngle(int H , int M){
		double x=30*(H%12)+0.5*M;
		double y=6*M;

		//内角の角度
		return  Math.min(1.0*Math.abs(x-y),1.0*Math.abs(360-Math.abs(x-y)));

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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

int modpow(int a, int n)
{
    int res = 1;
    while(n > 0)
    {
        if(n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);


    int N, K; cin >> N >> K;
    vi dp(K+1, 0);
    int ans = 0;
    for(int i = K; i >= 1; i--)
    {
        dp[i] = modpow(K/i, N);
        for(int j = 2*i; j <= K; j += i)
        {
            dp[i] -= dp[j];
        }
        if(dp[i] < 0) dp[i] += MOD;
        ans += i * dp[i] % MOD;
    }
    cout << ans % MOD << endl;
}

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

#define M 100
#define WHITE 1
#define BLACK 2
#define GRAY 3
#define INFTY (1<<21)

int n,A[M][M];

void dic(){
  int d[M],p[M],min,color[M],u;

  for(int i = 0;i < n;i++){
    color[i] = WHITE;
    d[i] = INFTY;
  }
  d[0] = 0;
  color[0] = GRAY;

  while(1){
    min = INFTY;
    for(int i = 0;i < n;i++){
      if(color[i] != BLACK && d[i] < min){
	min = d[i];
	u = i;
      }
    }
    if(min == INFTY) break;

    color[u] = BLACK;

    for(int i = 0;i < n;i++){
      if(color[i] != BLACK && A[u][i] != INFTY){
	if(d[u] + A[u][i] < d[i]){
	  d[i] = d[u] + A[u][i];
	  p[i] = u;
	  color[i] = GRAY;
	}
      }
    }
  }
  for(int i = 0;i < n;i++){
    cout << i << " ";
    if(d[i] != INFTY) cout << d[i];
    else cout << -1;
    cout << endl;
  }
}

int main(){
  int s,t,u,v;
    
  cin >> n;
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      A[i][j] = INFTY;
    }
  }

  for(int i = 0;i < n;i++){
    cin >> s >> t;
    for(int j = 0;j < t;j++){
      cin >> u >> v;
      A[s][u] = v;
    }
  }

  dic();

  return 0;
}
  



Measured memory_bytes: 3160
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn read_n<T: FromStr>(n: u32) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

fn read_n_logic<T: FromStr>(n: u32, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

fn main() {
  let n = read::<usize>();
  let x = read::<usize>();
  let l_list = read_n::<usize>(n as u32);

  let mut sum = 0;
  let mut bound = 1;

  for i in 0..n {
    sum += l_list[i];
    if sum <= x {
      bound += 1;
    };
  }

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

Measured memory_bytes: 4352
def examA():
    N, R = LI()
    ans = R+100*max(0,(10-N))
    print(ans)
    return

def examB():
    N, K = LI()
    ans = 1
    while(N>=K):
        N //=K
        ans += 1
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 39152
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

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


int const MAX_N = 100000;
int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ
int num[MAX_N]; // iが親である時の要素数


// n要素で初期化
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        depth[i] = 0;
        num[i] = 1;
    }
}

// 木の根を求める
int find(int x){
    if (par[x] == x) {
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

// 属するグループの要素数
int elem(int x){
    return num[par[x]];
}

// xとyの属する集合を合併
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (depth[x] < depth[y]) {
        par[x] = y;
        num[y] += num[x];
    }else{
        par[y] = x;
        num[x] += num[y];
        if (depth[x] == depth[y]) depth[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}


int main(){
    int n, m, k;
    cin >> n >> m >> k;
    int a[m], b[m];
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    int c[k], d[k];
    rep(i, k) {
        cin >> c[i] >> d[i];
        c[i]--;
        d[i]--;
    }
    int fri[n];
    int block[n];
    rep(i, n){
        fri[i] = 0;
        block[i] = 0;
    }

    init(n);
    rep(i, m){
        unite(a[i], b[i]);
        fri[a[i]]++;
        fri[b[i]]++;
    }
    rep(i, k){
        if (same(c[i], d[i])) {
            block[c[i]]++;
            block[d[i]]++;
        }
    }
    rep(i, n){
        cout << num[find(i)] - fri[i] - block[i] - 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4352
N=int(input())
A=[0]+list(map(int,input().split(' ')))+[0]
D=[abs(A[i+1]-A[i]) for i in range(N+1)]
S=sum(D)
for i in range(N):
  print(S-abs(A[i]-A[i+1])-abs(A[i+1]-A[i+2])+abs(A[i]-A[i+2]))

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

using namespace std;

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

#define int ll

main(){
	ll a,b;
	int k;

	cin >> a >> b >> k;

	for(int i=0;i<k;i++){
		if(i%2==0){
			a -= a%2;
			b += a/2;
			a -= a/2;
		}else{
			b -= b%2;
			a += b/2;
			b -= b/2;
		}
	}

	cout << a << " " << b << endl;

	return 0;
}


Measured memory_bytes: 3632
S = str(input())
T = str(input())

s_len = len(S)
t_len = len(T)

Ss = list(S)
Ts = list(T)

answer = 9999

for si in range(s_len):
    candidate = 0
    if si + t_len > s_len:
        continue

    for ti in range(t_len):
        if Ss[si + ti] != Ts[ti]:
            candidate += 1

    if candidate < answer:
        answer = candidate

print(answer)

Measured memory_bytes: 9064
from math import sqrt

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]

def calc(r): #半径rが与えられたときに全てが重なるかを判定
    lst = [] #交点を入れるリスト
    for i in range(N - 1):
        x1 = XY[i][0]
        y1 = XY[i][1]
        for j in range(i + 1, N):
            x2 = XY[j][0]
            y2 = XY[j][1]
            diff = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

            if diff > 2 * r:
                return False
            
            h = sqrt(r ** 2 - (diff / 2) ** 2)
            
            if x1 == x2:
                ny = (y1 + y2) / 2
                lst.append([x1 - h, ny])
                lst.append([x1 + h, ny]) 
            elif y1 == y2:
                nx = (x1 + x2) / 2
                lst.append([nx, y1 - h])
                lst.append([nx, y1 + h])
            else:
                a = (y2 - y1) / (x2 - x1) #2点を結ぶ直線の傾き

                b = -1 / a

                size = sqrt(1 + b ** 2)

                nx = h / size
                ny = nx * b

                #もとの2点の中点
                xc = (x1 + x2) / 2
                yc = (y1 + y2) / 2

                lst.append([xc + nx, yc + ny])
                lst.append([xc - nx, yc - ny])
    # print (r)
    # print (lst)
    nr = r + eps
    for x, y in lst: #中心の点
        flag = True
        for X, Y in XY:
            tmp = (x - X) ** 2 + (y - Y) ** 2
            if tmp > nr ** 2:
                flag = False
                break
        if flag:
            return True
          
    
l = 0
r = 1000

eps = 10 ** (-9)

for i in range(100):
    mid = (l + r) / 2
    if calc(mid):
        r = mid
    else:
        l = mid

print (r)


Measured memory_bytes: 9536
# Rectangle Cutting
# https://atcoder.jp/contests/abc130/tasks/abc130_c

from sys import stdin, stdout

w, h, x, y = map(int, stdin.readline().split())
ways = 0
if x * 2 == w and y * 2 == h:
    ways = 1
stdout.write("%.6F %d\n" % (w * h / 2, ways))


Measured memory_bytes: 2940
k=int(input())
N=list(map(int,'1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')))
print(N[k-1])

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int gcd(int a, int b){
    if(a < b){
        int tmp = a;
        a = b;
        b  =tmp;
    }
    while(b != 0){
        int tmp = b;
        b = a%b;
        a = tmp;
    }
    return a;
}

int gcd(int a, int b, int c){
    
    return gcd(gcd(a, b), c);
}


int main(){
    int k;
    long long sum = 0;
    cin >> k;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            for(int c = 1; c <= k; c++){
                sum += gcd(a, b, c);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	string table = "RGB";
	unordered_map<char,int> map;
	for(int i=0;i<3;i++){
		map[table[i]] = i;
	}
	vector<vector<int>> idx(3);
	for(int i=0;i<n;i++){
		idx[map[s[i]]].push_back(i);
	}
	
	LL res = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(s[i] == s[j]) continue;
			int ii = 3-map[s[i]]-map[s[j]];
			int item = j+1;
			int l = 0;
			int r = idx[ii].size();
			while(l<r){
				int m = (l+r)/2;
				if(idx[ii][m]>=item){r = m;}
				else{l = m+1;}
			}
			res+=idx[ii].size()-l;
			if((2*j-i)<n && map[s[2*j-i]] == ii){
				res-=1;
			}
		}
	}
	cout<<res<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3704
class UnionFind:  # O(α(N))
    def __init__(self, size):  # construct a Union-Find tree (1-idx)
        self.parent = [i for i in range(size)]
        self.rank = [0] * size
 
    def find(self, x):  # find the group (root) of a vertex
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
 
    def is_same(self, x, y):  # check two vertices are in the same group
        return self.find(x) == self.find(y)
 
    def unite(self, x, y):  # unite two groups
        x, y = self.find(x), self.find(y)
        if x == y:  # the same group
            return
        # unite a small one to a bigger one to balance trees
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def main():
    N, Q = map(int, input().strip().split())
    ab = [map(int, input().strip().split()) for _ in range(Q)]
    uf = UnionFind(N)
    for a, b in ab:
        uf.unite(a-1, b-1)
    for i in range(N):
        uf.find(i)
    import collections
    print(collections.Counter(uf.parent).most_common()[0][1])

                

if __name__=="__main__":
    main()


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

using namespace std;
int main()
{
  long long n;
  int i,r;
  cin>>n;
  string s="";
  while(n>0)
  {
      i=n%26;
      if(i==0){
      s='z'+s;
      
        n=n/26; 
        n--;
        continue; 
      }
     
      s=(char)(96+i)+s;
      n=(n-i)/26;
  }
  cout<<s<<endl;



}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;


// 素因数分解
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) { // √n以下にしか約数(素数)はない
		while (n % i == 0) { // 小さい数(2)からスタートすることで必ず素数のみがこのループに入る
			ret[i]++; // 何回割り切れるのかで何条か判断する
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1; // 最後に残った数を追加
	return ret;
}

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

	ll N;
	cin >> N;

	ll ans = 0;
	map<ll, ll> m = prime_factor(N);
	for (auto i : m) {
		//cout << i.first << " ^ " << i.second << endl;
		ll now = 1;
		while (1) {
			if (i.second >= now) {
				i.second -= now;
				now++;
				ans++;
			}
			else{
				break;
			}
		}
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3656
N = int(input())
A = list(map(int, input().split()))

ans = 0

for i in range(N - 1):
    if A[i] > A[i + 1]:
        ans += A[i] - A[i + 1]
    A[i + 1] = max(A[i], A[i + 1])

print(ans)


Measured memory_bytes: 32256
/**********
Author: WLBKR5
Problem: ABC176 B
Date: 2020/08/22
**********/
#include<bits/stdc++.h>
using namespace std;
inline int getint(){
    int ans=0,f=1;
    char c=getchar();
    while(c>'9'||c<'0'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        ans=ans*10+c-'0';
        c=getchar();
    }
    return ans*f;
}
int main(){
    string s;
    cin>>s;
    int sum=0;
    for(auto i:s){
        sum+=i-'0';
    }
    cout<<(sum%9==0?"Yes":"No");
}

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

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

    long long i = 0;
    long long n = s.size();

    bool flag = false;
    while(i < n){
        if(s[i] == s[i+1]){
            long long length = 1;

            while(i < n and s[i] == s[i+1]){
                i++;
                length++;
            }
            if(length >= 3) flag = true;
        }
        i++;
    }

    if(flag == true) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    string S, T;
    cin >> S >> T;

    int N = S.size();
    ll ans = 0;
    REP(i,N){
        if(S[i] != T[i])
            ans++;
    }

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


Measured memory_bytes: 3864
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	//A
	public static void main(String[] args){
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(Math.min(N*A,B));
	}

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
struct tr
{
	int t[202020];
	void gx(int xh,int vl)
	{
		xh++;
		while(xh<202020)
		{
			t[xh]+=vl;
			xh+=xh&-xh;
		}
	}
	int gt1(int xh)
	{
		xh++;
		int ans=0;
		while(xh>0)
		{
			ans+=t[xh];
			xh-=xh&-xh;
		}
		return ans;
	}
};
tr tt;
int n;
long long k,cnt[202020],ans;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>cnt[i];
		cnt[i]-=k;
		cnt[i]+=cnt[i-1];
	}
	vector<long long>v;
	for(int i=0;i<=n;i++)
	{
		v.push_back(cnt[i]);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=0;i<=n;i++)
	{
		int p=lower_bound(v.begin(),v.end(),cnt[i])-v.begin();
		ans+=tt.gt1(p);
		tt.gx(p,1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define in(x, y) (0 <= (x) && (x) < w && 0 <= (y) && y < h)
#define f(x, y) (y*w+x)
 
typedef pair<int, int> P;
 
const int N = 55;
char field[N][N];
bool ng[N][N];
bool tmp[N][N];
 
struct UnionFind{
    int par[N*N];
    UnionFind(){
        rep(i, N*N) par[i] = i;
    }
    int find(int x){
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        par[find(x)] = find(y);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};
 
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
 
int r[N];
 
int main(){
    int h, w, d, n;
    cin >> h >> w >> d >> n;
    int sx, sy;
    rep(i, h) rep(j, w){
        cin >> field[i][j];
        if (field[i][j] == 'D') sx = j, sy = i;
        if (field[i][j] == '#') ng[i][j] = true;
    }
 
    UnionFind uf;
    rep(i, h) rep(j, w) rep(d, 4){
        if (field[i][j] == '#') continue;
        int nx = j + dx[d], ny = i + dy[d];
        if (in(nx, ny) && field[ny][nx] != '#'){
            uf.unite(f(nx, ny), f(j, i));
        }
    }
 
    rep(i, d) cin >> r[i];
    r[d] = N;
 
    while (n--){
        int x, y, s;
        cin >> x >> y >> s;
 
        for (int i = y - r[s]; i <= y + r[s]; ++i){
            for (int j = x - r[s]; j <= x + r[s]; ++j){
                if (!in(j, i)) continue;
                tmp[i][j] = ng[i][j];
            }
        }
 
        rep(i, h) rep(j, w) ng[i][j] = true;
 
        for (int i = y - r[s]; i <= y + r[s]; ++i){
            for (int j = x - r[s]; j <= x + r[s]; ++j){
                if (!in(j, i)) continue;
                ng[i][j] = tmp[i][j];
            }
        }
 
        if (s){
            for (int i = y - r[s - 1]; i <= y + r[s - 1]; ++i){
                for (int j = x - r[s - 1]; j <= x + r[s - 1]; ++j){
                    if (!in(j, i)) continue;
                    ng[i][j] = true;
                }
            }
        }
    }
 
    bool yes = false;
    bool no = false;
    rep(i, h) rep(j, w){
        if (!ng[i][j]){
            if (uf.same(f(j, i), f(sx, sy))) yes = true;
            else no = true;
        }
    }
    if (yes && no) cout << "Unknown" << endl;
    else if (yes) cout << "Yes" << endl;
    else if (no) cout << "No" << endl;
    else cout << "Broken" << endl;
 
    return 0;
}

Measured memory_bytes: 1180
#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);
    vector<ll> A(5);
    ll k;

    REP(i, 5){
        cin >> A[i];
    }
    cin >> k;

    for(ll i=0; i<4; i++){
        for(ll j=i+1; j<5; j++){
            if(abs(A[i]-A[j]) > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
w, h, x, y, r  = map(int, input().split())

ans = "Yes"
if (x - r) < 0: ans = "No"
if (x + r) > w: ans = "No"
if (y - r) < 0: ans = "No"
if (y + r) > h: ans = "No"

print(ans)


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

//const ll Hmax = 0;

ll f(const ll i)
{
	//if (i < Hmax) return a[i];
	if (i <= 1) return 1;
	return 2 * f(i / 2) + 1;
}

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

	ll H;
	cin >> H;

	ll ans = f(H);

	cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 256
N,X,Y = map(int,input().split())

dist = [i*0 for i in range(N)]


for i in range(1,N+1):
  for j in range(i,N+1):
    if(i==j):
      continue
    a = abs(i-j)
    b = abs(X-i)+1+abs(Y-j)
    c = abs(X-j)+1+abs(Y-i)
    
    dist[min(a,b,c)]+=1

for i in range(1,N):
  print(dist[i])




Measured memory_bytes: 48348
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, s, n) for (int i = s; i < n; i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)

int main() {
	ll x; cin >> x;
	ll ans = 0;
	ll y;
	if (x > 11) {
		ans += (x / 11) * 2;
		y = x % 11;
	}
	else {
		y = x;
	}

	if (y == 0);
	else if (y <= 6) ans += 1;
	else if (y <= 11) ans += 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef struct{
  int prev,next,weight;
}Data;
Data data[500000];

void SSS();
int num,size;       
int main(){
  int i,j,id,nextnum;
 
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d%d",&id,&nextnum);
    for(j=0;j<nextnum;j++){
      
      
      data[size].prev=id;
      scanf("%d%d",&data[size].next,&data[size].weight);
      size++;
     
    }
  }
  SSS();
  return 0;
}


void SSS(){
  int cost[10000];
  int i,flag=1;
  for(i=0;i<num;i++){
    cost[i]=1000001;
  }
  cost[0]=0;
 
  
  while(flag==1){
    flag=0;
    for(i=0;i<size;i++){
      if(cost[data[i].prev]==1000001) continue;
      if(cost[data[i].prev]+data[i].weight<cost[data[i].next]){
	cost[data[i].next]=cost[data[i].prev]+data[i].weight;
	flag=1;
      }
    
    
    }
  }
  
  for(i=0;i<num;i++){
    if(cost[i]==1000001) printf("%d -1\n",i);   /*output*/
    else printf("%d %d\n",i,cost[i]);
  }
}



Measured memory_bytes: 7564
// Problem : 
// 			A - Rainy Season
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int ans=0,tmp=0;
	string s;
	cin >> s;
	for(auto x:s)
	{
		if(x == 'R')	
			tmp++;
		else {
			ans =max(ans,tmp);
			tmp = 0;
		}
	}	
	ans = max(ans,tmp);
	cout << ans ;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
 
int main(void)
{
 
  int x, y, r, tmp;
 
 
  scanf("%d %d", &x,&y);
  

  /* 自然数 x > y を確認・入替 */
  if(x >= 1 && x < y && y<=1000000000){
    tmp = x;
    x = y;
    y = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }
 
  /* 最大公約数を出力 */
  printf("%d\n", y);
 
  return 0;
}

Measured memory_bytes: 592
#include<iostream>

using namespace std;

void printRectAngle(int,int);

int main()
{
	int H,W;

	cin >> H >> W;

	while ( H>0 || W>0 )
	{
		printRectAngle( H, W );
		
		cin >> H >> W;
	}

return 0;
}

void printRectAngle( int H, int W )
{
	int h,w;

	for ( h = 0 ; h < H ; h++ )
	{
		for ( w = 0 ; w < W ; w++ )
			cout << "#";
		cout << endl;
	}
	
	cout << endl;
}



Measured memory_bytes: 3096
use std::io::{Read, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_to_string(&mut buf).unwrap();
    let mut buf = buf.split_whitespace().map(|x| x.parse::<i32>().unwrap());

    let a = buf.next().unwrap();
    let b = buf.next().unwrap();

    println!("{} {}", a * b, (a + b) * 2);
}


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

long long gcd(long long a, long long b) {
  if(a < b) return gcd(b, a);
  long long r;
  while (r=a%b) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  long long A, B, C, D; cin >> A >> B >> C >> D;
  long long sum = B - A + 1;
  long long E = C * D / gcd(C, D);
  
  long long AC = A / C;
  long long BC = B / C;
  long long AD = A / D;
  long long BD = B / D;
  long long AE = A / E;
  long long BE = B / E;
  if(A%C == 0) BC++;
  if(A%D == 0) BD++;
  if(A%E == 0) BE++;
  
  long long res = sum + AC - BC + AD - BD - AE + BE;
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return b.second > a.second;
    }
    return a.first < b.first;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    double d, w, h;
    while (cin >> d >> w >> h)
    {
        if (d == 0 && w == 0 && h == 0)
            break;

        double dist = min({sqrt(h * h + w * w) / 2.0, sqrt(h * h + d * d) / 2.0, sqrt(w * w + d * d) / 2.0});
        int n;
        cin >> n;
        for (int i = 0; i < n; ++i)
        {
            double r;
            cin >> r;
            if (r > dist)
            {
                cout << "OK" << endl;
            }
            else
                cout << "NA" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>

using namespace std;

int main() {
    int h , w;
    cin >> h >> w;
    char a[11][11];
    for(int i = 0; i < 11; i++){
        for(int j = 0; j < 11; j++){
            a[i][j] = '.';
        }
    }

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    a[0][0] = '.';
    for(int i = 0, j = 0;;) {
        if(i == h -1 && j == w - 1){
            break;
        }

        //if(a[i+1][j] == '#' && a[i][j+1] == '#') {

            //cout << "Impossible" << endl;
            //return 0;
        if(a[i+1][j] == '.' && a[i][j+1] == '.'){
            cout << "Impossible" << endl;
            return 0;
        }
        if(a[i+1][j] == '#') {
            a[i+1][j] = '.';
            i++;
            continue;
        }
        if(a[i][j+1] == '#') {
            a[i][j+1] = '.';
            j++;
            continue;
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#'){
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }

    cout << "Possible" << endl;
    return 0;
}

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

int main(void) {
    double r;
    char buf[8];
    char *p;

    p = fgets(buf, 8, stdin);
    sscanf(buf, "%lf", &r);

    printf("%lf\n", r * 2 * M_PI);
    
    
    return 0;
}


Measured memory_bytes: 3784
from collections import deque

H, W = map(int, input().split())

G = []
black = 0
for i in range(H):
    line = list(input())
    G.append(line)
    black += line.count("#")
    
ls = deque([[0, 0, 0]])
D = [[float("inf")] * W for i in range(H)]
direction = [[1,0], [-1,0], [0,1], [0,-1]]
find = False
while len(ls) > 0:
    h, w, depth = ls.popleft()
    
    if h == H-1 and w == W-1:
        route = depth + 1
        find = True
        break
        
    for dh, dw in direction:
        if h + dh < 0 or H-1 < h + dh: continue
        if w + dw < 0 or W-1 < w + dw: continue
        if depth + 1 < D[h+dh][w+dw] and G[h+dh][w+dw] != "#":
            ls.append([h+dh, w+dw, depth+1])
            D[h+dh][w+dw] = depth + 1
            
if find:
    ans = (H * W) - black - route
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9368
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
int A[MAX_N];

int main(void)
{
  cin >> N;
  REP(i, N) cin >> A[i];

  double a = 0;
  ll all = 1;
  // REP(i, N) all *= A[i];
  // REP(i, N) { a += (double)all / A[i]; }
  REP(i, N) { a += 1.0 / A[i]; }
  printf("%.10f\n", 1.0 / (double)a);
  // printf("%.10f\n", (double)all / (double)a);
  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <stdio.h>
#include <math.h>

#define MAX 1000

typedef long long ll;

using namespace std;
int N;
vector<int> data;

//提出時には消す
#include <fstream>

int main()
{
    int n;
    int i = 1;
    cin >> n;

    while(true)
    {
        if(n <= 1000*i){
            cout << (1000*i - n) << "\n";
            break;
        }
        i++;
    }

    return 0;
}

Measured memory_bytes: 3104
def main():
    n = int(input())
    l_0 = []
    r_0 = []
    ls_plus = []
    ls_minus = []
    sum_l = 0
    sum_r = 0
    for i in range(n):
        s = input()
        left, right = 0, 0
        for j in range(len(s)):
            if s[j] == '(':
                right += 1
            else:
                if right > 0:
                    right -= 1
                else:
                    left += 1
        if left == right == 0:
            continue

        if left == 0:
            l_0.append((left, right))
        elif right == 0:
            r_0.append((left, right))
        elif left < right:
            ls_plus.append((left, right))
        else:
            ls_minus.append((left, right))
        sum_l += left
        sum_r += right

    if len(ls_plus) == len(ls_minus) == len(l_0) == len(r_0) == 0:
        print("Yes")
        return

    if len(l_0) == 0 or len(r_0) == 0:
        print("No")
        return
    if sum_l != sum_r:
        print("No")
        return

    # r-lの大きい順
    ls_plus.sort(key=lambda x: x[1] - x[0], reverse=True)
    # lの小さい順
    ls_plus.sort(key=lambda x: x[0])

    # l-rの小さい順
    ls_minus.sort(key=lambda x: x[0] - x[1])
    # lの大さい順
    ls_minus.sort(key=lambda x: x[0], reverse=True)

    now_r = 0
    for ll in l_0:
        now_r += ll[1]

    # now_l = 0
    for i in range(len(ls_plus)):
        # l = ls[i][0]
        r = ls_plus[i][1]
        x = now_r - ls_plus[i][0]
        if x >= 0:
            # now_l = now_l
            now_r = x + r
        else:
            print("No")
            return

    for i in range(len(ls_minus)):
        # l = ls[i][0]
        r = ls_minus[i][1]
        x = now_r - ls_minus[i][0]
        if x >= 0:
            # now_l = now_l
            now_r = x + r
        else:
            print("No")
            return

    print("Yes")


main()


Measured memory_bytes: 80172
from bisect import*
r=range
n,*t=map(int,open(0).read().split())
x=t[:n]
d=[[bisect(x,y+t[n])-1for y in x]]+[[0]*n for _ in r(16)]
for i in r(16):
  for j in r(n):
    d[i+1][j]=d[i][d[i][j]]
for a in zip(t[n+2::2],t[n+3::2]):
  a,b=sorted(i-1for i in a)
  c=1
  for i in r(16,-1,-1):
    if d[i][a]<b:
      a=d[i][a]
      c+=2**i
  print(c)

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){

  string c1,c2;
  cin>>c1>>c2;

  reverse(c2.begin(),c2.end());
  //cout<<c1<<endl;
  if(c1==c2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;



return 0;}


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if ((A % 2 != 0) || (B % 2 != 0) || (C % 2 != 0))
		cout << 0 << endl;
	else if (A == B && B == C)
		cout << -1 << endl;
	else {
		int ans = 0;
		while (true) {
			if ((A % 2 != 0) || (B % 2 != 0) || (C % 2 != 0))
				break; 

			int a, b, c;
			a = B / 2 + C / 2;
			b = C / 2 + A / 2;
			c = A / 2 + B / 2;
			A = a; B = b; C = c;

			ans++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int n,x;
VI v,ans;
int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d",&x);
		v.pb(x-1);
	}
	rep(i,0,n) {
		bool suc=0;
		per(j,0,SZ(v)) if (v[j]==j) {
			suc=1;
			ans.pb(j+1);
			v.erase(v.begin()+j);
			break;
		}
		if (!suc) {
			puts("-1");
			return 0;
		}
	}
	reverse(all(ans));
	for (auto p:ans) printf("%d\n",p);
}


Measured memory_bytes: 256
//
// Created by Tzyark on 2018/10/10.
//
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());

    string P[4] = {"dream", "dreamer", "erase", "eraser"};
    for(int i = 0; i < 4; i++) {
        reverse(P[i].begin(), P[i].end());
    }

    for(int i = 0; i < S.size(); ) {
        bool f = false;
        for(int j = 0; j < 4; j++) {
            if (S.compare(i, P[j].size(), P[j]) == 0) {
                i += P[j].size();
                f = true;
                break;
            }
        }
        if (!f) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

	int ta[5000][2];
int main(){
	int n;
	for(int i=0;i<=1000;i++){
		for(int j=0;j<=1000;j++){
		ta[i+j][0]++;
		ta[i+j][1]++;
		}
	}
	
	
while(cin>>n){
	int cnt=0;
	for(int i=0;i<=n;i++){
		cnt+=ta[i][0]*ta[n-i][1];
	}
	cout<<cnt<<endl;
}
	return 0;
}

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

const int N = 2e5+10;
int p[N], s[N];

int find(int x){
	return x == p[x] ? x : p[x] = find(p[x]);
}

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	int u, v;
	for(int i = 1; i <= n; i++){
		p[i] = i;
		s[i] = 1;
	}
	int res = 0;
	for(int i = 0; i < m; i++){
		scanf("%d%d", &u, &v);
		int ur = find(u);
		int vr = find(v);
		if(ur != vr){
			s[vr] += s[ur];
			p[ur] = vr;
			res = max(res, s[vr]);
		}
	}
	cout << max(res, 1) << endl;
}

Measured memory_bytes: 4792
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
int main(){
    int a[200];
    int n = 0;
    char b[100];
    while(scanf("%s", b)!= EOF) {
        if (b[0] == '+') {
            a[n-2] = a[n-2] + a[n-1];
            n--;
        } else if (b[0] == '-') {
            a[n-2] = a[n-2] - a[n-1];
            n--;
        } else if (b[0] == '*') {
            a[n-2] = a[n-2] * a[n-1];
            n--;
        } else {
            a[n] = atoi(b);
            n++;
        }
    }
    cout << a[0] << endl;
}


Measured memory_bytes: 3228
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template<int MOD>
class ModInt {
public:
    ModInt() :value(0) {}
    ModInt(long long val) :value((int)(val<0 ? MOD + val%MOD : val%MOD)) { }

    ModInt& operator+=(ModInt that) {
        value = value + that.value;
        if (value >= MOD)value -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        value -= that.value;
        if (value<0)value += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        value = (int)((long long)value * that.value % MOD);
        return *this;
    }
    ModInt &operator/=(ModInt that) {
        return *this *= that.inverse();
    }
    ModInt operator+(ModInt that) const {
        return ModInt(*this) += that;
    }
    ModInt operator-(ModInt that) const {
        return ModInt(*this) -= that;
    }
    ModInt operator*(ModInt that) const {
        return ModInt(*this) *= that;
    }
    ModInt operator/(ModInt that) const {
        return ModInt(*this) /= that;
    }
    ModInt pow(long long k) const {
        if (value == 0)return 0;
        ModInt n = *this, res = 1;
        while (k) {
            if (k & 1)res *= n;
            n *= n;
            k >>= 1;
        }
        return res;
    }
    ModInt inverse() const {
        long long a = value, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
    int toi() const { return value; }

private:
    int value;
};
typedef ModInt<1000000007> mint;
ostream& operator<<(ostream& os, const mint& x) {
    os << x.toi();
    return os;
}

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

    int N, M;
    cin >> N >> M;
    vector<mint> fact(N + M + 10);
    fact[0] = 1;
    rep(i, N + M + 10 - 1)fact[i + 1] = fact[i] * (i + 1);
    if (N > M)swap(N, M);
    if (M - N > 1) {
        cout << 0 << endl;
    } else if (M - N == 1) {
        cout << fact[N] * fact[M] << endl;
    } else {
        cout << fact[N] * fact[M] * 2 << endl;
    }
}


Measured memory_bytes: 1024
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N =  sc.nextInt();
		int d[] = new int[N];
		for(int i = 0;i < N;i++){
			d[i] = sc.nextInt();
		}
		
		int sum = 0;
		for(int i = 0;i < N;i++){
			for(int j = i + 1;j < N;j++){
				sum += d[i]*d[j];
			}
		}

		System.out.println(sum);



		
	}
}







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

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m; cin >> n >> m;
	
	ll r = (n-1)/2;
	vector<P> ans;
	
	ll e = r/2;
	ll o = r-e;
	
	rep(i, 1, o){
		ans.push_back(P(i, i+2*(o-i+1)-1));
	}
	
	rep(i, 1, e){
		ans.push_back(P(n-i+1, n-i+1-(2*(e-i+1))));
	}
	
	zep(i, 0, m){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5236
S = input()
ABD = S.replace("BC","D")
a_cnt = 0
ans = 0
# print(ABD)
# print(S)
for s in ABD:
    if s == 'A':
        a_cnt += 1
    elif s == 'D':
        ans += a_cnt
    elif s == 'B' or s == 'C':
        a_cnt = 0
print(ans)

Measured memory_bytes: 3500
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

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;
}
///using P = pair<int,int>;
///pow(x,n)
///cout << fixed << setprecision(桁数);
///string = to_string(数値)
///int = stoi(文字列)
///(int)(char-'0')
///string = itoa(int)
///円周率: M_PI

///0b:2進数 16進数

const unsigned int BIT_FLAG_0 = (1<<0);
const unsigned int BIT_FLAG_1 = (1<<1);
const unsigned int BIT_FLAG_2 = (1<<2);
const unsigned int BIT_FLAG_3 = (1<<3);
const unsigned int BIT_FLAG_4 = (1<<4);
const unsigned int BIT_FLAG_5 = (1<<5);
const unsigned int BIT_FLAG_6 = (1<<6);
const unsigned int BIT_FLAG_7 = (1<<7);

int main() {
    int n; cin>>n;
    vector<int> a(n+1);
    rep(i,n) cin>>a[i+1];
    int cnt=0;
    rep(i,n){
        if((i+1)%2==0) continue;
        else{
            if(a[i+1]%2!=0) ++cnt;
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 3620
#include <stdio.h>
#include <math.h>
int main() {
		int A, B;
		long shou = 0;
		double ret;
		scanf("%d %d", &A, &B);
		if (A == 0) {
			shou = B / 100;
		}
		else if(A ==1 ) {
			shou = (B * 100) / 10000;
                        shou = shou * 100;
		}
		else {
			shou = (B * 10000) / 1000000;
                        shou = shou * 10000;
		}
		ret = pow(100, A) * B + shou;
		printf("%.lf\n", ret);
		return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    vl a(n);
    REP(i,n){
        cin>>a[i];
    }
    REPR(i,n-1){
        a[i]-=a[0];
    }
    vl b(m);
    REP(i,m){
        cin>>b[i];
    }
    REPR(i,m-1){
        b[i]-=b[0];
    }
    ll x=0;
    REP(i,n){
        (x+=a[i]*(i)-a[i]*(n-i-1)+MOD)%=MOD;
    }
    ll y=0;
    REP(i,m){
        (y+=b[i]*(i)-b[i]*(m-i-1)+MOD)%=MOD;
    }
    cout<<(x*y+MOD)%MOD<<endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int l[] = new int[N];
    for(int i=0;i<N;i++){
      l[i]=sc.nextInt();
    }
    int answer =0;
    Arrays.sort(l);
    for(int i=1;i<=K;i++){
      answer = answer+l[N-i];
    }
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 23892