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

int main() {

	int  p = 5;
	vector<pair<int,int>> pa;
	for (int i = 0; i < p; i++) {
		int s; cin >> s;
		pa.push_back({ s % 10, s });
	}
	sort(pa.begin(), pa.end());
	int ans = 0;
	int check = true;
	for (int i = 0; i < pa.size(); i++) {
		if (pa[i].first == 0) {
			ans += pa[i].second;
		}
		else {
			if (check) {
				ans += pa[i].second;
				check = false;
			}
			else {
				ans += (pa[i].second / 10 + 1) * 10;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

ll f(ll n, ll m) {
	return (n * n) % m;
}

int main() {
	ll N, X, M; cin >> N >> X >> M;
	ll A, preA, ans = 0;
	ll loopcnt = 0, cnt = 0, sum_loop = 0, rec_A;
	vector<bool> visit(1000010,false);
	bool dub = false;
	for(int i = 1; i <= N; i++) {
		if(i == 1) {
			A = X;
			ans += A;
			visit[A] = true;
			cnt++;
			continue;
		}
		preA = A;
		A = f(A, M);
		if(dub) {
			if(A == rec_A) break;
			ans += A; sum_loop += A; loopcnt++; cnt++;
		}
		else {
			if(visit[A]) {
				dub = true; rec_A = A; sum_loop += A; loopcnt++;
			}
			ans += A;
			cnt++;
			visit[A] = true;
		}
	}
	A = preA;
	if(dub) {
		ans += sum_loop * ((N - cnt) / loopcnt);
		ll rem = (N - cnt) % loopcnt;
		for(int i = 0; i < rem; i++) {
			A = f(A, M);
			ans += A;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define IL inline
#define _  200005
#define ll long long
#define RG register
using namespace std ;

IL int gi() {
	RG int data = 0 , fu = 1 ; RG char ch = 0 ;
	while(ch != '-' && (ch < '0' || ch > '9')) ch = getchar() ; if(ch == '-') fu = -1 , ch = getchar() ;
	while('0' <= ch && ch <= '9') data = (data << 1) + (data << 3) + (ch ^ 48) , ch = getchar() ; return data * fu ;
}

#define mod 1000000007

char s[_] ; int ans[_] , Ans ; 
int n ;

int main() {
	n = gi() ;
	scanf("%s" , s + 1) ;
	for(int i = 1; i <= n; i ++) ans[s[i] - 'a'] ++ ;
	Ans = 1 ;
	for(int c = 0; c < 26; c ++) Ans = 1ll * Ans * (ans[c] + 1) % mod ;
	Ans = (Ans + mod - 1) % mod ;
	cout << Ans << endl ;
	return 0 ; 
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 200020
#define MOD 1000000007
using namespace std;

int Solve(int n, int k)
{
    int l, r;

    l = (long long)(0 + k - 1) * k / 2 % MOD;
    r = (long long)(n - k + 1 + n) * k / 2 % MOD;

    // printf("sel %d : %d\n", k, r - l + 1);

    return ((r - l + 1) % MOD + MOD) % MOD;
}

int main(void)
{
    int n, k;
    int i, o;

    cin >> n >> k;
    for(i = k, o = 0; i <= n + 1; i ++)
        o = (o + Solve(n, i)) % MOD;
    cout << o << endl;

    return 0;
}


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

using namespace std;

int main(){
    int n,ans = 0;
    cin >> n;
    for(int i = 2;i <= n;i++){
        int components = 0;
        for(int j = 1;j <= i;j++){
            if(i%j == 0)components++;
        }
        if(components == 8 && i % 2 != 0)ans++;
    }
    cout << ans;
    return 0;
}

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

long long getCnt(const vector<int> &v, int from, int to) {
    if (from == 0) return v[to];
    return v[to] - v[from-1];
}

long long getCnt(const vector<int>  &a, const vector<int> &b, int i, const int N) {
    return getCnt(a, 0, i-1) * getCnt(b, i+1, N-1) + getCnt(b, 0, i-1) * getCnt(a, i+1, N-1);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N;
  string S;
  cin >> N >> S;
  vector<int> R(N, 0);
  vector<int> G(N, 0);
  vector<int> B(N, 0);
  if (S[0] == 'R') ++R[0];
  else if (S[0] == 'G') ++ G[0];
  else ++B[0];

  long long result = 0;
  for (int i = 1; i < N; ++i) {
    R[i] = R[i-1];
    G[i] = G[i-1];
    B[i] = B[i-1];
    if (S[i] == 'R') ++R[i];
    else if (S[i] == 'G') ++ G[i];
    else ++B[i];
  }

  for (int i = 1; i < N-1; ++i) {
      if (S[i] == 'R') result += getCnt(G, B, i, N);
      else if (S[i] == 'G') result += getCnt(R, B, i, N);
      else result += getCnt(R, G, i, N);
      for (int j = i-1, k = i+1; j >= 0 && k < N; --j, ++k) {
          if (S[j] != S[i] && S[k] != S[i] && S[j] != S[k]) {
              --result;
          }
      }
  }

  cout << result << endl;
  return 0;
}

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

using namespace std;

#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,s,d;
    
    cin >> a >> s >> d;
    
    int l = 0,r = 0;
    
    for(int i = 0;i < s; ++i)
    {
        int x;
        cin >> x;
        if(x < d)
        {
            l++;
        }
        else
        {
            r++;
        }
    }
    cout << min(l, r) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){fastio
    dd a,b,p,q,r;cin>>a>>b>>p>>q>>r;
    dd s=b*p-b*q+a*q;
    s/=(r+q);
    cout<<setprecision(20)<<b+s<<endl;
    
    return 0;
}



Measured memory_bytes: 3316
use std::collections::HashMap;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n : String = read();
    let origin:Vec<char> = n.chars().collect();
    let mut cp = origin.clone();
    cp.reverse();
    let ans = if cp == origin {
        "Yes".to_string()
    } else{
        "No".to_string()
    };
    println!("{}",ans);
}



Measured memory_bytes: 4352
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}
string s;
void input(){
    cin>>s;
}
void src(){
    int s1=10*(s[0]-'0')+(s[1]-'0');
    int s2=10*(s[2]-'0')+(s[3]-'0');
    cout<< (1<=s1 and s1<=12 ? (1<=s2 and s2<=12 ? "AMBIGUOUS":"MMYY" ):((1<=s2 and s2<=12 ? "YYMM":"NA")));
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>
#include <map>
#include <queue>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )


int main() {
    string s;
    int K;
    cin >> s;
    cin >> K;
    std::vector<string> L;
    ullrep(i, 0, s.size()) {
        ullrep(j, 0, K) {
            L.push_back(s.substr(i, j+1));
        }
    }
    sort(L.begin(), L.end());
    auto end = std::unique(L.begin(), L.end());
    cout << *(L.begin() + K - 1) << endl;
}

Measured memory_bytes: 1288
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};



//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!


int imos[1000000];
int ans[1000000];
signed main() {
	int N,M;
	cin >> N >> M;
	vector<int> A;
	rep(i, N) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());

	vector<pair<int, int>> CB;
	rep(i, M) {
		int b, c;
		cin >> b >> c;
		CB.push_back(make_pair(c, b));
	}
	sort(CB.begin(), CB.end());
	reverse(CB.begin(), CB.end());

	int now = 0;
	for (auto cb : CB) {
		//bだけ置き換える
		rep(i, cb.second) {
			if (A[now] < cb.first) {
				A[now] = cb.first;
				now++;
			}
			else {
				break;
			}
		}
		if (now >= N) break;
	}

	int ans = 0;
	rep(i, N) {
		ans += A[i];
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
	int a=0;
	int b=0;
	int n=0;
	int m=0;
	scanf("%d %d",&n,&m);
	int A[100][100]={};
	int B[100]={};
	int X[100]={};

	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			scanf("%d", &a);
			A[i][j]=a;
		}
	}

	for(int k=0; k<m; k++){
		scanf("%d", &b);
		B[k]=b;
	}

	for(int s=0; s<n; s++){
		for(int t=0; t<m; t++){
			X[s] += A[s][t]*B[t];
		}
	}

	for(int u=0; u<n; u++){
		printf("%d\n",X[u]);
	}

	return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  int count = 0;
  for (int i = 0; i < S.size() / 2; i++) {
    char front = S.at(i);
    char back = S.at(S.size() - 1 - i);
    
    if (front != back) {
      count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    string list = "abcdefghijklmnopqrstuvwxyz.?! ";
    while(true){
	string s = readln();
	if(stdin.eof()) break;
	s = s.chomp();
	if(s.length % 2 == 1){
	    writeln("NA");
	    continue;
	}
	string ans = "";
	for(int i=0;i<s.length/2;i++){
	    int c = to!int(s[2*i]-'0') - 1;
	    int r = to!int(s[2*i+1]-'0') - 1;
	    if(5<c || 4<r || c < 0 || r < 0){
		ans = "NA";
		break;
	    }
	    ans ~= list[5*c + r];
	}
	writeln(ans);
    }

}

Measured memory_bytes: 2352
n = int(input())
s = input()

ans_list = []
for i in range(n):
    ans = 0
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    for j in range(len(x)):
        if x[j] in y:
            ans += 1
    ans_list.append(ans)

a = max(ans_list)
print(a)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FF fflush(stdout)
#define debug printf("Hello\n")
//why is my rating plummeting
int n, m, k, x, y, sum, cnt, ans;
string s;
int main () {
	cin>>s;
	if (s.length()>=4&&s.substr(0, 4)=="YAKI") printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    int cls[10] = {1,1,0,2,0,0,1,0,1,0};
    string ans[3] = {"hon", "pon", "bon"};
    cout << ans[cls[N % 10]] << endl;
    return 0;
}


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

int main() {
  int N;
  string x;
  cin >> N;
  
  string ans = "Three";
  for(int i = 0; i < N; i++){
  	cin >> x;
    if(x == "Y"){
      ans = "Four";
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
# encoding: utf-8
K, A, B = map(int, input().split())

if B - A > 2: # hit and trade
    if A < 1 + K:
        # trade available
        time = K + 1 - A
        ans = A
        ans += (B - A) * (time // 2)
        ans += (time % 2) # one more hit if possible
    else:
        ans = K + 1 # hit only
else:
    ans = K + 1 # hit only

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

typedef struct PP{
    double x,y;
}Point;

void koch(int d,Point p1,Point p2){
    if(d==0)return ;
    Point s,t,u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * p1.x + 1.0 * p2.x)/3;
    s.y = (2.0 * p1.y + 1.0 * p2.y)/3;
    t.x = (1.0 * p1.x + 2.0 * p2.x)/3;
    t.y = (1.0 * p1.y + 2.0 * p2.y)/3;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(d-1,p1,s);
    printf("%.9f %.9f\n",s.x,s.y);
    koch(d-1,s,u);
    printf("%.9f %.9f\n",u.x,u.y);
    koch(d-1,u,t);
    printf("%.9f %.9f\n",t.x,t.y);
    koch(d-1,t,p2);
}

int main(void){
    Point a,b;
    int n;
    scanf("%d",&n);
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    
    printf("%.9f %.9f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.9f %.9f\n",b.x,b.y);
    return 0;
}




Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int n;
int main() { 
		cin>>n;
		for(int i=1;i<=n;i++)cin>>a[i];
		sort(a+1,a+n+1);
		for(int i=1;i<=n-1;i++)
			if(a[i]==a[i+1])
			{
				cout<<"NO";
				return 0;
			}
		cout<<"YES";
   	return 0; 
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  if (abs(X) / D >= K) {
    cout << abs(X) - K * D << endl;
  } else if ((K - abs(X) / D) % 2 == 0) {
    cout << abs(X) % D << endl;
  } else {
    ll minv = abs(X) % D;
    cout << abs(minv - D) << endl;
  }
  return 0;
}

Measured memory_bytes: 3184
#include <iostream>

using namespace std;

int main(int argc, char** argv){
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int count = 0;
    for (int r=0; r<=3000; r++){
        if (r*R > N) break;
        for (int g=0; g<=3000; g++){
            if (r*R + g*G > N) break;
            if ((N - r*R - g*G) % B == 0){
                count++;
            }
        }
    }

    cout << count << "\n";

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
graph=[[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
  graph[ab[i][0]-1][ab[i][1]-1]=1
  graph[ab[i][1]-1][ab[i][0]-1]=1
visited=[0 for _ in range(n)]

def dfs(v):
  visited[v]=1
  for v2 in range(n):
    if graph[v][v2]==0:
      continue
    if visited[v2]==1:
      continue
    dfs(v2)

ans=0

for i in range(m):
  graph[ab[i][0]-1][ab[i][1]-1]=0
  graph[ab[i][1]-1][ab[i][0]-1]=0
  for j in range(n):
    visited[j]=0
  dfs(0)
  bridge=0
  for j in range(n):
    if visited[j]==0:
      bridge=1
  if bridge==1:
    ans+=1
  graph[ab[i][0]-1][ab[i][1]-1]=1
  graph[ab[i][1]-1][ab[i][0]-1]=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	string s;
	cin >> s;

	int ans = 0;
	int cnt = 0;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == 'R') {
			++cnt;
		} else {
			cnt = 0;
		}
		ans = max(ans, cnt);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3600
def gcd(a,b): 
    while b!=0:
        a,b=b,a%b
    return a
 
def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d=map(int,input().split())
z=b-a+1
ak=(a-1)-((a-1)//c)-((a-1)//d)+((a-1)//(lcm(c,d)))
bk=b-b//c-b//d+b//(lcm(c,d))
print(bk-ak)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 998244353
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define sz(x) (ll)((x).size())
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll,ll>
#define psi pair<string,ll>
#define msi map<string,ll>
#define mii map<ll,ll>
#define mp  make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define mem(x,val) memset(x,val,sizeof(x))
#define r0 return 
const long long INF=1e18;
template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
#define dbgv(container) {cerr << #container << " : \n"; int cnt = 0; for (auto& x: container) cerr << #container << "[" << cnt++ << "] = " << x << '\n';} 
#define dbgvv(container) {cerr << #container << " : \n"; int c1=0,c2=0; for (auto& x : container){c2 = 0; for (auto& y : x) {cerr << #container << "[" << c1 << "][" << c2++ << "] = " << y << '\n';}c1++;}}
#define dbg(...)__f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

//code begins here
ll dp[100005],h[100005],n,k;
ll calc(ll i)
{
	if(i>=n+1) return INF;
	if(i==n) return 0;
	if(dp[i]!=-1) return dp[i];
	dp[i]=INF;
	rep(j,i+1,min(i+k,n)+1) dp[i]=min(dp[i],calc(j)+abs(h[i]-h[j]));
	return dp[i];
}
void solve()
{
 	cin>>n>>k;
 	mem(dp,-1);
 	rep(i,1,n+1) cin>>h[i];
 	cout<<calc(1);
}
signed main()
{
	fast
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  if(N == 1){
    cout << "Hello World" << endl;
  }
  
  else{
    int a, b;
    cin >> a >> b;
    
    cout << a + b << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) //これでiやjを定義しなくていいらしい
using namespace std;

int main(){
  int x,n,ans=1001001001;
  cin >> x >> n;
  if(n==0){
    cout << x << endl;
  }else{
    vector<int> p(n);
    rep(i,n){
      cin >> p[i];
    }
    bool flag_a,flag_b;
    int i;
    for(i=0;;i++){
      //cout << i << endl;
      flag_a = true;
      flag_b = true;
      int a;
      a = x-i; //小さい方から見る
      rep(j,n){
        if(a==p[j]){
          flag_a = false;
          break;
        }
      }
      if(flag_a){//小さい方がかぶりなければ抜ける
        ans = a;
        break;
      }else{
        a = x+i; //大きい方を見る
        rep(j,n){
          if(a==p[j]){
            flag_b = false;
            break;
          }
        }
        if(flag_b){//大きい方にかぶりなければ抜ける
          ans = a;
          break;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int max(int a,int b){
	if(a>b) return a;
	return b;
}
int main(void){
	int n,k;
	int b,i;
	unsigned long cnt=0;
	scanf("%d%d",&n,&k);
	for(i=k+1;i<=n;i++){
		cnt=cnt+n/i*(i-k)+max(n%i-max(k,1)+1,0);
	}
	printf("%lu\n",cnt);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 29;
const double EPS = 1e-10;
const ll mod = 1000000007;

ll fact[250010];
ll rfact[250010];

ll modpow(ll p, ll n, ll mod){
  if(n == 0) return 1;
  if(n == 1) return p;
  if(n % 2) return p * modpow(p, n - 1, mod) % mod;
  else return modpow(p * p % mod, n / 2, mod); 
}


ll comb(int n, int r){
  if(r  >  n || n < 0 || r < 0) return 0;
  else return (fact[n] * rfact[r] % mod) * rfact[n - r] % mod;
}

ll calc(int n, int k){
  // nツ嘉アツづ個つ、ツつソkツ嘉アツ甘アツづィツ督ケツつキツづゥツ嘉アツ青板、ツつスツつセツつオツ甘アツづィツ督ケツつオツつスツ嘉アツ青板つェツ甘アツづィツ督ケツつオツづづ按つ「ツ嘉アツ青板づーツ越ツつヲツづづ債つ「ツつッツづ按つ「
  return (comb(n, k) - comb(n, k - 1) + mod) % mod;
}

int main(){
  ll N, M, K;
  fact[0] = 1;
  rfact[0] = 1;
  rep(i, 250000) {
    fact[i+1] = (fact[i] * (i + 1)) % mod;
    rfact[i+1] = modpow(fact[i+1], mod - 2, mod);
  }
  while(cin >> N >> M >> K){
    ll res = 0;
    rep(i, K + 1){
      ll c = calc(N + 2 * i, i) * calc(M + 2 * (K - i), (K - i)) % mod;
      res = (res + c * comb(N + M + K * 2, N + 2 * i)) % mod;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))

A = np.array([0] + A, dtype=int)
B = A.copy()
B[A < 0] = 0

cs1 = A.cumsum()
cs2 = B.cumsum()

ans = 0
for i in range(N - K + 1):
    a = max(cs1[i + K] - cs1[i], 0)
    b = cs2[i] + cs2[-1] - cs2[i + K]
    ans = max(a + b, ans)
print(ans)


Measured memory_bytes: 26056
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll n;
    cin>>n;
    ll ans=n/500;
    ans*=1000;
    n=n%500;
    n/=5;
    n*=5;
    ans=ans+n;
    cout<<ans<<endl;




return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N;
	string verdict;
	int verd[4];
	fill_n(verd, 4, 0);
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> verdict;
		if (verdict == "AC") ++verd[0];
		else if (verdict == "WA") ++verd[1];
		else if (verdict == "TLE") ++verd[2];
		else ++verd[3];
	}
	cout << "AC x " << verd[0] << "\nWA x " << verd[1] << "\nTLE x " << verd[2] << "\nRE x " << verd[3];
	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll n,k; cin >> n >> k;
    vector<Pll> a(n);
    rep(i,n) cin >> a[i].fi >> a[i].se;
    sort(ALL(a));
    ll res=0;
    ll now=0;
    rep(i,n){
        now=a[i].fi;
        res+=a[i].se;
        if(res>=k){
            cout << now << endl;
            return 0;
        }
    }
}


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

int main() {
	long int powedx, sum, d;
	while (cin >> d) {
		sum = 0;
		for (int i = d; i <= (600 - d); i += d) {
			powedx = i * i;
			sum += (powedx * d);
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3016
import heapq
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N = int(input())
adj = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    adj[a].append(b)
    adj[b].append(a)

# heapqで大きい順に取り出したいから、マイナスにしておく。
L = list(map(lambda x: -int(x), input().split()))
heapq.heapify(L)
# Maxは一番大きい数字以外の和.(全体の和-最大の整数)でも止める。
# Lはマイナスがかけてあるので、min(L)で最大の和が求まる
score = -sum(L)+min(L)


# nodeに書く数字
node = [-1]*N

# leafを探す,leafからbfsして訪問順に大きい数字を入れていく
leaf = -1
for i, a in enumerate(adj):
    if len(a) == 1:
        leaf = i
        break

# bfs
Q = [leaf]
while Q:
    cur = Q.pop()
    for a in adj[cur]:
        if node[a] == -1:  # まだたどり着いてないとこには、数字を入れる。
            node[a] = - heapq.heappop(L)
            Q.append(a)
print(score)
print("\n".join(map(str, node)))


Measured memory_bytes: 6004
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll lcm(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll gcd(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){

    string s, t;
    cin >> s >> t;


    int len = s.size();
    bool flag = false;
    for (int i = 0; i < len; ++i) {
        bool equal = true;
        for (int j = 0; j < len; ++j) {
            int now = i + j;
            if (len <= now) now -= len;
            if (s[now] != t[j]) {
                equal = false;
            }
        }
        if (equal) {
            flag = true;
        }
    }

   if (flag) cout << "Yes" << endl;
   else cout << "No" << endl;



}



//              g++ -std=c++1z


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 200000

int n;
ll a[MAX];
ll dp[MAX];
ll ans[MAX];
vector<int> G[MAX];

void dfs(int v, int pre){
    int itr = lower_bound(dp, dp + n, a[v]) - dp;
    ll t = *lower_bound(dp, dp + n, a[v]);
    *lower_bound(dp, dp + n, a[v]) = a[v];
    ans[v] = lower_bound(dp, dp + n, LINF) - dp;
    for (auto to : G[v]) {
        if (to == pre) continue;
        dfs(to, v);
    }
    dp[itr] = t;
}

signed main() {
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }
    int u, v;
    rep(i, n - 1) {
        cin >> u >> v;
        u--;
        v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    fill(dp, dp + n, LINF);
    dfs(0, -1);
    rep(v, n) {
        cout << ans[v] << endl;
    }
    return 0;
}

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

int main() {
  int x;
  cin>>x;
  set<int> memo;
  for(int i=1;i<=31;i++){
    memo.insert(i*i);
  }
  for(int i=1;i<=10;i++){
    memo.insert(i*i*i);
  }
  for(int i=1;i<=5;i++){
    memo.insert(i*i*i*i);
  }
  memo.insert(32);memo.insert(243);memo.insert(128);memo.insert(512);
  for(int i=x;i>=1;i--){
    if(memo.count(i)==1) {
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


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

struct block {
    int weight, solid, value;

    bool operator<(const block &other) const {
        return solid < other.solid;
    }
};

const int TOWER_MAX = 20005;

int N;
vector<block> blocks;

int main() {
    scanf("%d", &N);
    blocks.resize(N);

    for (block &b : blocks) {
        scanf("%d %d %d", &b.weight, &b.solid, &b.value);
        b.solid += b.weight;
    }

    sort(blocks.begin(), blocks.end());
    vector<long long> dp(TOWER_MAX, 0);

    for (block &b : blocks)
        for (int w = b.solid; w >= b.weight; w--)
            dp[w] = max(dp[w], dp[w - b.weight] + b.value);

    printf("%lld\n", *max_element(dp.begin(), dp.end()));
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==b){
		cout<<"Draw"<<endl;
		
	}
	 
	else if(a==1){
		cout<<"Alice"<<endl;
		
	}
	
	else if(b==1){
		cout<<"Bob"<<endl;
		
	}
	
	else if(a<=b){
		cout<<"Bob"<<endl;
		
	}
	
	else if(a>=b){
		cout<<"Alice"<<endl;
		
	}
	
	
	
}

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

int main() {
    int n, d;
    cin >> n >> d;
    
    vector < vector < int > > points(n, vector < int > (d));
    
    for (int i = 0; i < n; i++)
        for (int j = 0; j < d; j++)
            cin >> points[i][j];
    
    auto isInteger = [&] (int a, int b) {
        int sum = 0;
        for (int i = 0; i < d; i++)
            sum += (points[a][i] - points[b][i]) * (points[a][i] - points[b][i]);
            
        int X = sqrt(sum);
        
        return (int)(X * X == sum);
    };
    
    int ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            ans += isInteger(i, j);
            
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define ten5 100000+10
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define iif(c,t,f) ((c)?(t):(f))
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair

int intcmp(const void *v1,const void *v2){return *(int *)v1-*(int *)v2;}




int main(){
  string s;
  cin>>s;
  int ans=0;
  rep(i,0,4){
    ans+= s[i]=='+'?1:-1;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b < c + d) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

const ll N_MAX = 100000 + 10;
ll n, A[N_MAX], B[N_MAX], C[N_MAX], ans;

int main() {
	rd(n);
	repi(i, 0, n) rd(A[i]);
	repi(i, 0, n) rd(B[i]);
	repi(i, 0, n) rd(C[i]);
	sort(A, A + n);
	sort(C, C + n);

	repi(i, 0, n) {
		ll idxA, *posA, idxC, *posC;
		posA = lower_bound(A, A + n, B[i]);
		idxA = distance(A, posA);
		posC = lower_bound(C, C + n, B[i] + 1);
		idxC = distance(C, posC);
		ans += (idxA)*(n - idxC);
	}
	wrln(ans);

	return 0;
}

Measured memory_bytes: 2560
N, M = map(int, input().split())
list1 = (input()).split(' ')
def answer(N: int, M: int, list1: list) -> int:
    homework_days = 0
    for i in range(0, M):
        homework_days += int(list1[i])
        i += 1
    if homework_days <= N:
        return N - homework_days
    else:
        return -1
print(answer(N, M, list1))

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

using namespace std;

int main() {
  string S;
  
  cin >> S;
  
  for (int i = 1; i < 4; i++) {
    if (S[i] == S[i - 1]) {
      cout << "Bad" << endl;
      
      return 0;
    }
  }
  
  cout << "Good" << endl;
  
  return 0;
}


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

template<typename T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<typename T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}

int n;

long long w, weight[110], value[110];

long long dp[110][100100] = { 0 };

int main() {
	cin >> n >> w;
	for (int i = 0;i < n;i++)cin >> weight[i] >> value[i];

	for (int i = 0;i < n;i++) {
		for (int sum_w = 0;sum_w <= w;sum_w++) {
			if (sum_w - weight[i] >= 0) {
				chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
			}

			chmax(dp[i + 1][sum_w], dp[i][sum_w]);

		}
	}

	cout << dp[n][w] << endl;

}

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

int linearSearch(int A[],int n,int key){
	int i=0;
	A[n] = key;//???????¨?????????¢?´¢????????????????????±???????????????????????????
	while( A[i] != key ) i++;
	return i != n;
}

int main(){
	int n,q;
	int S[100000+1],T;
	int i,j,same=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&T);
		if(linearSearch(S,n,T)) same++;
	}
	
	printf("%d\n",same);
	return 0;
}

Measured memory_bytes: 1416
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
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;
}
///////////////////////////////////////////////
int main(){
    ll N; cin >> N;
    string S;
    cin >> S;

    ll num[26] = {};

    int l = S.length();
    REP(i,l){
        char c = S[i];
        num[c - 'a']++;
    }
    ll ans = 1;

    REP(i,26){
       ans = (ans * (num[i] + 1)) % MOD;
    }
    ans--;

    cout << ans << endl;

}






Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2000+10;
int n,a;
int main() {
    while(~scanf("%d%d",&n,&a)){
        n%=500;
        printf("%s\n",n<=a?"Yes":"No");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)

using namespace std;
typedef long long ll;
int main()
{
    ll n;
    string s;
    while(cin>>n>>s)
    {
        bool flag=true;
        if(n%2==1) flag=false;
        else
        {
            rep(i,n/2)
            {
                if(s[i]!=s[i+n/2]) flag=false;
            }
        }
        if(flag) cout<<"Yes\n";
        else cout<<"No\n";
    }
}


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

int main() {
   int N;
   cin >> N;
   int f = 0;
   int n = N;

   while(n) {
      int dig = n % 10;
      f += dig;
      n /= 10;
   }

   if(N % f == 0) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }
}

Measured memory_bytes: 3604
n=int(input())
m=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0

for i in range(n):
  if m[i]>c[i]:
    ans+=c[i]
  elif m[i]<=c[i]<m[i]+m[i+1]:
    ans+=c[i]
    m[i+1]=m[i]+m[i+1]-c[i]
  else:
    ans+=(m[i]+m[i+1])
    m[i+1]=0
  
print(ans)

Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    cin >> d;
    if (d == 25)
    {
        cout << "Christmas" << endl;
    }
    else if (d == 24)
    {
        cout << "Christmas Eve" << endl;
    }
    else if (d == 23)
    {
        cout << "Christmas Eve Eve" << endl;
    }
    else if (d == 22)
    {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}


Measured memory_bytes: 256
s = input()


MOD = 10 ** 9 + 7
n = len(s)
dp = [[0] * 2 for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    dp[i+1][1] += dp[i][1] * 3
    dp[i+1][1] %= MOD
    if s[i] == '1':
        dp[i+1][0] += dp[i][0] * 2
        dp[i+1][0] %= MOD
        dp[i+1][1] += dp[i][0]
        dp[i+1][1] %= MOD
    else:
        dp[i+1][0] += dp[i][0]
        dp[i+1][0] %= MOD

ans = (dp[n][0] + dp[n][1]) % MOD
print(ans)

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

int main() {
    int k, s;
    cin >> k >> s;

    int cmb = 0;
    if (k >= s) {
        cmb = (s+2)*(s+1)/2;
    }
    else {
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - (x + y);
                if (0 <= z and z <= k) cmb++;
            }
        }
    }
    cout << cmb << endl;
}


Measured memory_bytes: 256
def main():

    N = int(input())
    A = list(map(int, input().split()))
    count = dict()
    for v in A:
        count[v] = count.get(v, 0) + 1
    tot = 0
    for v in count:
        tot += count[v] * (count[v] - 1) // 2

    for k in range(N):
        v = A[k]
        u = tot - count[v] * (count[v] -1) // 2
        u += (count[v]-1) * (count[v] - 2) // 2
        print(u)

if __name__ == '__main__':
    main()

Measured memory_bytes: 87628
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

signed main() {
	int n;
	while (scanf("%d", &n)) {
		if (!n)
			break;
		vector<int> used;
		function<void(int, int)> func = [&](int sum, int bef) {
			if (sum == n) {
				REP(i, used.size()) {
					printf("%d", used[i]);
					if (i != (int) used.size() - 1)
						printf(" ");
				}
				printf("\n");
				return;
			}
			for (int i = bef; 1 <= i; i--) {
				if (sum + i <= n) {
					used.push_back(i);
					func(sum + i, i);
					used.erase(--used.end());
				}
			}
		};

		func(0, n);
	}
	return 0;
}

Measured memory_bytes: 3212
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
typedef struct{
  double x,y;
}P;//Point
void Koch(int ,P ,P );
double radian=PI/3;//60degrees

int main(void){
  int n;
  P p1={0,0},p2={100,0};
  scanf("%d",&n);
  printf("%.8f %.8f\n",0.0,0.0);
  Koch(n,p1,p2);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}

void Koch(int n,P left,P right){
  P s,t,u;
  if(n==0)return ;
  s.x=(2*left.x+right.x)/3;
  s.y=(2*left.y+right.y)/3;
  t.x=(left.x+2*right.x)/3;
  t.y=(left.y+2*right.y)/3;
  u.x=(t.x-s.x)*cos(radian)-(t.y-s.y)*sin(radian)+s.x;
  u.y=(t.x-s.x)*sin(radian)+(t.y-s.y)*cos(radian)+s.y;
  Koch(n-1,left,s);
  printf("%.8f %.8f\n",s.x,s.y);
  Koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  Koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  Koch(n-1,t,right);
}


Measured memory_bytes: 2104
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll n;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>n;
	n%=10;
	if(n==2||n==4||n==5||n==7||n==9)
	cout<<"hon";
	else if(n==3)
	cout<<"bon";
	else
	cout<<"pon";
	return 0;
}


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

int main(){
	string S, T;
	cin >> S >> T;
	int q;
	cin >> q;
	int a[q], b[q], c[q], d[q];
	for(int i=0; i<q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	int scnt[S.size() + 1], tcnt[T.size() + 1];
	scnt[0] = tcnt[0] = 0;
	if(S[0] == 'A') scnt[1] = 1;
	else scnt[1] = 0;
	if(T[0] == 'A') tcnt[1] = 1;
	else tcnt[1] = 0;
	for(int i=0; i<S.size(); i++){
		if(S[i] == 'A') scnt[i+1] = scnt[i] + 1;
		else scnt[i+1] = scnt[i];
	}
	for(int i=0; i<T.size(); i++){
		if(T[i] == 'A') tcnt[i+1] = tcnt[i] + 1;
		else tcnt[i+1] = tcnt[i];
    }
	for(int i=0; i<q; i++){
		int anum1, anum2, bnum1, bnum2;
		anum1 = scnt[b[i]] - scnt[a[i] - 1];
		bnum1 = b[i] - a[i] + 1 - anum1;
		anum2 = tcnt[d[i]] - tcnt[c[i] - 1];
		bnum2 = d[i] - c[i] + 1 - anum2;
		if((anum1 - bnum1 - anum2 + bnum2) % 3 == 0) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if abs(a - c) <= d || (abs(a - b) <= d && abs(c - b) <= d) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  V<> d{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  V<string> s{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
  while (true) {
    int x, y; cin >> x >> y, --x, --y;
    if (x == -1) break;
    int a = 0;
    for (int i = 0; i < x; ++i) a += d[i];
    a += y;
    cout << s[(a + 3) % 7] << '\n';
  }
}


Measured memory_bytes: 2972