akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var nk = Input3();
            var a = nk[0] % nk[1];
            long ans = Math.Min(Math.Abs(a - nk[1]), a);
            Console.WriteLine(ans);
                
                





        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  ll ma=max({A,B,C}),ot=A+B+C-max({A,B,C});
  REP(i,K){
    ma*=2;
  }
  cout<<ot+ma<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define N 100

int m[N+1][N+1];

int matrixChainOrder(int *p, int n){
  int i, j, k, l, q;

  for(i=1; i<=n; i++){
    m[i][i] = 0;
  }

  for(l=2; l<=n; l++){
    for(i=1; i<= n-l+1; i++){
      j = i+l-1;
      m[i][j] = INT_MAX;
      for(k=i; k<=j-1; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	m[i][j] = ((m[i][j] <= q) ? m[i][j] : q);
      }
    }
  }
  return m[1][n];
}

int main(){

  int n, i;
  int p[N+1];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d%d", &p[i], &p[i+1]);
  }

  printf("%d\n", matrixChainOrder(p, n));

  return 0;

}

Measured memory_bytes: 632
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
    int S;
    cin >> S;
    int h = S/3600;
    int m = (S-h*3600)/60;
    int s = (S-h*3600-m*60)%60;
    printf("%d:%d:%d\n",h,m,s);
}

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

int main(){
    ll x, n = 0;
    ll z = 100;
    cin >> x;

    while(z<x){
        n++;
        z = 1.01 * z;
    }
    /*
    while(z<x){
        n++;
        z = 100 * pow(1.01, n);
    }
    */
    cout << n << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y,z;
};
Point operator-(const Point& a,const Point& b)
{
  Point ret={a.x-b.x,a.y-b.y,a.z-b.z};
  return ret;
}
double dot(Point a,Point b)
{
  return a.x*b.x+a.y*b.y+a.z*b.z;
}
Point cross(Point a,Point b)
{
  Point ret={a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};
  return ret;
}
double norm(Point a)
{
  return a.x*a.x+a.y*a.y+a.z*a.z;
}

string board[210];
int H,W;
int sx,sy;
int gx,gy;
int primin=inf;
int solmin=inf;
int d[210][210];
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
typedef pair<int,int> P;
void solve(int sy,int sx,char decide)
{
  queue<P> que;
  for(int i=0;i<H;i++)
    {
      for(int j=0;j<W;j++)
	{
	  d[i][j]=inf;
	}
    }
  d[sy][sx]=0;
  que.push(P(sy,sx));
  while(!que.empty())
    {
      P p=que.front();que.pop();
      gy=p.first;
      gx=p.second;
      if(board[p.first][p.second]==decide) break;
      for(int i=0;i<4;i++)
	{
	  int ny=p.first+dy[i];
	  int nx=p.second+dx[i];
	  if(ny<0 || H<=ny || nx<0 || W<=nx || board[ny][nx]=='#' || d[ny][nx]!=inf) continue;
	  que.push(P(ny,nx));
	  d[ny][nx]=d[p.first][p.second]+1;
	}
    }
  if(decide=='@') primin=min(primin,d[gy][gx]);
  else if(decide=='$') solmin=min(solmin,d[gy][gx]);
}

int main(int argc,char const* argv[])
{
  cin >> H >> W;
  for(int i=0;i<H;i++)
    {
      cin >> board[i];
    }
  bool solex=false;
  for(int i=0;i<H;i++)
    {
      for(int j=0;j<W;j++)
	{
	  if(board[i][j]=='%')
	    {
	      sy=i,sx=j;
	    }
	  if(board[i][j]=='$') solex=true;
	}
    }
  solve(sy,sx,'@');
  if(solex) solve(sy,sx,'$');
  if(primin>=solmin){cout << "No" << endl;}
  else{cout << "Yes" << endl;}
  return 0;
}



Measured memory_bytes: 3372
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int gcd(int a,int b){
  if(a%b==0){
    return b;
  }
  return gcd(b,a%b);
}

void solve(){
  int a,b;
  while(cin>>a>>b){
    if(a<b){
      swap(a,b);
    }
    cout<<gcd(a,b)<<endl;
  }
}

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

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    for(int i=0;i<N+1;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    
    ll total = 0;
    for(int i=0;i<N;i++){
        ll n1 = min(A[i], B[i]);
        total += n1;
        B[i] -= n1;
        ll n2 = min(A[i+1], B[i]);
        total += n2;
        A[i+1] -= n2;
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n; cin >> n;
    vi v(n), c(n);
    rep(i, n) cin >> v[i];

    ll tot = 0;
    rep(i, n){
        cin >> c[i];
        v[i] -= c[i];
        if(v[i] > 0) tot += v[i];
    }
    cout << tot << endl;
    return;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

int main( void )
{
    int a, b;
    cin >> a >> b;
    if ( b % a == 0 )
    {
        cout << a + b << endl;
    }
    else
    {
        cout << b - a << endl;
    }

    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

void Main(){
    int n;
    cin >> n;
    int ans = 0;
    REP (i, n+1) {
        if (divisor(i).size() == 8 & i % 2 == 1) {
            ans++;
        }
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

void dfs(const vector<vector<pair<int64_t, int64_t>>>& links,
         vector<int64_t>* output, int64_t cur, int64_t parent_color = 0) {
    int64_t color = 1;
    if (color == parent_color) {
        ++color;
    }
    for (const auto& link : links[cur]) {
        auto id = link.second;
        if ((*output)[id] > 0) {
            continue;
        }

        (*output)[id] = color;
        dfs(links, output, link.first, color);

        ++color;
        if (color == parent_color) {
            ++color;
        }
    }
}

main() {
    int64_t n;
    cin >> n;

    vector<vector<pair<int64_t, int64_t>>> links(n);
    for (auto i : irange(0L, n - 1)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        links[a].emplace_back(b, i);
        links[b].emplace_back(a, i);
    }

    uint64_t k = 0;
    for (const auto& l : links) {
        k = max(k, l.size());
    }

    vector<int64_t> ans(n - 1);
    dfs(links, &ans, 0);

    cout << k << endl;
    for (auto a : ans) {
        cout << a << "\n";
    }
}

Measured memory_bytes: 8832
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; 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 COM(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
    COMinit();
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 0;
    rep(i,N){
        ans += COM(i,K-1) * A[i] % MOD - COM(N-i-1,K-1) * A[i] % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8704
N=int(input())
S=input()
n_left=0
n_right=0
for a in S:
    if a==")":
        if n_left==0:
            n_right+=1
        else:
            n_left-=1
    else:
        n_left+=1
print((n_right*"(")+S+(n_left*")"))


Measured memory_bytes: 38256
#include <bits/stdc++.h> 
 
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
 
#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  int N;
  cin>>N;
  vector<int>u(N-1),v(N-1),w(N-1);
  for(int i=0;i<N-1;i++)cin>>u[i]>>v[i]>>w[i];
  for(int i=0;i<N-1;i++)w[i]%=2;
  for(int i=0;i<N-1;i++)u[i]--,v[i]--;
  vector<vector<pii>>e(N);
  for(int i=0;i<N-1;i++)
    e[u[i]].push_back({v[i],w[i]}),e[v[i]].push_back({u[i],w[i]});
 
  queue<pii>q;
  q.push({0,0});
  vector<bool>used(N,false);
  used[0]=true;
  vector<int>ans(N);
  while(q.size()>0){
    int now=q.front().first;
    int c=q.front().second;
    q.pop();
    ans[now]=c;
    for(auto it:e[now]){
      if(!used[it.first])q.push({it.first,(c+it.second)%2}),used[it.first]=true;
    }
  }
  for(auto it:ans)cout<<it<<endl;
  return 0;
}

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

int main(){
  string s;
  while(getline(cin,s)) {
    string r;
    for(int i=0; i<s.length(); i++) {
      if(s[i] == '@')
	r += string(s[i+1]-'0',s[i+2]),i += 2;
      else
	r += string(1,s[i]);
    }
    cout<<r<<endl;
  }
}

Measured memory_bytes: 0
var output;
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
  var s = next();
  while(s.length > 0){
     var five = s.slice(-5);
     var six = s.slice(-6);
     var seven = s.slice(-7);
     if(five == "dream" || five == "erase"){
        s = s.slice(0,s.length - 5);
     }else if(seven == "dreamer"){
        s = s.slice(0,s.length - 7);
	 }else if(six == "eraser"){
		s = s.slice(0,s.length - 6);
	 }else{
        myout("NO");
       return;
     }
  }
  myout("YES");
}


Measured memory_bytes: 9144
#include <iostream>
//#include <bits/stdc++.h>
// a&1 check odd or not and a>>=1 halfs a
// for(int& i : vector) cin>>i input
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
using namespace std;

void solve(){
	int n,m;
	cin>>n>>m;
	vector<int> a(m);
	int sum=0;
	for(int& v:a){
		cin>>v;
		sum+=v;
	}
	if(sum>n){
		cout<<-1<<endl;
	}
	else{
		cout<<n-sum<<endl;
	}

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	//~ cin>>t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
pair<int,int> tree[1000000*2-1];

int main(){
  int n,q;
  for(;cin>>n>>q;)
    {

      for(int i=0;i<n*2-1;i++)
	tree[i]=make_pair(0,0);
      for(int i=0;i<q;i++)
	{
	  int a,v;
	  cin>>a>>v;
	  a--;
	  int num=a+(n-1);
	  // cout<<num<<endl;
	  tree[num].first+=v;
	  tree[num].second=a+1;
	  pair<int,int> base;
	  while(true)
	    {
	      num=(num-1)/2;
	      if(num*2+2<n*2-1 &&( tree[num*2+1].first<tree[num*2+2].first|| (tree[num*2+1].first==tree[num*2+2].first &&tree[num*2+1].second>tree[num*2+2].second)))
		base=tree[num*2+2];
	      else
		base=tree[num*2+1];
	      tree[num]=base;
	      if(num==0)
		break;
	    }
	  cout<<tree[0].second<<" "<<tree[0].first<<endl;
	  //	  output();
	}
    }
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int n;
string str;
int isEdge[222222];
int cou[3];
int pointer[222222];
int ans[222222];
bool used[222222];

int main(){

	REP(i,222222)pointer[i] = i;

	cin >> n;

	cin >> str;
	str = '1' + str + '1';

	REP(i,2*n){
		int tmp = 0;
		isEdge[i] = ((str[i] == '1') + (str[i+1] == '1'));
		cou[isEdge[i]]++;
	}

	if(cou[2] % 2){
		cout << "No" << endl;
		return 0;
	}

	int nowNum = 1;

	if(cou[2] % 4 == 2){
		vector<vector<int>> paths;
		vector<int> path;
		int pla = 0;
		REP(i,2*n){
			if(isEdge[2*n-1-i] == 1){
				pla = 2*n-1-i;
				break;
			}
		}
		for(int i = 0;i < 2*n;i++){
			int place = (i + pla) % (2*n);
			if(isEdge[place] == 0){

			}
			else if(isEdge[place] == 1){
				path.PB(place);
				if(path.size() > 1){
					if(path.size() > 2){
						paths.PB(path);
					}
					path.clear();
				}
			}
			else{
				path.PB(place);
			}
		}
		if(paths.size() <= 1){
			cout << "No" << endl;
			return 0;
		}

		ans[paths[0][1]] = 1;
		ans[paths[1][1]] = 1;
		nowNum++;
		isEdge[paths[0][1]] = -1;
		isEdge[paths[1][1]] = -1;
		swap(pointer[paths[0][0]],pointer[paths[1][0]]);
	}

	vector<int> seica;
	REP(i,2*n){
		if(isEdge[i] == 1)seica.PB(i);
		if(seica.size() == 2){
			ans[pointer[seica[0]]] = nowNum;
			ans[pointer[seica[1]]] = nowNum;
			nowNum++;
			seica.clear();
		}
	}

	REP(i,2*n){
		if(isEdge[pointer[i]] == 2)seica.PB(i);
		if(seica.size() == 4){
			ans[seica[0]] = nowNum;
			ans[seica[1]] = nowNum + 1;
			ans[seica[2]] = nowNum;
			ans[seica[3]] = nowNum + 1;
			nowNum+=2;
			seica.clear();
		}
	}

	REP(i,2*n){
		if(isEdge[i] == 0)seica.PB(i);
		if(seica.size() == 2){
			ans[seica[0]] = nowNum;
			ans[seica[1]] = nowNum;
			nowNum++;
			seica.clear();
		}
	}

	cout << "Yes" << endl;
	REP(i,2*n)cout << ans[i] << ' ';cout << endl;

	return 0;
}


Measured memory_bytes: 4856
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

  double ans;
  int odd=0;
  for(int i=1;i<=N;i++){
    if(i%2) odd++;
  }

  ans=1.0*odd/(double)N;
  cout<<fixed<<setprecision(10)<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n, m, l, r, max = 0;
    string s;
    cin >> n >> m;
    int min = n;
    for (int i = 0; i < m; i++){
        cin >> l >> r;
        if (max < l){
            max = l;
        }
        if (min > r){
            min = r;
        }
    }
    if(min - max < 0){
        cout << 0 << endl;
        return 0;
    }
    cout << min - max + 1 << endl;
}

Measured memory_bytes: 256
let () =
  let rotate n str =
    String.sub str n (String.length str - n) ^ String.sub str 0 n
  in
  let rec shuffle card = function
      0 -> card
    | i ->
      let h = read_int () in
      shuffle (rotate h card) (i-1)
  in
  let rec loop () =
    match read_line () with
      "-"  -> ()
    | card ->
      let times = read_int () in
      print_endline (shuffle card times);
      loop ()
  in loop ()

Measured memory_bytes: 2044
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

vc a;

int main(){
	a=vc(12);
	for(vc::iterator i=a.begin();i!=a.end();i++) cin>>*i;
	for(int i=0;i<4;i++) cout<<a[i];
	cout<<' ';
	for(int i=4;i<12;i++) cout<<a[i];
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    int B[n];
    int C[n];
    int ans = 0;
    REP(i,n) cin >> A[i];
    REP(i,n){
        cin >> B[i];
        ans += B[i];
    }

    REP(i,n-1) cin >> C[i];

    REP(i,n-1){
        if(A[i] + 1 == A[i + 1]) ans += C[A[i]-1];

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	int n,d,i,cnt=0;
	cin>>n>>d;
	for(i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)
			cnt++;
	}
	cout<<cnt<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


Measured memory_bytes: 3640
a, b, c = (int(x) for x in input().split())

tmp = 0

for i in range(2):
    if a > b:
        tmp = a
        a = b
        b = tmp
    if b > c:
        tmp = b
        b = c
        c = tmp
    if a > c:
        tmp = a
        a = c
        c = tmp

print(a, b, c)



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

const int INF = 0x3f3f3f3f;
const int dx[]{-1, 0, 1, 0};
const int dy[]{0, -1, 0, 1};

char s[200123];

int main()
{
    scanf("%s", s);
    for(int i = 0; s[i]; ++i) if(s[i] == '?') s[i] = 'D';
    puts(s);
    return 0;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lowbit(x) ((x)&(-x))
#define inf 0x3f3f3f3f
#define endl "\n"
#define MP(x,y) (make_pair(x,y))
#define pll pair<int,int>
#define pi 3.1415926535
using namespace std;
int k;
int dp[15][10];
int main(){
    scanf("%d",&k);
    for(int i=0;i<=9;i++)
        dp[1][i] = 1;
    for(int i=2;i<=10;i++){
        for(int j=0;j<=9;j++){
            if(j == 0){
                dp[i][j]=dp[i-1][0]+dp[i-1][1];
            }else if(j==9){
                dp[i][j] = dp[i-1][9]+dp[i-1][8];
            }else{
                dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
            }
        }
    }
   // for(int i=0;i<10;i++) cout<<dp[2][i]<<endl;
    int len=0,s;
    for(int i=1;i<=10;i++){
        for(int j=1;j<=9;j++){
            if(k>dp[i][j]) k-=dp[i][j];
            else {
                len = i,s=j;
                break;
            }
        }
        if(len>0) break;
    }
    //cout<<len<<endl;
    cout<<s;
    for(int i=len-1;i>0;i--){
        for(int j=0;j<=9;j++){
            if(abs(s-j)>1) continue;
            if(k>dp[i][j]) k-=dp[i][j];
            else{
                s=j;
                cout<<j;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args){
        FastReader scan=new FastReader();
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            long x=scan.nextLong();
            long c=100;
            int y=0;
            while(c<x){
                c+=c/100;
                y++;
            }
            out.println(y);
        }
        out.flush();
        out.close();
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

}


Measured memory_bytes: 32684
#include<stdio.h>
#include<stdlib.h>
 
#define NIL NULL
 
struct node{
 
  struct node *right;
 
  struct node *left;
 
  struct node *parent;
 
  int key;
};
 
typedef struct node * Node;
  
Node root;
 
 
void treeD(Node);
void treeInsert(int);
void inorder(Node);
void preorder(Node);
Node treeMin(Node);
Node treeS(Node,int);
Node treeSuc(Node);
 
int main(){
 
  int n, i, x;
 
  char com[20];
   
  scanf("%d", &n);
  
  for (i = 0;i < n;i ++ )
    {
    scanf("%s", com);
 
    if (com[0] == 'f' )
      {
    scanf("%d", &x);
    Node t = treeS(root, x);
    if ( t != NIL ) printf("yes\n");
    else printf("no\n");
      }
    else if ( com[0] == 'i' )
      {
    scanf("%d", &x);
    treeInsert(x);
      }
    else if ( com[0] == 'p' )
      {
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
      }
    else if ( com[0] == 'd' )
      {
    scanf("%d", &x);
    treeD(treeS(root, x));
      }
    }
  return 0;
}
 
Node treeMin(Node x){
 
  while(x->left != NIL)
    {
      x = x->left;
    }
  return x;
}
  
Node treeS(Node u, int k){
 
  if(u == NIL || k == u->key)
    {
      return u;
    }
   
  if(k < u->key)
    {
      return treeS(u->left, k);
    }
  else{
    return treeS(u->right,k);
  }
}
 
Node treeSuc(Node x){
 
  Node y;
   
  if(x->right != NIL)
    {
      return treeMin(x->right);
    }
   
  y = x->parent;
 
  while(y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }
  return y;
}
 
void treeD(Node z){
  Node y; 
  Node x; 
}
  
void treeInsert(int k){
 
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
 
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while (x!=NIL)
    {
      y = x;
      if (z->key < x->key)
    {
      x = x->left;
    }
      else {
    x = x->right;
      }
    }
   
  z->parent = y;
   
  if(y == NIL)
    {
      root = z;
    }
  else if(z->key < y->key)
    {
      y->left = z;
    }
  else{
    y->right = z;
  }
   
}
 
void inorder(Node u){
 
  if (u != NIL)
    {
      inorder(u->left);
      printf(" %d",u->key);
      inorder(u->right);
    }
}
 
void preorder(Node u){
 
  if (u != NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }
}

Measured memory_bytes: 24040
#include<iostream>
using std::cin;
using std::cout;

int main () {
    int H1,M1,H2,M2,K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int startTime = H1 * 60 + M1;
    int endTime = H2 * 60 + M2;
    
    int ans = endTime -K - startTime;

    cout << ans ;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    ll i,j,k,n;
    string s,t;

    cin>>n;
    cin>>s>>t;
    for(i=0;i<n;i++)
        cout<<s[i]<<t[i];
    cout<<"\n";




    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdint.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/
int main(){
  int n;
  cin >> n;
  map<int,int> a;
  REP(i,n){
    int tmp;
    cin >> tmp;
    a[tmp]++;
  }
  bool flg=true;
  for(auto x : a){
    if(x.second>=2){
      flg=false;
      break;
    }
  }
  if(flg) cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
int main(){
    string S;
    getline(cin,S);

    int K = 10000000;
    int l = S.length();

    REP(i,l-1){
        if (S[i] == S[i+1]) continue;
        K=min(K,max(i+1,l-i-1));
    }

    if (K==10000000) PRINTD(l);
    else PRINTD(K);
    return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i <= N; ++i)
    {
        if (int(i * 1.08) == N)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
 #define rep(i,n) for(int i=0;i<(n);i++)
 using namespace std;
  int main(){
      int n;
      cin >> n;
      vector<int> a(n);
      int mod = 1000000007;
      long long sum = 0;
      rep(i,n){
          cin >> a[i];
          sum += a[i];
          sum %= mod;
      }
      long long ans =0;
      rep(i,n){
          sum -= a[i];
          if(sum<0)sum += mod;

          ans += a[i]*sum;
          ans %= mod;
      }
      cout << ans << endl;
      return 0;
  }

Measured memory_bytes: 4056
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define IOS ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	map<int,int>mp;
	int n;
	cin>>n;
	for(int i = 1; i <= n; i++)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	for(auto it : mp)
	{
		if(it.second > 1) 
		{
			cout<< "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}


Measured memory_bytes: 9600
# この解法は嘘を含む

from itertools import groupby
H, W = map(int, input().split())
S_ = ["" for _ in range(W)]
T_ = []
for _ in range(H):
    s = input()
    T_.append(s)
    for i, c in enumerate(s):
        S_[i] += c
T = [sorted(t) for t in T_]
S = [sorted(s) for s in S_]
cnt = 0
for _, g in groupby(sorted(T)):
    if len(list(g))%2:
        cnt += 1
if H%2 < cnt:
    print("NO")
    exit()
cnt = 0
for _, g in groupby(sorted(S)):
    if len(list(g))%2:
        cnt += 1
if W%2 < cnt:
    print("NO")
    exit()
if W%2 or H%2:
    print("YES")
    exit()
T1 = []
T2 = []
for i, (_, t) in enumerate(sorted(zip(T, T_))):
    if i%2:
        T1.append(t)
    else:
        T2.append(t)
T_p = T1 + T2[::-1]
S_pp = ["" for _ in range(W)]
for t in T_p:
    for i, c in enumerate(t):
        S_pp[i] += c
S1 = []
S2 = []
for i, (_, s) in enumerate(sorted(zip(S, S_pp))):
    if i%2:
        S1.append(s)
    else:
        S2.append(s)
S_p = S1 + S2[::-1]
for s1, s2 in zip(S_p, S_p[::-1]):
    for c1, c2 in zip(s1, s2[::-1]):
        if c1!=c2:
            print("NO")
            exit()
print("YES")


Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextIntSlice(size int) []int {
	re := make([]int, size)
	for i := 0; i < size; i++ {
		re[i] = nextInt()
	}
	return re
}

func max(a []int) int {
	max := a[0]
	for _, v := range a {
		if v > max {
			max = v
		}
	}
	return max
}

func min(a []int) int {
	min := a[0]
	for _, v := range a {
		if v < min {
			min = v
		}
	}
	return min
}

func main() {
	sc.Split(bufio.ScanWords)
	h, w := nextInt(), nextInt()
	a := make([]string, h)
	for i := 0; i < h; i++ {
		a[i] = nextLine()
	}

	b := make([][]string, h+2)
	for i := 0; i < h+2; i++ {
		b[i] = make([]string, w+2)
		for j := 0; j < w+2; j++ {
			b[i][j] = "#"
		}
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			b[i+1][j+1] = string(a[i][j])
		}
	}
	for i := 0; i < h+2; i++ {
		for j := 0; j < w+2; j++ {
			fmt.Print(b[i][j])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 1024
import java.util.*;
import java.math.BigInteger;
 class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      int[] c = new int[n] ;
      int[] d = new int[n] ;
      
      for(int i = 0 ; i<n ; i++){
          c[i] = scan.nextInt();
          d[i] =scan.nextInt() ;
      }
      int sum = 0 ; 
      for(int i = 0 ; i<n ; i++){
          sum+= d[i] - c[i] +1 ;
      }
      System.out.println(sum) ; 
    }
}

Measured memory_bytes: 27324
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <bitset>
#define ll long long
using namespace std;


int main() {
	int n, k, v[100], t, hoge[100], num;
	ll sum, max;
	max = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> v[i];

	for (int a = 0; a <= k; a++) {
		for (int b = 0; b <= k; b++) {
			num = 0;
			sum = 0;
			t = k - a - b;
			if (t < 0)continue;
			if (a + b > min(n, k))continue;
			if (a > n)continue;
			for (int i = 0; i < a; i++) {
				hoge[num] = v[i];
				num++;
			}
			if (b > n)continue;
			for (int i = 0; i < b; i++) {
				hoge[num] = v[n - 1 - i];
				num++;
			}
			sort(hoge, hoge + num);
			for (int i = 0; i < t; i++) {
				if (hoge[i] > 0)break;
				if (i > a + b)break;
				hoge[i] = 0;
			}
			for (int i = 0; i < num; i++) {
				sum += hoge[i];
			}
			if (sum > max)max = sum;
		}
	}
	cout << max << endl;
	return 0;
}


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

string S;
int main(int argc, char const *argv[]) {
  cin >> S;
  map<char, int> s;
  bool flag = true;
  for (size_t i = 0; i < S.size(); i++) {
    s[S[i]]++;
    if (s[S[i]] != 1) {
      flag = false;
    }
  }
  if (flag) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main(){cin.tie(0);ios::sync_with_stdio(0);_main();}
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





#define rrep(i,a,b) for(int i=a;i>=b;i--)
int N, D, d[501010];
int X[501010], NG[501010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> D;
    rep(i, 1, N + 1) cin >> d[i];

    X[0] = D;
    rep(i, 1, N + 1) X[i] = min(X[i - 1], abs(X[i - 1] - d[i]));

    NG[N + 1] = 1;
    rrep(i, N, 1) {
        if (NG[i + 1] <= d[i] / 2) NG[i] = NG[i + 1];
        else  NG[i] = NG[i + 1] + d[i];
    }

    int Q; cin >> Q;
    rep(_q, 0, Q) {
        int q; cin >> q;
        if (X[q - 1] == 0 || NG[q + 1] > X[q - 1]) printf("NO\n");
        else printf("YES\n");
    }
}

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

using namespace std;

int main (){
    long long  int A, B;
    cin >> A >> B;
    long long  int a = max(A,B);
    long long  int b = min(A,B);
    long long int x = a;
    long long int y = b;
    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    long long int z = x*y/b;
    cout << z;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    long long int a;
    long long int h=0;
    long long int ans=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a;
        if(i==0){
            h=a;
        }
        if(h>a){
            ans+=h-a;
        }else if(h<=a){
            h=a;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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



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

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

	int cnt = 1;
	rep(i, n) {
		if (a[i] == cnt) {
			cnt++;
		}
	}

	if (cnt == 1) cout << -1 << endl;
	else cout << n - cnt + 1 << endl;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long num = 0;

		for(int i = 1; i < N+1; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				num += i;
			}
		}

		System.out.println(num);
	}

}

Measured memory_bytes: 35864
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;

int main(){  
    char c;cin>>c;
    if(c>='A'&&c<='Z'){
        cout<<"A";
    }else{
        cout<<"a";
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100000 + 10;

int a[N];

int main()
{
	int n, i;
	cin>>n;
	for (i=0; i<n; i++) cin>>a[i];
	sort(a, a + n);
	cout<<a[n/2] - a[n/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
using namespace std;
typedef long long ll;

int main()
{
    ll n,m;
    cin >> n >> m;
    if(2 * n > m){
        cout << min(n,m/2);
    }else{
        cout << n + (m - 2 * n) / 4;
    }
}

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

using namespace std;

template <class M, class N>
common_type_t<M, N> gcd(M a, N b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

using ll = long long;
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> cnts{{1, 1}};
  if (n == 1) {
    return cnts;
  }

  ll a = 2;
  while (n >= a * a) {
    ll cnt = 0;
    while (n % a == 0) {
      n /= a;
      cnt++;
    }

    if (cnt > 0) {
      cnts.push_back({a, cnt});
    }

    a++;
  }

  if (n != 1) {
    cnts.push_back({n, 1});
  }
  return cnts;
}

int main(int argc, const char *argv[]) {
  ll a, b;
  cin >> a >> b;

  ll ab_gcd = gcd(a, b);
  auto prime_facts = prime_factorize(ab_gcd);
  cout << prime_facts.size() << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>
#include <iomanip>
using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    if(a+b==3)cout<<3<<endl;
    if(a+b==4)cout<<2<<endl;
    if(a+b==5)cout<<1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int h,w;
  int i,j;



  while(1){
    scanf("%d %d",&h,&w);
    if(h==0&&w==0)
      break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1)
	  printf("#");
	else if(j==0||j==w-1)
	  printf("#");
	else
	  printf(".");
      }
	printf("\n");
      }
      printf("\n");
    }


  return 0;
}

Measured memory_bytes: 1808
#include <cstdio>
#include <queue>

const int N=200005;

int p[N],f[N][20],Log[N];

int min(int x,int y){
	return p[x]<p[y]?x:y;
}

int find(int x,int y){
	int z=Log[y-x+1];
	return min(f[x][z],f[y-(1<<z)+1][z]);
}

struct info{
	int l,r,x,y;
	info(const int a=0,const int b=0):
		l(a),r(b),x(find(a,b)),y(find(x+1,b+1)){}
};

bool operator <(info a,info b){
	return p[a.x]>p[b.x];
}

std::priority_queue<info> q;

int main(){
	int n;
	scanf("%d\n",&n);
	p[0]=n+1;Log[0]=-1;
	for (int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		f[i][0]=f[i][1]=i;
		Log[i]=Log[i>>1]+1;
	}
	for (int i=n;i;i--)
		for (int j=2;i+(1<<j)-1<=n+1;j++)
			f[i][j]=min(f[i][j-1],f[i+(1<<(j-1))][j-1]);
	q.push(info(1,n));
	for (;!q.empty();){
		info a=q.top();q.pop();
		printf("%d %d ",p[a.x],p[a.y]);
		if (a.l<a.x) q.push(info(a.l,a.x-1));
		if (a.x+1<a.y) q.push(info(a.x+1,a.y-1));
		if (a.y<a.r) q.push(info(a.y+1,a.r));
	}
}

Measured memory_bytes: 19444