akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  long long m;
  cin>>n>>m;
  long long a[n];
  REP(i,n){
    cin>>a[i];
    a[i] %= m;
  }
  long long s[n];
  REP(i,n){
    if(i==0){
      s[i] = a[i];
    }else{
      s[i] = s[i-1]+a[i];
      s[i] %= m;
    }
  }
  
  long long ans=0;
  REP(i,n){
    if(s[i] == 0){
      ans++;
    }
  }
  
  map<long long, long long> mp;
  REP(i,n){
    mp[s[i]]++;
  }
  for(auto p:mp){
    ans += p.second*(p.second-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5760
from collections import deque
n,m = map(int,input().split())
white = 0
maze = []
for _ in range(n):
  row = list(input())
  white += row.count(".")
  maze.append(row)
steps = [ [-1]*m for _ in range(n) ]
steps[0][0] = 0

q = deque([(0,0)])
while q:
  r,c = q.popleft()

  for x,y in [(1,0), (0,1), (-1,0), (0,-1)]:
    nr,nc = r+x,c+y
    if nr<0 or nc<0 or nr>=n or nc>=m: continue
    if maze[nr][nc] == "#": continue
    if steps[nr][nc] != -1: continue
    steps[nr][nc] = steps[r][c] + 1
    if nr==n-1 and nc==m-1:
      break
    else:
      q.append((nr,nc))

if steps[n-1][m-1] == -1:
  print(-1)
else:
  print( white - steps[n-1][m-1] - 1)



Measured memory_bytes: 72064
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double R;
    cin >> R;
    cout << 2 * pi * R << endl;
}


Measured memory_bytes: 3776
N, K = map(int, input().split())
A=list(map(int,input().split()))
A.sort()
right = A[-1]+1
left = 0
flag = True
mid = (left+right)//2
minN = right
result = mid
while right-left>1 and flag:
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count <= K:
        right = mid
        if minN>mid:
            minN = mid
            result = mid
    elif count > K:
        left = mid
print(result)


Measured memory_bytes: 30884
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
XY = zip(m,m)

MOD = 10**9 + 7

graph = [[] for _ in range(N+1)]
for x,y in XY:
    graph[x].append(y)
    graph[y].append(x)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

dp_w = [1] * (N+1) # 根が白
dp_b = [1] * (N+1)

for x in order[::-1]:
    w = dp_w[x]; b = dp_b[x]
    p = parent[x]
    dp_w[p] *= (b+w); dp_w[p] %= MOD
    dp_b[p] *= w; dp_b[p] %= MOD

answer = (dp_w[1] + dp_b[1]) % MOD
print(answer)

Measured memory_bytes: 73388
#include<cstdio>
#define sacnf scanf
#define pritnf printf
#define srnad srand
#define rnad rand
#define sl(sl_a) strlen(sl_a)
#define gt(gt_a) goto gt_a
#define mst(mst_a,mst_b) memset(mst_a,mst_b,sizeof(mst_a))
#define fora(fora_x,fora_a,fora_b) for(re nti (fora_x)=(fora_a);(fora_x)<=(fora_b);++(fora_x))
#define forb(forb_x,forb_a,forb_b) for(re nit (forb_x)=(forb_a);(forb_x)>=(forb_b);--(forb_x))
#define foral(foral_x,foral_a,foral_b) for(re ll (foral_x)=(foral_a);(foral_x)<=(foral_b);++(foral_x))
#define forbl(forbl_x,forbl_a,forbl_b) for(re ll (forbl_x)=(forbl_a);(forbl_x)>=(forbl_b);--(forbl_x))
#define re register
#define inl inline
#define br break
#define con continue
#define stt struct
#define nms namespace
#define gc getchar
#define rt return
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define in(in_a) freopen("F:/""/in"in_a".in","r",stdin)
#define out(out_a) freopen("F:/""/out"out_a".out","w",stdout)
#define fin(filein_a) freopen(filein_a".in","r",stdin)
#define fout(fileout_a) freopen(fileout_a".out","w",stdout)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=100004;
const nit maxb=54;
const nit maxc=4;
const tni maxd=24;
#include<cstring>

tni s,clo=0,ans=0;
char x[maxa];

tni main()
{
	scanf("%s",x+1);
	//
	s=sl(x+1);
	fora(i,1,s)
	{
		if(clo)
		{
			--clo;
			if(x[i]=='g')
			{
				++ans;
			}
		}
		else
		{
			++clo;
			if(x[i]=='p')
			{
				--ans;
			}
		}
	}
	//
	pritnf("%d\n",ans);
	rt 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define rad2deg(a) ((a)/M_PI * 180.0)
#define deg2rad(a) ((a)/180.0 * M_PI)
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> a(2,std::vector<int>(n+1,0));
    rep(i,n){int ai; std::cin >> ai; a[0][i+1]=a[0][i]+ai;}
    rep(i,n){int ai; std::cin >> ai; a[1][i+1]=a[1][i]+ai;}

    int ans = 0;
    rep(i,n){ans = std::max(ans,a[0][i+1]+a[1][n]-a[1][i]);}
    std::cout << ans << "\n";
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

ll dp[2000];

int main() {
    ll s;
    cin >> s;
    dp[0] = 1;
    rep2(i, 3, s + 1) {
        dp[i] = dp[i - 1] + dp[i - 3];
        dp[i] %= MOD;
    }
    cout << dp[s] << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
//#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=5e3+100;
ll mod=1e9+7;
deque <int> dp[N];
vector <int> g[N];
void mrg(ll v,ll u){
    deque <int> pd;
    for (int i=0;i<dp[u].size()+dp[v].size();i++) pd.pb(0);
    for (int i=0;i<dp[v].size();i++){
        for (int j=0;j<dp[u].size();j++){
            pd[i+j]+=(ll)dp[u][j]*(ll)dp[v][i]%mod;
            pd[i+j]%=mod;
            /// mod
        }
    }
    dp[v]=pd;
}
ll fac[N];
void dfs(ll v,ll p){
    vector <int> b;
    for (auto u : g[v]){
        if (u==p) continue;
        dfs(u,v);
        b.pb(u);
        dp[u].push_front(0);
        for (int i=2;i<dp[u].size();i+=2){
            dp[u][0]+=(ll)-dp[u][i]*fac[i-1]%mod;
            dp[u][0]+=mod;
            dp[u][0]%=mod;
            /// mod
        }
    }
    if (!b.size()){
        dp[v].pb(1);
        return ;
    }
    dp[v]=dp[b[0]];
    for (int i=1;i<b.size();i++){
        mrg(v,b[i]);
    }
}
int32_t main(){
    sync;
    ll n;
    cin >> n ;
    fac[1]=1;
    for (int i=3;i<N;i++){
        fac[i]=fac[i-2]*(ll)i%mod;
    }
    for (int i=0;i<n-1;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1,1);
    ll ans=0;
    for (int i=1;i<dp[1].size();i+=2){
        ans+=(ll)dp[1][i]*fac[i]%mod;
    }
    cout << ans%mod << endl;
}


Measured memory_bytes: 45356
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  rep(i,0,k){
    vector<ll>b(n+1);
    rep(j,0,n){
      b[max(j-a[j],0LL)]++;
      b[min(j+a[j]+1,n)]--;
    }
    rep(i,0,n)b[i+1]+=b[i];
    //debug(b,n+1);
    b.resize(n);
    if(a==b){
      //cout<<i<<endl;
      break;
    }
    a=b;
  }
  debug(a,n);
  return 0;
}

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

vector<int>E[100000];
int s[100000],t[100000];
int ord[100000],low[100000],k;
bool used[100000];
vector<P>V;

void dfs(int v,int p){
	used[v]=true;
	low[v]=ord[v]=k++;
	for(auto u:E[v]){
		if(!used[u]){
			dfs(u,v);
			low[v]=min(low[v],low[u]);
			if(ord[v]<low[u])V.push_back(P(min(u,v),max(u,v)));
		}
		else if(p!=u){
			low[v]=min(low[v],ord[u]);
		}
	}
}
int main(){
	int v,e;scanf("%d%d",&v,&e);
	rep(i,e){
		scanf("%d%d",&s[i],&t[i]);
		E[s[i]].push_back(t[i]);
		E[t[i]].push_back(s[i]);
	}
	dfs(0,-1);
	sort(V.begin(),V.end());
	for(auto p:V){
		cout<<p.first<<' '<<p.second<<endl;
	}
}

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

using namespace std;
constexpr uint64_t mod = 1e9 + 7;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  string s, t;
  cin >> n >> s >> t;
  if (n == 1) {
    cout << "3\n";
    return 0;
  }

  // bpat: 0 -> |
  // bpat: 1 -> =
  int bpat = s[0] == s[1];
  int64_t ans = bpat == 0 ? 3 : 6;
  int i;
  for (i = 1 + bpat; i < n - 1; ++i) {
    if (s[i] == s[i + 1]) {
      if (bpat == 0) {  // |=
        ans = (ans * 2) % mod;
      } else {          // ==
        ans = (ans * 3) % mod;
      }
      ++i;
      bpat = 1;
    } else {
      if (bpat == 0) {  // ||
        ans = (ans * 2) % mod;
      } else {  // =|
        // do nothing, we must select just one color which not used before.
      }
      bpat = 0;
    }
  }
  if (i == n - 1) {
    if (bpat == 0) {  // ||
      ans = (ans * 2) % mod;
    } else {  // =|
      // do nothing
    }
  }
  cout << ans << "\n";
}


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

using namespace std;

#define cerr if(false)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const int maxN = 2e5 + 9, maxV = 1e6 + 9, MOD = 2019, SQ = 322;

ll arr[2020];

int main(){

	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	reverse(s.begin(), s.end());
	++arr[0];
	ll curr_mod = 0;
	ll pot10 = 1;
	for(int i = 0; i < s.size(); i++){
		curr_mod = (curr_mod + (s[i] - '0') * pot10 ) % MOD;
		pot10 = pot10 * 10 % MOD;
		what(i);
		what(curr_mod);
		++arr[curr_mod];
	}

	ll ans = 0;
	for(int i = 0; i < 2019; i++){
		ans += (arr[i] * (arr[i] - 1) ) / 2;
	}

	cout << ans << endl;



	return 0;
}

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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

const ll mod = 1e9 + 7;

ll binpow(ll a, long long b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}



void solve() {

	ll n;
	cin >> n;

	ll a[n + 1];

	for (int i = 1 ; i <= n;  ++i)
		cin >> a[i];

	ll pref[n + 1];

	pref[1] = a[1] % mod;

	for (int i = 2 ; i <= n ; i++)
		pref[i] = (pref[i - 1] % mod + a[i] % mod) % mod;

	ll ans = 0;

	for (int i = 1 ; i <= n ; i++)
	{
		ans = (ans % mod + (((pref[n] - pref[i] + mod) % mod) * (a[i] % mod) % mod)) % mod;
	}

	cout << ans << "\n";
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
		solve();
	return 0;
}





Measured memory_bytes: 6760
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    string s;
    cin >> s;
    bool allchecked = false;
    int pp = 0;
    vector<int> checked(s.length(), 0);
    for (int i = 0; i < s.length(); ++i) {
        auto a = s[i];
        if(!checked[i] && a == 'g') {
            if(!pp) pp = i+1;
            for (int j = pp; j < s.length(); ++j) {
                if(s[j] == 'p' && !checked[j]){
                    checked[i] = 1;
                    checked[j] = 1;
                    pp = j+1;
                    break;
                }
                if(j == s.length()-1) allchecked = true;
            }
        }
        if(allchecked) break;
    }
    int a = 0, b = 0;
    for (int i = 0; i < s.length(); ++i) {
        if(!checked[i]){
            if(s[i] == 'g') a++;
            else b++;
        }
    }
    cout << a/2-b << "\n";
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i*m+j*n-2*i*j==k)
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
}


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

#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;

class Point{
public:
  double x,y;
  
  Point(double x = 0, double y = 0): x(x),y(y){};
  
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double a) {return Point(a*x,a*y);}

  double own_dot(){return x*x+y*y;};
  double abs(){return sqrt(own_dot());}

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

// 内積 
double dot(Point a, Point b){
  return a.x*b.x+a.y*b.y;
}

// 外積
double cross(Point a, Point b){
  return a.x*b.y-a.y*b.x; 
}

//ベクトルp0p1に対する点p2の位置を求める
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2){
  Point a = p1-p0;
  Point b = p2-p0;
  if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
  if(cross(a,b) < -EPS) return CLOCKWISE;
  if(dot(a,b) < -EPS) return ONLINE_BACK;
  if(a.own_dot() < b.own_dot()) return ONLINE_FRONT;
  return ON_SEGMENT;
}

Point in[4];

bool isconvex(Point p[4]) {
  int c = ccw(p[0],p[1],p[2]);
  for (int i = 0; i < 4; i++)
    if (c != ccw(p[i], p[(i+1)%4], p[(i+2)%4] )) return false;
  return true;
}

int main(){
  while(1){
    char c;

    for(int i = 0; i < 4; i++)
      if(i == 3) cin >> in[i].x >> c >> in[i].y;
      else if(!(cin >> in[i].x >> c >> in[i].y >> c)) return 0;

    if(isconvex(in)) cout << "YES" << endl;
    else cout << "NO" << endl;

  }
  return 0;
}

Measured memory_bytes: 1216
//:::: Alien :::://
// Muhammad Eid //
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define prINT pair<int, int>

//const int N = 100 +5;

void Mo35(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

int main(){
Mo35();

    int c = 0, in;
    int n; cin>> n;
    for(int i=1; i<=n; ++i){
        cin>> in;
        if(i%2 && in%2) c++;
    }
    cout<< c;

return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int npow(int a, int b);

int main(void)
{
int a, b;
int n;


scanf("%d",&a);
scanf("%d",&b);

if (a <= b) printf("%d",npow(a, b));

else printf("%d", npow(b, a));

return 0;
}

int npow(int a, int b)
{
	int n, m;
	m = 0;
	for(n=0; n < b; n++)
	{
		m += a*pow(10,n);
	}
	return m;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int mod=998244353;
int t, n, m, k,l[200010], r[200010];
int p[200010];


int32_t main(){
INIT
cin>>n>>k;
for(int i=1; i<=k; i++){
    cin>>l[i]>>r[i];
}

p[1]=1;

for(int i=2; i<=n; i++){
    p[i]+=p[i-1];
    for(int j=1; j<=k; j++){
        if( (i-l[j])<1 ){continue;}
        p[i]+=(p[i-l[j] ]-p[max(0ll, i-r[j]-1)]+mod)%mod; p[i]%=mod;
    }
    //cout<<p[i]<<"\n";
}
cout<<((p[n]-p[n-1]+mod)%mod);

return 0;
}





Measured memory_bytes: 5216
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int r; cin >> r;
	cout << r * r << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,a,b;
  cin >> n >> a >> b;
  if(a==0)
  {
    cout << "0";
    exit(0);
  }
  long long int sum=a+b,count=a*(n/sum);
  if(n%sum>a)
    count+=a;
  else
    count += n%sum;
  cout << count;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    sc.close();

    long ans = 0;
    if (N % 2 == 0)
      for (long n = 10; n <= N; n *= 5)
        ans += N / n;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    vector<double> b(n);
    b[0] = a[0];
    for (int i = 1; i < n; i++) {
        double m = 0;
        int r = a[i];
        for (int j = 0; j < i; j++) {
            int l = a[j];
            int h = max(l,r) - min(l,r);
            int s = l+r;
            double bot = sqrt(s*s - h*h);
            m = max(m, b[j]+bot);
        }
        b[i] = m;
    }
    double l = 1e9, r = 0;
    for (int i = 0; i < n; i++) {
        l = min(l, b[i]-a[i]);
        r = max(r, b[i]+a[i]);
    }
    printf("%.12lf\n", r-l);
}

Measured memory_bytes: 3220
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){

	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int a,b,c;
	scanf("%d%d%d\n", &a,&b,&c);
	if(a == b)	printf("%d\n",c);
	else if(a == c)	printf("%d\n",b);
	else printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 128
import std.stdio, std.string, std.conv, std.math;
void main() {
	int n = readln.chomp.to!int;
	long debt = 100000;
	foreach(i;0..n) debt = (((debt+debt*0.05)/1000.0).ceil*1000).to!long;
	debt.writeln;
}

Measured memory_bytes: 2436
#include <bits/stdc++.h>
#define ll long long
using namespace std; 
#define mod 924844033
#define maxn 4010
int n,m,tot;
bool lk[maxn];
long long f[maxn][maxn][2],jiecheng[maxn],ans;
void init(){
	jiecheng[0]=1;
	for(int i=1;i<=4000;i++)
		jiecheng[i]=(jiecheng[i-1]*i)%mod;
}
int main(){
	scanf("%d%d",&n,&m);
	init();
	for(int i=1;i<=m;i++)
		for(int t=2;t--;)
			for(int j=i;j<=n;j+=m){
				tot++;
				if(j!=i) lk[tot]=1;
			}
	f[0][0][0]=1;
	for(int i=0;i<2*n;i++)
		for(int j=0;j<=n;j++){
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mod;
			if(lk[i+1]) f[i+1][j+1][1]=f[i][j][0];
		}
	for(int i=0,t=1;i<=n;i++,t=-t){
		f[2*n][i][0]=(ll)(f[2*n][i][0]+f[2*n][i][1])*jiecheng[n-i]%mod;
		ans=(ans+f[2*n][i][0]*t+mod)%mod;
	}
	cout<<ans;
}

Measured memory_bytes: 249728
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, ans=0;
  cin >> n;
  rep(i, 1, n + 1) { ans += i; }
  cout << ans << endl;
}

Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
using namespace std;
int main(){
  int N;
  int K;
  long long S;
  cin >> N >> K >> S;

  vector <long long> ans;
  if(S != 1000000000){
    for(int i = 0; i < K; i++){
      ans.push_back(S);
    }
    for(int i = 0; i < N - K; i++){
      ans.push_back(S + 1);
    }
  } else {
    for(int i = 0; i < K; i++){
      ans.push_back(S);
    }
    for(int i = 0; i < N - K; i++){
      ans.push_back(S - 1);
    }
  }

  for(int i = 0; i < N; i++){
    if(i != N - 1){
      cout << ans[i] << " ";
    } else {
      cout << ans[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2292
// A Dynamic Programming based solution for Knapsack problem 
#include<iostream> 
#include <iomanip> 
using namespace std;
  
long long knapSack01(long long W, int weight[], int val[], int n) 
{ 
   long long F[n+1][W+1]; 
   //Build table K[][] in bottom up manner 
   for (int k = 0; k <= n; k++) 
   { 
       for (int w = 0; w <= W; w++) 
       	{ 
			if (k==0 || w==0) 
			   F[k][w] = 0; 
			else if (weight[k-1] <= w) 
			     F[k][w] = max(F[k-1][w], F[k-1][w-weight[k-1]]+val[k-1]); 
			else
			     F[k][w] = F[k-1][w]; 
       	} 
   } 
   return F[n][W]; 
} 

int main() 
{ 
	std::ios::sync_with_stdio(false);
	long long n, W;
	std::cin>>n>>W;
	int *val=new int[n];
	int *wt = new int[n];
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
	}
    std::cout<< knapSack01(W, wt, val, n)<<endl; 
    delete []val;
	delete []wt;
    return 0; 
} 

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

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

    ll ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        ans += a - 1;
    }

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


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

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

bool isSq(int n) {
    int x = cast(int)sqrt(1.0 * n);
    return x * x == n;
}

int calc(int d, int[][] a) {
    int ans = 0;
    for (int i = 0; i < a.length; i++) {
        for (int j = i + 1; j < a.length; j++) {
            int len = 0;
            for (int k = 0; k < d; k++) {
                len += abs(a[i][k] - a[j][k]) ^^ 2;
            }

            if (isSq(len)) ans++;
        }
    }
    return ans;
}

void main() {
    int n, d; scan(n, d);
    int[][] a;
    foreach (_; 0..n) a ~= readints;

    writeln(calc(d, a));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    long long ans = 0LL;
    for(int j = 0; j < n; j++)
    {
        auto ita = lower_bound(a.begin(),a.end(),b[j]);
        auto itc = upper_bound(c.begin(),c.end(),b[j]);
        ans += (ita-a.begin())*(c.end()-itc);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long d = sc.nextInt();
        d *= d;
        int res = 0;
        for(int i=0; i<n; i++) {
            long x = sc.nextInt();
            long y = sc.nextInt();
            long a = x * x + y * y;
            if(a <= d) res++;

        }
        System.out.println(res);
    }



}

Measured memory_bytes: 59040
#include <iostream>
#include <vector>
#include <string>
class PocketBell {
public:
	std::string decode(const std::string &str) const {
		if (str.size() == 0) {
			return "";
		}
		else if ((str.size() & 1) == 1) {
			return "NA";
		}
		else {
			auto head = str.substr(0, 2);
			auto tail = decode(str.substr(2));
			if (tail == "NA" || !is_valid(head)) {
				return "NA";
			}
			else {
				return at(head) + tail;
			}
		}
	}
private:
	bool is_valid(const std::string &str) const {
		auto n = std::stoi(str);
		return (n / 10) > 0 && (n / 10) < 7 && (n % 10) > 0 && (n % 10) < 6;
	}
	char at(const std::string &str) const {
		auto n = std::stoi(str);
		return key.at((n / 10) * 5 + n % 10 - 6);
	}
	static const std::vector<char> key;
};
const std::vector<char> PocketBell::key{ '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', '.', '?', '!', ' ' };

int main() {
	PocketBell bell;
	for (std::string str; std::cin >> str;) {
		std::cout << bell.decode(str) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll ok[101];
signed main() {
    ll n, m, k, a = 360, b = 0, c = 0; string s, t;
    cin >> n;
    while (true) {
        if (a % n == 0) { break; }
        a += 360;
    }
    cout << a / n << endl;
    return 0;
}

Measured memory_bytes: 3620
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

ans = 0
for tmp_t in T:
    left = 0
    right = n
    while(left<right):
        mid = (left + right)//2
        if S[mid]==tmp_t:
            ans += 1
            break
        elif S[mid]>tmp_t:
            right = mid
        else:
            left = mid+1

print(ans)

Measured memory_bytes: 18688
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
/*int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート 1,2,....9
}
int cmp2(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? -1:1;//降順
}*/

int cmp(const void *a, const void *b){
    char A=*(char *)a, B=*(char *)b;
    return A-B;//昇順ソート a,b....z
}
int cmp2(const void *a, const void *b){
    char A=*(char *)a, B=*(char *)b;
    return B-A;
}

int main(void){
    ll snum[101], tnum[101];
    char s[101], t[101];
    ins(s); ins(t);
    /*ll N=strlen(s);
    rep(i, N) snum[i] = s[i] - 'a';
    qsort(snum, N, sizeof(ll), cmp);
    rep(i, N) s[i] = 'a' + snum[i];
    N=strlen(t);
    rep(i, N) tnum[i] = t[i] - 'a';
    qsort(tnum, N, sizeof(ll), cmp2);
    rep(i, N) t[i] = 'a' + tnum[i];
    if(strcmp(s,t) < 0) puts("Yes");
    else puts("No");
    */

    //qsort万能説
    qsort(s, strlen(s), sizeof(char), cmp);
    qsort(t, strlen(t), sizeof(char), cmp2);
    if(strcmp(s,t)<0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;


vector<vector<bool>> to(50,vector<bool>(50,false));
int N,M; vector<pair<int,int>> Bridge; vector<bool> visited;

int cnt = 0;

void bfs(int x){
  for(int i = 0; i < N ; i++){
    visited[i] = false;}
  // dfsのたびにvisited初期化
   queue<int> Q;
   Q.push(x); visited[x] = true;
   
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    for(int i = 0; i < 50; i++){
      if(to[p][i] == true && visited[i] == false){
        visited[i] = true; Q.push(i);}}}
  
  bool flag = true;
  for(int i = 0; i < N; i++){ if(visited[i] == false){ flag = false;}}
  //一つでも訪れたことのない点があればfalseを返す
  if(!flag){ cnt++;}
  return ;}
      
  
  
            
  
  
  
  
  
using namespace std;

int main(){
  cin >> N >> M; 
  Bridge.resize(M); visited.resize(N);
  for(int i = 0; i < M; i++){
    int a,b; cin >> a >> b; a--; b--;//0-indexed
    to[a][b] = true; to[b][a] = true;
     Bridge[i].first = a; Bridge[i].second = b;}
  
  for(int i = 0; i < M; i++){
    to[Bridge[i].first][Bridge[i].second] = false;
    to[Bridge[i].second][Bridge[i].first] = false;
    //辺を破壊
    bfs(0); // 橋だったか否かを判定
    to[Bridge[i].first][Bridge[i].second] = true;
    to[Bridge[i].second][Bridge[i].first] = true;
    // 橋を修復
  }
  
  cout << cnt << endl;
  return 0;}
    
    

Measured memory_bytes: 256
var
	n,m,t1,i,j:int64;
	s,t:ansistring;
function gcd(x,y:longint):longint;
var
	r,t:longint;
begin
	if x<y then
	begin
		t:=x; x:=y; y:=t;
	end;
        if y=0 then exit(x);
	r:=x mod y;
	while r<>0 do
	begin
		x:=y; y:=r;
		r:=x mod y;
	end;
	exit(y);
end;
begin
	readln(n,m);
	readln(s); readln(t);
	t1:=n*m div gcd(n,m);
	i:=1; j:=1;
	while (i<=n) and (j<=m) do
	begin
		if s[i]<>t[j] then
		begin
			writeln(-1);
			halt;
		end;
		i:=i+t1 div m;
		j:=j+t1 div n;
	end;
	writeln(t1);
end.


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String[] N1 = new String[3];
      	int ans = 0;
      	sc.useDelimiter("");
      	N1[0] = sc.next();
      	N1[1] = sc.next();
      	N1[2] = sc.next();
	    sc.next();
		for (int i = 0; i < 3; i++) {
			if (N1[i].equals(sc.next())) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> h(n + 2);
  for (int i = 0; i < n; i++) cin >> h.at(i);
  
  vector<int> dp(n + 2, 1e9 + 5); // 配るDP
  dp.at(0) = 0;
  
  for (int i = 0; i < n - 1; i++) {
    dp.at(i + 1) = min(dp.at(i + 1), dp.at(i) + abs(h.at(i) - h.at(i + 1)));
    dp.at(i + 2) = min(dp.at(i + 2), dp.at(i) + abs(h.at(i) - h.at(i + 2)));
  }
  
  cout << dp.at(n - 1) << '\n';
}

Measured memory_bytes: 1024
# coding: utf-8
import sys


def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))

    nearest = [0, sys.maxsize]
    for i, x in enumerate(h, 1):
        tmp = abs((t - x * 0.006) - a)
        if tmp < nearest[1]:
            nearest = [i, tmp]

    print(nearest[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
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; }

// 二項係数を用いる
const int MAX = 1000100;
const int MOD = 1000000007;

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

  // テーブルを作る前処理
  /* facが普通の階乗を求めている。invが逆数を求めている。finvが逆数の階乗を求めている。*/
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;
    }
}

  // 二項係数を計算する
long long COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int x, y;

int main() {
    cin >> x >> y;
    COMinit();
    // n+2m = x, 2n+m = y
    int mmm = 2*x-y;
    int nn;
    bool flg = false;
    if(mmm >= 0 && mmm % 3 == 0) {
        mmm /= 3;
        nn = x-2*mmm;
        if(nn >= 0) flg = true;
    }

    if(flg) cout << COM(nn+mmm, nn) << endl;
    else cout << 0 << endl;
}

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

typedef struct water{
  double t;
  int v;
} node;

int readInt(void){
  int c=getchar();
  while(!('0'<=c && c<='9')) c=getchar();
  int res=0;
  while('0'<=c && c<='9'){
    res=10*res+c-'0';
    c=getchar();
  }
  return res;
}

void run(void){
  int n,l;
  scanf("%d%d",&n,&l);
  node *q=(node *)calloc(n,sizeof(node));
  int front=0;
  int last=0;
  double t;
  int v;
  scanf("%lf%d",&t,&v);
  printf("%.7f\n",t);
  q[last++]=(node){t,v};
  double qtv=t*v;
  int i;
  for(i=1;i<n;i++){
    node in;
    in.t=readInt();
    in.v=readInt();
    int sum=0;
    node p=q[front];
    while(sum+p.v<=in.v){
      qtv-=p.v*p.t;
      sum+=p.v;
      front++;
      p=q[front];
    }
    if(sum<in.v){
      qtv-=q[front].t*(in.v-sum);
      q[front].v-=in.v-sum;
    }
    qtv+=in.t*in.v;
    while(front<last && q[last-1].t>in.t){
      last--;
      p=q[last];
      in=(node){(in.t*in.v+p.t*p.v)/(in.v+p.v),in.v+p.v};
    }
    q[last++]=in;
    printf("%.7f\n",qtv/l);
  }
}

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


Measured memory_bytes: 16768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cstdlib>
#define _GLIBCXX_DEBUG
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; }

const long long INF = 1LL << 60;

// 入力   ただしこの書き方はC言語の書き方 同じことをC++で書きたいなら vector で書くべし
int N;
long long h[100010];  
// vector<long long> h(100010); と書くのと同じ

// DP テーブル
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5088
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;
int main(){
  int N;
  cin >> N;
  for (int i=0 ; i<10 ;i++){
    if (N==10000){
      cout << 0 <<endl;
      break;
    }
    if (N-1000*i==0){
      cout << 0 <<endl;
      break;
    }
    if (N-1000*i<1000){
      cout << 1000*(i+1)-N<<endl;
      break;
    }
  }
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

// 文字列をアルファベット順に並べる　  qsort((void *)Data, N, sizeof(Data[0]), char_sort);
int char_sort(const void * a, const void * b) {
  return *(char *)a - *(char *)b;}
// 文字をアルファベット順に並べる
int charcmp( const void *p, const void *q ) {return strcmp( p , q );}

int int_sort( const void * a , const void * b ) {
  return strcmp(( char * )a , ( char * )b );
}

int main(void){
    char s[charsize*2][16];
    ll n;
    ll ans=1;
    scanf("%lld",&n);
    // ll [n];
    rep(i,0,n){
        scanf("%s",s[i]);
    }
    // qsort((void *)s, n, sizeof(s[0]), char_sort);
    qsort((void*)s,n,sizeof(s[0]),int_sort);
    rep(i,0,n-1){
        // printf("%s\n",s[i]);
        if( strcmp(s[i],s[i+1]) != 0 ){
            ans++;
        }
    }

    
    printf("%lld\n",ans);
    return 0;
}


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

int findSumOfDigits(int n)
{
    int sum = 0;
    while(n > 0)
    {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}



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

    int min = N;
    for (int a = 1; a < N; a++)
    {
        int b = N - a;
        int sum = findSumOfDigits(a) + findSumOfDigits(b);

        if (sum < min)
        {
            min = sum;
        }
    }

    cout << min << endl;

    return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

int n;
int f[N], siz[N], ans[N];
int head[N], nex[N << 1], to[N << 1], ecnt;
int fac[N], ifac[N];

inline int read() {
	int x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void addE(int u, int v) {
	to[++ecnt] = v;
	nex[ecnt] = head[u], head[u] = ecnt;
}

inline int fpm(int x, int y) {
	int r = 1;
	while(y) {
		if(y & 1) r = 1LL * x * r % mod;
		x = 1LL * x * x % mod, y >>= 1;
	}
	return r;
}

inline int perm(int x, int y) { return 1LL * fac[x] * ifac[x - y] % mod; }
inline int comb(int x, int y) { return 1LL * perm(x, y) * ifac[y] % mod; }

void preDfs(int u, int fa) {
	f[u] = 1, siz[u] = 0;
	for(int i = head[u], v; i; i = nex[i]) {
		v = to[i];
		if(v == fa) continue;
		preDfs(v, u);
		siz[u] += siz[v];
		f[u] = 1LL * comb(siz[u], siz[v]) * f[u] % mod * f[v] % mod;
	}
	++siz[u];
}
void cr(int u, int fa) {
	ans[u] = f[u];
	for(int i = head[u], v; i; i = nex[i]) {
		v = to[i];
		if(v == fa) continue;
		int fv = f[v], sizv = siz[v], fu = f[u], sizu = siz[u];
		--siz[u];
		f[u] = 1LL * fpm(comb(siz[u], siz[v]), mod - 2) 
		* fpm(f[v], mod - 2) % mod * f[u] % mod;
		siz[u] -= siz[v], siz[v] += siz[u];
		++siz[u];
		f[v] = 1LL * comb(siz[v], siz[u]) * f[v] % mod * f[u] % mod;
		++siz[v];
		cr(v, u);
		f[u] = fu, f[v] = fv;
		siz[u] = sizu, siz[v] = sizv;
	}
}

int main() {
	n = read();
	for(int i = 1, u, v; i < n; ++i) {
		u = read(), v = read();
		addE(u, v), addE(v, u);
	}
	
	fac[0] = 1;
	for(int i = 1; i <= n; ++i) fac[i] = 1LL * i * fac[i - 1] % mod;
	ifac[n] = fpm(fac[n], mod - 2);
	for(int i = n; i; --i) ifac[i - 1] = 1LL * i * ifac[i] % mod;
	
	preDfs(1, 0);

	cr(1, 0);
	
	for(int i = 1; i <= n; ++i)
		printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 10752