akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> bool chmin(T &target, const T &value){
  if( target > value ){
    target = value;
    return true;
  }
  return false;
}


const long long INF = 1e18;


vector<int> g[5050];

vector<ll> A;
vector<ll> dp0[5050];
vector<ll> dp1[5050];

vector<ll> merge(const vector<ll> &dp, const vector<ll> &op0, const vector<ll> &op1, bool source_only){
  vector<ll> res(dp.size() + op0.size(), INF);
  for(int i = 0 ; i < dp.size() ; i++){
    for(int j = 0 ; j < op0.size() ; j++){
      if( !source_only ) chmin(res[i+j], op0[j] + dp[i]);
      chmin(res[i+j], op1[j] + dp[i]);
      if( op0[j] < 0 ) chmin(res[i+j+1], dp[i]);
      if( op1[j] != INF) chmin(res[i+j+1], dp[i]);
    }
  }
  return move(res);
}

void dfs(int root, int parent){
  dp0[root] = vector<ll>(1, A[root]);
  dp1[root] = vector<ll>(1, A[root] > 0 ? A[root] : INF);

  for( auto i : g[root]){
    if( parent == i ) continue;
    dfs(i, root);
    dp0[root] = merge(dp0[root], dp0[i], dp1[i], false);
    dp1[root] = merge(dp1[root], dp0[i], dp1[i], true);
  }
//  cout << "==" << " " << root << " " << "==" << endl;
//  for(int i = 0 ; i < dp0[root].size() ; i++){
//    cout << i << ": " << dp0[root][i] << " " << dp1[root][i] << endl;
//  }

}

void add_edge(int a,int b){
  g[a].push_back(b);
  g[b].push_back(a);
}


void solve(long long N, vector<long long> A, vector<long long> U,
           vector<long long> V) {
  ::A = A;

  for(int i = 0 ; i < N - 1 ; i++){
    add_edge(U[i]-1, V[i]-1);
  }
  dfs(0, -1);

  for(int i = 0 ; i < dp0[0].size() ; i++){
    if( dp0[0][i] < 0 || dp1[0][i] != INF ){
      cout << i << endl;
      return;
    }
  }




}




int main() {

  long long N;
  scanf("%lld", &N);
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  vector<long long> U(N - 1);
  vector<long long> V(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &U[i]);
    scanf("%lld", &V[i]);
  }
  solve(N, A, U, V);
  return 0;
}


Measured memory_bytes: 164224
# -*- coding: utf-8 -*-
#abc146_a
import sys
import math
import collections
#sys.setrecursionlimit(100000)

#m=int(input())

#tmp = input().split()
#d,c = list(map(lambda a: int(a), tmp))

s=input()

if(s=="SUN"):
	print(7)
if(s=="MON"):
	print(6)
if(s=="TUE"):
	print(5)
if(s=="WED"):
	print(4)
if(s=="THU"):
	print(3)
if(s=="FRI"):
	print(2)
if(s=="SAT"):
	print(1)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.length();
  rep(i, s.length()) {
    int c = s[i] - 'a';
    if (c == 0) continue;
    if (26 - c <= k) {
      k -= 26 - c;
      s[i] = 'a';
    }
  }
  int c = s[n - 1] - 'a';
  (c += k) %= 26;
  s[n - 1] = 'a' + c;
  cout << s << endl;
}

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

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

int main() {
    int n; cin >> n;
    vector<int> a(n);

    rep(i, n)
        cin >> a.at(i);
    
    int odd = 0;
    rep(i, n) {
        if (a.at(i) % 2)
            odd++;
    }

    cout << ((odd % 2) ? "NO" : "YES") << endl;
}

Measured memory_bytes: 640
while True :
    H,W = map(int, input().split())
    if H == 0 and W == 0 : break
    for i in range(H):
        for j in range(W):
            if i == 0 or i == H-1 : print('#',end = "")
            elif j == 0 or j == W-1 : print('#',end = "")
            else : print('.',end = "")
        print()
    print()



Measured memory_bytes: 7000
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;



int main(int argc, char* argv[])
{
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int x;
  cin >> x;
  if (x == 7 || x == 5 || x == 3) cout << "YES\n";
  else cout << "NO\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define debug(a) cout<<a<<endl
#define pii pair<ll,ll>
#define maxn 100009
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll vet[maxn];
    for(int i=0;i<n;i++){
        cin>>vet[i];
    }
    sort(vet,vet+n);
    vector<pii> op; // num qtd
    for(int i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        op.push_back({b,a});
    }
    sort(op.begin(),op.end());
    reverse(op.begin(),op.end());
    ll pos=0;
    for(int i=0;i<m;i++){
        int cont=0;
        for(int j=pos;j<n;j++){
            if(vet[j]<op[i].first && cont<op[i].second){
                vet[j]=op[i].first;
                cont++;
            }
            else{
                pos=j;
                break;
            } 
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=vet[i];
    }
    cout<<ans<<endl;
    return 0;
}
///usar double sempre ou long double
///pensar em casos que coisas dao negativas
///N esquecer de limpar as coisas em quest de varios testes
///OLHAR A COMPLEXIDADE PRA VER SE N PASSA POR BRUTE FORCE OU BRUTE FORCE COM ALGUMAS OTIMIZACOES

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

int main() {
  string S;
  cin >> S;
  
  int count0 = 0;
  int count1 = 0;
  
  for (int i=0; i<S.size(); i++) {
    if (S[i] == '0') count0++;
    else count1++;
  }
  
  if (count0 < count1) cout << count0*2 << endl;
  else cout << count1*2 << endl;
  
  
}

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

const int N=2005,P=924844033;
int n,k,f[N],tot,dp[2*N][N][2],s[2*N];
bool vis[2*N],ed[2*N];

int power(int a,int x)
{
	int ans=1;
	for(;x;x>>=1,a=1ll*a*a%P)
		if(x&1)ans=1ll*ans*a%P;
	return ans;
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=f[0]=1;i<=n;i++)f[i]=1ll*f[i-1]*i%P;
	for(int i=1;i<=n;i++)
		for(int j=0;j<2;j++)
			if(!vis[2*i+j])
			{
				vis[2*i+j]=true;
				s[++tot]=2*i+j;
				for(int x=i+k,y=j^1;x<=n;x+=k,y^=1)s[++tot]=2*x+y,vis[2*x+y]=true;
				ed[tot]=true;
			}
	dp[1][0][0]=1;
	for(int i=1;i<tot;i++)
		for(int j=0;j<=n;j++)
		{
			dp[i+1][j][0]=(dp[i][j][0]+dp[i][j][1])%P;
			if(j<=n&&!ed[i])dp[i+1][j+1][1]=dp[i][j][0];
		}
	int ans=0;
	for(int i=0,t=1;i<=n;i++,t*=-1)
		ans=(ans+1ll*t*f[n-i]*(dp[tot][i][0]+dp[tot][i][1]))%P;
	printf("%d\n",(ans+P)%P);
	return 0;
}


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

int gcd(int a, int b){
    if(a < b) swap(a, b);
    int d, r;
    r = a % b;
    return (r > 0 ? gcd(b, r) : b);
}

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

    int n, x;
    cin >> n >> x;
    vector<int> A(n + 1);
    REP(i, n) cin >> A[i];
    A[n] = x;
    sort(A.begin(), A.end());

    int g = A[1] - A[0];
    for(int i = 1; i < n; i++){
        g = gcd(g, A[i + 1] - A[i]);
    }

    cout << g << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n,k;cin>>n>>k;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    vector<ll> a(n+1,0),inva(n+1,0);
    rep(i,n)a[i+1]=a[i]+v[i];
    auto iv=v;
    reverse(iv.begin(),iv.end());
    rep(i,n)inva[i+1]=inva[i]+iv[i];
    ll res=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=min(i,n);j++){//取り出す作業を何回行うか
            for(int l=0;l<=j;l++){//左から何回取り出すか
                ll tmp=0;
                tmp+=a[l];
                int r=j-l;
                tmp+=inva[r];
                int buf=i-j;
                priority_queue<ll, vector<ll>, greater<ll> > que;
                rep(x,l)que.push(v[x]);
                rep(x,r)que.push(iv[x]);
                rep(x,buf){
                    if(que.size()==0)break;
                    tmp-=que.top();que.pop();
                }
                chmax(res,tmp);
            }
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
struct BIT
{
    int n;
    vector<T> bit;
    // 1-indexed
    BIT(int n_) : n(n_ + 1), bit(n + 1, 0) {}

    T sum(int i)
    {
        T s(0);
        for (int x = i; x > 0; x -= (x & -x))
            s += bit[x];
        return s;
    }

    void add(int i, T a)
    {
        if (i == 0)
            return;
        for (int x = i; x <= n; x += (x & -x))
            bit[x] += a;
    }

    // [l, r)
    T query(int l, int r)
    {
        return sum(r - 1) - sum(l - 1);
    }

    int lower_bound(int w)
    {
        if (w <= 0)
            return 0;
        int x = 0, r = 1;
        while (r < n)
            r <<= 1;
        for (int k = r; k > 0; k >>= 1)
        {
            if (x + k <= n && bit[x + k] < w)
            {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }

    // 0-indexed
    T sum0(int i) { return sum(i + 1); }
    void add0(int i, T a) { add(i + 1, a); }
    T query0(int l, int r) { return sum(r) - sum(l); }
};

int main()
{
    ll n, q;
    cin >> n >> q;
    vector<ll> C(n);
    for (int i = 0; i < n; i++)
        cin >> C[i];
    BIT<ll> bit(n);
    vector<vector<ll>> RL(q, vector<ll>(3));
    for (int i = 0; i < q; i++)
    {
        ll r, l;
        cin >> l >> r;
        r--;
        l--;
        RL[i] = {r, l, i};
    }
    sort(RL.begin(), RL.end());
    vector<ll> last(n, -1), ans(q, 0);
    ll now = -1;
    for (int i = 0; i < q; i++)
    {
        ll r, l, j;
        r = RL[i][0];
        l = RL[i][1];
        j = RL[i][2];
        while (now < r)
        {
            now++;
            ll c = C[now];
            c--;
            if (last[c] == -1)
            {
                bit.add0(now, 1);
            }
            else
            {
                bit.add0(last[c], -1);
                bit.add0(now, 1);
            }
            last[c] = now;
        }
        ans[j] = bit.query0(l, r + 1);
    }
    for (int i = 0; i < q; i++)
        cout << ans[i] << endl;
}


Measured memory_bytes: 46728
import math
A, B, H, M = map(int, input().split())
Short = (H * (360/12)) + M * 1/2
Long = M * (360/60)
angle = abs(Long - Short)
Angle = min(angle, (360 - angle))
print((A**2 + B**2 -2*A*B*math.cos(math.radians(Angle)))**0.5)

Measured memory_bytes: 9516
using System;

class Plogram
{
    static void Main()
    {
        var line = Console.ReadLine().Split();

        int A = int.Parse(line[0]);
        int B = int.Parse(line[1]);
        int C = int.Parse(line[2]);

        int max = Math.Max(Math.Max(A, B),C)*9;
        int sum = max + A + B + C;

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13140
local mfl = math.floor
local ns = io.read()
local k = io.read("*n")
if k == 1 then
  local a = tonumber(ns:sub(1, 1))
  print(a + 9 * (#ns - 1))
elseif k == 2 then
  if #ns == 1 or ns == "10" then print(0)
  else
    local a = tonumber(ns:sub(1, 1))
    local b, bpos = 0, #ns + 1
    for i = 2, #ns do
      if ns:sub(i, i) ~= "0" then
        b, bpos = tonumber(ns:sub(i, i)), i
        break
      end
    end
    -- use 1st but not max
    local ret = (#ns - 1) * 9 * (a - 1)
    -- don't use 1st
    ret = ret + 81 * mfl((#ns - 1) * (#ns - 2) / 2)
    -- use 1st by max
    if bpos <= #ns then
      ret = ret + b + 9 * (#ns - bpos)
    end
    print(ret)
  end
else
  if #ns < 3 then print(0)
  else
    local a = tonumber(ns:sub(1, 1))
    local b, bpos = 0, #ns + 1
    for i = 2, #ns do
      if ns:sub(i, i) ~= "0" then
        b, bpos = tonumber(ns:sub(i, i)), i
        break
      end
    end
    local c, cpos = 0, #ns + 1
    for i = bpos + 1, #ns do
      if ns:sub(i, i) ~= "0" then
        c, cpos = tonumber(ns:sub(i, i)), i
        break
      end
    end
    -- don't use 1st
    ret = 729 * mfl((#ns - 1) * (#ns - 2) * (#ns - 3) / 6)
    -- use 1st but not max
    ret = ret + (a - 1) * 81 * mfl((#ns - 1) * (#ns - 2) / 2)
    -- use 1st by max
    if bpos <= #ns - 1 then
      -- don't use second
      ret = ret + 81 * mfl((#ns - bpos) * (#ns - bpos - 1) / 2)
      -- use 2nd but not max
      ret = ret + (b - 1) * 9 * (#ns - bpos)
      -- use 2nd by max
      if cpos <= #ns then
        ret = ret + c + 9 * (#ns - cpos)
      end
    end
    print(ret)
  end
end


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int V,E,R,S[500010], T[500010], D[500010];
int C[100010];
const int Inf = 10000*100000+100;

int main(){
    cin >> V >> E >> R;
    for (int i=0; i<E; ++i)
        cin >> S[i] >> T[i] >> D[i];
    for(int i=0;i<V;i++){
        C[i] = Inf;
    }
    C[R] = 0;
    for (int t=0; t<V; ++t) {
        bool update = false;
        for (int i=0; i<E; ++i) {
            int s = S[i], t = T[i], d = D[i];
            if (C[s] < Inf && C[t] > C[s]+d) {
                C[t] = C[s]+d;
                update = true;
            }
        }
        if (!update) break;
    }
    for(int i=0;i<V;i++){
        if(C[i]!=Inf)
            cout << C[i] << endl;
        else
            cout << "INF" << endl;
    }
}

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

int main() {
	map<string, int> ma;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string tmp;
		cin >> tmp;
		ma[tmp]++;
	}
	int M;
	cin >> M;
	for (int i = 0; i < M; i++) {
		string tmp;
		cin >> tmp;
		ma[tmp]--;
	}
	int ans = 0;
	for (auto x : ma) {
		if (ans < x.second) {
			ans = x.second;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
// Aizu Vol0 0033: Ball
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

#define MAX 10

int main()
{
	int ball[MAX+5];
	int i, n, j;
	int b, c;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < MAX; j++) scanf("%d", &ball[j]);
		b = c = 0;
		for (j = 0; ; j++) {
			if (j == MAX) {
				puts("YES");
				break;
			}
			if (ball[j] > b) b = ball[j];
			else if (ball[j] > c) c = ball[j];
			else {
				puts("NO");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int main (){
	int n;
	cin>>n;
	tint res=0;
	int P=1;
	forn(i, n){
		tint A;
		cin>>A;
		if(i==0){
			res+=(A-1);
			P=2;
			continue;
		}
		if(A==P){
			P++;
			continue;
		}
		if(A>P){
			tint compro=A/P;
			if(A%P==0){
				compro--;
			}
			res+=compro;
		}
	}
	cout<<res<<endl;
}


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

using ll = int64_t;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	string s; std::cin >> s;
	int len = s.size();
	ll cur = 0, ans = 0;
	rep(i, len) {
		if (s[i] == '>') {
			ll cnt = 0;
			while (i < len && s[i] == '>')
				cnt++, i++;
			if (cur < cnt)
				ans += cnt - cur;
			cnt--, i--;
			ans += (cnt + 1) * cnt / 2;
			cur = 0;
		} else {
			cur++;
			ans += cur;
		}
	}
	std::cout << ans << "\n";
}


Measured memory_bytes: 1172
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
     string a,b,c;
     cin>>a>>b>>c;
     cout<<a[0]<<b[0]<<c[0]<< "\n";
    return 0;
}



Measured memory_bytes: 256
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 1e5 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent

struct Vacation {
	int Swim, bugs, homework;
};
int n;
vector<Vacation> v;
//int mem[N][4];
int dp[N][4];
/*int solve(int idx = 0, int prev = 0)
{
	if (idx == n)
		return 0;
	int& ret = mem[idx][prev];
	if (~ret)return ret;
	ret = 0;
	if (prev != 1)
		ret = max(ret, solve(idx + 1, 1) + v[idx].Swim);
	if (prev != 2)
		ret = max(ret, solve(idx + 1, 2) + v[idx].bugs);
	if (prev != 3)
		ret = max(ret, solve(idx + 1, 3) + v[idx].homework);

	return ret;
}*/
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	//clr(mem, -1);
	cin >> n;
	v = vector<Vacation>(n);
	for (int i = 0; i < n; i++)
		cin >> v[i].Swim >> v[i].bugs >> v[i].homework;
	//cout << solve() << endl;

	//baseCase
	dp[n][1] = dp[n][2] = dp[n][3] = 0;


	for (int idx = n-1; idx >=0; idx--) {
		int& ret1 = dp[idx][1];
		int& ret2 = dp[idx][2];
		int& ret3 = dp[idx][3];
		ret1 = ret2 = ret2 = 0;;

		ret1 = max(ret1, dp[idx + 1][2] + v[idx].Swim);
		ret1 = max(ret1, dp[idx + 1][3] + v[idx].Swim);

		ret2 = max(ret2, dp[idx + 1][1] + v[idx].bugs);
		ret2 = max(ret2, dp[idx + 1][3] + v[idx].bugs);

		ret3 = max(ret3, dp[idx + 1][1] + v[idx].homework);
		ret3 = max(ret3, dp[idx + 1][2] + v[idx].homework);

	}

	cout << max({ dp[0][1],dp[0][2],dp[0][3] }) << endl;
}


Measured memory_bytes: 5824
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int N = int.Parse(Console.ReadLine());
		
      	// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
      	int[] H = new int[N];
      	for (int i = 0;i<N;i++){
          H[i] = int.Parse(input[i]); 
        }
		//int A = int.Parse(input[0]);
		//int B = int.Parse(input[1]);
		// 文字列の入力
		//string s = Console.ReadLine();
		//出力
      	int anser = 0;
      	int count = 0;
      	int nowH = H[0];
      	for(int i = 1;i< N ;i++){
          if ( nowH >= H[i]){
            count++;
          }else{
          	count = 0;
          }
          if ( count>anser){
            anser = count;
          }
          nowH = H[i];
        }
		Console.WriteLine(anser);
	}
}


Measured memory_bytes: 27100
import math
from sys import stdin
input = stdin.readline

n = int(input())
s = [int(input()) for _ in range(n)]

sorted_s=sorted(s)
sum_a=sum(s)
not_ans=0
if sum_a%10==0:
    for i in range(n):
        if sorted_s[i]%10!=0:
            print(sum_a-sorted_s[i])
            exit()
        else:
            continue
    print(0)
else:
    print(sum_a)

Measured memory_bytes: 38256
from collections import defaultdict
n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
d = defaultdict(int)

for i in range(1,n+1):
    prime = prime_factorize(i)
    for p in prime:
        d[p] += 1

#5*5*3
#15*5
#25*3
#75

over4 = 0
over2 = 0
over14 = 0
over24 = 0
over74 = 0
for dd in d.values():
    if dd >= 4:
        over4 += 1
    if dd >= 2:
        over2 += 1
    if dd >= 14:
        over14 += 1
    if dd >= 24:
        over24 += 1
    if dd >= 74:
        over74 += 1

i1 = over74
i2 = over24 * (over2 - 1)
i3 = over14 * (over4 - 1)
i4 = over4 * (over4 - 1) * (over2-2) // 2
print(i1+i2+i3+i4)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
int main(void){
    string s;
    bool sw=true;
    int ans=0,nt=0;
    cin>>s;
    vector<int> a(s.size()),b(s.size()),d(s.size());
    rep(i,s.size()){
        char c=s[i];
        if(i==0)a[i]=max(nt,0);
        else a[i]=max(nt,a[i-1]);
        if(c=='/'){
            nt++;
        }
        else if(c=='_'){
            
        }
        else{
            nt--;
        }
        //cout<<nt+5;
    }
    //cout<<endl;
    rep(i,s.size()){
        int j=s.size()-i-1;
        char c=s[j];
        if(i==0)b[j]=nt;
        else b[j]=max(nt,b[j+1]);
        if(c=='\\'){
            nt++;
            if(i==0)b[j]=nt;
            //if(sw)b[j]=-5000000;
        }
        else if(c=='_'){
            //if(sw)b[j]=-5000000;
        }
        else{
            sw=false;
            nt--;
        }
    }
    rep(i,s.size()){
        d[i]=min(a[i],b[i]);
    }
        rep(i,s.size()){
        //cout<<d[i]+5;
    }
    // cout<<endl;
    //     rep(i,s.size()){
    //     cout<<b[i]+5;
    // }
    // cout<<endl;
    // rep(i,s.size()){
    //     cout<<d[i]+5;
    // }
    // cout<<endl;
    rep(i,s.size()){
        //cout<<d[i];
    }
    //cout<<endl;
    vi e,f;e.push_back(0);
    rep(i,s.size()){
        char c=s[i];
        if(c=='/'){
            nt++;
            if(nt<=d[i]){
                ans+=((d[i]-nt)*2+1);
                sw=true;
            }
        }
        else if(c=='_'){
            ans+=2*(d[i]-nt);
            if(nt<d[i])sw=true;
        }
        else{
            nt--;
            if(nt<d[i]){
                ans+=(d[i]-nt)*2-1;
                sw=true;
            }
        }
        //cout<<ans;
        if(nt==d[i]&&sw){
            //cout<<"!"<<i<< " "<<ans<<"?";
            e.push_back(ans);
            sw=false;
        }
        // e.push_back(ans/2);
    }
    cout<<ans/2<<endl;
    if(ans/2){
        cout<<e.size()-1<<" ";
        rep(i,e.size()-1){
            cout<<(e[i+1]-e[i])/2<<(e.size()-2!=i?" ":"");
        }
    }
    else cout<<0;
    cout<<endl;
    
}






Measured memory_bytes: 3400
#include<iostream>
  #include<math.h>
  using namespace std;
  int main()
  {
    long x,y;
    cin>>x>>y;
    long ans;
    if(x % y == 0) ans = -1;
    else ans = x * (y - 1);
    cout<<ans<<endl;
    return 0;
  }


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

using namespace std;

int main(){
    vector<int> A(4);
    copy_n(istream_iterator<int>(cin), 4, A.begin());
    sort(A.begin(), A.end());
    cout << min(abs(A[0] + A[1] - A[2] - A[3]), abs(A[0] + A[3] - A[1] - A[2])) << endl;
}


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


int main(){
  int N;
  cin >> N;
  int a = N;
  int sum = 0;
  while(N){
    int num = N % 10;
    sum += num;
    N /= 10;

  }

  if(a % sum == 0){ cout << "Yes"; }
  else{ cout << "No"; }
 return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
struct ToUpper {
    char operator()(char c) { return toupper(c); }
};
struct ToLower {
    char operator()(char c) { return tolower(c); }
};
const int N=200010;
const int P=1000000007;
using ll = long long;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/

/*
	char s[N];
	strlen(s)
*/

/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/

/*添字1がa個、2がb個
  vector<vector<ll>> map(a,vector<ll>(b));
*/

int main(){
	ll x,n;
  cin>>x>>n;
  if(x*2<=n&&x*4>=n&&n%2==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

int N, A, B;

int main() {
    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
}


Measured memory_bytes: 256
// 126-B
// YYMM or MMYY

#include<iostream>
using namespace std;

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

    int L = S / 100;
    int R = S % 100;

    if (1 <= L && L <= 12)
    {
        if (1 <= R && R <= 12)
        {
            cout << "AMBIGUOUS" << endl;
        }
        else
        {
            cout << "MMYY" << endl;     
        }
    }
    else
    {
        if (1 <= R && R <= 12)
        {
            cout << "YYMM" << endl;
        }
        else
        {
            cout << "NA" << endl;
        }
        
    }
    
}

Measured memory_bytes: 888
import java.util.*

fun main() {
    fun readIntList():List<Int>{return readLine()!!.split(" ").map { it.toInt() }}
    val (n,q)=readIntList()
    var g:MutableList<MutableSet<Int>> = MutableList(n+1){ mutableSetOf<Int>()}
    var ans: MutableList<Int> = MutableList(n+1){0}


    for (i in 1 until n){
        var (a,b)=readIntList()
        g[a].add(b)
        g[b].add(a)
    }
    for (i in 0 until q){
        var (p,x)=readIntList()
        ans[p]+=x
    }
    fun exe(g: MutableList<MutableSet<Int>>, i:Int, done: MutableSet<Int>, ans: MutableList<Int>, que: ArrayDeque<Int>){
        done.add(i)
        for (j in g[i]){
            if (!done.contains(j)){
                ans[j]+=ans[i]
                que.push(j)
            }
        }
    }
    var done: MutableSet<Int> = mutableSetOf(0)
    var que=ArrayDeque<Int>()
    que.push(1)
    while (!que.isEmpty()){
        exe(g,que.pop(),done, ans, que)
    }
    println(ans.slice(1 until ans.size).joinToString(" "))
}

Measured memory_bytes: 161100
N,M=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
P=10**9+7
X=0
Y=0
for i in range(1,N+1):
  X+=x[i-1]*(2*i-1-N)
  X=X%P
for j in range(1,M+1):
  Y+=y[j-1]*(2*j-1-M)
  Y=Y%P
print((X*Y)%P)


Measured memory_bytes: 19472
n,k=map(int,input().split())
hlist=list(map(int,input().split()))
 
mins=[0]
 
for i in range(1,n):
	if i == 1:
		mins.append(abs(hlist[1]-hlist[0]))
		continue
	
	tmplist=[]
	tmp=hlist[i]
	for j in range(min(k,i)):
		tmplist.append(mins[i-j-1]+abs(tmp-hlist[i-j-1]))
	mins.append(min(tmplist))
 
print(mins[n-1])

Measured memory_bytes: 58208
#include <bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long int ll;
int num[N];
int ans[N];
int main(){
    std::ios::sync_with_stdio(false);
	cin.tie(0);
    int n, tmp;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>tmp;
        num[tmp]++;
    }
    for(int i=1;i<=100000;++i){
        ans[i] = num[i-1] + num[i] + num[i+1];
    }
    int m = ans[1];
    for(int i=1;i<=100000;++i){
        m = max(m, ans[i]);
    }
    cout << m << '\n';

	return 0;
}


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

int main()
{
	char a, b;

	cin >> a;

	if ('a' <= a && a <= 'z') {
		cout << 'a';
	}
	else if ('A' <= a && a <= 'Z') {
		cout << 'A';
	}

	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
 char num[1010];
 int a;
 while(1){
     scanf("%s", &num);
     if(num[0]=='0')
     break;
     else{
       //   printf("%lld\n", num);
     int sum = 0;
     for(int i=0; i<strlen(num); i++){
         sum+=num[i]-'0';//i桁目の文字を数字に変換
     }
     printf("%d\n", sum);
     }

 }
 return 0;

}


Measured memory_bytes: 2064
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
using namespace std;

bool m[2010][2010];
int *l1[2010][2010];
int *l2[2010][2010];
int ll1[4000000];
int ll2[4000000];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        for(int j = 0; j < w; j++){
            m[i][j] = (s[j] == '#');
        }
    }
    int ll1p = 0;
    int ll2p = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(m[i][j]){
                l1[i][j] = NULL;
                ll1p++;
            }else{
                l1[i][j] = &ll1[ll1p];
                ll1[ll1p]++;
            }
        }
        ll1p++;
    }
    for(int i = 0; i < w; i++){
        for(int j = 0; j < h; j++){
            if(m[j][i]){
                l2[j][i] = NULL;
                ll2p++;
            }else{
                l2[j][i] = &ll2[ll2p];
                ll2[ll2p]++;
            }
        }
        ll2p++;
    }
//    for(int i = 0; i < h; i++){
//        for(int j = 0; j < w; j++){
//            if(l2[i][j] == NULL){
//                cerr << 0;
//            }else{
//                cerr << *l2[i][j];
//            }
//        }
//        cerr << endl;
//    }

    int ma = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(l1[i][j] == NULL || l2[i][j] == NULL){
                continue;
            }
            int c = *l1[i][j] + *l2[i][j] - 1;
            ma = max(ma, c);
        }
    }

    cout << ma << endl;

    return 0;
}


Measured memory_bytes: 98560
using System;
using System.Linq;

namespace AtCoder.BC083
{
    public class B
    {
        public static void Main()
        {
            var nums = Console.ReadLine().Split(" ").Select(n => int.Parse(n)).ToArray();
            int sum = 0;

            for (int i = 1; i <= nums[0]; i++)
            {
                int tmp = 0, t = i;

                while (t > 0)
                {
                    tmp += t % 10;
                    t /= 10;
                }
                if (nums[1] <= tmp && tmp <= nums[2]) sum += i;
            }

            Console.WriteLine(sum);
        }
    }
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int main(){
	int X,A;
	cin >> X >> A;

	if( X< A) cout << 0;
	else cout << 10;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int S, W;
	cin >> S >> W;
	if (S <= W) {
		printf("unsafe");
	}
	else {
		printf("safe");
	}



EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




Measured memory_bytes: 3220
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a==b) printf("%d",c);
    if (b==c) printf("%d",a);
    if (a==c) printf("%d",b);
    return 0;
}


Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=2023};

int cnt[N];

int main(){
	int n=ci();
	int x=ci(), y=ci();
	rep(i,1,n) rep(j,i+1,n){
		int dis = min(j-i,abs(i-x)+abs(j-y)+1);
		cnt[dis]++;
	}
	rep(i,1,n-1) printf("%d\n",cnt[i]);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

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

Measured memory_bytes: 3568
import math

a, b, x = map(int, input().split())
x /= a
if a * b >= x * 2:
    c = x * 2 / b
    print(math.degrees(math.atan2(b, c)))
else:
    c = (a * b - x) * 2 / a
    print(math.degrees(math.atan2(c, a)))

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

int CountFactors(int n) {
  int ret = 0;
  int f;
  for (f = 1; f * f < n; f += 2) {
    if (n % f == 0)
      ret += 2;
  }
  if (f * f == n)
    ++ret;
  return ret;
}

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

  int ret = 0;
  for (int k = 1; k <= n; k += 2) {
    if (CountFactors(k) == 8)
      ++ret;
  }
  cout << ret << "\n";
  return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

bool solve(int N, int M, int A, int B, char fld[1010][1010], bool special = false)
{
	if (special) {
		if (N < 3 || M < 3) {
			return false;
		}
		fld[N-3][M-3] = '<';
		fld[N-3][M-2] = '>';
		fld[N-3][M-1] = '^';
		fld[N-2][M-1] = 'v';
		fld[N-1][M-1] = '>';
		fld[N-1][M-2] = '<';
		fld[N-1][M-3] = 'v';
		fld[N-2][M-3] = '^';
		A -= 2;
		B -= 2;
	}

	if (N & 1) {
		rep(j, M-1) {
			if (fld[N-1][j] == '.' && fld[N-1][j+1] == '.' && A > 0) {
				--A;
				fld[N-1][j] = '<';
				fld[N-1][j+1] = '>';
			}
		}
	}

	if (M & 1) {
		rep(i, N-1) {
			if (fld[i][M-1] == '.' && fld[i+1][M-1] == '.' && B > 0) {
				--B;
				fld[i][M-1] = '^';
				fld[i+1][M-1] = 'v';
			}
		}
	}

	for (int i = 0; i + 1 < N; i += 2) {
		for (int j = 0; j + 1 < M; j += 2) {	
			if (fld[i][j] != '.' || fld[i+1][j+1] != '.' || fld[i][j+1] != '.' || fld[i+1][j] != '.') continue;

			if (A) {
				fld[i][j] = '<';
				fld[i][j+1] = '>';
				--A;
				if (A) {
					fld[i+1][j] = '<';
					fld[i+1][j+1] = '>';
					--A;
				}		
			} else if (B) {
				fld[i][j] = '^';
				fld[i+1][j] = 'v';
				--B;
				if (B) {
					fld[i][j+1] = '^';
					fld[i+1][j+1] = 'v';
					--B;
				}
			}
		}
	}
	return (A == 0 && B == 0);
}

int N, M, A, B;
char c[1010][1010];

void init()
{
	rep(i, N) {
		rep(j, M) {
			c[i][j] = '.';
		}
	}
}

int main() {
	cin >> N >> M >> A >> B;

	init();
	if (solve(N, M, A, B, c)) {
		puts("YES");
		rep(i, N) puts(c[i]);
		return 0;
	}

	init();
	if (solve(N, M, A, B, c, 1)) {
		puts("YES");
		rep(i, N) puts(c[i]);
		return 0;
	}
	puts("NO");

	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
using namespace std;
int N, W;
int V[101], M[101];
int dp[101][10001];
int main(void) {
	cin >> N >> W;
	for (int i = 1; i <= N; ++i) cin >> V[i] >> M[i];
	for (int n = 1; n <= N; ++n) for (int w = 1; w <= W; ++w) {
		dp[n][w] = dp[n - 1][w];
		if (M[n] <= w) dp[n][w] = max(dp[n][w], dp[n - 1][w - M[n]] + V[n]);
	}
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 7016
// g++ -std=gnu++1y -O2 xxx.cpp

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

    vector<int> Pn(N);
    for (int i=0;i<N;i++) cin>>Pn[i];

    int currMin=INT_MAX;
    int cnt=0;
    for (int i=0;i<N;i++) {
        if (Pn[i] <= currMin) {
            cnt++;
            currMin = Pn[i];
        }
    }

    cout << cnt << endl;

    return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

struct less_key {
    bool operator()(const std::pair<i64,i64> &left, const std::pair<i64,i64> &right) {
        return left.first < right.first;
    }
};

i64 gcd (i64 a, i64 b, i64 & x, i64 & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    i64 x1, y1;
    i64 d = gcd (b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

i64 rev(i64 a, i64 m) {
    i64 x, y;
    i64 g = gcd(a, m, x, y);
    if (g != 1) {
        throw g;
    }
    return (x % m + m) % m;
}

i64 binpow(i64 a, i64 p) {
    if (p == 0) {
        return 1;
    }
    if (p == 1) {
        return a;
    }
    i64 t = binpow(a, p / 2);
    t *= t;
    t %= mod;

    if (p % 2) {
        t *= a;
        t %= mod;
    }

    return t;
}

const i64 MAXN = 22;

i64 h, w;
string a[MAXN];

vector<pair<i64, i64>> b = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

i64 bfs(pair<i64, i64> s) {
    set<pair<i64, i64>> v;

    set<pair<i64, i64>> q;
    q.insert(s);
    v.insert(s);

    i64 max_lvl = 0;

    i64 lvl = 0;
    while(!q.empty()) {
        set<pair<i64, i64>> nq;
        max_lvl = max(max_lvl, lvl);

        while (!q.empty()) {
            auto c = *q.begin();
            q.erase(q.begin());

            v.insert(c);

            for (auto t : b) {
                pair<i64, i64> n = {c.first + t.first, c.second + t.second};
                if (n.first < 0 || n.first >= h || n.second < 0 || n.second >= w) {
                    continue;
                }
                if (a[n.first][n.second] != '.') {
                    continue;
                }
                if (v.count(n)) {
                    continue;
                }
                nq.insert(n);
            }
        }
        q = nq;
        lvl += 1;
    }

    return max_lvl;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

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

    i64 R = 0;
    for (i64 i = 0; i < h; i++) {
        for (i64 j = 0; j < w; j++) {
            if (a[i][j] == '.')
            R = max(R, bfs({i, j}));
        }
    }
    cout << R << endl;

    return 0;
}


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

int main(){
	string s; cin>>s;
	lint n;
	n=s.size();
	lint c=0,ans=0;
	rep(i,n){
		lint ne=s[i]-'A';
		if(ne<=c)++ans;
		c=ne;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3208
#include<stdio.h>
int main()
{
    int h,a;
    scanf("%d%d",&h,&a);
    if(h%a==0)
    {
        printf("%d\n",h/a);
    }
    else
    {
        printf("%d\n",(h/a)+1);
    }
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        int m = 1000000007;
        long sum = 1;

        for (int i = 1; i <= n; i++) {
            sum *= i;
            sum %= m;
        }

        System.out.println(sum);

    }
}


Measured memory_bytes: 21076