akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<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 (b<a) {a=b; return 1;} return 0;}

bool isok(string s) {
    return s.find("##") == string::npos;
}

bool isok2(string s, int a, int b) {
    bool res = false;
    for (int i = a; i <= b; ++i) {
        if (i+1 < s.size() && s.substr(i-1, 3) == "...") res = true;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--; b--; c--; d--;
    bool ans = false;
    if (c == d) {
        cout << "No" << endl;
        return 0;
    }
    if (c < d) {
        if (isok(s.substr(a, c-a+1)) && isok(s.substr(b, d-b+1))) ans = true;
    } else {
        if (isok(s.substr(a, c-a+1)) && isok2(s, b, d))ans = true;
    }
    cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
long long ans[101][100001];
int weight[101];
int value[101];
int main(){
	int n, w;
	cin>>n>>w;
	for(int i = 0; i < n; ++i)cin>>weight[i]>>value[i];
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= w; ++j){
			if(i == 0 || j == 0)ans[i][j]=0;
			else if(weight[i - 1] <= j){
				ans[i][j] = max(value[i - 1] + ans[i - 1][j - weight[i - 1]], ans[i - 1][j]);
			}
			else{
				ans[i][j] = ans[i - 1][j];
			}
		}
	}
	cout<<ans[n][w]<<endl;		
	return 0;
}


Measured memory_bytes: 79104
H, W = list(map(lambda n: int(n), input().split(" ")))
S = []
for i in range(H):
  if i == 0:
    S.append("X" * (W + 2))
  S.append("X" + input() + "X")
else:
  S.append("X" * (W + 2))

unpaintable = False
for i in range(1, H+1):
  for j in range(1, W+1):
    if S[i][j] == "#" and "#" not in [S[i-1][j], S[i+1][j], S[i][j-1], S[i][j+1]]:
      unpaintable = True
      break
      
print("No") if unpaintable else print("Yes")

Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m,n;
    cin >> m >> n;
    vi a(n);
    vi od;
    rep(i,n){
        cin >> a[i];
        if(a[i] % 2){
            od.pb(a[i]);
        }
    }
    vi ans;
    if(len(od) > 2){
        cout << "Impossible\n";
        return 0;
    }else if(len(od) == 2){
        cout << od[0] << " ";
        if(od[0] != 1){
            ans.pb(od[0]-1);
        }
        rep(i,n){
            if(a[i] % 2 == 0){
                cout << a[i] << " ";
                ans.pb(a[i]);
            }
        }
        cout << od[1] << "\n";
        ans.pb(od[1]+1);
    }else if(len(od) == 1){
        cout << od[0] << " ";
        if(od[0] != 1){
            ans.pb(od[0]-1);
        }
        rep(i,n){
            if(a[i] % 2 == 0){
                cout << a[i] << " ";
                ans.pb(a[i]);
            }
        }
        cout << "\n";
        ans.pb(1);
    }else{
        ans.pb(a[0]-1);
        rep(i,n-1){
            ans.pb(a[i+1]);
        }
        ans.pb(1);
        rep(i,n){
            cout << a[i] << " ";
        }
        cout << "\n";
    }
    cout << len(ans) << "\n";
    rep(i,len(ans)){
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  ll ans = 0;
  for(int i=2;i<s.size();i+=2){
    bool flag = true;
    for(int j=0;j<i/2;j++){
      if(s[j]!=s[j+i/2]) flag = false;
    }
    if(flag) ans = max(ans,(ll)i);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

int main(void)
{
    string s;
    cin >> s;
    int len = s.size();
    ll ans = 0;
    for (ll i = 0; i < (1 << len - 1); ++i)
    {
        vector<int> bt;
        rep(j, 0, len) if (i >> j & 1) bt.push_back(j);
        ll x = 0;
        ll y = 0;
        rep(j, 0, len)
        {
            if (find(all(bt), j - 1) != bt.end())
            {
                x += y;
                y = s[j] - '0';
            }
            else
                y = 10 * y + (s[j] - '0');
        }
        ans += x + y;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int X1, Y1, X2, Y2;

int main(void){
    
    scanf("%d %d %d %d", &X1, &Y1, &X2, &Y2);
    
    for(int i = 0; i < Y2 - Y1; ++i) printf("U");
    for(int i = 0; i < X2 - X1; ++i) printf("R");
    for(int i = 0; i < Y2 - Y1; ++i) printf("D");
    for(int i = 0; i < X2 - X1; ++i) printf("L");
    
    printf("L");
    for(int i = 0; i < Y2 - Y1 + 1; ++i) printf("U");
    for(int i = 0; i < X2 - X1 + 1; ++i) printf("R");
    printf("D");
    
    printf("R");
    for(int i = 0; i < Y2 - Y1 + 1; ++i) printf("D");
    for(int i = 0; i < X2 - X1 + 1; ++i) printf("L");
    printf("U");
    
    return 0;
}

Measured memory_bytes: 256
import itertools

def main():
    
    N, M, Q_num= map(int, input().split())
    Q = [list(map(int, input().split(" "))) for _ in range(Q_num)]
    
    
    
    l = range(1, M+1)
    max_score = 0
    for v in itertools.combinations_with_replacement(l, N):
        score = 0
        for q in Q:
            if (v[q[1]-1] - v[q[0]-1]) == q[2]:
                score += q[3]
            max_score = max(max_score, score)
    print(max_score)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 73392
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  long n;
  std::cin >> n;
  std::vector<std::string> s(n);
  for (long i = 0; i < n; ++i) {
    std::cin >> s[i];
  }

  long abNum = 0;
  long endA = 0;
  long beginB = 0;
  long both = 0;

  for (long i = 0; i < n; ++i) {
    long len = s[i].length();
    if (s[i][len - 1] == 'A') ++endA;
    if (s[i][0] == 'B') ++beginB;
    if (s[i][len - 1] == 'A' && s[i][0] == 'B') ++both;
    for (long j = 0; j < len - 1; ++j) {
      if (s[i][j] == 'A' && s[i][j + 1] == 'B') ++abNum;
    }
  }

  long addNum = std::min(endA, beginB);
  if (both > 0 && endA == both && beginB == both) --addNum;
  std::cout << abNum + addNum << std::endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main(){
    int N;
    scanf("%d", &N);
    vector<long long> A(N);
    
    long long ans = 0;
    long long mi = 0;
    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
        if(A[i] < 0){
            mi++;
            A[i] *= -1;
        }
        ans += A[i];
    }
    sort(A.begin(), A.end());
    if(mi % 2 == 1)ans -= A[0] * 2;
    
    printf("%lld\n", ans);
}

Measured memory_bytes: 1024
import math


class Solution:
    def solve(self, n: int, points: list) -> int:

        s = 0.

        for i in range(n):
            p = points[i]
            for j in range(i+1, n):
                q = points[j]
                s += math.sqrt((p[0]-q[0])**2 + (p[1] - q[1])**2)

        return 2 * s / n


if __name__ == '__main__':

    # standard input
    n = int(input())
    points = []

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

    # solve
    solution = Solution()
    print(solution.solve(n, points))


Measured memory_bytes: 3064
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int h,w;
ll k;
char x[1005][1005];
struct ma
{
	ll val[3][3];
};

ma mul(ma a,ma b)
{
	ma t;
	memset(t.val,0,sizeof(t.val));

	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=2;j++)
		{
			for(int k=1;k<=2;k++)
			{
				if(!a.val[i][k]||!b.val[k][j])continue;
				t.val[i][j]+=(a.val[i][k]*b.val[k][j])%mod;
				t.val[i][j]=(t.val[i][j]+mod)%mod;
			}
		}
	}
	return t;
}

ma po(ma x,ll y)
{
	ma t;
	memset(t.val,0,sizeof(t.val));
	for(int i=1;i<=2;i++)
	{
		t.val[i][i]=1;
	}
	while(y)
	{
		if(y&1)
		{
			t=mul(t,x);
		}
		x=mul(x,x);
		y>>=1;
	}
	return t;
}

void solve()
{
	scanf("%d%d%lld",&h,&w,&k);

	int a=0,b=0,c=0;
	for(int i=1;i<=h;i++)
	{
		scanf("%s",x[i]+1);
		for(int j=1;j<=w;j++)
		{
			a+=(x[i][j]=='#');
		}
	}
	int ud=0,lr=0;
	for(int i=1;i<=h;i++)
	{
		lr+=(x[i][1]=='#'&&x[i][w]=='#');
	}
	for(int i=1;i<=w;i++)
	{
		ud+=(x[1][i]=='#'&&x[h][i]=='#');
	}
	if((lr&&ud)||(k==1))
	{
		puts("1");
		return;
	}
	if(!lr&&!ud)
	{
		ll res = po(a,k-1,mod);
		printf("%lld",res);
		return;
	}
	c=ud+lr;
	if(ud)
	{
		for(int i=1;i<=w;i++)
		{
			for(int j=2;j<=h;j++)
			{
				b+=(x[j][i]=='#'&&x[j-1][i]=='#');
			}
		}
	}
	else
	{
		for(int i=1;i<=h;i++)
		{
			for(int j=2;j<=w;j++)
			{
				b+=(x[i][j]=='#'&&x[i][j-1]=='#');
			}
		}
	}
	ma t;
	t.val[1][1]=a;
	t.val[1][2]=-b;
	t.val[2][1]=0;
	t.val[2][2]=c;
	//cout<<a<<" "<<b<<" "<<c<<endl;
	t=po(t,k-1);
	ll res = ((t.val[1][1]+t.val[1][2])%mod+mod)%mod;
	printf("%lld",res);
}


int main()
{
    solve();
	return 0;
}

Measured memory_bytes: 1280
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let s = read_line().chars().collect::<Vec<_>>();
    let t = read_line().chars().collect::<Vec<_>>();

    let len = s.len();

    for i in 0..len {
        let mut ok = true;

        for j in 0..len {
            if s[(j + i) % len] != t[j] {
                ok = false;
                break;
            }
        }

        if ok {
            println!("Yes");
            return;
        }
    }

    println!("No");
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = f64::from(x).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}

fn bit_high(bits: u64, pos: u64) -> bool {
    bits & (1 << pos) != 0
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

map<ll,ll>a;
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	ll ans=0;
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
        if(itr->second%2!=0){
        	ans++;
        }
    }
    cout << ans;
    // your code goes here
	return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int K;
ll A[200000];
ll count1;

int cal(ll keta, ll val, ll f){
    if(keta==1){
        val += f;
        A[count1++] = val;
        return 0;
    }else{
        val += pow(ll(10),keta-1) * f;
        if(f==0){
            cal(keta-1,val,0);
            cal(keta-1,val,1);
        }else if(f == 9){
            cal(keta-1,val,8);
            cal(keta-1,val,9);
        }else{
            cal(keta-1,val,f-1);
            cal(keta-1,val,f);
            cal(keta-1,val,f+1);
        }
    }
    return 0;
}

int main(void){
    cin >> K;
    for(ll i=1;i<19;i++) {
        for(ll j=1;j<=9;j++){
            int r = cal(i,0,j);
            if (K <= count1) break;
        }
        if (K <= count1) break;
    }
    cout << A[K-1] << endl;
    return 0;
}



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

dA = []
for i in range(1, N):
    dA.append(A[i] - A[i-1])
    if i == N - 1:
        dA.append(A[0] - (A[i] - K))

dA = sorted(dA)
print(sum(dA[:N-1]))

Measured memory_bytes: 25836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, div, total;
  cin >> N;
  
  for(int i = 1;i <= N;i++){
  div = 0;
    if(i % 2 != 0){ 
      for(int j = 1;j <= i;j++){
        if(i % j == 0){
        div++;
        }
      }
      if(div == 8){
      total++;
      }
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  int tmp=n;
  int sum=0;
  while(n){
    int dig=n%10;
    sum+=dig;
    n=n/10;
  }
  if(tmp%sum==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 1000000
using namespace std;
char str1[MAXN+5],str2[MAXN+5];
int L,pos[MAXN+5],s,t;
int que[MAXN+5],que2[MAXN+5];
int main()
{
//	freopen("blank.in","r",stdin);
//	freopen("blank.out","w",stdout);
	scanf("%d %s %s",&L,str1+1,str2+1);
	if(strcmp(str1+1,str2+1)==0)
	{
		printf("0\n");
		return 0;
	}
	for(int i=L,j=L;i>=1&&j>=1;i--)
	{
		while(str2[i]==str2[i-1])
			i--;
		while(j&&(j>i||str1[j]!=str2[i]))
			j--;
		if(j==0)
		{
			printf("-1\n");
			return 0;
		}
		pos[i]=j;
	}
	int del=0,ans=1;
	for(int i=1;i<=L;i++)
	{
		if(pos[i]==0)	continue;
		int p=pos[i];
		while(s<t&&que[s]+del<p)
			s++;
		if(s==t&&pos[i]==i)
		{
			del=0;
			continue;
		}
		del++;
		if(i-2>=1&&str2[i-1]==str2[i-2])
			que[t]=i-del,que2[t++]=2-del;
		ans=max(ans,que2[s]+del);
	}
	printf("%d\n",ans);
	return 0;
}
/*
15
dqvfqxxbuizsxiw
ddqqvfqqxxxxbuu
5
abcde
aaacc
 
*/

Measured memory_bytes: 12800
import java.util.Scanner;

class Main{
  public static void main(String[] arg){
    Scanner scan=new Scanner(System.in);
    String[] alpha={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
    int back=scan.nextInt();
    String in=scan.next();
    String[] sc=in.split("");
    int num=0;
    for(int b=0; b<sc.length; b++){
      for(int a=0;a<alpha.length; a++){
        if(sc[b].equals(alpha[a])){
          num=a;
        }
      }
      if(num+back>=alpha.length){
        num-=alpha.length;
      }
      sc[b]=alpha[num+back];
    }
    for(int a=0; a<sc.length; a++){
      System.out.print(sc[a]);
    }
  }
}

Measured memory_bytes: 29112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
int n = 305,k = 100005;
vector<int> a(n);
vector<bool> win(k);
vector<int> flg(k,0);

bool dfs(int i){
  bool res = false;
  rep(j,n){
    if(i-a.at(j) < 0) break;
    if(flg.at(i-a.at(j)) == 0){
      win.at(i-a.at(j)) = dfs(i-a.at(j));
      flg.at(i-a.at(j)) = 1;
    }
    if(!win.at(i-a.at(j))){
      res = true;
      break;
    }
  }
  return win.at(i) = res;
}
    
    
    
  
 
int main(){
  cin >> n >> k;
  rep(i,n) cin >> a.at(i);
  win.at(0) = 0; flg.at(0) = 1;
  dfs(k);
  if(win.at(k)) cout << "First" << endl;
  else cout << "Second" << endl;
  
  return 0;
}



Measured memory_bytes: 6912
s = input()
while len(s) != 0:
    if s[:5] == "dream":
        # s[5:7]がerであったら分岐
        if s[5:7] == "er":
            # dreameraseの場合 -> dreamとして認識
            if s[5:10] == "erase":
                s = s[5:]
            # dreamerXXXXX(dreamerdream, dreamererase, dreamereraser)の場合 -> dreamerとして認識
            else:
                s = s[7:]
        else:
            s = s[5:]
    elif (s[:5] == "erase")&(s[:6] != "eraser"):
        s = s[5:]
    elif s[:6] == "eraser":
        s = s[6:]
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 133876
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		int c = 0;
		/*
		if(s.charAt(0)==t.charAt(0)){
			c++;
		}
		if(s.charAt(1)==t.charAt(1)){
			c++;
		}
		if(s.charAt(2)==t.charAt(2)){
			c++;
		}
		*/
		
		for (int i=0;i<=2;i++){
			if(s.charAt(i)==t.charAt(i)){
				c++;
			}
		}
		
		System.out.println(c);
		
	}

}


Measured memory_bytes: 21844
import numpy as np

K,A,B = map(int,input().split())

if A+1>=B or K<A+1:
    print(K+1)
else:
    ex = (K-A+1)//2
    res= (K-A+1)%2
    # print(ex)
    # print(res)
    print(A+ex*(B-A)+res)

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

static const int MAX_N = 2000001;
static const u_short MAX_ELEM = 10000;

void countingSort(u_short A[], u_short Bucket[], int k, int size) {

    int Count[k + 1];
    int i, j;

    for (i = 0; i <= k; i++) {
        Count[i] = 0;
    }

    for (j = 0; j < size; j++) {
        Count[A[j]]++;
    }

    for (i = 1; i <= k; i++) {
        Count[i] = Count[i] + Count[i - 1];
    }

    for (j = 0; j < size; j++) {
        Bucket[Count[A[j]]] = A[j];
        Count[A[j]] -= 1;
    }
}

int main() {
    int N, i;

    cin >> N;

    u_short* In = (u_short *)malloc(N * sizeof(short) + 1);
    u_short* Out = (u_short *)malloc(N * sizeof(short) + 1);

    for (i = 0; i < N; i++) {
        cin >> In[i];
    }
    
    countingSort(In, Out, MAX_ELEM, N);

    for (i = 1; i <= N; i++) {
        if (i > 1) {
            cout << " ";
        }
        cout << Out[i];
    }

    cout << endl;

    return 0;
}


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

int n;
char buf[1145141919];

int main() {
  scanf("%d", &n);

  int a = 0;
  int un = 0;
  bool ans = true;
  while (n--) {
    scanf(" %s", buf);
    int k = strlen(buf);
    if (k == 1) a++;
    else un++;

    if (un > a) ans = false;
  }

  if (un != a) ans = false;
  if (ans) puts("YES");
  else puts("NO");
}

Measured memory_bytes: 3160
# coding: utf-8
def main():
    n = int(input())
    s = input()
    r = s.count('R')
    g = s.count('G')
    b = n - r - g
    ans = r * g * b
    for i in range(n):
        for d in range(n):
            j = i + d
            k = j + d
            if k >= n:
                break
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1
    print(ans)    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9116
#include <stdio.h>
#include <algorithm>

long long int N, M;
long long int ans;

int main(void)
{
	scanf("%lld%lld", &N, &M);

	ans = std::min(N, M / 2);
	M -= ans * 2;
	ans += M / 4;

	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if ( a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}


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

struct Edge{
    int from,to,cap,rev;
};
using Graph=vector<vector<Edge>>;
class Flow{
    Graph g;
    vector<int> used;
    int S,T;
    int flow=0;
    const int INF=1e9;
    int bound;
    int dfs(int v,int t,int f){
        used[v]=true;
        if(v==t) return f;
        for(auto &e:g[v]){
            if(used[e.to] || e.cap<=bound) continue;
            int ret=dfs(e.to,t,min(f,e.cap));
            if(ret){
                e.cap-=ret;
                g[e.to][e.rev].cap+=ret;
                return ret;
            }
        }
        return 0;
    }
    int dash(int v,int t,int f){
        int ret=dfs(v,t,f);
        fill(used.begin(),used.end(),false);
        return ret;
    }

    public:
    Flow(int n,int S,int T):g(n),used(n),S(S),T(T){}

    void addEdge(int a,int b){
        g[a].push_back(Edge{a,b,1,(int)g[b].size()});
        g[b].push_back(Edge{b,a,1,(int)g[a].size()-1});
    }

    void removeEdge(int a,int b){
        auto remove=[&](int from,int to){
            bound=1;
            for(auto &e:g[to]){
                if(e.to==from){
                    if(e.cap==2){
                        e.cap=0;
                        g[e.to][e.rev].cap=0;
                        if(dash(from,S,1)==1){
                            dash(T,to,1);
                            flow--;
                        }
                        else{

                            dash(from,to,1);
                        }
                    }
                    else if(e.cap==1){
                        e.cap=0;
                        g[e.to][e.rev].cap=0;
                    }
                }
            }
        };
        remove(a,b);
        remove(b,a);
        
    }

    int maxFlow(){
        bound=0;
        int f;
        while(f=dash(S,T,INF)){
            flow+=f;
        }
        return flow;
    }

};
int main(){
    int n,e,q;
    cin>>n>>e>>q;
    Flow flow(n,0,n-1);
    for(int i=0;i<e;i++){
        int f,t;
        cin>>f>>t;
        f--,t--;
        flow.addEdge(f,t);
    }
    while(q--){
        int m,a,b;
        cin>>m>>a>>b;
        a--,b--;
        if(m==1){
            flow.addEdge(a,b);
        }
        else{
            flow.removeEdge(a,b);
        }
        cout<<flow.maxFlow()<<endl;
    }
    return 0;
}


Measured memory_bytes: 3888
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b});
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

if c%b != 0:
    cb = c//b+1
else:
    cb = c//b
if a%d != 0:
    ad = a//d+1
else:
    ad = a//d

if cb <= ad:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61896
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string a, b, c; cin >> a >> b >> c;
    int diff = 'A' - 'a';

    cout << char(a[0] + diff) << char(b[0] + diff) << char(c[0] + diff) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int main()
{
	ll x;
	cin>>x;
	ll p=x/11,r=x%11,ans=p*2;
	if(r&&r<=6) ans++;
	else if(r) ans+=2;
	cout<<ans<<"\n";
}


Measured memory_bytes: 256
import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
q=collections.deque()
q.append(1)
check=[0]*(n+1)
check[1]=1
ans=[0]*(n+1)
while len(q)!=0:
 v=q.popleft()
 for u in g[v]:
   if check[u]==0:
     check[u]=1
     ans[u]=v
     q.append(u)
print('Yes')
for i in range(2,n+1):
 print(ans[i])

Measured memory_bytes: 34772
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
  int N, count = 1, ans = 0;
  ll a[200000];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < N; i++) {
    if (a[i] == count) {
      count++;
      ans++;
    }
    //cout << a[i] << endl << count << " " << ans << endl;
  }

  if (ans == 0) {
    cout << -1 << endl;
  }
  else {
    cout << N - ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
# 数値を受け取る
train_A = gets.chomp.to_i
train_B = gets.chomp.to_i
bus_A = gets.chomp.to_i
bus_B = gets.chomp.to_i

# if文で大小比較して足す
sum = 0
if train_A > train_B
  sum += train_B
else
  sum += train_A
end

if bus_A > bus_B
  sum += bus_B
else
  sum += bus_A
end

puts sum

Measured memory_bytes: 1788
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }
    let m = s[5].to_digit(10).unwrap() * 10 + s[6].to_digit(10).unwrap();
    if m <= 4 {
        println!("Heisei");
    } else if m > 4 {
        println!("TBD");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e18;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
//ll fac[250001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   ll n,m,i,j,a,b,c=0,r,k=0;
   string s;
   cin>>n>>m;
   vector<pair<ll,ll> >v;
   unordered_map<ll,ll>mp;
   for(i=1;i<=m;i++)
   {
       cin>>r;
       cin>>s;
       if(s=="AC")
       v.pb({r,1});
       else
       v.pb({r,0});
   }
   for(i=0;i<v.size();i++)
   {
       if(v[i].ss==1)
       {
           if(mp[v[i].ff]==0)
            c++,mp[v[i].ff]=i+1;
       }
   }
   for(i=0;i<v.size();i++)
   {
       if(v[i].ss==0)
       {
           if(mp[v[i].ff]!=0 && mp[v[i].ff]>i+1)
            k++;
       }
   }
   cout<<c<<" "<<k<<endl;
}


Measured memory_bytes: 5872
#include <iostream>
#include <algorithm>
#include <string>

std::string strArr[105];
int count[105];
int n, m;

int findString(std::string str)
{
	for (int i = 0; i < n; i++)
	{
		if (strArr[i] == str)
			return i;
	}
	return -1;
}
int main()
{
	std::cin >> n;
	int ind = 0;
	for (int i = 0; i < n; i++)
	{
		std::string t;
		std::cin >> t;
		if (findString(t) == -1)
		{
			count[ind] = 1;
			strArr[ind++] = t;
		}
		else
			count[findString(t)]++;
	}
	std::cin >> m;
	for (int i = 0; i < m; i++)
	{
		std::string t;
		std::cin >> t;
		if (findString(t) == -1)
			;
		else
			count[findString(t)]--;
	}
	int max = count[0];
	for (int i = 0; i < n; i++)
	{
		if (count[i] > max)
			max = count[i];
	}
	std::cout << ((max > 0) ? max : 0);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for i in range(n):
    if(b[i] > a[i]):
        ans += a[i]
        tmp = b[i] - a[i]
        if(tmp < a[i+1]):
            ans += tmp
            a[i+1] = a[i+1] - tmp
        else:
            ans += a[i+1]
            a[i+1] = 0
    else:
        ans += b[i]

print(ans)


Measured memory_bytes: 18476
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String strA = sc.next();
        String strB = sc.next();

        BigDecimal A = new BigDecimal(strA);
        BigDecimal B = new BigDecimal(strB);

        BigDecimal result = A.multiply(B).setScale(0, RoundingMode.DOWN);

        System.out.println(result);
    }
}

Measured memory_bytes: 35944
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
int h,w;
cin>>h>>w;
string s[h];
rep(i,0,h)
cin>>s[i];
int cnt=0;
if(s[0][0]=='#')
cnt++;

int dp[h+1][w+1];

memset(dp,0,sizeof(dp));
if(s[0][0]=='#')
dp[1][1]=1;
for(int i=1;i<=h;i++)
{
	for(int j=1;j<=w;j++)
	{
		if(i==1&&j==1)
		continue;
		int x=INT_MAX-1,y=INT_MAX-1;
		if(i>1)
	 {
	   x=dp[i-1][j];
		 if(s[i-2][j-1]=='.'&&s[i-1][j-1]=='#')
		 x++;
	}
	if(j>1)
	{
		y=dp[i][j-1];
		if(s[i-1][j-2]=='.'&&s[i-1][j-1]=='#')
		y++;
	}
	dp[i][j]=min(x,y);

}



}
cout<<dp[h][w];}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[200010], factinv[200010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,200010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    while(t--)
        solve();
} 

void solve()            
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double ans,angle,x,y;
    x=2.00*pi*(h/12.0 +m/720.0);
    y=2.00*pi*(m/60.0);
    angle=fabs(x-y);
    ans=sqrt(a*a+b*b-2*a*b*cos(angle));
    cout << fixed << setprecision(15) << ans;
}

Measured memory_bytes: 4120
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;

int main() {
	long int n;
	cin >> n;
	vector<string> s(n);
	
	for (int i = 0; i < n; i++) {
		vector<char> c(10);
		for (int j = 0; j < 10; j++) {
			cin >> c[j];
		}
		sort(c.begin(), c.end());
		string hoge(c.begin(), c.end());
		s[i] = hoge;
	}
	
	sort(s.begin(),s.end());

	long int num = 0;
	int i = 0;
	while(i<n) {
		long int a = 1;
		for(int j=i+1;j<n;j++){
			if (s[i] != s[j]) {
				break;
			}
			a++;
		}
		num += a * (a - 1) / 2;
		i += a;
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll h, n;
  cin >> h >> n;
  ll sum = 0;
  rep(i,n){
    ll a = 0;
    cin >> a;
    sum+=a;
  }
  if(sum<h)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main() {
  int N, W;
  cin >> N >> W;
  vector<vector<i64>> dp(N + 1, vector<i64>(W + 1, -1e18));
  dp[0] = vector<i64>(W + 1, 0);
  for(int i = 1;i <= N;i++) {
    i64 v, w;
    cin >> v >> w;
    for(int j = 0;j <= W;j++) {
      dp[i][j] = dp[i - 1][j];
      if(j - w >= 0) {
        dp[i][j] = max(dp[i][j], dp[i][j - w] + v);
      }
    }
  }

  cout << dp[N][W] << endl;
}



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

int main() {
  int H,W,N;
  cin >> H>>W;
  N=H*W;
 vector<string> vec(H);
for (int i = 0; i < H; i++) { cin >> vec.at(i);}
  for (int i = 0; i < W+2; i++){  cout <<"#";}
  cout <<endl;
  
  for (int i = 0; i < H; i++) { 
     cout <<"#"<<vec.at(i)<<"#"<<endl;
  
  }
   for (int i = 0; i < W+2; i++){  cout <<"#";}
  cout <<endl;
}  


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;
int kur(int n, int k)
{
	return (n - 1) / k + 1;
}
int main(void)
{
	int n, k, a[100001], min = 0;
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	sort(a, a+n);
	while(min < n && a[min] == a[0]) min++;
	cout << kur(n - min, k - 1) << endl;
	return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp[110][110][330];
void solve() {
    ll n, q;
    cin >> n >> q;
    vec<tuple<ll, ll, ll>> xst(n);
    REP(i, n) {
        ll x, s, t;
        cin >> s >> t >> x;
        xst[i] = {x, s, t};
    }

    set<P> d;
    REP(i, q) {
        ll dd;
        cin >> dd;
        d.insert({dd, i});
    }

    sort(all(xst));
    Array ans(q, -1);
    REP(i, n) {
        auto [x, s, t] = xst[i];
        auto ss = d.lower_bound({s - x, 0});
        auto tt = d.lower_bound({t - x, 0});
        while(ss != tt) {
            auto [dd, i] = *ss;
            ans[i] = x;
            ss = d.erase(ss);
        }
    }

    REP(i, q) {
        cout << ans[i] << en;
    }
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 21948
import math

l=list(map(int, input().split(' ')))
a=l[0]
b=l[1]
h=l[2]
m=l[3]
hours = (h+m/60)/12
minutes = m/60
theta = 2*math.pi*(hours-minutes)
ans = a**2+b**2-2*a*b*math.cos(theta)
print(ans**0.5)


Measured memory_bytes: 9512
X=int(input())
b=0
if(X>=400 and X<=599):
    b=8
elif(X>=600 and X<=799):
    b=7
elif(X>=800 and X<=999):
    b=6
elif(X>=1000and X<=1199):
    b=5
elif(X>=1200and X<=1399):
    b=4
elif(X>=1400and X<=1599):
    b=3   
elif(X>=1500and X<=1799):
    b=2
elif(X>=1800and X<=1999):
    b=1
print(b)




Measured memory_bytes: 9052
#include <iostream>
#include <stack>
using namespace std;
int main() {
  int n;
  stack<int> st;
  while(cin >> n) {
    if(n == 0) {
      cout << st.top() << endl;
      st.pop();
    }
    else {
      st.push(n);
    }
  }
  return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    string s; cin>>s;
    vector<int> red(n,0), white(n,0);
    rep(i,n){
        if(s[i]=='W'){
            white[i]=1;
        }else{
            red[i]=1;
        }
    }
    rep(i,n-1){
        white[i+1]=white[i+1]+white[i];
        red[n-2-i]=red[n-1-i]+red[n-2-i];
    }
    int ans=0;
    rep(i,n){
        if(white[i]>=red[i]){
            ans=min(white[i],red[i]);
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5112
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, m; cin >> n >> m;
	vector<vector<int>> edg(n);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		edg[a].push_back(b);
	}
	vector<int> par(n, -1), used(n);
	deque<int> que;
	set<int> ans, buf;
	for (int st = 0; st < n; st++) {
		for (int i = 0; i < n; i++) par[i] = -1, used[i] = 0;

		que.clear();
		que.push_back(st);
		used[st] = true;
		while (!que.empty()) {
			int pos = que.front();
			que.pop_front();

			bool flag = false;
			for (int c : edg[pos]) {
				if (used[c]) {
					if (c == st) {
						while (pos != st) {
							buf.insert(pos);
							pos = par[pos];
						}
						buf.insert(st);
						flag = true;
						break;
					}
					continue;
				}
				used[c] = true;
				que.push_back(c);
				if (par[c] == -1) par[c] = pos;
			}
			if (flag) break;
		}
		if (buf.size() > 0 && (ans.size() == 0 || ans.size() > buf.size())) swap(ans, buf);
		buf.clear();
	}
	if (ans.size() == 0) cout << -1 << endl;
	else {
		cout << ans.size() << endl;
		for (int a : ans) cout << a + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;


int main() {

    int N;
    cin >> N;

    vector<pair<int, int>> vs;

    for (int i = 0; i < N; ++i) {
        int D1, D2;
        cin >> D1 >> D2;
        vs.push_back(make_pair(D1, D2));
    }
    bool ok = false;
    for (int i = 0; i < N - 2; ++i) {
        if (vs[i].first == vs[i].second
            and vs[i + 1].first == vs[i + 1].second
            and vs[i + 2].first == vs[i + 2].second) {
            ok = true;
            break;
        }
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;

}

Measured memory_bytes: 3628