akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  double t, x;
  cin >> t >> x;
  cout << t / x << endl;
  return 0;
}

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

int main(){
	int a, b, c;
	int tmp;
	cin >> a >> b >> c;
	if(a>b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if(a>c){
		tmp = a;
		a = c;
		c = tmp;
	}
	if(b>c){
		tmp = b;
		b = c;
		c = tmp;
	}
	cout << a << " " << b << " " << c << "\n";
}


Measured memory_bytes: 3088
/*

*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long 
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
using namespace std;
const int MAXN = 1e6 + 10, INF = 1e9 + 10;
const double eps = 1e-9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int main() {
	int a = read(), b = read();
	printf("%d ", a - b + 1);
    return 0;
}
/*

*/

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

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

struct Combination{
    vector<ll> fac,finv,inv;
    Combination(int mx){init(mx);}
    void init(int mx){
        fac.resize(mx+1);
        finv.resize(mx+1);
        inv.resize(mx+1);
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for(int i=2;i<=mx;i++){
            fac[i]=fac[i-1]*i%MOD;
            inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
            finv[i]=finv[i-1]*inv[i]%MOD;
        }
    }
    ll calc(int n,int k){
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
    }
};

int main(){
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    Combination comb(2*n);
    ll ans=0;
    ll p=(a*modpow(a+b,MOD-2))%MOD;
    ll pn=modpow(p,n);
    ll q=(b*modpow(a+b,MOD-2))%MOD;
    ll qn=modpow(q,n);
    ll pi=1,qi=1;
    for(int i=0;i<n;i++){
        if(i){
            pi=(pi*p)%MOD;
            qi=(qi*q)%MOD;
        }
        ll t=(comb.calc(n-1+i,i)*(n+i))%MOD;
        t=(t*((pn*qi)%MOD+(pi*qn)%MOD)%MOD)%MOD;
        ans=(ans+t)%MOD;
    }
    ans=((ans*100)%MOD*modpow(a+b,MOD-2))%MOD;
    cout<<ans<<endl;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  bool isApproved = true;
  int64_t a;
  for(int i=0;i<n;i++){
    cin >> a;
    if(isApproved && (a%2==0 && (a%3!=0&&a%5!=0) )){
      isApproved = false;
    }
  }
  if(isApproved) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RREP(i,n) for (int i=n-1;i>=0;i--)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (ll)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e6+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll fac[MAXn],inv[MAXn];
ll mul(ll a,ll b){
    return a*b%MOD;
}
ll add(ll a,ll b){
    ll ret = a + b;
    if (ret >= MOD) ret -= MOD;
    return ret;
}
ll sub(ll a,ll b){
    ll ret = a-b;
    if (ret < 0) ret += MOD;
    return ret;
}
ll fpow(ll a,ll b){
    ll ret = 1;
    while (b) {
        if (b&1) ret = mul(ret,a);
        a = mul(a,a);
        b >>= 1;
    }
    return ret;
}
ll C(ll n,ll m){
    ll ret = mul(fac[n],inv[m]);
    ret = mul(ret,inv[n-m]);
    debug(n,m,ret);
    return ret;
}
int main(){
    IOS();
    int r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    fac[0] = 1;
    inv[0] = 1;
    REP1 (i,MAXn-1) {
        fac[i] = mul(fac[i-1],i);
        inv[i] = fpow(fac[i],MOD-2);
    }
    ll ans = 0;
    for (ll i=c1+1;i<=c2+1;i++) {
        ans = add(ans,C(r2+i,i));
        ans = sub(ans,C(r1-1+i,i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200010;
ll arr[N];
ll n;

int main() {
    cin >> n;
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];//存数组
    }
    ll ans = 0; //记录答案
    ll right = 0; //右指针
    ll curr = 0;//用来维护区段异或，其中异或的零元是0
    for(int left = 0; left < n; left ++) {
        //固定左指针的位置
        while(right < n && (arr[right] & curr) == 0) {
            //尝试寻找满足条件的最远的右指针
            curr ^= arr[right];
            right ++;
        }
        ans += (right - left);//这里是增加每一个元素作为最左端的元素对数量
        curr ^= arr[left];//左指针右移动
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
# S = input()
N = input()
# v = map(int, input().split())

n = int(N)

keta = len(N)

if keta == 1:
    print(n)
elif keta == 2:
    print(9)
elif keta == 3:
    print(9 + n - 99)
elif keta == 4:
    print(909)
elif keta == 5:
    print(909 + n - 9999)
elif keta == 6:
    print(90909)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<map>
#include<queue>
using namespace std;

typedef pair<int,int> P;

vector<P> G[550];
int n,m;

int dijk(int from, int to){
  int d[550];
  for(int i=1;i<=n;i++)d[i] = 100000000;
  d[from] = 0;
  priority_queue<P,vector<P>,greater<P> > q;
  q.push(P(0,from));

  while(q.size()){
    P p = q.top(); q.pop();
    if(p.second == to)return d[to];

    for(int i=0;i<(int)G[p.second].size();i++){
      P next = G[p.second][i];
      if(d[next.second] > p.first + next.first){
	d[next.second] = p.first + next.first;
	q.push(P(d[next.second],next.second));
      }
    }
  }
}

int main(){
  while(cin >> n >> m , n||m){
    string s,p,g;
    cin >> s >> p >> g;


    for(int i=1;i<=n;i++)G[i].clear();    
    map<string,int> ma;
    int cnt = 1;

    for(int i=0;i<m;i++){
      string a,b;
      int d,t;
      cin >> a >> b >> d >> t;
      if(!ma[a])ma[a] = cnt++;
      if(!ma[b])ma[b] = cnt++;
      G[ma[a]].push_back(P(d/40+t,ma[b]));
      G[ma[b]].push_back(P(d/40+t,ma[a]));
    }

    cout << dijk(ma[s],ma[p]) + dijk(ma[p],ma[g]) << endl;
  }
}
    

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    vector<long long> sum;
    for (int l = 0; l < n; l++) {
        for (int r = l; r < n; r++) {
            long long s = 0;
            for (int i = l; i <= r; i++) {
                s += a.at(i);
            }
            sum.push_back(s);
        }
    }

    int len = n * (n + 1) / 2;
    long long ans = 0;
    vector<bool> to_use(sum.size(), true);
    for (int digit = 45; digit >= 0; digit--) {
        int cnt = 0;
        for (int i = 0; i < len; i++) {
            if (!to_use.at(i)) continue;

            if (sum.at(i) & (1ll << digit)) cnt++;
        }
        if (cnt >= k) {
            ans += 1ll << digit;

            for (int i = 0; i < len; i++) {
                if (!(sum.at(i) & (1ll << digit))) to_use.at(i) = false;
            }
        }
    }

    cout << ans << endl;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    if (S[K-1] == 'A') S[K-1] = 'a';
    if (S[K-1] == 'B') S[K-1] = 'b';
    if (S[K-1] == 'C') S[K-1] = 'c';
    
    cout << S << endl;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int count= 0;
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='A' || s.at(i)=='C' || s.at(i)=='G' || s.at(i)=='T') count++;
        else{
            ans = max(ans,count);
            count = 0;
        }
    }
    ans = max(ans,count);
    cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#define maxn 200005
long long t[maxn];
int main()
{
    int n;
    int i;
    long long ans = 0;
    long long t1;
    scanf("%d %lld", &n, &t1);
    for(i = 1; i<=n;i++)
        {
            scanf("%lld", t+i);
            if(i >= 2)
            {
                if((t[i] - t[i-1])>=t1)
                    ans += t1;
                else ans += t[i] - t[i-1];
            }
        }
    printf("%lld\n", ans + t1);
    return 0; 
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

int showAll(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector<int> v;
  int tmp;
  rep(i, n) {
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());
  if (v[0] == 1) {
    cout << 1 << endl;
    return 0;
  }
  while (v.size() != 1) {
    if (v[1] > v[0] * 2) v[1] = v[1] % v[0];
    else v[1] -= v[0];
    if (v[1] == 1) {
      cout << 1 << endl;
      return 0;
    } else {
      if (v[1] <= 0) v.erase(v.begin() + 1);
      else swap(v[0], v[1]);
    }
  }
  cout << v[0] << endl;
  return 0;
}



Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

ll gcd(ll x,ll y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  ll a,b;
  cin >> a >>b;
  ll ans = (a*b)/gcd(a,b);
  cout<< ans <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int H,W,K,Sx,Sy,Ex,Ey;
vector<vector<bool> > Map;
vector<bool> MapTmp;
vector<vector<int> > Pace;
vector<int> PaceTmp;
typedef pair<int,int> pii;
queue<pii> Q;

inline bool alw(int x,int y){
    if(x<=0||y<=0||x>H||y>W)
        return 0;
    return Map[x][y];
}

inline int bfs(){
    static int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
    Q.push(pii(Sx,Sy));
    Pace[Sx][Sy]=0;
    Map[Sx][Sy]=0;
    while( Q.size() ){
        int x=Q.front().first,y=Q.front().second;
        Q.pop();

        for(int i=0;i<4;i++)
            for(int t=1,X=x+dx[i],Y=y+dy[i];t<=K;t++,X+=dx[i],Y+=dy[i])
                if(alw(X,Y)&&( Pace[X][Y]==Pace[x][y]+1||Pace[X][Y]==-1 ) ){
                    if(Pace[X][Y]!=-1)
                        continue;
                    Q.push( pii(X,Y) );
                    Pace[X][Y]=Pace[x][y]+1;
                }
                else break;
    }

    return Pace[Ex][Ey];
}

inline bool isLeaf(){
    char c=getchar();
    while(c!='@'&&c!='.')
        c=getchar();
    return c=='@';
}
int main(){
    cin>>H>>W>>K;
    cin>>Sx>>Sy>>Ex>>Ey;
    for(int j=0;j<=W;j++)
        MapTmp.push_back(0),PaceTmp.push_back(-1);
    Map.push_back(MapTmp);
    Pace.push_back(PaceTmp);
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++)
            MapTmp[j]=!isLeaf();
        Map.push_back(MapTmp);
        Pace.push_back(PaceTmp);
    }
    cout<<bfs();
    return 0;
}

Measured memory_bytes: 15440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<pair<ll, int>> f(ll n)
  {vector<pair<ll, int>> result;
  ll c = 0, d = 2, m = n;
  while (d <= m && d * d <= n)
    {if (m % d == 0)
      {m = m / d; ++c;}
    else
      {if (c > 0) result.push_back({d, c});
      c = 0; ++d;}}
  if (c > 0) result.push_back({d, c});
  else if (m > 1) result.push_back({m, 1});
  return result;}
ll g(ll n)
  {ll s = 0;
  ll c = 0;
  for (ll i = 1; s < n; ++i)
    {s += i;
    c++;};
  return (s == n ? c : c - 1);}
int main()
  {ll N; cin >> N;
  auto ps = f(N);
  ll ans = 0;
  for (auto p : ps)
    {ans += g(p.second);}
  cout << ans << endl;}

Measured memory_bytes: 3632
#include <stdio.h>

int main() {
     char dance[101];
     scanf("%s", dance);
     for (int i = 0; dance[i] != '\0'; i++) {
          if ((i+1)%2 == 0) {
               if (dance[i] == 'L' || dance[i] == 'U' || dance[i] == 'D') {
                    continue;
               } else {
                    printf("No\n");
                    return 0;
               }
          }
          else {
               if (dance[i] == 'R' || dance[i] == 'U' || dance[i] == 'D') {
                    continue;
               } else {
                    printf("No\n");
                    return 0;
               }
          }

     }
     printf("Yes\n");

     return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll res = 0;
    for(int i = 1; i <= N;i++){
        ll x = i*i;
        if(x > N)break;
        res = x;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,temp,sum = 0;
    scanf("%d",&n);
    temp = n;
    while(temp){
        sum = sum + (temp%10);
        temp = temp/10;
    }

    if(n % sum == 0)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 1716
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
    char str[105];
    int arr[130];

    while(scanf("%s",str)==1)
    {
        int len=strlen(str);

        memset(arr,0,sizeof(arr));

        for(int i=0; i<len; i++)
        {
            arr[str[i]]++;
        }

        int flag=0;

        for(int i=97; i<=122; i++)
        {
            if(arr[i]%2!=0)
            {
                flag=1;

                break;
            }
        }

        if(flag==0)
            printf("Yes\n");

        else
            printf("No\n");
    }

    return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int rd(){int x=0,c=0,f=1;for(;c<'0'||c>'9';c=getchar())f=c!='-';
for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';return f?x:-x;}
int main(){
	int n=rd(),a=0,b=0,c=0;
	for(int i=1;i<=n;i++){
		int x=rd();
		if(x%4==0)c++;
		else if(x&1)a++;
		else b++;
	}
	c-=a;
	if(c<0&&(c!=-1||b)){
		puts("No");
		//return 0;
	}
	else puts("Yes");
	//else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int n; cin>> n;
        int sm= 0;
        for (int i= 1; i<= n; i++) {
                if (i% 3== 0 || i% 5== 0) continue;
                else sm+= i;
        }
        cout << sm;
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 3620
s = input() # これを繰り返しまくる
t = input() # これを探す

# 判定
s_set = set(s)
s_len = len(s)

if all((t_ in s_set) for t_ in t):
    ans = 0
    ss = s + s
    found_index_old = -1

    for t_ in t:
        found_index = ss.find(t_, found_index_old + 1)
        # print(ss, found_index_old + 1, found_index, found_index + 1 - (found_index_old + 1))
        ans += found_index - found_index_old # found_index + 1 - (found_index_old + 1)
        found_index_old = found_index % s_len
    print(ans)
else:
    print(-1)


Measured memory_bytes: 3444
#include <stdio.h>

int A(char snake[])
{
	int i, num;
	
	if (snake[0] != '>' || snake[1] != '\''){
		return (0);
	}
	
	i = 2;
	num = 0;
	while (snake[i] == '='){
		i++;
		num++;
	}
	
	if (num == 0){
		return (0);
	}
	
	if (snake[i++] != '#'){
		return (0);
	}
	
	while (snake[i] == '='){
		i++;
		num--;
	}
	
	if (snake[i++] != '~'){
		return (0);
	}
	
	if (num == 0 && snake[i] == '\0'){
		return (1);
	}
	
	return (0);
}

int B(char snake[])
{
	int i;
	
	if (snake[0] != '>' || snake[1] != '^'){
		return (0);
	}
	
	i = 2;
	while (snake[i] == 'Q' && snake[i + 1] == '='){
		i += 2;
	}
	
	if (i == 2){
		return (0);
	}
	
	if (snake[i] == '~' && snake[i + 1] == '~' && snake[i + 2] == '\0'){
		return (1);
	}
	
	return (0);
}

int main(void)
{
	int i, n;
	char snake[256];
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%s", snake);
		if (A(snake)){
			puts("A");
		}
		else if (B(snake)){
			puts("B");
		}
		else {
			puts("NA");
		}
	}
	
	return (0);
}

Measured memory_bytes: 584
#include <iostream>
#include <string>

using ll = long long;
using std::cout;
using std::cin;
using std::endl;

int main(){
    int h,w,k;
    cin >> h >> w >> k;    
    char c[6][6];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> c[i][j];
        }
        
    }
    
    int iter_h = (1<<h);
    int iter_w = (1<<w);
    int ans = 0;
    for(int i=0; i<iter_h; i++){
        for(int j=0; j<iter_w; j++){
            int count = 0;
            for(int n=0; n<h; n++){
                if(i&(1<<n)) continue;
                for(int m=0; m<w; m++){
                    if(j&(1<<m)) continue;
                    if(c[n][m] == '#') count++;
                }
            }
            if(count == k) ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
first_arg = gets.split(' ').map(&:to_i)

waribiki_count = first_arg[2]

reizo = gets.split(' ').map(&:to_i)
rendi = gets.split(' ').map(&:to_i)
discounts = []

1.upto(waribiki_count) do |count|
  discount = gets.split(' ').map(&:to_i)
  discounts.push(discount)
end

min = reizo.min + rendi.min

discounts.each do |discount|
  prise = reizo[discount[0] - 1] + rendi[discount[1] - 1] - discount[2]
  min = prise if prise < min
end

puts min


Measured memory_bytes: 18956
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int DMAX=100000+5;
const int MOD=1000000000+7;
template<class T> inline void read(T &x){
	x=0;
	T f=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-'){
			f=-1;
		}
		ch=getchar();
	}
	while(ch<='9' && ch>='0'){
		x=x*10+(ch-'0');
		ch=getchar();
	}
	x*=f;
}

int n,m;
int a[105];
int cnt=0;
int add=0;
int main(){
	read(n),read(m);
	for(int i=1;i<=n;i++){
		read(a[i]);
		add+=a[i];
	}
	if(add%(4*m)!=0){
		add=add/(4*m);
		add++;
	}
	else{
		add=add/(4*m);
	}
	for(int i=1;i<=n;i++){
		if(a[i]>=add){
			cnt++;
		}
	}
	if(cnt>=m){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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


int main(){
    int N;
    cin >> N;
    vector<int> T(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        sum += T[i];
    }
    int M;
    cin >> M;
    for (int i = 0; i < M; i++) {
        int P, X;
        cin >> P >> X;
        cout << sum - T[P-1]  + X << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

const int N = 22;
const int N2 = 1<<22;
const int mod = 1e9 + 7;
int n;
int dp[N][N2];
int a[N][N];



int solve(int id, int bit)
{
    if(dp[id][bit] != -1) return dp[id][bit];
    if(id == n) return 1;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[id][i] == 1 && !(bit & (1 << i))){
            ans += solve(id+1, bit|(1<<i) );
            ans %= mod;
        }
    }
    return dp[id][bit] = ans;

}

int32_t SALI()
{

    memset(dp,-1,sizeof(dp));
    cin >> n;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a[i][j];

    cout << solve(0,0);
}




/**< WRITEN BY ALI ADELKHAH */



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

using ll=long long;
const int mod=1e9+7;

ll modinv(ll a, ll m) {
  ll b=m, u=1, v=0;
  while(b) {
    ll t=a/b;
    a -= t*b; swap(a, b);
    u -= t*v; swap(u, v);
  }
  u %= m;
  if(u<0)
    u += m;
  return u;
}
 
ll cmb(ll n, ll k) {
    ll i;
    if(k>n-k)
        k = n-k;
    ll r1=1, r2=1;
    for(i=n; i>n-k; i--)
        r1 = r1*i%mod;
    for(i=1; i<=k; i++)
        r2 = r2*i%mod;
    return r1 * modinv(r2,mod) % mod;
}

int main() {
    ll X,Y;
    cin >> X >> Y;

    if((X+Y)%3==0 && X-(X+Y)/3>=0 && Y-(X+Y)/3>=0) {
        cout << cmb((X+Y)/3, X-(X+Y)/3) << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]
ans = [0]*N

first = sorted(A)[-1]
second = sorted(A)[-2]

for i in range(N):
    if A[i]==first:
        ans[i] = second
    else:
        ans[i] = first

print(*ans, sep="\n")

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

int main(){
  int n;
  cin >> n;
  int A[n], maxv = 0, secondMaxv = 0;
  for ( int i = 0; i < n; i++){
    cin >> A[i];
    if ( A[i] >= maxv){
      secondMaxv = maxv;
      maxv = A[i];
    } else if ( A[i] > secondMaxv){
      secondMaxv = A[i];
    }
  }

  for ( int i = 0; i < n; i++){
    if ( A[i] == maxv){
      cout << secondMaxv << endl;
    } else {
      cout << maxv << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2432
# coding: utf-8

import sys
input = sys.stdin.readline

def f3(n, p):
    dp = [ 0.0 ] * (n + 1)
    dp[0] = 1.0
    for i in range(n):
        pi_ = 1 - p[i]
        dp = [dp[j - 1] * p[i] + dp[j] * pi_ \
            for j in range(n + 1)]
    return(sum(dp[n // 2 + 1:]))

n = int(input()) # n: odd, 1 <= n <= 2999
p = list(map(float, input().split())) # 0 < pi[i] < 1
print(f3(n, p))


Measured memory_bytes: 3316
N, P = map(int,input().split())
A = list(map(int,input().split()))
check = False
for a in A:
  if(a%2 != 0):
    check = True
    break
if(check == True):
  print(2**(N-1))
else:
  if(P == 0):
    print(2**N)
  else:
    print(0)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int a,b,k;
	cin >> a>> b>> k;
	int f=0,m[105];
	for(int i=1;i<=a&&i<=b;i++) {
		if(a%i==0&&b%i==0) {
			m[f]=i;
			f++;
		}
	}
	cout << m[f-k] ;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N  = sc.nextLong();
		
		long p = 1;
		long c = 1000000007;
		
		for(long i = 1; i <= N; i++) {
			p = p % c * i % c;
		}
		System.out.println(p);
	}
}


Measured memory_bytes: 23252
N,M = map(int,input().split())
Data = list(map(int,input().split()))
Data.sort()

if N >= M:
    print(0)
else:
    Diff = []
    for i in range(len(Data)-1):
        Diff.append(Data[i+1]-Data[i])
    Diff.sort()
    ans = 0
    for i in range((M-1)-(N-1)):
        ans += Diff[i]
    print(ans)


Measured memory_bytes: 13968
module Main where

import Data.List
import Control.Monad
import Debug.Trace

dropTail :: String -> [String]
dropTail s = fmap (\l -> drop l s) [0..toDrop] where
    toDrop = length s - 1

dropF :: String -> [String]
dropF s = fmap (\l -> take l s) [1..len] where
    len = length s

check :: String -> Bool
check s = all (\c -> c == 'A' || c == 'C' || c == 'G' || c == 'T') s

solve :: String -> Int
solve s = case lengthList of 
        [] -> 0
        x:xs -> x
    where
        lengthList =  reverse $ sort $ map length $ filter check $ dropF s >>= dropTail


main = do
    s <- getLine
    print $ solve s



Measured memory_bytes: 508
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    string s = read!string;
    writeln(s.count!(c => c == 'x') <= 7 ? "YES" : "NO");
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    x <- readLn
    a <- readLn
    b <- readLn
    -- 出力
    putStrLn . show $ (x - a) `mod` b


Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

using namespace std;

using PII = pair<int, int>;

// Union-Find
class UnionFind {
private:
	// parents[i] >= 0 なら i の親
	// parents[i] < 0 で、根。abs(parents[i])がその木に属する頂点数
	vector<int> parents;
	int n_root;

public:
	UnionFind();
	UnionFind(int n) {
		parents.assign(n, -1);
		n_root = n;
	}
	~UnionFind() {
		parents.clear();
	};

	int find(int x) {
		if (parents[x] < 0) {
			return x;
		} else {
			return parents[x] = find(parents[x]);
		}
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);

		if (x == y) {
			return;
		}

		if (size(x) < size(y)) {
			swap(x, y);
		}

		parents[x] += parents[y];
		parents[y] = x;
		n_root--;
		return ;
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// xが属する集団のサイズ
	int size(int x) {
		return -parents[find(x)];
	}

	// いくつの集団があるか
	int get_n_root() {
		return n_root;
	}
};

int main() {
	int n, k, l, a, b;
	cin >> n >> k >> l;

	UnionFind road(n), railway(n);
	for (int i = 0; i < k; i++) {
		cin >> a >> b;
		road.unite(a-1, b-1);
	}
	for (int i = 0; i < l; i++) {
		cin >> a >> b;
		railway.unite(a-1, b-1);
	}

	map<PII, int> cities;
	for (int i = 0; i < n; i++) {
		cities[make_pair(road.find(i), railway.find(i))]++;
		// printf("%2d %2d %2d\n", i, road.find(i), railway.find(i));
	}

	for (int i = 0; i < n; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << cities[make_pair(road.find(i), railway.find(i))];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 13568
#include<stdio.h>
#define N 10000
#define Q 500
int main(){
  int n, q, S[N], T[Q], i, j, C = 0, f;
  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[i]);
  }
  for(i = 0; i < q; i++){
    f = 0;
    for(j = 0; j < n; j++){
      if(f == 0){
	if(T[i] == S[j]){
	  C++;
	  f++;
	  break;
	}
      }
    }
  }
  printf("%d\n", C);
  return 0;  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n);
    rep(i,m){
        cin>>a[i];
        n-=a[i];
    }
    if(n>=0)cout<<n<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 7212
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b) = listOfInt()
    val diff = b - a
    val heightB = diff * (diff + 1) / 2
    println(heightB - b)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37864
#include <iostream>

using namespace std;

int main(void){
  int state; //ツ前ツ嘉アツづ個督ョツつ「ツつスツ陛サツ古シ
  int x, y; //current position
  bool horizon[5][4];
  bool vertical[4][5];
  char tmp;
  int i,j;

  for(i=0;i<9;i++){
	if(i%2 == 0){
	  for(j=0;j<4;j++){
		cin >> tmp;
		if(tmp == '1'){
		  horizon[i/2][j] = true;
		}else{
		  horizon[i/2][j] = false;
		}
	  }
	}else{
	  for(j=0;j<5;j++){
		cin >> tmp;
		if(tmp == '1'){
		  vertical[i/2][j] = true;
		}else{
		  vertical[i/2][j] = false;
		}
	  }
	}
  }

  state = 'R';
  cout << "R";
  x = 0;
  y = 1;
  
  while(!(x == 0 && y == 0)){
	if(state == 'R'){
	  if(x - 1 >= 0 && vertical[x-1][y] ){
		state = 'U';
		x--;
		cout << "U";
	  }else if(y <= 3 && horizon[x][y]){
		state = 'R';
		y++;
		cout << "R";
	  }else if(x <= 3 && vertical[x][y]){
		state = 'D';
		x++;
		cout << "D";
	  }else{
		state = 'L';
		y--;
		cout << "L";
	  }
	}else if(state == 'D'){
	  if(y <= 3 && horizon[x][y]){
		state = 'R';
		y++;
		cout << "R";
	  }else if(x <= 3 && vertical[x][y]){
		state = 'D';
		x++;
		cout << "D";
	  }else if( y >= 1 && horizon[x][y-1]){
		state = 'L';
		y--;
		cout << "L";
	  }else{
		state = 'U';
		x--;
		cout << "U";
	  }
	}else if(state == 'L'){
	  if(x <= 3 && vertical[x][y]){
		state = 'D';
		x++;
		cout << "D";
	  }else if(y >= 1 && horizon[x][y-1]){
		state = 'L';
		y--;
		cout << "L";
	  }else if(x >= 1 && vertical[x-1][y]){
		state = 'U';
		x--;
		cout << "U";
	  }else{
		state = 'R';
		y++;
		cout << "R";
	  }
	}else{
	  if(y >= 1 && horizon[x][y-1]){
		state = 'L';
		y--;
		cout << "L";
	  }else if(x >= 1 && vertical[x-1][y]){
		state = 'U';
		x--;
		cout << "U";
	  }else if(y <= 3 && horizon[x][y]){
		state = 'R';
		y++;
		cout << "R";
	  }else{
		state = 'D';
		x++;
		cout << "D";
	  }
	}
	//cout << x << " " << y << endl;
	//cin >> i;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>

using namespace std;

int main(){
  string S; cin >> S;
  bool flag_N = false; bool flag_E = false; bool flag_S = false; bool flag_W = false;
  for(int i = 0;  i < S.size(); i++){
    if(S[i] == 'N'){ flag_N = true;}
    else if(S[i] == 'E'){flag_E = true;}
    else if(S[i] == 'S'){flag_S = true;}
    else if(S[i] == 'W'){flag_W = true;}}
  
  if(!(flag_N ^ flag_S) && !(flag_E ^ flag_W)){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  return 0;}

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

int main(){
  int a,b,c,d;	cin >> a >> b >> c >> d;
  while(1){
    c-=b;
    if(c<=0){
      cout << "Yes";
      return 0;
    }
    a-=d;
    if(a<=0){
      cout << "No";
      return 0;
    }
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_HW = 405;
char c[MAX_HW][MAX_HW];
vector<int> B;
bool visited[MAX_HW][MAX_HW];
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
ll cntB = 0, cntW = 0;
int H,W;

void dfs(int x, int y)
{
	if (visited[x][y]) return;
	visited[x][y] = true;
	if (c[x][y] == '#') cntB++;
	else cntW++;
	rep(i,4)
	{
		int xx = x+dx[i], yy = y+dy[i];
		if (xx >= 0 && xx < H && yy >= 0 && yy < W)
		{
			if (c[x][y] == '#' && c[xx][yy] == '.')
			{
				dfs(xx,yy);
			}
			else if (c[x][y] == '.' && c[xx][yy] == '#')
			{
				dfs(xx,yy);
			}
		}
	}
	return;
}

int main()
{
	cin >> H >> W;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> c[i][j];
		}
	}

	ll ans = 0;
	rep(i,H)
	{
		rep(j,W)
		{
			cntB = 0, cntW = 0;
			dfs(i,j);
			ans += cntB * cntW;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13832
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n,k;
    cin>>n>>k;
    ll int h[n];
    ll int i,j;ll int dp[n];
    for(i=0;i<n;i++)
    	cin>>h[i];
    dp[0]=0;dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++)
    {
    	dp[i]=INT_MAX;
    	for(j=max((ll int)0,i-k);j<i;j++)
    	{
    		dp[i]=min(dp[j]+abs(h[j]-h[i]),dp[i]);
    	}	
	}
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	vector<int> A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K; cin >> K;
	cout << A[K-1] << endl;

	
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    // １分間に長針が動く角度
    private static double LONG_ANGLE  = 0.5;
    // １分間に短針が動く角度
    private static double SHORT_ANGLE = 6.0;

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

        // 長針の長さ
        int a = sc.nextInt();
        // 短針の長さ
        int b = sc.nextInt();

        int h = sc.nextInt();
        int m = sc.nextInt();

        double angleH = LONG_ANGLE  * (h * 60 + m);
        double angleM = SHORT_ANGLE * m;
        double angle = 0;
        if (angleH > angleM) {
            angle = angleH - angleM;
        } else {
            angle = angleM - angleH;
        }

        System.out.println(
                Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
    }
}

Measured memory_bytes: 27180
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<int,int> P;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<std::vector<P>> A(N);
  rep(i,N) {
    int a; std::cin >>a;
    rep(j,a) {
      int x,y; std::cin >> x >> y;
      x--;
      A[i].push_back( {x,y} );
    }
  }

  int ans = 0;
  for(int b=0; b<(1LL<<N); b++) {
    bool isCONSISTENT = true;
    rep(i,N) {
      int k = (b & (1LL<<i)) != 0 ? 1 : 0;
      if ( k == 1 ) {
        rep(j,sz(A[i])) {
          int m = (b&(1LL<<A[i][j].first)) != 0 ? 1 : 0;
          if ( m != A[i][j].second ) isCONSISTENT = false;
        }
      }
    }
    if ( isCONSISTENT ) {
      ans = std::max(ans, (int)std::bitset<15>(b).count());
    }
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
#define mp make_pair
bool isPrime(ll n) 
{ 
    
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
   
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll minthis(ll a, ll b){
if(a < b){
return a;
}
return b;
}
ll maxthis(ll a, ll b){
if(a > b){
return a;
}
return b;
}
int gcd(int a, int b){
    if( a<0 ) a = -a;
    if( b<0 ) b = -b;
    while( b!=0 ){
        a %= b;
        if( a==0 ) return b;
        b %= a;
    }
    return a;
}
 
int findLargestDivisor(int n) 
{ 
	int max = 1;
    for (int i = 2; i < n; i++) {        
        if(n %(i) == 0) { 
            max = i;
        } 
    }
    return max;     
} 
 
 
ll power(ll x, ll y)  
{  
    ll temp;  
    if(y == 0)  
        return 1;  
    temp = power(x, y / 2);  
    if (y % 2 == 0)  
        return temp * temp;  
    else
    {  
        if(y > 0)  
            return x * temp * temp;  
        else
            return (temp * temp) / x;  
    }  
}  
vector<ll> v;
vector<ll> dp;
const ll mod = 1000000007;
ll recurse(ll target , ll sum){
	if(sum > target) return 0ll;
	if(sum == target) return 1ll;
	if(dp[sum] != -1) return dp[sum];
	ll ans = 0ll;
	for(ll i = 0 ; i < (ll)v.size() ; i++){
		ans += recurse(target , (sum+v[i])%(mod));	
		ans = ans%mod;
		dp[sum] = ans;	
	}	
	return ans;
}
 
 
void solve(){	
	
	ll n, target;
	cin >> target;	
	for(ll i = 3 ; i <= target ; i++){
		v.pb(i);
	}
	dp.resize(target , -1);
	ll ans = recurse(target , 0);
	cout << ans << "\n";
}
  
int main(){ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1; 
    while(t--){
		solve();
	}
    return 0; 
}


Measured memory_bytes: 3756
import java.util.Scanner;

public class Main{
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int tm = Math.min(A, B);
		int bm = Math.min(C, D);
		System.out.println(tm+bm);
	}
}



Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
	string str,str2;
	vector<short int> array[4001];
	int i,j;
	
	for(i=0;i<4001;i++)
	{
		for(j=0;j<4001;j++)
		{
			array[i].push_back(0);
		}
	}
	
	for(;cin >> str;)
	{
		cin >> str2 ;
		int ans=0;
		for(i=1;i<=str.size();i++)
		{
			for(j=1;j<=str2.size();j++)
			{
				array[i][j]=0;
				if(str[i-1]==str2[j-1])
				{
					array[i][j]=array[i-1][j-1]+1;
				}
				if(ans<array[i][j])
					ans=array[i][j];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 32000
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
r = np.array(range(N))
X = r+A
Y = r-A
ans = 0
x_dic = {}
y_dic = {}
for x in X:
    if x in x_dic:
        x_dic[x] += 1
    else:
        x_dic[x] = 1
  
for y in Y:
    if y in y_dic:
        y_dic[y] += 1
    else:
        y_dic[y] = 1

for x in x_dic:
    if x in y_dic:
        ans += x_dic[x]*y_dic[x]        
print(ans)
#print(X,x_dic,Y,y_dic)


Measured memory_bytes: 75468