akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vi x(N),y(N);
  rep(i,N) cin >> x[i];
  rep(i,N) cin >> y[i];
  ll ans = 0LL;
  vi edge;
  RREP(p,51,1){
    vvl g(51,vl(51,LINF));
    rep(i,51) g[i][i] = 0LL;
    // pの辺を貼る必要があるか?
    for(int i:edge){
      rep(u,51) g[u][u%i] = 0LL;
    }
    // p抜きのグラフを構築する
    REP(i,1,p){
      rep(u,51) chmin(g[u][u%i],1LL<<i);
    }
    // Warshall-Floyd
    rep(i,51) rep(j,51) rep(k,51) chmin(g[i][j],g[i][k]+g[k][j]);
    bool check = true, clear = true;
    rep(i,N) check &= (g[x[i]][y[i]] != LINF), clear &= (g[x[i]][y[i]] == 0LL);
    if(clear) break;
    if(!check){
      if(p==51){
        cout << "-1" << endl;
        return 0;
      }else{
        edge.pb(p);
      }
    }
  }
  for(int i:edge) ans |= (1LL << i);
  dump(edge);
  cout << ans << endl;
  return 0;
}


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

const ll MOD = 1000000000 + 7;

ll mypow(ll x, ll n){
  ll res = 1LL, tmp = x;
  while(n){
    if(n&1) res = (res * tmp) % MOD;
    tmp = (tmp * tmp) % MOD;
    n = (n / 2) % MOD;
  }
  return res;
}

int main(void){
  int N; cin >> N;
  string str; cin >> str;
  vector<int> cnt('z'-'a'+1, 0);
  for(const auto& c: str){
    cnt[c - 'a']++;
  }

  ll ans = 1;

  for(const auto& c: cnt){
    ans = (ans * (c + 1) % MOD) % MOD;
  }

  cout << ans-1 << endl;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int W,a,b,ans = 0;

int main(){
	ios::sync_with_stdio(false);
	cin >> W >> a >> b;
	if(a >= b){
		ans = a-b-W;
	}else{
		ans = b-a-W;
	}
	if(ans < 0){
		ans = 0;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


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

  int fi=0, se=0;
  int p[n];
  REP(i, n){
    cin>>p[i];
    if(p[i]<=a) ++fi;
    else if(p[i]<=b) ++se;
  }

  int ans=min(fi, min(se, n-fi-se));
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define Forr(i,a,b) for(register int i=a;i>=b;i--)
using namespace std;
inline void read(int &x)
{
    int p=1;
    x=0;
    char c=getchar();
    while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
    while(isdigit(c)){x=(x<<3)+(x<<1)+(c^'0');c=getchar();}
    x*=p;
}
char s[10];
int len;
int main()
{
	scanf("%s",s+1);
	len=strlen(s+1);
	int flag=0;
	For(i,1,len-1)
		if(s[i]=='A'&&s[i+1]=='C')
		{
			flag=1;
			printf("Yes\n");
			break;
		}
	if(flag==0)printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int table[26];
char S[5];

int main(){

	for(int i = 0; i < 26; i++){

		table[i] = 0;
	}

	scanf("%s",S);

	for(int i = 0; S[i] != '\0'; i++){

		table[S[i]-'A']++;
	}

	int num_2 = 0;

	for(int i = 0; i < 26; i++){
		if(table[i] == 2){

			num_2++;
		}
	}

	if(num_2 == 2){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as B  
import qualified Data.Vector.Unboxed as VU
import Data.Char

solve :: VU.Vector Int -> Int -> Int
solve xs acc
    | VU.null xs || VU.all (==0) xs = acc 
    | otherwise = solve ((VU.map (subtract 1) ts) VU.++ ds') (acc+1)
    where
        ds = VU.dropWhile (<=0) xs 
        ts = VU.takeWhile (>0) ds
        ds' = VU.drop (VU.length ts) ds

main = do
    n <- readLn :: IO Int
    hs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ solve hs 0

Measured memory_bytes: 1020
#include<iostream>
using namespace std;
#include<iomanip>
int main(){
  int n,i=0;
  cin>>n;
  double a[n];
  double sum=0;
  while(i<n){
    cin>>a[i];
    sum=sum+(1/a[i]);
    i++;
  }
  cout<<fixed;
  cout<<setprecision(5)<<1/sum;
  return 0;
}

Measured memory_bytes: 256
// EducationalDPContest.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 1 << 30;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
int main()
{
	// B - Frog 2
	int n, k;
	cin >> n >> k;
	vector<int> dp(n, INF);
	vector<int> h(n);
	for (int i = 0; i < n; i++)	cin >> h[i];
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		for (int j = max(i - k, 0); j < i; j++) {
			chmin(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
//最大=その他の和
int main(){
    int a, b, c;
    cin>>a>>b>>c;
    if(a==b+c){
        cout << "Yes" << endl;
        return 0;
    }
    if(b==a+c){
        cout << "Yes" << endl;
        return 0;
    }
    if(c==b+a){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long mod = 1e9+7;

int main(void) {
    int r; cin >> r;
    cout << 3*r*r << endl;

  return 0;
}

// EOF


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;
typedef std::vector<int> vi;

using namespace std;

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

    int n;
    cin >> n;
    int ans = 0;
    rep(i, 1, n) {
        rep(j, 1, n) {
            if (i * j < n)
                ans++;
            else
                break;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int N=65;
const double eps=1e-9;
int n,k;
double x[N],y[N],c[N],r[N];
double dis(pair<double,double> a,pair<double,double> b) {
    return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
vector<pair<double,double> > cal(double x1,double y1,double r1,double x2,double y2,double r2) {//两圆交点
    x1-=x2,y1-=y2;
    double S=x1*x1+y1*y1,a=(S+r2*r2-r1*r1)/2,D=S*r2*r2-a*a;
    if(D<0) return {};
    double A1=a*x1,B1=y1*sqrt(D);
    double A2=a*y1,B2=x1*sqrt(D);
    return {{(A1+B1)/S+x2,(A2-B2)/S+y2},{(A1-B1)/S+x2,(A2+B2)/S+y2}};
}
bool check(double t) {
    for(int i=0;i<n;i++) r[i]=t/c[i];
    vector<pair<double,double> > vec;
    for(int i=0;i<n;i++) {
        vec.push_back({x[i],y[i]});
        for(int j=i+1;j<n;j++) {
            auto v=cal(x[i],y[i],r[i],x[j],y[j],r[j]);
            for(auto it:v) vec.push_back(it);
        }
    }
    for(auto it:vec) {
        int cnt=0;
        for(int i=0;i<n;i++) {
            if(r[i]+eps>=dis(it,{x[i],y[i]})) cnt++;
        }
        if(cnt>=k) return true;
    }
    return false;
}
int main() {
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) {
        scanf("%lf%lf%lf",&x[i],&y[i],&c[i]);
    }
    double L=0,R=1e9;
    for(int i=0;i<100;i++) {
        double mid=(L+R)/2;
        if(check(mid)) R=mid;
        else L=mid;
    }
    printf("%.6f\n",R);
    return 0;
}


Measured memory_bytes: 508
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    string S;
    cin >> S;
    int N = S.size();

    map<int, int> dp;
    int eo = 0;
    rep(i, N) {
        eo ^= 1 << (S[i] - 'a');

        int n = eo == 0 || ((eo - 1) & eo) == 0 ? 1 : INF;
        auto ie = dp.find(eo);
        if (ie != dp.end()) {
            dp[eo] = min(n, (*ie).second + 1);
        }

        rep(c, 26) {
            auto io = dp.find(eo ^ (1 << c));
            if (io != dp.end()) {
                n = min(n, (*io).second + 1);
            }
        }

        if (ie != dp.end()) dp[eo] = min(dp[eo], n);
        else dp[eo] = n;
    }

    write(dp[eo]);
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()

template<typename U, typename T>
void chmin(U &x, T y) { x = min(x, y); }

template<typename U, typename T>
void chmax(U &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> P;

const int INF = INT_MAX/3;
const double EPS = 1e-14;
const int dx[4] = {0, 1, 0, -1}; // {-1,  0,  1, -1, 1, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0}; // {-1, -1, -1,  0, 0,  1, 1, 1};

int n;

int main() {
  cout << fixed << setprecision(10);
  cin >> n;
  if (n == 0 || n == 2) {
    cout << 1 << endl;
  } else if (n == 1) {
    cout << 2 << endl;
  } else {
    cout << 0 <<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextLine()) {
            int number = s.nextInt();
            int digits = s.nextInt();

            if(number == 0 && digits == 0) break;

            List<Integer> resultList = new LinkedList<Integer>();
            resultList.add(number);
            int result = exec(number, digits, resultList);
            System.out.println(String.valueOf(resultList.indexOf(result)) + " " + result + " " + String.valueOf(resultList.lastIndexOf(result) - resultList.indexOf(result)));
        }
    }

    private static int exec(int number, int digits, List<Integer> resultList){
        int result = sortNumber(number, digits, false) - sortNumber(number, digits, true);
        if(resultList.contains(result)){
            resultList.add(result);
            return result;
        } else {
            resultList.add(result);
            return exec(result, digits, resultList);
        }
    }

    private static int sortNumber(int targetNum, int digits, boolean isAsc){
        String targetNumStr = String.valueOf(targetNum);
        int length = targetNum == 0 ? 1 : (int)(Math.log10(targetNum)+1);
        for(int l = length; l < digits; l++){
            targetNumStr += "0";
        }

        List<String> list = new ArrayList<String>();

        for(int i = 0; i < targetNumStr.length(); i++){
            list.add(String.valueOf(targetNumStr.charAt(i)));
        }
        if(isAsc){
            Collections.sort(list, ASC);
        } else {
            Collections.sort(list, DESC);
        }
        String sortedNumStr = "";
        for(String s : list){
            sortedNumStr += s;
        }
        return Integer.valueOf(sortedNumStr);
    }

    private static Comparator<String> ASC = new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            int res = String.CASE_INSENSITIVE_ORDER.compare(o1, o2);
            return (res != 0) ? res : o1.compareTo(o2);
        }
    };

    private static Comparator<String> DESC = new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            int res = String.CASE_INSENSITIVE_ORDER.compare(o2, o1);
            return (res != 0) ? res : o1.compareTo(o2);
        }
    };

}

Measured memory_bytes: 32924
"use strict";
function gcd(a) {
    var f = (a, b) => b ? f(b, a % b) : a;
    var ans = a[0];
    for (var i = 1; i < a.length; i++) {
        ans = f(ans, a[i]); 
    }
    return ans;
}
function Main(input) {
    let lines = input.split("\n");
    let cols = lines[0].split(/\s/).map((v) => v - 0);
    let N = cols[0], X = cols[1];
    let x = lines[1].split(/\s/).map((v) => v - 0);
    let y = x.map((v) => Math.abs(X - v));
    console.log(gcd(y));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(void){
    int H,W,K;
    cin >> H >> W >> K;
    string c[H];
    for(int i =0;i<H;i++)cin>>c[i];

    int ans = 0;
    for(int i = 0;i<(1<<H);i++){
        for(int j = 0;j<(1<<W);j++){
            int cnt = 0;
            for(int k = 0;k<H;k++){
                if((i&(1<<k)) != 0)continue;
                for(int l = 0;l<W;l++){
                    if((j&(1<<l))!= 0)continue;
                    if(c[k][l] == '#')cnt++;
                }
            }
            if(cnt == K)ans++;
        }
    }

    cout<< ans <<  endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const long long INF = 1e15;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
typedef pair<int,int> pii;
int main(){
    int n;
    cin >> n;
    vector<pair<long long,pii>> data;
    long long tem;
    rep(i,n){
        rep(j,n){
            cin >> tem;
            if(j>i) data.push_back(make_pair(tem,make_pair(i+1,j+1)));
        }
    }
    sort(data.begin(),data.end());
    long long distance[n+1][n+1];
    rep(i,n+1){
        rep(j,n+1){
            distance[i][j]=INF;
        }
    }
    rep(i,n+1){
        distance[i][i] = 0;
    }
    int a,b;
    long long c;
    long long ans = 0;
    rep(i,data.size()){
        a = data[i].second.first;
        b = data[i].second.second;
        c = data[i].first;
        if(c>distance[a][b]){
            cout << "-1" << endl;
            //cout << "a: " << a << " b: " << b << " dist: " << distance[a][b] << " cost: "  << c << endl;
            return 0;
        }
        if(distance[a][b] != c){
            distance[a][b] = c;
            distance[b][a] = c;
            for(int j = 1;j<=n;j++){
                for(int k = 1;k<=n;k++){
                    distance[j][k] = min(distance[j][k],distance[j][a]+distance[a][k]);
                }
            }
            for(int j = 1;j<=n;j++){
                for(int k = 1;k<=n;k++){
                    distance[j][k] = min(distance[j][k],distance[j][b]+distance[b][k]);
                }
            }            
            ans+=c;
        }
        //cout << "dist: " << distance[1][4] << endl;
    }
    cout << ans << endl;
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

int main(void)
{
    int x, y;
    cin >> x >> y;

    for(int i = 1; i <= x; i++) {
        int j = x-i;
        if(2*i + 4 * j == y || 4 * i + 2 * j == y) {
            cout << "Yes" << endl;
            return 0;
        } 
    }
    cout << "No" << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    if(s[2] != s[3] || s[4] != s[5]) {
        cout << "No" << endl;
        return 0;
    } 
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	int minj;
	int count=0;
	for(int i=0;i<n;i++){
		minj=i;
		for(int j=i;j<n;j++)
			if(a[j]<a[minj])
				minj=j;
		swap(a[i],a[minj]);
		if(i!=minj)
			count++;
	}
	for(int i=0;i<n;i++){
		cout << a[i];
		if(i!=n-1)
			cout << " ";
		else cout << endl;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n>=30)
     cout<<"Yes";
    else
     cout<<"No";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, req[3];
    cin >> a >> b;
    req[0] = a+b;
    req[1] = a-b;
    req[2] = a*b;
    sort(req, req+3);
    cout << req[2] << endl;
return 0;
}


Measured memory_bytes: 256
#14:18
n,t = map(int,input().split())
a = list(map(int,input().split()))
b = [0]
for i in range(n)[::-1]:
  b.append(max(b[-1],a[i]))
b.reverse()
b.pop()
#print(b)
c = []
for i in range(n):
  c.append(b[i]-a[i])
c.sort(reverse=True)
#print(c)
cnt = 0
for i in range(n):
  if c[0] == c[i]:
    cnt += 1
  else:
    print(cnt)
    break

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

int main(void){
    int H, W;
    cin >> H >> W;
    string s[H];

    for(int i = 0; i < H; i++){
        cin >> s[i];
        s[i] = '#' + s[i] + '#';
    }

    for(int i = 0; i < W+2; i++)
        cout << '#';
    cout << endl;
    for(int i = 0; i < H; i++)
        cout << s[i] << endl;
    for(int i = 0; i < W+2; i++)
        cout << '#';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

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

	if (K > (N - 1) * (N - 2) / 2){
		cout << "-1" << endl;
		return 0;
	}

	vector<pair<int, int> > v;
	for (int i = 2; i <= N; i++){
		v.push_back(pair<int, int>(1, i));
	}

	int temp = (N - 1) * (N - 2) / 2 - K;
	for (int i = 0, a = 2, b = 3; i < temp; i++){
		v.push_back(pair<int, int>(a, b));

		b++;
		if (b == N + 1){
			a++;
			b = a + 1;
		}
	}

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


Measured memory_bytes: 384
#include<stdio.h>
int main(){
int num,priya,purna,sum=0;
scanf("%d",&num);
priya=num;
while(priya!=0){
    purna=priya%10;
    sum=sum*10+purna;
    priya=priya/10;
}
if(num==sum)
    printf("Yes");
else
    printf("No");
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner a = new Scanner(System.in);
		int number1 = a.nextInt();
		int number2 = a.nextInt();
		
		System.out.println(gcd(number1,number2));

	}
	
	public static int gcd(int x,int y) 
	{
		int temp = 0;
		if(y == 0 ) {return x;}
		if(x<=y) 
		{
			temp =y;
			y=x;
			x= temp;
			return gcd(y,x%y);
		}
		else{return gcd(y,x%y);}
	}

}


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

int main()
{
    int n;
    cin >> n;
    bool b[105];
    for(int i = 0; i < n; i++){
        int d1, d2;
        cin >> d1 >> d2;
        if(d1 == d2) b[i] = true;
    }
    for(int i = 0; i < n - 2; i++){
        if(b[i] + b[i + 1] + b[i + 2] == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int t=63000;
	for(int i=t;i;i--){
		for(int j=max(i,9);j;j--){
			if(i<10&&j<10)cout<<10-i<<"x"<<10-j<<"="<<(10-i)*(10-j)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2916
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int x,a,b;
  cin >> x >> a >>b;
  if(abs(x-a)<abs(x-b)){cout << 'A' << endl;}else{cout <<'B' << endl;}
}

Measured memory_bytes: 3640
var n,m,i,j,ans,k,l,num:longint;
var cc:char;
var c:array[0..100] of ansistring;
begin
  readln(n,m);
  for i:=1 to n do readln(c[i]);
  for i:=1 to n do
  begin
    for j:=1 to m do
    begin
      if c[i,j]='.' then
      begin
        ans:=0;
        for k:=-1 to 1 do
          for l:=-1 to 1 do
          if (i+k>0) and (i+k<=n) and (j+l>0) and (j+l<=m) then
          if c[i+k,j+l]='#' then inc(ans);
          write(ans);
      end else write(c[i,j]);
    end;
    writeln;
  end;
end.

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, d, x;
  cin >> n >> d >> x;

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

  int ans = x;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= d; j=j+a[i]) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = int(input())
d = {s: 1}
i = 1

while True:
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    i += 1
    if s in d.keys():
        print(i)
        exit()
    else:
        d[s] = i


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 5e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int x, a;
	cin >> x >> a;
	cout << (x < a ? 0 : 10);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
public class c
{
  public static void Main()
 {
   string b = Console.ReadLine();
   int i,j;
    int n=b.Length;
    int count=0;
    int countmax=0;
    for(i=0;i<n;i++)
    {
      if(b[i]=='A'||b[i]=='T'||b[i]=='C'||b[i]=='G')
      {  for(j=i;j<n;j++)
        {
          if(b[j]=='A'||b[j]=='T'||b[j]=='C'||b[j]=='G')count++;
          else break;
        }
       if(count>countmax)countmax=count;
      
      }
      count=0;
    }
    Console.WriteLine(countmax);
 }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf (1<<30)

int main(){
	int n;cin>>n;
	int ans=0;
	vector<int>a(n+1);
	a[n]=0;
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	for(int i=0;i<n;++i){
		if(a[i]==a[i+1]){
			int x=1;
			while(a[i+2]==x)++x;
			a[i+1]=x;
			++ans;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
 
  ll sum = 0, ans = -1;
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    ans += y;
    sum += x*y;
  }

  while(sum>9){
    ans+=sum/10;
    sum = sum-(sum/10)*9;
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
n = int( input() )

Floor_list = [[[0 for x in range(10)] for j in range(3)] for i in range(4)]

for i in range(n):
    b , f , r , v = map( int,input().split() )
    Floor_list[b-1][f-1][r-1] += v

for b in range(4):
    for f in Floor_list[b]:
        print(" "+" ".join([str(x) for x in f]))
    if b != 3:
        print("".join(["#" for x in range(20)]))


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

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


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

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

void solve(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
    cout<<a*x/b-x/b*a<<en;
}

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

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

    return 0;
}


Measured memory_bytes: 3608
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

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

fn main() {
    let s: String = input();
    let vec: Vec<char> = s.chars().collect();
    if vec[0] == vec[1] && vec[1] == vec[2] && vec[2] == vec[3] {
        println!("No");
        return;
    }
    if vec[0] == vec[1] {
        if vec[2] == vec[3] {
            println!("Yes");
            return;
        }
    }
    if vec[0] == vec[2] {
        if vec[1] == vec[3] {
            println!("Yes");
            return;
        }
    }
    if vec[0] == vec[3] {
        if vec[1] == vec[2] {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	string S;
	cin >> S;
	S.push_back('S');
	ll ans = 0;
	ll anstmp = 0;
	rep(i, 4) {
		if (S[i] == 'R')
			anstmp++;
		else {
			ans = max(ans, anstmp);
			anstmp = 0;
		}

	}




	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int tran(float t)
{
	int x = t;
	if(t - x < 0.5)return x;
	else
		return x + 1;
}
int main()
{
	int a, b;
	cin >> a >> b;
	int ta, tb, t1, t2;
	ta = a / 0.08;
	tb = b / 0.1;
	//cout << ta << "  " << tb << endl;
	for(int i = min(ta,tb); i <= max(ta,tb)+1; i++){
		//cout << " i : " << i << "  " << (int)(i*0.08) << "  " << (int)(i*0.1) << endl;
		t1 = i*0.08;t2 = i*0.1;
		if(t1 == a && t2 == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

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


int main(){
    int K,S;cin>>K>>S;
    int Z;
    int ans=0;
    for(int i=0;i<K+1;++i){
        for(int j=0;j<K+1;++j){
            int c=S-i-j;
            if(0<=c&&c<=K)ans++;
        }

    }
    cout<<ans<<endl;
}

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

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(i % 2 && s[i] == 'R') return cout << "No\n", 0;
        if(i % 2 == 0 && s[i] == 'L') return cout << "No\n", 0;
    }
    cout << "Yes\n";
}


Measured memory_bytes: 256
import collections
n, m = map(int, input().split())
A = [int(i) for i in input().split()]

R = [0]
a = 0
for i in range(n):
    a += A[i]
    a %= m
    R.append(a)


def nc2(n):
    return n*(n-1)//2


c = collections.Counter(R)
ans = 0
for r in set(R):
    ans += nc2(c[r])
print(ans)


Measured memory_bytes: 17096
import java.util.*;

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 x = b*10+c;
    if(x%4==0){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }
  }
}
    
    
    

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int n,m,b[1000][1000];
char x;
int main()
{
    cin>>n>>m;
    for (int i=1; i<=n; ++i)
    for (int j=1; j<=m; ++j)
    {
        cin>>x;
        if (x=='#') {b[i][j]=-10000; b[i][j+1]++; b[i+1][j]++; b[i+1][j+1]++; b[i-1][j]++; b[i][j-1]++; b[i-1][j-1]++; b[i-1][j+1]++; b[i+1][j-1]++;}
    }
    for (int i=1; i<=n; ++i)
    {
    for (int j=1; j<=m; ++j)
    if (b[i][j]<0) cout<<'#';
    else cout<<b[i][j];
    cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin>>n;
    vector<ll> p(n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n/i;j++){
            p[i*j-1]++;
        }
    }
    ll ans=0;
    rep(i,n){
        ans+=(i+1)*p[i];
    }
    cout<<ans<<endl;
    return 0;
}



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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    int h;
    REP(i, n) {
        cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

satis = 0
for i in range(N):
    satis += B[A[i]-1]
    if i in range(N-1):
        if A[i+1]-A[i] == 1:
            satis += C[A[i]-1]

print(satis)

Measured memory_bytes: 3064
#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;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }



int main(){
  int a,b,c;
  cin >> a >> b >>c ;
  cout << (a + b + c - 2 * max(a,max(b,c)) == 0?"Yes":"No") << endl;
}


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

int main(){
    unsigned long long X, Y;
    cin >> X >> Y;
    unsigned long long m, num;
    num = X;
    m = 1;
    while(num <= Y){
        num = num*2;
        m++;
    }
    cout << m-1 << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
h = gets.split(" ").map(&:to_i)

dp = Array.new(n, 1.0 / 0)
dp[0] = 0

(0..(n - 1)).each do |i|
  dp[i] = [dp[i], dp[i - 1] + (h[i] - h[i - 1]).abs].min
  dp[i] = [dp[i], dp[i - 2] + (h[i] - h[i - 2]).abs].min if i > 1
end

puts dp[-1]

Measured memory_bytes: 11396
#include<bits/stdc++.h>
#include <queue>
#include <cstring>
#define mp make_pair
#define pb push_back
#define p push

#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
#define MAXN 100005
using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;


int main (){
    ll n;
    cin>>n;
    ll k= n %100;
    ll t = n/100;
    if(k > t *5)cout<<0;
    else cout <<1;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k, n;
    cin >> k >> n;

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

    int maxDis = 0;
    for(int i = 0; i < n - 1; i++) {
        maxDis = max(maxDis, a[i + 1] - a[i]);
    };

    maxDis = max(maxDis, k - a[n - 1] + a[0]);

    cout << k - maxDis << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,a,b; cin >> n >> a >> b;
    cout << min(a,b) << " " << max(a+b-n,0LL) << endl;
}





Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,n,s[101],t[101],g[101],flg,z;
	while(1){
	flg=0;
	scanf("%d",&n);
	if(n==0)	break;
	for(i=0;i<n+1;i++){
		scanf("%d",&s[i]);
		}
	for(i=0;i<n+1;i++){
		for(j=0;j<n;j++){
		if(j>=i){
			t[j]=s[j+1];
			}
		else{
			t[j]=s[j];
			}
		}	
		for(j=0;j<n-1;j++){
			g[j]=t[j+1]-t[j];
			}
		for(j=0;j<n-2;j++){
			if(g[j]!=g[j+1]){
			flg=0; break;
			}
			if(g[j]==g[j+1]){
			flg=1;
			}
		}
	if(flg==1){
		z=s[i];
		i=103;
		}
	}
	printf("%d\n",z);
	}
		return 0;
}

Measured memory_bytes: 1028
S, T = input(), input()

ret = len(T)


# burst force
for st in range(0, len(S)-len(T) + 1):

    diff = 0

    for idx in range(0, len(T)):
        if S[st + idx] != T[idx]:
            diff += 1

    ret = min(ret, diff)

print('{}'.format(ret))



Measured memory_bytes: 9120
n = int(input())
t_point = 0
h_point = 0

for i in range(n):
    t_card, h_card = input().split()
    
    if t_card== h_card:
        t_point += 1
        h_point += 1
    elif t_card> h_card:
        t_point += 3
    else:
        h_point += 3

print('{} {}'.format(t_point, h_point))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main() {
    int64_t n;
    cin>>n;
    int64_t sum=0;
    for(int i=1;i<=n;i++){
        if(i%3==0 ||i%5==0){
            continue;
        }else{
            sum+=i;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool comparator(P a, P b) {
	return a.first / a.second < b.first / b.second;
}

int main() {
	string s;
	cin >> s;
	if (s[1] == 'B') {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}


Measured memory_bytes: 3132
def cmb(n,r):
    r=min(r,n-r)
    result=1
    for i in range(n-r+1,n+1):
        result*=i
    for i in range(1,r+1):
        result//=i
    return result

def factorize(n):
    i=2
    result={}
    while True:
        if i**2>n:
            break
        count=0
        while n%i==0:
            n//=i
            count+= 1
        if count!=0:
            result[i]=count
        i+=1
    if n>1:
        result[n]=1
    return result


N,M = map(int,input().split())
l = factorize(M)

r = 1
for i,j in l.items():
    r *= cmb(j+N-1,j)%(10**9+7)
    r %= (10**9+7)
print(r)

Measured memory_bytes: 3064
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
w = ns()
y = w.count("Y")

if y:
    print("Four")
else:
    print("Three")

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

int main() {
	int n;
	cin >> n;
	int res = n;
	for(int i = 0; i <= n; i++){
		int cc = 0;
		int t = i;
		while(t > 0){
			cc += t % 6;
			t /= 6;
		}
		t = n - i;
		while(t > 0){
			cc += t % 9;
			t /= 9;
		}
		if(res > cc){
			res = cc;
		}
	}
	cout << res << endl;
	return 0;
}

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

#define endl "\n"
#define all(V) V.begin(),V.end()
#define see(x) cerr << #x << " = " << x << "\n";
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int n , a[ N ];
int dp[ N ];

int main( ) {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        for( int i = 1; i <= n; i++ ) dp[i] = inf;
        dp[n] = 0;
        for( int i = n; i >= 1; i-- ) {
                for( int j = 1; j <= 2; j++ ) {
                        if( i + j <= n ) {
                                dp[i] = min( dp[i] , dp[i+j] + abs(a[i+j] - a[i]) );
                        }
                }
        }
        cout << dp[1] << endl;
        return 0;
}









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

int main() {
	long long a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	c *= 2;
	long long ans = (long long)1e10;
	for (long long i = 0; i <= max(x,y); i++) {
		ans = min(ans, c * i + max(0LL, x - i) * a + max(0LL, y - i) * b);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#create date: 2020-08-11 09:28

import sys
stdin = sys.stdin
from itertools import product

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    s = ns()
    ans = 0

    for a in product(range(10), repeat=3):
        i = 0
        for si in s:
            if int(si) == a[i]:
                i += 1
            if i == 3:
                ans += 1
                break
    print(ans)

if __name__ == "__main__":
    main()

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

const long long MOD = 1000000007;

void solve(long long N, long long K) {
    long long begin = 0;
    long long end = N;
    long long ans = 0;
    for (long long k = 1; k <= N + 1; k++) {
        if (k >= K) {
            ans += (end - begin + 1) % MOD;
        }
        begin += k;
        end += N - k;
    }
    cout << ans % MOD << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 3732
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <functional>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

template<class T = lint>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T = lint>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

	int V = (int)edges.size();
	const int INF = numeric_limits<T>::max();
	vector<T> dist(V, INF);
	dist[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
	p_que.emplace(dist[st], st);

	while (!p_que.empty()) {

		Edge<T> now(p_que.top().to, p_que.top().cost);
		p_que.pop();

		if (dist[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (dist[e.to] > tmp_cost) {
				dist[e.to] = tmp_cost;
				p_que.emplace(e.to, dist[e.to]);
			}
		}
	}

	return dist;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int u, v, len;
	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < N - 1; i++) {
		cin >> u >> v >> len;
		edges[u - 1].emplace_back(v - 1, len % 2);
		edges[v - 1].emplace_back(u - 1, len % 2);
	}

	auto ans = Dijkstra<int>(edges, 0);

	for (const auto& i : ans) {
		if (i % 2) cout << '1' << "\n";
		else cout << '0' << "\n";
	}

	return 0;
}


Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N, M, D;

	public static void main(String[] args) {
		while (true) {
			M = sc.nextInt();
			N = sc.nextInt();
			D = sc.nextInt();
			if (M == 0) break;
			System.out.println(solve() ? 1 : 0);
		}
	}

	static boolean solve() {
		int[][] mat = new int[M * N][M * N + 1];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < M; ++j) {
				mat[i * M + j][M * N] = sc.nextInt();
				mat[i * M + j][i * M + j] = 1;
				for (int k = -D; k <= D; ++k) {
					if (j + k < 0 || M <= j + k) continue;
					int dy = D - Math.abs(k);
					if (i - dy >= 0) {
						mat[i * M + j][(i - dy) * M + j + k] = 1;
					}
					if (i + dy < N) {
						mat[i * M + j][(i + dy) * M + j + k] = 1;
					}
				}
			}
		}
		boolean[] used = new boolean[N * M];
		for (int i = 0; i < N * M; ++i) {
			int pivot = -1;
			for (int j = 0; j < N * M; ++j) {
				if (used[j]) continue;
				if (mat[j][i] == 1) {
					pivot = j;
					break;
				}
			}
			if (pivot == -1) continue;
			used[pivot] = true;
			for (int j = 0; j < N * M; ++j) {
				if (j == pivot || mat[j][i] == 0) continue;
				for (int k = 0; k <= N * M; ++k) {
					mat[j][k] += mat[pivot][k];
					if (mat[j][k] == 2) mat[j][k] = 0;
				}
			}
		}
		for (int i = 0; i < N * M; ++i) {
			if (mat[i][N * M] == 0) continue;
			boolean ok = false;
			for (int j = 0; j < N * M; ++j) {
				if (mat[i][j] != 0) ok = true;
			}
			if (!ok) return false;
		}
		return true;
	}

}

Measured memory_bytes: 63244
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,i,a,x,d,f;
  cin >>N;
  for(i=0;i<N;i++){
    string s;
    cin >>s;
    if(s=="P"){
    if(a==0) a++;
    }
    if(s=="W"){
      if(x==0) x++;
    }
    if(d==0){
      if(s=="G") d++;
    }
    if(f==0){
      if(s=="Y") f++;
    }
  }
    a =a+x+d+f;
    if(a==3){
    cout <<"Three" <<endl;
    }
    if(a==4){
      cout <<"Four" <<endl;
    }
}
    

Measured memory_bytes: 256