akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#define MN 201000

int ls[MN * 100], rs[MN * 100], lazy1[MN * 100], lazy2[MN * 100], sum[MN * 100];
int h[MN], nxt[2 * MN], to[2 * MN], K = 0;
int tot = 0;
int rt[MN], fa[MN], v[MN];

void ins(int u, int v) {nxt[++K] = h[u]; h[u] = K; to[K] = v;}

void add(int x)
{
	sum[x] = lazy1[x] = 0;
	lazy2[x] = 1;
}

void pushdown(int x, int l, int r)
{
	if(!lazy1[x] && !lazy2[x]) return;
	if(!ls[x]) ls[x] = ++tot;
	if(!rs[x]) rs[x] = ++tot;
	if(lazy2[x]) 
	{
		add(ls[x]);
		add(rs[x]);
		lazy2[x] = 0;
	}
	int mid = l + r >> 1;
	if(lazy1[x])
	{
		sum[ls[x]] += (mid - l + 1) * lazy1[x];
		sum[rs[x]] += (r - mid) * lazy1[x];
		lazy1[ls[x]] += lazy1[x];
		lazy1[rs[x]] += lazy1[x]; 
		lazy1[x] = 0;
	}
}

int merge(int rt1, int rt2, int l, int r)
{
	if(!ls[rt1] && !rs[rt1])
	{
		sum[rt2] += sum[rt1];
		lazy1[rt2] += lazy1[rt1];
		return rt2;
	}
	if(!ls[rt2] && !rs[rt2])
	{ 
		sum[rt1] += sum[rt2];
		lazy1[rt1] += lazy1[rt2];
		return rt1; 
	}
	pushdown(rt1, l, r);
	pushdown(rt2, l, r);
	ls[rt1] = merge(ls[rt1], ls[rt2], l, l + r >> 1);
	rs[rt1] = merge(rs[rt1], rs[rt2], (l + r >> 1) + 1, r);
	sum[rt1] = sum[ls[rt1]] + sum[rs[rt1]];
	return rt1;
}

void modify(int x, int l, int r, int L, int R)
{
	if(l == L && r == R) {add(x); return;}
	pushdown(x, l, r);
	int mid = l + r >> 1;
	if(R <= mid) modify(ls[x], l, mid, L, R);
	else if(L > mid) modify(rs[x], mid + 1, r, L, R);
	else modify(ls[x], l, mid, L, mid), modify(rs[x], mid + 1, r, mid + 1, R);
	sum[x] = sum[ls[x]] + sum[rs[x]];
}

int query(int x, int l, int r, int k)
{
	if(!k) return 0;
	if(l == k && r == k) return sum[x];
	pushdown(x, l, r);
	int mid = l + r >> 1;
	if(k <= mid) return query(ls[x], l, mid, k);
	else return query(rs[x], mid + 1, r, k);
}

int n; 

void dfs(int x, int f, int Mx)
{
	++tot; lazy1[tot] = 1; sum[tot] = n;
	rt[x] = tot; fa[x] = f;
	for(int i = h[x]; i; i = nxt[i])
	{
		if(to[i] == f) continue;
		dfs(to[i], x, std::max(Mx, f));
		modify(rt[to[i]], 1, n, 1, to[i]);
		rt[x] = merge(rt[x], rt[to[i]], 1, n);
	}
	v[x] = query(rt[x], 1, n, std::max(Mx, f));
	if(Mx > x) v[x] -= query(rt[x], 1, n, Mx);
}

void dfs2(int x)
{
	v[x] += v[fa[x]];
	for(int i = h[x]; i; i = nxt[i]) if(to[i] != fa[x]) dfs2(to[i]);
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i < n; i++)
	{
		int a, b; scanf("%d%d", &a, &b);
		ins(a, b); ins(b, a);
	}
	dfs(1, 0, 0); dfs2(1);
	for(int i = 2; i <= n; i++) printf("%d ", v[i]);
	return 0;
}

Measured memory_bytes: 275072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 1e9 + 7;
typedef long long ll;

int main(){
	int D;
	cin >> D;
	string ans;
	if(D == 25)ans = "Christmas";
	else if(D == 24)ans = "Christmas Eve";
	else if(D == 23)ans = "Christmas Eve Eve";
	else if(D == 22)ans = "Christmas Eve Eve Eve";
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200010],b[200010];
long long sa[200010],sb[200010];
int n,m,k,ans = 0;
int Binary_search(int sum){
    int l = 0,r = m,mid;
    while(l < r){
       mid = (l+r+1)/2;//+1取决于mid-1
       if(sb[mid]+sum>k){
        r = mid - 1;
       }else{
        l = mid;
       }
    }
    return l;
}
int main() {
  cin >> n >> m >> k;
  sa[0] = sb[0] = 0;
  for(int i = 1; i <= n; i++){
        cin >> a[i];
        sa[i] = sa[i-1]+a[i];
  }
  for(int i = 1; i <= m; i++){
        cin >> b[i];
        sb[i] = sb[i-1]+b[i];
  }
  for(int i = 0; i <= n; i++){
    if(sa[i] <= k){
        ans = max(ans,i+Binary_search(sa[i]));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8272
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
	char x,y,z;
	cin>>x>>y>>z;
	ll s=0;
	if(x=='A'||y=='A'||z=='A')
		s++;
	if(x=='B'||y=='B'||z=='B')
		s++;
	if(s==2)
		cout<<"Yes";
	else
		cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b+c>21){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import re

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B = map(int, raw_input().split())

ans = 0
cnt = 1

while cnt < B:
    cnt -= 1
    cnt += A
    ans += 1

print ans


Measured memory_bytes: 2812
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(all(d));
    cout << d[n/2] - d[(n-1)/2]  << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;   
int main()  
{  
    int n,k;
	cin>>n>>k;
	int a[1000];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int sum=0;
	for(int i=n-1;i>=n-k;i--)
		sum+=a[i];
	cout<<sum<<endl;
}  

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

#define mod 1000000007
#define int long long int
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define vs vector<string>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(v) v.begin(),v.end()
#define endl "\n"

const int maxn=1e4+5;
int cnt[maxn];
int32_t main()
{
	int h,n,e;
	cin>>h>>n;
	for(int i=0;i<n;cnt[e]++,i++)
		cin>>e;
	int ans=0;
	for(int i=maxn-1;i>=1;i--)
		for(int j=1;h>0 && j<=cnt[i];ans++,j++)
			h-=i;
	if(h>0)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}

Measured memory_bytes: 384
// Gracias, Rodolfo
// Gracias, MarcosK
// Gracias, Graphter
// Obrigado, Dilson
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for (Long i = a; i < b; i++)
#define roF(i,a,b) for (Long i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long Long;
typedef long double Double;
typedef unsigned long long ULong;
typedef pair<Long, Long> Pair;
typedef vector<Long> Vector;
typedef vector<Pair> PairVector;

const int N = 1e6;
const Long INF = 1e18;
const Double EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
Long random(Long a, Long b) { return uniform_int_distribution<Long> (a, b) (rng); }

void solve() {
	Long n;
	cin >> n;
	Double ans = ((Double) (n % 2 == 0 ? n / 2 : (n + 1) / 2))/ n;
	cout << setprecision(10) << fixed << ans << endl;
}

int main() {
	fastio;
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 20;
const int M = (int) (1 << 16) + 1000;
const int K = (int) 350;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF + 2;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;

int n, m;
int a[N];
int f[M], inv[M];
int dp[N][M];

inline void add(int &x, int y) {
  x += y;
  if (x < 0) 
    x += INF;
  if (x >= INF) 
    x -= INF;
}

inline int mult(const int &x, const int &y) {
  return 1ll * x * y % INF;
}

inline int cnk(const int &n, const int &k) {
  return mult(f[n], mult(inv[n - k], inv[k]));
}

inline int bp(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) 
      ans = mult(ans, x);
    x = mult(x, x);
    y /= 2;
  }
  return ans;
}

int main() {
  #define fn "saddle"
  #ifdef witch
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #else
      //freopen(fn".in", "r", stdin);
      //freopen(fn".out", "w", stdout);
  #endif
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i];
  }
  f[0] = 1;
  for (int i = 1; i <= (1 << n); i++) {
    f[i] = mult(f[i - 1], i);
  }
  inv[(1 << n)] = bp(f[(1 << n)], INF - 2);
  for (int i = (1 << n) - 1; i >= 0; i--) {
    inv[i] = mult(inv[i + 1], i + 1);
  }
  sort(a + 1, a + m + 1, greater<int>());
  dp[1][0] = 1; 
  for (int i = 1; i <= m; i++) {
    for (int mask = 0; mask < (1 << n); mask++) {
      int cnt = (1 << n) - a[i];
      for (int j = 0; j < n; j++) {
        if ((mask >> j) % 2) {
          cnt -= (1 << j);
        }
      }
      for (int j = 0; j < n; j++) {
        if ((mask >> j) % 2 == 0) {
          add(dp[i + 1][mask | (1 << j)], mult(dp[i][mask], mult(cnk(cnt, (1 << j) - 1), f[(1 << j)])));  
        }
      }
      add(dp[i + 1][mask], dp[i][mask]);
    }
  }
  int ans = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    int cnt = (1 << n) - 1;
    int xr = 0;
    for (int j = 0; j < n; j++) {
      if ((mask >> j) % 2) {
        cnt -= (1 << j);
        xr ^= 1;
      }
    }
    //cout << mask << " " << dp[m + 1][mask] << endl;
    if (!xr)
      add(ans, mult(f[cnt], dp[m + 1][mask]));
    else  
      add(ans, -mult(f[cnt], dp[m + 1][mask]));
  }
  cout << mult(ans, (1 << n));
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s;

void solve()
{
    cin >> s;
    for (int i=0; i<s.size(); i+=2) {
        if (s[i]=='R'||s[i]=='U'||s[i]=='D') continue;
        nout("No"); return;
    }
    for (int i=1; i<s.size(); i+=2) {
        if (s[i]=='L'||s[i]=='U'||s[i]=='D') continue;
        nout("No"); return;
    }nout("Yes");

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d%d",&a,&b);
	if (a < b){
		printf("a < b\n");
	} else if (a > b) {
		printf("a > b\n");
	} else {
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2052
def b_robot_arms():
    from operator import itemgetter
    N = int(input())
    Robots = [[int(i) for i in input().split()] for j in range(N)]

    robot_arms = sorted([[x - l, x + l] for x, l in Robots], key=itemgetter(1))
    current = -float('inf')
    ans = 0
    for left, right in robot_arms:
        if current <= left:
            ans += 1
            current = right
    return ans

print(b_robot_arms())

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

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn parse_line_vec<T: FromStr>() -> Vec<T> {
    let line = parse_line::<String>();
    line.split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn println<T: std::string::ToString>(s: T) {
    println!("{}", s.to_string());
}

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

type Point = Vec<i32>;

fn squared_magnitude(p1: &Point, p2: &Point) -> u32 {
    p1.into_iter()
        .zip(p2)
        .map(|(x1, x2)| (x1 - x2).pow(2) as u32)
        .sum::<u32>()
}

fn distance(p1: &Point, p2: &Point) -> f32 {
    (squared_magnitude(p1, p2) as f32).sqrt()
}

fn main() {
    let (n, _d) = parse_pair::<usize, usize>();

    let x: Vec<Point> = (0..n).map(|_| parse_line_vec()).collect();

    let valid_count = (0..n - 1)
        .map(|i| {
            (i + 1..n)
                .map(|j| distance(&x[i], &x[j]))
                .filter(|dist| dist.fract() == 0.0)
                .count()
        })
        .sum::<usize>();

    println(valid_count);
}


Measured memory_bytes: 4352
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int N = 25-sc.nextInt();
		System.out.print("Christmas");

		for(int n=0;n<N;n++){
			System.out.print(" Eve");
		}
		System.out.println();
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    deque<int> d;
    rep(i, n) {
        int idx = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
        if (idx == 0) {  // dの全ての要素がa[i]以上のとき、塗り分ける色(=dのサイズ)が増加
            d.push_front(a[i]);
        }
        else {  // dの要素の内、a[i]より小さい中で最大のものをa[i]に書き換える、塗り分ける色は増えない
            d[idx - 1] = a[i];
        }
    }
    cout << d.size() << endl;
    return 0;
}


Measured memory_bytes: 4016
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
ll K;

int main()
{
	scanf("%d",&n);
	if(n <= 999)printf("ABC\n");
	else printf("ABD\n");
	return 0;
}


Measured memory_bytes: 128
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

# print(n, k, r, s, p)
# print(t)

# 貪欲法
point = 0
score = {'r': p, 's': r, 'p': s}
taka = [True] * k # i 番目で勝った

for i in range(k):
    point += score.get(t[i])
for i in range(k, n):
    if t[i] == t[i - k]: # k回前と同じ手は出せない
        if taka[i - k]: # k回前に勝っている = 今回は勝てない
            taka.append(False)
        else: # k回前に負けている = 今回勝てばいい
            point += score.get(t[i])
            taka.append(True)
    else:
        # 勝てる
        point += score.get(t[i])
        taka.append(True)

print(point)

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

int main() {
   int N;
   string S;
   cin >> N >> S;
   int total=0;
   for (int i=0; i<1000; i++) {
       string s=to_string(i);
       if (s.size()==1) s="00"+s;
       else if (s.size()==2) s="0"+s;
       int count=0;
       for (int j=0; j<N; j++) {
           if (s.at(0)==S.at(j) && count==0) count++;
           else if (count==1 && s.at(1)==S.at(j)) count++;
           else if (count==2 && s.at(2)==S.at(j)) {
               total++;break;
           }
       }
   }
   cout << total << endl;
}

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

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


void solve(long long N, long long K, vector<long long> H){
    long long ans;

    if (N <= K) {
        ans = 0;
    } else if (K == 0) {
        ans = accumulate(H.begin(), H.end(), 0LL);
    } else {
        sort(H.begin(), H.end());
        REP(i, K) {
            H.pop_back();
        }
        ans = accumulate(H.begin(), H.end(), 0LL);
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    cin >> N;
    long long K;
    cin >> K;
    vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        cin >> H[i];
    }
    solve(N, K, move(H));
}


Measured memory_bytes: 1792
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    S = readline().strip()
    T = readline().strip()

    idx_in_S = []
    last_idx = 0
    for t in T:
        t_idx = S.find(t, last_idx) + 1
        if t_idx:
            idx_in_S.append(t_idx)
            last_idx = t_idx
        else:
            t_idx = S.find(t, 0, last_idx) + 1
            if not t_idx:
                print(-1)
                exit()
            else:
                idx_in_S.append(t_idx)
                last_idx = t_idx

    
    rep = 0
    for i in range(len(T) - 1):
        if idx_in_S[i] < idx_in_S[i+1]:
            continue
        else:
            rep += 1

    ans = len(S) * rep + idx_in_S[-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 7284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    long double A,B,H,M;
    cin >> A >> B >> H >> M;
    long double pi = 3.1415926535;
 
    long double funkaku,jikaku;
    funkaku = M / 60;
    jikaku = H / 12 + M / 720;
 
    long double theta = abs(funkaku - jikaku) * 2 * pi;
    // cout << theta;
    long double result;
 
    if(theta == 0){
        result = abs(A-B);
    }
    else{
        result = sqrt(pow(A,2) + pow(B,2) - 2 * A * B * cosl(theta));
    }
    
    cout << fixed << setprecision(15) << result;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

vector<int32> G[112345];
int32 N;
vector<int64> A;

int64 dfs(int32 v, int32 p){
	if(G[v].size() == (p != -1)) return A[v];
	vector<int64> c;
	int64 sum = 0;
	REP(i, G[v].size()){
		if(G[v][i] == p) continue;
		c.push_back(dfs(G[v][i], v));
		sum += c[c.size()-1];
		if(c[c.size()-1] == -1) return -1;
	}
	sort(all(c), greater<int64>());
	int64 x = 2*A[v]-sum;
	if(A[v] > sum || (sum-x)%2) return -1;
	if(p == -1){
		if(G[v].size() > 1 && x != 0) return -1;
		if(G[v].size() == 1 && sum != A[v]) return -1;
	}
	if((sum-x)/2 <= (sum-c[0]) && (sum-x)/2 <= sum/2) return x;
	return -1;
}

int main(void){
	cin >> N;
	A.resize(N);
	REP(i, N) cin >> A[i];
	REP(i, N-1){
		int32 a, b;
		cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if(dfs(0, -1) == -1) cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 17408
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int n, m, q;
	static int[] a, b, c, d;
	static int ans = 0;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		q = sc.nextInt();
		a = new int[q];
		b = new int[q];
		c = new int[q];
		d = new int[q];
		for (int i = 0; i < q; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		sc.close();

		List<Integer> list = new ArrayList<>();
		list.add(1);
		dfs(list);
		System.out.println(ans);
	}

	static void dfs(List<Integer> list) {
		if (list.size() == n + 1) {
			int val = 0;
			for (int i = 0; i < q; i++) {
				if (list.get(b[i]) - list.get(a[i]) == c[i]) {
					val += d[i];
				}
			}
			ans = Math.max(ans, val);
			return;
		}
		int start = list.get(list.size() - 1);
		for (int i = start; i <= m; i++) {
			list.add(i);
			dfs(list);
			list.remove(list.size() - 1);
		}
	}
}


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

int main(){
  string S; cin >> S;
  if(S=="Sunny"){
    cout << "Cloudy\n";
  }else if(S=="Cloudy"){
    cout << "Rainy\n";
  }else{
    cout << "Sunny\n";
  }
  return 0;
}

Measured memory_bytes: 256
local n = tonumber(io.read());
local input = {}

for v in string.gmatch(io.read(), "(%d+)") do
    table.insert(input, tonumber(v));
end

table.sort(input, function(a, b)
    return a < b;
end)

local result = input[#input] - input[1];
print(result);


Measured memory_bytes: 1008
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))
 
#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("WA.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
#define sz(v)			((LL)v.size())
#define pi 				(acos(-1.0));
using namespace std;

string S[55];
LL C[55];
const LL inf = 1e18;
LL N;
LL dp[55][25][25][55];

bool isPal( LL i , LL x, LL y ){
	assert(x>-1); assert(y>-1);
	assert(x<sz(S[i]));
	assert(y<sz(S[i]));
	while( S[i][x] == S[i][y]  ){
		x++;
		y--;
		if(x>=y) break;
	}
	return x>=y;
}

LL F( LL a, LL i, LL j, LL b ){
	
	LL &ret = dp[a][i][j][b];
	
	if(ret!=-1) return ret;
	
	while( i<sz(S[a]) && j>=0 ){
		if( S[a][i] == S[b][j] ){
			i++;
			j--;
		}
		else break;
	}
	
	
	if( i >= sz(S[a]) && j<0 ) return  ret = 0;
	
	ret = inf;
	
	if( i<sz(S[a]) && j>=0 ) ret = inf;
	else{
		
		if( i==sz(S[a]) ){
			
			if( isPal(b,0,j) ) ret = 0;
			FOR(k,1,N) ret = min( ret , C[k] + F(k,0,j,b) );
		}
		else{
			
			if(isPal(a,i,sz(S[a])-1)) ret = 0;
			FOR(k,1,N) ret = min( ret , C[k] + F(a,i,sz(S[k])-1,k));
		}
	}
	return ret;
}

int main(){ 
	//FILEIN;
	SET(dp);
	SL(N);
	FOR(i,1,N){
		cin>>S[i];
		assert(S[i].empty()==false);
		cin>>C[i];
	}
	
	LL ans = inf;
	FOR(i,1,N)FOR(j,1,N){
		
		ans = min( ans , C[i]+C[j] + F(i,0,sz(S[j])-1,j));
		if(i==j){
			if(isPal(i,0,sz(S[i])-1)) ans = min(ans,C[i]);
		}
		//DEBUG(ans);
	}
	
	if(ans>=inf) ans = -1;
	cout<<ans<<endl;
	
return 0;}



Measured memory_bytes: 18520
#include<stdio.h>
int main()
{int i,j=0;
char a[3],b[3];
scanf(" %c%c%c",&a[0],&a[1],&a[2]);
scanf(" %c%c%c",&b[0],&b[1],&b[2]);
for(i=0;i<3;i++)
{if(a[i]==b[i])
j++;}
printf("%d",j);
 return 0;
}

Measured memory_bytes: 128
S = input()

YY = ["{:02d}".format(i) for i in range(100)]
MM = ["{:02d}".format(i) for i in range(1, 13)]

flag = [False, False]
result = ""

# YYMMフォーマット
if S[0:2] in YY and S[2:4] in MM:
    flag[0] = True
# MMYYフォーマット
if S[2:4] in YY and S[0:2] in MM:
    flag[1] = True

if flag[0] and flag[1]:
    print("AMBIGUOUS")
elif flag[0]:
    print("YYMM")
elif flag[1]:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3064
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,c,k=map(int,readline().split())
    if a+b>=k:
        print(min(a,k))
    elif a+b<k:
        n=k-(a+b)
        print(a-n)
if __name__=="__main__":
    main()

Measured memory_bytes: 9000
// 2017/05/01 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

const int INFTY = 1000000001;

int C;		// ???????????°

void Merge(int A[], int left, int mid, int right)
{
	int n1 = mid-left;
	int n2 = right-mid;

	int* L = new int[n1+1];		// ???????????????????¢????
	int* R = new int[n2+1];

	for(int i=0; i<n1; i++){
		L[i] = A[left+i];
	}
	for(int i=0; i<n2; i++){
		R[i] = A[mid+i];
	}
	L[n1] = INFTY;
	R[n2] = INFTY;

	for(int i=0, j=0, k=left; k<right; k++){
		if(C++, L[i]<=R[j]){
			A[k] = L[i];
			i++;
		}
		else{
			A[k] = R[j];
			j++;
		}
	}

	delete[] L;			// ???????????????????§£???
	delete[] R;
}

void mergeSort(int A[], int left, int right)
{
	if(left+1>=right)		// ?????°??????????????¶
		return;

	int mid = (left+right)/2;
	mergeSort(A, left, mid);
	mergeSort(A, mid, right);
	Merge(A, left, mid, right);
}

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

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

	C = 0;
	mergeSort(S, 0, n);

	for(int i=0; i<n; i++){
		cout << S[i];

		if(i<n-1){
			cout << ' ';
		}
		else{
			cout << endl;
		}
	}
	cout << C << endl;

	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  set<int> a;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a.insert(t);
  }
  cout << (int(a.size()) == n ? "YES" : "NO") << endl;
}


Measured memory_bytes: 9600
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}*/ 
int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	vector<int> a(q);
	int sum=0;
	int freq[n]={0};
	for(int i=0;i<q;i++){
		cin>>a[i];
		sum+=a[i];
		freq[a[i]-1]++;
	}
	for(int i=0;i<n;i++)
	{
		int r=q-freq[i];
		if(k-r<=0)
		{
			cout<<"No"<<endl;
		}
		else
		cout<<"Yes"<<endl;
	}
	return 0;
}







Measured memory_bytes: 1408
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=b;i>=a;i--)
#define sc(x) scanf("%d",&x)
#define pb push_back

int main(int argc, char** argv) {
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ad=min(a,k);
	int j=max(min(k,c+b+a)-(a+b),0);
	cout<<ad-j;
	return 0;
}

Measured memory_bytes: 3624
import std.stdio, std.string, std.algorithm, std.range, std.conv, std.math;

void main() {
  auto abc = readln.chomp.split.map!(to!int).array.sort;
  if (abc[0] + abc[1] == abc[2]) {
    "Yes".writeln;
  } else {
    "No".writeln;
  }
}


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


using namespace std;

int main(){
 int n,l;
  cin >> n >> l;
  
  int sum=0;
  int small=300;
  int res=0;
  
  
  for(int i=1;i<=n;i++){
    sum+=l+i-1; 
    
    if(small>=abs(l+i-1)){
    small=abs(l+i-1);
    res=l+i-1;
    }
  }
 
  cout << sum-res << endl;
}

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

int main()
{
  int b, r, g, c, s, t;
  while (cin >> b >> r >> g >> c >> s >> t) {
    if ((b|r|g|c|s|t) == 0)
      break;

    int pay = (t-b*5-r*3-s) * 3 + (b*5+r*3) * 2;
    int get = (b*6+r*4)*15 + g*7 + c*2;

    cout << 100 + get - pay << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
deque<int> q;
int main(){
	ll m,k;
	cin>>m>>k;
	if(k>((1<<m)-1)){
		cout<<-1<<endl;
		return 0;
	}
	if(k==0){
		for(int i=0;i<(1<<m);i++){
			cout<<i<<" "<<i<<" ";
		}cout<<endl;
		return 0;
	}
	if(m==1){
		cout<<-1<<endl;
		return 0;
	}
	q.push_front(k);
	for(int i=0;i<(1<<m);i++){
		if(i==k) continue;
		q.push_front(i);
		q.push_back(i);
	}
	q.push_back(k);
	while(!q.empty()){
		cout<<q.front()<<" ";
		q.pop_front();
	}cout<<endl;
}

Measured memory_bytes: 2944
#include <cstdio>
#include <vector>
#include <functional>

using namespace std;

template <class RandomIt>
struct swin_result {
    RandomIt first, last;
    typename RandomIt::value_type top;
    typename RandomIt::difference_type number, largest, smallest;
    swin_result() {}
    swin_result(typename RandomIt::value_type init):
        top(init), number(0), largest(0), smallest(0)
    {}
};

template <
    class RandomIt, class UnaryPredicate, class BinaryOperation,
    class BinaryInvOperation,
    class BinaryPredicate=less<typename RandomIt::value_type>
>
swin_result<RandomIt> slide_window(
    RandomIt first, RandomIt last, UnaryPredicate unary_p,
    BinaryOperation binary_op, BinaryInvOperation binary_invop,
    typename RandomIt::value_type e,
    BinaryPredicate binary_p=less<typename RandomIt::value_type>()
) {
    swin_result<RandomIt> res(e);
    typename RandomIt::value_type cur=e;
    typename RandomIt::difference_type len=0;
    for (RandomIt open=first, close=open; open<last; ++open) {
        while (!unary_p(cur) && close < last) {
            if (binary_p(res.top, cur)) {
                res.top = cur;
                res.first = open;
                res.last = close;
            }

            cur = binary_op(cur, *close);
            ++close;
            ++len;
        }

        if (unary_p(cur)) {
            res.number += len + 1;
            if (res.largest < len)
                res.largest = len;
            if (res.smallest > len || !res.smallest)
                res.smallest = len;
        }

        cur = binary_invop(cur, *open);
        --len;
    }

    return res;
}

int main() {
    size_t N;
    int S;
    scanf("%zu %d", &N, &S);

    vector<int> a(N);
    for (size_t i=0; i<N; ++i)
        scanf("%d", &a[i]);

    auto add=[](int lhs, int rhs)->int {
        return lhs + rhs;
    };
    auto sub=[](int lhs, int rhs)->int {
        return lhs - rhs;
    };

    swin_result<vector<int>::iterator> res=slide_window(
        a.begin(), a.end(), [S](int lhs)->bool {
            return lhs >= S;
        }, add, sub, 0
    );

    printf("%td\n", res.smallest);
    return 0;
}

Measured memory_bytes: 2788
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
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;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int N, H, W;
	cin >> N >> H >> W;
	cout << (N - H + 1)*(N - W + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
// Submitted by Subhash Yadav
import java.io.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.*;

public class Main {
	
	

	public static void main(String[] args) throws IOException {
		FastScanner sc=new FastScanner();
		int d=sc.nextInt(),t=sc.nextInt(),s=sc.nextInt();
		System.out.println(s*t>=d?"Yes":"No");

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}

Measured memory_bytes: 32744
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define MEM(a,n) memset(a,n,sizeof(a))
#define p(S) cout<<(S)<<endl
using namespace std;

int main(){
	int N,M;
	int dx[4]={0,1,0,-1};
	int dy[4]={1,0,-1,0};
	map<char,int> m;
	m['N']=0;
	m['E']=1;
	m['S']=2;
	m['W']=3;
	while(cin>>N,N){
		bool g[21][21];
		MEM(g,false);
		int x,y;
		REP(i,0,N){
			cin>>x>>y;
			g[y][x]=true;
		}
		cin>>M;
		char h;
		int d;
		int nowx=10,nowy=10;
		REP(i,0,M){
			cin>>h>>d;
			REP(j,0,d){
				nowx+=dx[m[h]];
				nowy+=dy[m[h]];
				if(g[nowy][nowx]){
					g[nowy][nowx]=false;
					N--;
				}
			}
		}
		p(N==0?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 2984
import sys
import math
from decimal import Decimal
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = input().split()
    res = math.floor(Decimal(a) * Decimal(b))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10076
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>
#include <functional>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	ll N;
	cin >> N;
	vector<ll> a(3 * N), v1, v2;
	for (ll i = 0; i < 3 * N; i++)cin >> a[i];

	priority_queue<ll, vector<ll>, greater<ll>> que1; // 昇順
	priority_queue<ll, vector<ll>> que2; // 降順

	ll cnt1 = 0, cnt2 = 0, max;

	for (ll i = 0; i < N; i++)
	{
		que1.push(a[i]);
		cnt1 += a[i];
		que2.push(a[3 * N - i - 1]);
		cnt2 += a[3 * N - i - 1];
	}
	v1.push_back(cnt1);
	v2.push_back(cnt2);

	max = cnt1 - cnt2;

	for (ll i = N; i < 2 * N; i++)
	{
		que1.push(a[i]);
		cnt1 += a[i] - que1.top();
		que1.pop();
		v1.push_back(cnt1);
		que2.push(a[3 * N - i - 1]);
		cnt2 += a[3 * N - i - 1] - que2.top();
		que2.pop();
		v2.push_back(cnt2);
	}

	for (ll i = 0; i <= N; i++)
	{
		if (max < v1[i] - v2[N - i])
		{
			max = v1[i] - v2[N - i];
		}
	}

	cout << max << endl;
}

Measured memory_bytes: 7660
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    vector<int>A(3);
    REP(i,3)cin>>A[i];
    sort(A.begin(),A.end());
    cout<<A[0]+A[1]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define rep(i, x, n) for(int i = (x); i < (n); i++)
#define rrep(i, x, n) for(int i = (x); i >= (n); i--)
#define int long long
#define endl "\n"
#define mod 1000000007
#define mxx 100005
#define pb push_back
#define vll vector<long long>
#define vs vector<string>
#define pll pair<long long, long long>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
int fact[1000005];
void factorial(){
	fact[0] = 1;
	rep(i, 1, 1000002)fact[i] = (fact[i-1]*i) % mod;
}

int power(int a, int b ,int m){
	int res = 1;
	a = a % m;
	while ( b > 0){
	if (b & 1) res = (res * a) % m;
	b = b>>1;
	a = (a * a) % m;
	}
	return res % m;
}

int mod_in(int n){
	return ( power(n, mod-2,mod) % mod);
}

int ncr(int n, int r){
	return ( fact[n] * ((mod_in(fact[r]) * mod_in(fact[n-r])) % mod) % mod);
}

class dsu{
	public:
	vll v,size;
	dsu(int n){
		for(int i=0;i<n;i++){
			v.pb(i);
			size.pb(1);
		}
	}
	int par(int a){
		if(v[a]!=a) v[a] =  par(v[a]);
		return v[a];
	}

	int comp(int a,int b) {return par(a)==par(b);}
	
	void unio(int a, int b){
		int pa=par(a);
		int pb=par(b);
		if(pa!=pb){
			if(size[pb]>size[pa]) swap(pa,pb);
			v[pb]=pa;
			size[pa]+=size[pb];
		}
	}
};


signed main()
{
	int t=1;
	// cin >> t;
	while(t--){
		string s; cin >> s;
		int ans=0;
		rep(i,0,s.size()) ans+=s[i]-'0';
		if(ans%9) cout << "No\n";
		else cout << "Yes\n";
	}
}

Measured memory_bytes: 3724
N=int(input())
H=[int(i) for i in input().split()]

count=0
max_count=0
before=-1

for h in H:
    if before>=h:
        count+=1
    else:
        count=0
    if max_count<count:
        max_count=count
    before=h
    #print(h, count, max_count)

print(max_count)

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
    Main() {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long m = sc.nextInt();

        if (n > 1)
            n -= 2;

        if (m > 1)
            m -= 2;

        System.out.println(n * m);
    }

    public static void main (String[] args) {
        new Main();
    }

}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x->left != NIL ) x = x->left;
  return x;
}
Node treeMaximum(Node x){
  while( x->right != NIL ) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);
  if ( y->left != NIL ) x = y->left;
  else x = y->right;

  if ( x != NIL ) x->parent = y->parent;

  if ( y->parent == NIL ){
    root = x;
  } else {
    if (y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;
  }

  if ( y != z ){
    z->key = y->key;
  }

  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "find") == 0 ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( strcmp(com, "findMin") == 0 ){
	Node minn = treeMinimum(t);
	printf("%d\n", minn->key);
      } else if ( strcmp(com, "findMax") == 0 ){
	Node maxn = treeMaximum(t);
	printf("%d\n", maxn->key);
      } else {
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      }
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( strcmp(com, "delete") == 0 ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 20560
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

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

struct edge{
  int to, dis;
  edge(int too, int cost){
    dis = cost;
    to = too;
  }
};

int n, m, k, l[3333];
int mindis[3333], costed[3333], shop[3333];
vector<vector<edge> > graph(3333);

void Dijkstra(){
  
  fill_n(costed, 3333, INF);
  priority_queue<iP, vector<iP>, greater<iP> > que;
  for(int i = 0; i < k; i++){
    que.push(iP(0, shop[i])); costed[shop[i]] = 0;
  }
  while(!que.empty()){
    iP p = que.top(); que.pop();
    int now = p.sc, d = p.fr;
    for(int i = 0; i < graph[now].size(); i++){
      edge e = graph[now][i];
      if(d + e.dis < costed[e.to]){
        costed[e.to] = d + e.dis;
        que.push(iP(d + e.dis, e.to));
      }
    }
  }
}

    
int main(){
  
  cin >> n >> m >> k;
  for(int i = 0; i < m; i++){
    int a, b, c; cin >> a >> b >> c;
    graph[a].push_back(edge(b, c));
    graph[b].push_back(edge(a, c));
  }
  for(int i = 0; i < k; i++) cin >> shop[i];
  Dijkstra();

  double maxi = 0;
  for(int i = 1; i <= n; i++){
    for(int j = 0; j < graph[i].size(); j++){
      int tar, subs, t = graph[i][j].to;
      subs = costed[i] - costed[t];
      if(subs < 0) tar = costed[t], subs = -subs;
      else tar = costed[i];
      maxi = max(maxi, tar + (double)(graph[i][j].dis - subs)/2);
    }

  }
  cout << (int)(maxi + 0.5) << endl;
 
}

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

struct dice{
  int u;
  int s;
  int e;
  int w;
  int n;
  int d;
};

int main(){
  dice dice1;
  cin>>dice1.u>>dice1.s>>dice1.e>>dice1.w>>dice1.n>>dice1.d;
  char c;
  while(scanf("%c",&c)!=EOF){
    dice temp = dice1;
    if(c=='E'){     
      dice1.d = temp.e;
      dice1.w = temp.d;
      dice1.u = temp.w;
      dice1.e = temp.u;
    }else if(c=='N'){
      dice1.n = temp.u;
      dice1.u = temp.s;
      dice1.s = temp.d;
      dice1.d = temp.n;
    }else if(c=='S'){
      dice1.n = temp.d;
      dice1.u = temp.n;
      dice1.s = temp.u;
      dice1.d = temp.s;
    }else if(c=='W'){
      dice1.u = temp.e;
      dice1.w = temp.u;
      dice1.d = temp.w;
      dice1.e = temp.d;
    }
  }
  cout<<dice1.u<<endl;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int a,b; cin>>a>>b;
  int c[a][b],x[a],y[b],ans=0;
  rep(i,0,a) rep(j,0,b){cin>>c[i][j]; ans+=c[i][j];}
  rep(i,0,a){
    int z=0;
    rep(j,0,b) z+=c[i][j];
    x[i]=z;
  }
  rep(i,0,b){
    int z=0;
    rep(j,0,a) z+=c[j][i];
    y[i]=z;
  }
  rep(i,0,a){
    rep(j,0,b){
      cout<<c[i][j]<<" ";
    }
    co(x[i]);
  }
  rep(i,0,b) cout<<y[i]<<" ";
  co(ans);
  return 0;
}


Measured memory_bytes: 3100
s = input()

ans = 0
n = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
        n += 1
        if ans < n:
            ans = n
    else:
        n = 0

print (ans)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n)
	{
		cin >> l[i];
	}

	sort(l.begin(), l.end());
	ll ans = 0;
	for (int i = 0; i < n - 2; i++)
	{
		for (int j = i + 1; j < n - 1; j++)
		{
            if(l[n-1]<l[i]+l[j])
            {
                ans+=n-(j+1);
            }
            else
			for (int k = j + 1; k < n; k++)
			{
				if (l[k] < l[i] + l[j])
				{
					ans++;
				}
				else
				{
					break;
				}
			}

		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256