akhauriyash/Code-Regression huggingface dataset:
// SeeAlso: https://atcoder.jp/contests/abc138/tasks/abc138_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int N;

int main() {
    cin >> N;
    double s = 0;

    REP(i, N) {
        int a;
        cin >> a;
        double temp = 1.0/a;
        s += temp;
    }

    double ans = 1.0 / s;
    print(ans);
    return 0;
}


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

using lint = long long;


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, q;
    cin >> n >> q;
    const int S = 1<<18;
	vector<int> seg(2*S), lazy(2*S);
    // for (int i = 1; i <= n; ++i)
    // 	seg[i+S] = i;
    int h = __builtin_clz(1)-__builtin_clz(S);
    auto apply = [&](int v, int delta) {
		seg[v] += delta;
		if (v < S) lazy[v] += delta;
	};
	auto push = [&] (int v) {
		for (int s = h; s > 0; --s) {
			int i = v >> s;
			if (lazy[i]) {
				apply(2*i, lazy[i]);
				apply(2*i+1, lazy[i]);
				lazy[i] = 0;
			}
		}
	};
	auto update_all = [&](int v) {
		while(v /= 2) {
			seg[v] = min(seg[2*v], seg[2*v+1]);
			seg[v] += lazy[v];
		}
	};

	auto update = [&](int l, int r, int delta) {
		push(l + S), push(r + S - 1);
		for (int a = l+S, b = r+S; a < b; a /= 2, b /= 2) {
			if (a & 1) apply(a++, delta);
			if (b & 1) apply(--b, delta);
		}
		update_all(l + S), update_all(r + S - 1);
	};

	auto query = [&](int l, int r) {
		push(l + S), push(r + S - 1);
		int res = INT_MAX/2;
		for (int a = l+S, b = r+S; a < b; a /= 2, b /= 2) {
			if (a & 1) res = min(res, seg[a++]);
			if (b & 1) res = min(res, seg[--b]);
		}
		return res;
	};
    // for (int i = S; i; --i) seg[i] = (seg[2*i] + seg[2*i+1]);
    while(q--) {
    	int op, l, r;
    	cin >> op >> l >> r;
    	--l, --r;
    	if (op) {
    		cout << query(l, r+1) << '\n';
    	}
    	else {
    		int v;
    		cin >> v;
    		update(l, r+1, v);
    	}
    	// for (int i = 0; i < n; ++i) {
	    // 	cout << query(i, i+1) << ' ';
	    // }
	    // cout << endl;
    }
    
}


Measured memory_bytes: 7060
import bisect

N = int(input())
lisL = list(map(int,input().split()))

lisL.sort()
ans = 0
for i in range(N):
    for j in range(i+1,N):
        ab = lisL[i] + lisL[j]
        ans += bisect.bisect_left(lisL[j+1:],ab)

print(ans)

Measured memory_bytes: 53864
using System;
using System.Collections.Generic;

public class ABC0126_A3v2 {
    private static void Main(string[] args) {
        var input = Console.ReadLine().Trim();
        Prepare(input);
    }

    private static void Prepare(string input) {
        var words = input.Split();
        var numOfFaces = int.Parse(words[0]);
        var standardToWin = int.Parse(words[1]);

        Compute(numOfFaces, standardToWin);
    }

    private static void Compute(int numOfFaces, int standardToWin) {
        var numOfTimesToWinList = CalculateNumOfTimesToWinList(numOfFaces, standardToWin);

        var numerator = CalculateNumerator(numOfTimesToWinList, numOfFaces);
        var denominator = (int)Math.Pow(2, numOfTimesToWinList[0]) * numOfFaces;

        var answer = numerator / (decimal)denominator;
        OutputAnswer(answer.ToString());
    }

    private static void OutputAnswer(string text) => Console.WriteLine(text);

    private static List<int> CalculateNumOfTimesToWinList(int numOfFaces, int standardToWin) {
        var standard = Math.Min(numOfFaces, standardToWin);
        var numOfTimesToWinList = new List<int>();

        for (var roll = 1; roll <= standard; roll++) {
            numOfTimesToWinList.Add(CalculateNumOfTimesToWin(roll, standardToWin));
        }

        return numOfTimesToWinList;
    }

    private static int CalculateNumOfTimesToWin(int initialPoint, int standardToWin) {
        var count = 0;
        var point = initialPoint;

        while (point < standardToWin) {
            count++;
            point *= 2;
        }
        return count;
    }

    private static int CalculateNumerator(List<int> numOfTimesToWinList, int numOfFaces) {
        var total = 0;

        foreach (var numOfTimesToWin in numOfTimesToWinList) {
            total += (int)Math.Pow(2, numOfTimesToWinList[0] - numOfTimesToWin);
        }

        if (numOfTimesToWinList.Count < numOfFaces) {
            total += (int)Math.Pow(2, numOfTimesToWinList[0]) * (numOfFaces - numOfTimesToWinList.Count);
        }

        return total;
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
#define MAX 10000
#define NIL -1

typedef struct{
  int parent,left,right;
}family;

int setHeight(int);
int getSibling(int);
void setDepth(int,int);
void printchildren(int);

int D[MAX],H[MAX],n;
family t[MAX];

int main(){
  int i,id,lef,rig,root = 0,deg;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    t[i].parent = NIL;
    t[i].left = NIL;
    t[i].right = NIL;
  }
  for(i = 0;i < n;i++){
    scanf("%d",&id);
    scanf("%d",&lef);
    scanf("%d",&rig);
    t[id].right = rig;
    t[id].left = lef;
    if(rig != NIL) t[rig].parent = id;
    if(lef != NIL) t[lef].parent = id;
    
  }
  for(i = 0;i < n;i++) if(t[i].parent == NIL) root = i;
  setDepth(root,0);
  setHeight(root);
  
  for(i = 0;i < n;i++){
    deg = 0;
    printf("node %d: parent = %d, sibling = %d, ",i,t[i].parent,getSibling(i));
    if(t[i].left != NIL) deg++;
    if(t[i].right != NIL) deg++;
    printf("degree = %d, depth = %d, height = %d, ",deg,D[i],H[i]);
    if(t[i].parent == NIL) printf("root\n");
    else if(t[i].left == NIL && t[i].right == NIL) printf("leaf\n");
    else printf("internal node\n");
  }

  return 0;
}

void setDepth(int u,int p){
  if(u == NIL) return;
  D[u] = p;
  setDepth(t[u].left,p + 1);
  setDepth(t[u].right,p + 1);
}

int setHeight(int u){
  int h1 = 0,h2 = 0;
  if(t[u].left != NIL){
    h1 = setHeight(t[u].left) + 1;
  }
  if(t[u].right != NIL){
    h2 = setHeight(t[u].right) + 1;
  }
  if(h1 < h2) return H[u] = h2;
  else return H[u] = h1;
}

int getSibling(int u){
  if(t[u].parent == NIL) return NIL;
  if(t[t[u].parent].left != u && t[t[u].parent].left != NIL) return t[t[u].parent].left;
  if(t[t[u].parent].right != u && t[t[u].parent].right != NIL) return t[t[u].parent].right;
  return NIL;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int minus;
    int ans;
    for (int i = 1; ; ++i) {
        if (n <= i*(i+1)/2) {
            ans = i;
            minus = i*(i+1)/2 - n;
            break;
        }
    }
    for (int i = 1; i <= ans; ++i) {
        if (i == minus) continue;
        cout << i;
        if (i != ans) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
def main():
    N, W = map(int, input().split())
    wi, vi = map(int, input().split())
    dp = [0] * wi + [vi] * (W + 1 - wi)
    for _ in range(1, N):
        wi, vi = map(int, input().split())
        for i in range(W, wi - 1, -1):
            t = dp[i - wi] + vi
            if t > dp[i]:
                dp[i] = t
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9728
x, y = map(int, input().split())


def gcd(x, y):
    if x % y == 0:
        return y
    elif x % y == 1:
        return 1
    else:
        return gcd(y, x % y)

if x >= y:
    n = gcd(x, y)
    print(n)
else:
    n = gcd(y, x)
    print(n)

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/*
 * a+b = (a^b) + (a&b)*2, because a+b = a^b, a&b should be 0; meaning
 * a and b will not have the same bit with both 1.
 *
 * For any position i, if a+b result to 1 for i-th bit, there are 2
 * possibilities, ether a's bit is 1 or b's bit is 1. If a+b result
 * to 0, both a and b's i-th bit should be 0.
 */

const int mod = 1e9+7;
const int maxn = 1e5+5;
int digit[maxn], dp[maxn];

int dfs(const int i, const bool limit)
{
    if (i == -1)
        return 1;
    if (!limit && dp[i] != -1)
        return dp[i];
    const int last = limit ? digit[i] : 1;
    int ans = 0;
    FOR(d,0,last+1) {
        const int res = dfs(i-1, limit && d==last);
        if (d)
            ans += 2*res%mod;
        else
            ans += res;
        ans %= mod;
    }
    if (!limit)
        dp[i] = ans;
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    string L;
    while (cin >> L) {
        memset(dp,-1,sizeof(dp));
        int n = 0;
        FOR_ALLR(c,L)
            digit[n++] = *c-'0';
        cout << dfs(n-1,true) << endl;
    }
    return 0;
}


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

int main() {
  int h,w;cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>a[i][j];
  rep(i,w+2)cout<<'#';
  cout<<endl;
  rep(i,h){
    cout<<'#';
    rep(j,w){
      cout<<a[i][j];
    }
    cout<<'#'<<endl;
  }
  rep(i,w+2)cout<<'#';
  cout<<endl;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-

a, b, c, d = map(int, input().split(' '))

n = max([int(a / d) + 1, int (c / b) + 1])

for i in range(n):
    a -= d
    c -= b
    # print(a,c)
    if c <= 0:
        print('Yes')
        exit()
    elif a <= 0:
        print('No')
        exit()

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	string s;
	cin>>s;
	ll ans=0;
	ans=15-s.size();
	for(ll i=0;i<s.size();i++){
		if(s[i]=='o'){
			ans++;
		}
	}
	cout <<(ans>=8?"YES":"NO");
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 2000005
#define rank Ajgrsf
using namespace std;
typedef long long ll;
const int N = 1<<18;
const ll INF= INT_MAX; 

class RMQ{
public:
  ll n;
  vector<ll>dat;
  RMQ(){dat.resize(2*N-1),n=N;for(int i=0;i<n;i++) dat[i]=INF;}
  
  void update(int k,ll a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }

  ll query(int a,int b,int k=0,int l=0,int r=N){
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return dat[k];
    ll vl=query(a,b,k*2+1,l,(l+r)/2);
    ll vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
};

int Len,n;
int rank[MAX_N+1];
int tmp[MAX_N+1];
bool compare_sa(int i,int j){
  if(rank[i]!=rank[j])return rank[i]<rank[j];
  int ri=i+Len<=n?rank[i+Len]:-1;
  int rj=j+Len<=n?rank[j+Len]:-1;
  return ri<rj;
}

void construct_sa(string S,int *sa){
  n=S.length();
  for(int i=0;i<=n;i++){
    sa[i]=i;
    rank[i]=i<n?S[i]:-1;
  }
  
  for(Len=1;Len<=n;Len*=2){
    sort(sa,sa+n+1,compare_sa);
    tmp[sa[0]]=0;
    for(int i=1;i<=n;i++)
      tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
    for(int i=0;i<=n;i++)rank[i]=tmp[i];
  }
}

bool contain(string S,int *sa,string T){
  int left=0,right=S.length();
  while(right-left>1){
    int mid=(left+right)/2;
    if(S.compare(sa[mid],T.length(),T)<0)left=mid;
    else right=mid;
  }
  return S.compare(sa[right],T.length(),T)==0;
}


int Lower(string &S,int *sa,string T){
  int L=0,M,R=S.size();
  while(L<R){
    M = (L+R)/2;
    if(S.compare(sa[M],T.length(),T)>=0) R = M;
    else L = M+1;
  }  
  return L;
}

int Upper(string &S,int *sa,string T){
  int L=0,M,R=S.size();
  while(L<R){
    M = (L+R)/2;
    if(S.compare(sa[M],T.length(),T)>0) R = M;
    else L = M+1;
  }  
  return L;
}

int A[MAX_N],B[MAX_N];
int main(){
  string S,rS;
  cin>>S; rS = S;
  reverse(rS.begin(),rS.end());
  S+='{';rS+='{';
  construct_sa(S,A);
  construct_sa(rS,B);
  RMQ AT,BT;
  for(int i=0;i<=S.size();i++)AT.update(i,A[i]);
  for(int i=0;i<=S.size();i++)BT.update(i,B[i]);
  
  int q;  
  cin>>q;
  while(q--){
    string a,b;
    cin>>a>>b;

    reverse(b.begin(),b.end());
    if(!contain(S,A,a)||!contain(rS,B,b)){printf("0\n");continue;}
    int l = AT.query(Lower(S,A,a),Upper(S,A,a));
    int r = S.size()-BT.query(Lower(rS,B,b),Upper(rS,B,b))-b.size()-1;
    if(l+a.size()>r+b.size())printf("0\n");
    else printf("%d\n",r-l+b.size());
  }

  return 0;
}

Measured memory_bytes: 15168
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
void isl(int i,int j,char in[12][12]){
  in[i][j]='0';
  loop(k,-1,2){
    loop(a,-1,2){
      if(k&&a)continue;
      if(i+k>=0&&i+k<12&&j+a>=0&&j+a<12&&in[i+k][j+a]=='1')isl(i+k,j+a,in);
    }
  }
}
int main(){
  char in[12][12]={0};
  while(cin>>in[0]){
    rep(i,11)cin>>in[i+1];
    int co=0;
    rep(i,12){
      rep(j,12){
	if(in[i][j]=='1'){co++;isl(i,j,in);}
      }
    }
    cout<<co<<endl;
  }

}

Measured memory_bytes: 1148
#include <iostream>
using namespace std;
#define MAX 1000000
int N[MAX + 1];

int main(void){
    int K, temp, i;
    cin >> K;
    
    temp = 7 % K;
    for(i = 1; i < K; i++){
        if(temp == 0) break;
        N[i] = temp;
        temp = (temp * 10 + 7) % K;
    }
    
    if(temp == 0) cout << i << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#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 pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  ll a[N];
  rep(i,N) cin>>a[i];
  ll ans=1000;
  for(int i=0;i<N-1;i++){
    if(a[i]<a[i+1]){
      ll count=ans/a[i];
      ans-=(a[i]*count);
      ans+=(a[i+1]*count);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;

int main(){
    string s,t ;
    cin >> s;
    cin >> t;

    t.erase(t.end()-1);
    if(t == s) cout << "Yes" << endl;
    else
    {
         cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto x : v){cout << x << " ";} cout << endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(vv) for(auto v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

// Is T a subsequence of S ?
bool contain(string s, string t) {
    int n = s.size();
    int m = t.size();
    if (n < m) return false;
    int j = 0;
    rep(i, n) {
        if (s[i] == t[j]) {
            j++;
            if (j == m) {
                return true;
            }
        }
    }
    return false;
}

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

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

    int n = s.size();
    if (n == 1) {
        cout << "Yes" << endl;
        return 0;
    }

    string s1, s2;
    rep(i, n) {
        (i&1 ? s1 : s2) += s[i];
    }
    cout << (contain(t, s1) || contain(t, s2) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,s,mx=0;
	cin>>n>>s;
	int w[n],dp[s+1]={},v[n];
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	for(int i=0;i<n;i++)
		for(int j=s;j>=w[i];j--) 
			dp[j]=max(dp[j-1],dp[j-w[i]]+v[i]);
	cout<<dp[s];
	for(int i:dp) mx=max(mx,i);
	//cout<<mx;
}

Measured memory_bytes: 4412
#include <iostream>
#include <vector>
#include <cmath>

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> x(n), y(n), d(n);
	
	for (int i = 0; i < n; ++i)
		std::cin >> x[i];
	
	for (int i = 0; i < n; ++i)
		std::cin >> y[i];

	double s1 = 0, s2 = 0, s3 = 0, s4 = 0;
	for (int i = 0; i < n; ++i)
	{
		d[i] = abs(y[i] - x[i]);
		s1 += d[i];
		int dd = d[i] * d[i];
		s2 += dd;
		s3 += dd * d[i];
		if (d[i] > s4)
			s4 = d[i];
	}
	s2 = sqrt(s2);
	s3 = pow(s3, 1.0 / 3.0);
	std::cout.setf(std::ios_base::fixed);
	std::cout.precision(6);
	std::cout << s1 << std::endl;
	std::cout << s2 << std::endl;
	std::cout << s3 << std::endl;
	std::cout << s4 << std::endl;
	return 0;
}


Measured memory_bytes: 3420
import java.util.*;
import java.lang.*;
import java.awt.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] t = new int[26];
		
		while (sc.hasNext()) {
			String s = sc.nextLine();
			for (int i = 0; i<s.length(); i++){
				int countval = s.toLowerCase().codePointAt(i)-97;
				if (countval >= 0) t[countval]++;
				
			}
		}
		
		for (int a=0; a<t.length;a++) {
			System.out.println(String.format("%s : %d", (char)(a+97), t[a]));	
		}
		
		
		
		
	}
}


Measured memory_bytes: 30120
# Spreadsheet

sheet = [int(i) for i in input().rstrip().split()]
rows = sheet[0]
columns = sheet[1]

spreadSheet = []
for i in range(rows):
    row = [int(j) for j in input().rstrip().split()]
    rowTotal = 0
    for element in row:
        rowTotal += element
    row.append(rowTotal)
    spreadSheet.append(row)
# print(spreadSheet)
spreadColumns = columns + 1

totalRow = []
for column in range(spreadColumns):
    columnTotal = 0
    for i in range(rows):
        columnTotal += spreadSheet[i][column]
    totalRow.append(columnTotal)
spreadSheet.append(totalRow)
# print(spreadSheet)

for spreadRow in spreadSheet:
    row_str = [str(element) for element in spreadRow]
    print(' '.join(row_str))



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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, auto init = 0) {
    return std::accumulate(all(vec), T(init));
}
// -------------------------------------------------------------------

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

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

    repall (i, h)
        i = abs(t - i * 0.006 - a);

    print(min_element(all(h)) - h.begin() + 1);

    return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
#print(y-x,x-y+2,1+y+x,(-y-x)+1,y+x+1)

l=[]

if x<0:
    if y<x:
        print(x-y+2)
    elif y<=0:#x<=y<=0
        print(y-x)
    else:
        print(max(abs(x),abs(y))-min(abs(x),abs(y))+1)

elif x==0:
    if y<x:
        print(x-y+1)
    else:
        print(y-x)
else:#x>0
    if y>=x:
        print(y-x)
    elif x>y>0:
        print(x-y+2)
    elif y==0:
        print(x-y+1)
    else:
        print(max(abs(x),abs(y))-min(abs(x),abs(y))+1)


Measured memory_bytes: 38384
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>
#include<map>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);



//計算
void calc(vector<LL> vh, vector<LL> vw)
{
	map<LL, LL> mh, mw;

	REP(i, vh.size() - 1)vh[i + 1] += vh[i];
	REP(i, vw.size() - 1)vw[i + 1] += vw[i];

	REP(i, vh.size())FOR(j, i + 1, vh.size()) {
		LL len = vh[j] - vh[i];
		if (mh.find(len) == mh.end())mh[len] = 1;
		else mh[len]++;
	}
	REP(i, vw.size())FOR(j, i + 1, vw.size()) {
		LL len = vw[j] - vw[i];
		if (mw.find(len) == mw.end())mw[len] = 1;
		else mw[len]++;
	}


	LL res = 0;
	for (auto itr = mh.begin(); itr != mh.end(); ++itr) {
		LL len = itr->first;
		LL cnt = itr->second;

		auto wItr = mw.find(len);
		if (wItr != mw.end()) {
			res += cnt * wItr->second;
		}
	}
	//cerr << "=======";
	cout << res << endl;
}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	while (true) {
		int N, M;
		vector<LL> h, w;
		cin >> N >> M;
		if (N == 0)break;

		h.resize(N + 1); REP(i, N)cin >> h[i + 1];
		w.resize(M + 1); REP(i, M)cin >> w[i + 1];

		calc(h, w);
	}

	//debug();
	
	return 0;
}



Measured memory_bytes: 38856
// AOJ1056 Ben Toh

#include <iostream>

using namespace std;

int main(){
	int n;
	double dp[100001];
	dp[0] = 0.0; dp[1] = 1.0; dp[2] = 1.5;
	for(int i=3;i<=100000;i++){
		dp[i] = 0.0;
		double cur = 1.0, mul = 0.5;
		for(int j=2;j<=min(i,20);j++){
			dp[i] += cur*(1-mul)*(j-1+dp[i-j]);
			cur *= mul;
			mul *= 0.5;
		}
		if(i<=20) dp[i] += cur*i;
	}
	while(cin >> n, n)
		printf("%.2lf\n", dp[n]);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int n;
	cin>>n;
	if(n==1)cout<<2<<endl;
	else if(n%2)cout<<n*2<<endl;
	else cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
var
	N,p,T,S:Longint;
begin
	read(N);
	T:=N;
	S:=0;
	while T>0 do begin
		inc(S,T mod 10);
		T:=T div 10;
	end;
	if(S=1)and(N>1)then writeln(10)else writeln(S);
end.


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

const int N = 502;
typedef long long ll;
const ll inf = 1e18;

ll n , A[N][N] , B[N][N] , dp[N][N] , ans = inf;
ll S(ll x[][N] , int l , int r , int lim) { return x[r][lim] - x[l - 1][lim]; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0) , cout.tie(0);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)
        for(int j = 1 ; j <= n ; ++j)
            if(i < j) cin >> A[i][j];
            else if(i > j) cin >> B[i][j];

    for(int i = 1 ; i <= n ; ++i)
        for(int j = 1 ; j <= n ; ++j) {
            A[i][j] += A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1];
            B[i][j] += B[i - 1][j] + B[i][j - 1] - B[i - 1][j - 1];
        }
    
    for(int i = 1 ; i < n ; ++i) {
        dp[i][0] = A[i][i];
        for(int j = 1 ; j < i ; ++j) {
            dp[i][j] = inf;
            for(int k = 0 ; k < j ; ++k)
                dp[i][j] = min(dp[i][j] , dp[j][k] + S(A , j + 1 , i , i) + S(B , j + 1 , i , k));
        }
        for(int j = 0 ; j < i ; ++j)
            ans = min(ans , dp[i][j] + S(A , i + 1 , n , n) + S(B , i + 1 , n , j));
    }
    cout << ans << endl;
    return 0;
}

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


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());

    vector<ll>sum(n, 0);
    for(int i=0;i<n;i++){
        auto it = upper_bound(c.begin(), c.end(), b[i]);
        sum[i] = c.end()-it;
    }
    for(int i=n-2;i>=0;i--) sum[i] += sum[i+1];

    ll ans = 0;
    for(int i=0;i<n;i++){
        auto it = upper_bound(b.begin(), b.end(), a[i]);
        ans += sum[it-b.begin()];
    }

    cout << ans << endl;

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cout<<N*(N-1)/2<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
    int h,w;
    int count=0;
    cin >> h >> w;
    vector<vector<char>> data(h, vector<char>(w));

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> data.at(i).at(j);
    }
  }

    for(int i=0;i<(w+2);++i){
        cout << "#";
    }
    cout << endl;

    for(int j=0;j<h;++j){
        cout << "#";
        for(int k=0;k<w;++k){
            cout << data.at(j).at(k);
        }
        cout << "#" << endl;
    }

    for(int i=0;i<(w+2);++i){
        cout << "#";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a;
    cin >> a;
    int b = 0;
    for (int i = 1; i <= a; i += 2) {
        int c = 0;
        for (int j = 1; j <= i; ++j) {
            if (!(i % j)) c++;
        }
        if (c == 8) {
            b++;
        }
    }
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

const ll N=2e5+5;
ll n,m,top,a[N],fst[N],lst[N],nxt[N],flag[N],s[N],ans[N],k;

int main() {
  cin >> n >> k;
  for(ll i=1;i<=n;i++) {
    cin >> a[i];
    if(!fst[a[i]]) fst[a[i]]=i;
  }
  nxt[n+1]=1;
  for(ll i=n;i;i--) {
    if(!lst[a[i]]) nxt[i]=fst[a[i]]+1; 
    else nxt[i]=nxt[lst[a[i]]+1];
    lst[a[i]]=i;
  }
  for(ll i=1;!flag[i];i=nxt[i]) {
    flag[i]=1;
    s[++m]=i;
  }
  memset(flag,0,sizeof(flag));
  for(ll i=s[(k-1)%m+1];i<=n;i++) {
    if(!flag[a[i]])ans[++top]=a[i],flag[a[i]]=1;
    else {
      do{
        flag[ans[top--]]=0;
      } while(ans[top+1]!=a[i]);
    }
  }
  for(ll i=1;i<=top;i++) {
    if(i!=1) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 12416
from decimal import Decimal, ROUND_HALF_UP


def main():
    length = int(input())
    numbers = list(map(int, input().split()))
    target = Decimal(str(sum(numbers) / length)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    answer = 0
    for num in numbers:
        answer += (num - target) ** 2
    print(answer)


if __name__ == '__main__':
    main()



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

void fnInput(string& rsColor)
{
  int nColorSiz;
  cin >> nColorSiz >> rsColor;
}

int fnColorCount(string sColor)
{
  int nColorCnt = 0;
  int nBgn = 0;

  while (nBgn < sColor.size() )
  {
    int nFoward = nBgn;

    while ( nFoward < sColor.size() - 1  &&
            sColor[nFoward] == sColor[nFoward + 1] )
      nFoward++;

    nColorCnt++;
    nBgn = nFoward + 1;
  }
  return nColorCnt;
}

int main()
{
  string sColor;

  fnInput(sColor);
  cout << fnColorCount(sColor) << endl;

  return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll L, R, d; cin >> L >> R >> d;
    ll ans = 0;
    FOR(i, L, R+1) {
        if(i%d == 0) ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3616
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
$abc = array($a, $b ,$c);
$m = max($abc);
$abc_m = array_diff($abc, array($m));
$sum  = array_sum($abc_m);
if($sum == $m){
    print 'Yes';
}else{
    print 'No';
}

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

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

  vector<ll> div;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      div.push_back(i);
      if (i * i != n) div.push_back(n / i);
    }
  }
  ll sum = 0;
  for (ll i = 0; i < div.size(); i++) {
    ll tmp = div[i] - 1;
    if (tmp == 0) continue;
    if ((n / tmp) == (n % tmp)) { sum += tmp; }
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int N; cin >> N;
    vec A(N); readv(A);
    SORT(A);

    int ans = 0;
    if(N % 2 == 0){
        vec p({1, -1});
        REP(i, N / 2 - 1){
            p.push_back(2);
            p.push_back(-2);
        } 
        SORT(p);
        REP(i, N) ans += p[i] * A[i];
    }else{
        int ans1 = 0, ans2 = 0;
        vec p({-1, -1, 2});
        REP(i, N / 2 - 1){
            p.push_back(2);
            p.push_back(-2);
        }
        SORT(p);
        REP(i, N) ans1 += p[i] * A[i];
        p = vec({1, 1, -2});
        REP(i, N / 2 - 1){
            p.push_back(2);
            p.push_back(-2);
        }
        SORT(p);
        REP(i, N) ans2 += p[i] * A[i];
        ans = max(ans1, ans2);
    }

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 3300
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define int long long
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

main(void){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		int say=((double)i)*(1.08);
		if(say<n)continue;
		if(say==n){flag=i;break;}
	}
	if(flag!=0)printf("%lld\n",flag);
	else printf(":(");
	return 0;
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string N; cin >> N;
  if(N.size() == 1) {
    if(N[0] == '2' || N[0] == '4' || N[0] == '5' || N[0] == '7' || N[0] == '9') {
      cout << "hon" << endl;
    } else if(N[0] == '0' || N[0] == '1' || N[0] == '6' || N[0] == '8') {
      cout << "pon" << endl;
    } else if(N[0] == '3') {
      cout << "bon" << endl;
    }
  } else if(N.size() == 2) {
    if(N[1] == '2' || N[1] == '4' || N[1] == '5' || N[1] == '7' || N[1] == '9') {
      cout << "hon" << endl;
    } else if(N[1] == '0' || N[1] == '1' || N[1] == '6' || N[1] == '8') {
      cout << "pon" << endl;
    } else if(N[1] == '3') {
      cout << "bon" << endl;
    }
  } else if(N.size() == 3) {
    if(N[2] == '2' || N[2] == '4' || N[2] == '5' || N[2] == '7' || N[2] == '9') {
      cout << "hon" << endl;
    } else if(N[2] == '0' || N[2] == '1' || N[2] == '6' || N[2] == '8') {
      cout << "pon" << endl;
    } else if(N[2] == '3') {
      cout << "bon" << endl;
    }
  }
}

Measured memory_bytes: 3632
//config = {stdin: 'tmp', newline: '\r\n'}; // win
config = {stdin: '/dev/stdin', newline: '\n'}; // linux

line = require('fs').readFileSync(config.stdin, 'ascii')
	.trim()
	.split(config.newline)
	.map(function (line) { return line.split(' '); })
	.map(function (ary) { return parseInt(ary[0]) + parseInt(ary[1]); })
	.map(String)
	.map(function (str) { return str.length; })
	;

console.log(line.join('\n'));

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

typedef pair<int, int> P;

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

    int a, b;
    cin >> a >> b;

    for (int i = 1; i < 4; i++) {
        if (a * b * i % 2 == 1) {
            print("Yes");
            return 0;
        }
    }
    print("No");

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
using System;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.__or_2.Run();
        }
    }
    public class __or_2
    {
        public __or_2()
        {
        }
        public static void Run(){
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string[] ss = s.Split(' ');
            System.Collections.Generic.List<int> list = new System.Collections.Generic.List<int>();
            for (int i = 0; i < N; i++)
            {
                list.Add(int.Parse(ss[i]));
            }
            int k = 0;
            for (int i = 0; i < N;i++){
                while(list[i]>=2){
                    if (list[i] % 2 == 0)
                    {
                        k++;
                        list[i] /= 2;
                    }
                    else break;
                }
            }
            Console.WriteLine(k);
        }
    }
}


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

using namespace std;
int main() {
    int s,hour,minute,second;
    cin>>s;
    hour=s/3600;
    minute=(s%3600)/60;
    second=s-hour*3600-minute*60;
    
     cout<<hour<<":"<<minute<<":"<<second<<endl;
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef pair<int, int> P;
static const int INF = 99999999;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

void solve()
{
	int H, W, N;
	cin >> H >> W >> N;
	vector< vector<char> > field(H, vector<char>(W));
	P pos;
	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
		{
			cin >> field[i][j];
			if(field[i][j] == 'S')
			{
				pos.first = j;
				pos.second = i;
			}
		}
	}
	int ans = 0;
	vector< vector<int> > step(H, vector<int>(W));
	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
		{
			step[i][j] = INF;
		}
	}
	step[pos.second][pos.first] = 0;
	int level = 1;
	queue<P> Que;
	Que.push(pos);
	while(!Que.empty())
	{
		P p = Que.front();
		Que.pop();
		if('1' <= field[p.second][p.first] && field[p.second][p.first] <= '9' && level >= field[p.second][p.first] - '0')
		{
			ans += step[p.second][p.first];
			field[p.second][p.first] = '.';
			while(!Que.empty())
			{
				Que.pop();
			}
			++level;
			if(level >= N + 1)
			{
				break;
			}
			Que.push(P(p.first, p.second));
			for(int i = 0; i < H; ++i)
			{
				for(int j = 0; j < W; ++j)
				{
					step[i][j] = INF;
				}
			}
			step[p.second][p.first] = 0;
			continue;
		}
		int nx, ny;
		for(int i = 0; i < 4; ++i)
		{
			nx = p.first + dx[i];
			ny = p.second + dy[i];
			if(0 <= nx && nx < W && 0 <= ny && ny < H && field[ny][nx] != 'X' && step[ny][nx] == INF)
			{
				Que.push(P(nx, ny));
				step[ny][nx] = step[p.second][p.first] + 1;
			}
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std;

int main()
{
FASTIO
//input_from_file

ll n, w;
cin >> n >> w;

vector<pair<ll,ll>>v;
for(ll i = 0; i < n; i++){
  ll x, y;
  cin >> x >> y;
  v.pb(mp(x, y));
}

sort(v.begin(), v.end());

ll dp[n+1][w+1];
for(ll i = 0; i < n+1; i++){
  dp[i][0] = 0;
}
for(ll i = 0; i < w+1; i++){
  dp[0][i] = 0;
}

for(ll i = 1; i < n+1; i++){
  for(ll j = 1; j < w+1; j++){
    if(j < v[i-1].F){
      dp[i][j] = dp[i-1][j];
    }
    else{
      ll temp ;
      temp = max(dp[i-1][j], v[i-1].S + dp[i-1][j-v[i-1].F]);
      dp[i][j] = temp;
    }
  }
}
cout << dp[n][w];
}


Measured memory_bytes: 79232
n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
x = 0
t = []
for i in range(n):
    if s[i]%10 == 0:
        t.append(i)
        x += s[i]
cnt = 0
for i in t:
    del s[i-cnt]
    cnt += 1
s.sort()
while sum(s)%10 == 0 and len(s)>0:
    del s[0]
if sum(s) == 0:
    print(0)
else:
    print(sum(s)+x)

Measured memory_bytes: 9208
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

struct edge{
    ll to,cost;
};
ll n;
vector<edge>  G[100010],H[100010];
ll ds[100010],dt[100010];

void  dijkstra(ll s){
    priority_queue<pii,vector<pii>,greater<pii>> que;
    fill(ds,ds+n,LLINF);
    ds[s]=0;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p=que.top();que.pop();
        int v=p.second;
        if(ds[v]<p.first) continue;
        rep(i,(ll)G[v].size()){
            edge e=G[v][i];
            if(ds[e.to]>ds[v]+e.cost){
                ds[e.to]=ds[v]+e.cost;
                que.push(pii(ds[e.to],e.to));
            }
        }
    } 
}

void  dijkstra2(ll s){
    priority_queue<pii,vector<pii>,greater<pii>> que;
    fill(dt,dt+n,LLINF);
    dt[s]=0;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p=que.top();que.pop();
        int v=p.second;
        if(dt[v]<p.first) continue;
        rep(i,(ll)H[v].size()){
            edge e=H[v][i];
            if(dt[e.to]>dt[v]+e.cost){
                dt[e.to]=dt[v]+e.cost;
                que.push(pii(dt[e.to],e.to));
            }
        }
    } 
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll m,s,t,now=0;
    pll ans[100010];
    cin>>n>>m>>s>>t;
    s--;t--;
    rep(i,m){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        a--;b--;
        G[a].pb({b,c});
        G[b].pb({a,c});
        H[a].pb({b,d});
        H[b].pb({a,d});
    }
    dijkstra(s);
    dijkstra2(t);
    rep(i,n){
        ans[i]=pll(ds[i]+dt[i],i);
    }
    sort(ans,ans+n);
    rep(i,n){
        rep2(j,now,n){
            if(ans[j].second<i){
                now++;
            }
            else{
                cout<<1000000000000000-ans[j].first<<endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 20240
#include<stdio.h>
#define N 100000

int main(){
    int a,b,i,S[N],Q[N],key,cnt = 0,left = 0,right = 0;
    int mid;

    scanf("%d",&a);
    for(i = 0;i < a;i++){
        scanf("%d",&S[i]);
    }

    scanf("%d",&b);
    for(i = 0;i < b;i++){
        scanf("%d",&Q[i]);
    }

    for(i = 0;i < b;i++){
        key = Q[i];
        left = 0;
        right = a;
    while(left < right){
        mid = (left + right)/2;
        if(key == S[mid]){
            cnt++;
            break;
        }else if(key > S[mid]){
            left = mid + 1;
        }else if(key < S[mid]){
            right = mid;
        }
        }
      }
    
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2324
K=4000
R=range
y=min
l=len
S=[input()for i in R(3)]
A,B,C=S
a,b,c=[l(i)for i in S]
def F(S,T):
 Q=[1]*(K*2+1)
 for i in R(-l(T),l(S)):
  for j in R(max(i,0),y(l(S),l(T)+i)):
   if l(set([S[j],T[j-i],'?']))>2:Q[i]=0
 return Q
S=F(A,B)
T=F(A,C)
U=F(B,C)
m=K*3
k=R(-K,K+1)
for p in k:
 if S[p]!=0:
  for q in k:
   if T[q]!=0 and U[q-p]!=0:m=y(m,max(p+b,q+c,a)-y(p,q,0))
print(m)

Measured memory_bytes: 52800