akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int a[200010], b[200010];
int na[200010], nb[200010];

ll cnt(int k) {
  int T = 1 << k;
  for (int i = 0; i < N; i++) {
    na[i] = a[i] % (T << 1);
    nb[i] = b[i] % (T << 1);
  }
  vector<int> v;
  for (int i = 0; i < N; i++) {
    v.emplace_back(nb[i]);
  }
  sort(v.begin(), v.end());
  ll res = 0;
  for (int i = 0; i < N; i++) {
    res += lower_bound(v.begin(), v.end(), 2*T - na[i]) - lower_bound(v.begin(), v.end(), T - na[i]);
    res += lower_bound(v.begin(), v.end(), 4*T - na[i]) - lower_bound(v.begin(),
    v.end(), 3*T - na[i]);
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  ll ans = 0;
  for (int i = 0; i <= 28; i++) {
    ans += (cnt(i) & 1 ? (1 << i) : 0);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5256
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-10;
#define equals(a,b) (fabs((a) - (b)) < EPS)
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;


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); }
	Point operator / (double a) { return Point(x / a, y / a); }

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

	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 and fabs(y - p.y) < EPS;
	}
};

typedef Point Vector;
typedef vector<Point> Polygon;

double dot(Vector a, Vector b) {
	return a.x* b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
	return a.x* b.y - a.y * b.x;
}

class Segment {
public:
	Point p1, p2;
	Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
};

class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(),double r = 0.0) : c(c),r(r){}
};

//直交判定
bool isOrthogonal(Vector a, Vector b) {
	return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
	return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

//平行判定
bool isParallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
	return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}


signed main() {
	ios::sync_with_stdio(false);
	int q;
	cin >> q;
	int x0, y0, x1, y1, x2, y2, x3, y3;
	rep(i, q) {
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		Point p0 = Point(x0, y0);
		Point p1 = Point(x1, y1);
		Point p2 = Point(x2, y2);
		Point p3 = Point(x3, y3);
		if (isOrthogonal(Segment(p0,p1),Segment(p2,p3))) {
			cout << 1 << endl;
		}
		else if (isParallel(Segment(p0,p1),Segment(p2,p3))) {
			cout << 2 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
 	return 0;
}




Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = (int)1e5 + 5;
const ll MOD = (ll)1e9 + 7LL;

ll dp[MAX_N][4];
const int NO_ABC = 0, A = 1, B = 2, C = 3;

int main()
{
	memset(dp, 0LL, sizeof(dp));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	int n = (int)S.length();

	dp[0][NO_ABC] = 1LL;
	rep (i, n){
		rep (j, 4){
			if (S[i] != '?'){
				dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
			}else{
				dp[i+1][j] = (dp[i+1][j] + 3LL * dp[i][j]) % MOD;
				dp[i+1][j] %= MOD;
			} // end if
		} // end rep
		if (S[i] == 'A' || S[i] == '?'){
			dp[i+1][A] = (dp[i+1][A] + dp[i][NO_ABC]) % MOD;
		} // end if
		if (S[i] == 'B' || S[i] == '?'){
			dp[i+1][B] = (dp[i+1][B] + dp[i][A]) % MOD;
		} // end if
		if (S[i] == 'C' || S[i] == '?'){
			dp[i+1][C] = (dp[i+1][C] + dp[i][B]) % MOD;
		} // end if
	} // end rep
	
	ll res = dp[n][C];
	cout << res << endl;

	return 0;
}

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


typedef unsigned long long int ull;
vector<int> vec;
ull N;
ull dfs(string s) {
    size_t pos = 0;   // alias of size_t
    ull n = stoull(s, &pos);
    if (n > N) return 0;
    ull ret = 0;
    ret = (s.find('7') != string::npos && s.find('5') != string::npos && s.find('3') != string::npos) ? 1 : 0;
    vector<char> vec={'7','5','3'};
    for (char c: vec) {
        ret += dfs(s + c);
    }
    return ret;
}

int main() {
    cin >> N;
    ull ans = dfs("0");
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 

 
int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    double s = (a[0] + a[1]) / 2.0;
    REP(i,2,n){
        s = (s + a[i]) / 2.0;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sys/resource.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 2*(int)1e5 + 10;

int n, k, c;
char a[N];
int dp[N];
vector<int> tt, tt2;

int solve(int idx){
   if(idx > n){
      return 0;
   }

   int &ans = dp[idx];
   if(ans != -1)
      return ans;
   ans = 0;

   smax(ans, solve(idx+1));
   if(a[idx] == 'x'){
      return ans;
   }

   smax(ans, 1 + solve(idx+c+1));
   return ans;
}

void trace(int idx){
   if(idx > n){
      return ;
   }

   int &ans = dp[idx];
   if (ans == solve(idx+1)){
      trace(idx+1);
      return ;
   }
   else{
      assert(a[idx] != 'x');
      assert(ans == 1 + solve(idx+c+1));
      tt.push_back(idx);
      trace(idx+c+1);
   }
}

int solve2(int idx){
   if(idx <= 0){
      return 0;
   }

   int &ans = dp[idx];
   if(ans != -1)
      return ans;
   ans = 0;

   smax(ans, solve2(idx-1));
   if(a[idx] == 'x'){
      return ans;
   }

   smax(ans, 1 + solve2(idx-c-1));
   return ans;
}

void trace2(int idx){
   if(idx <= 0){
      return ;
   }

   int ans = solve2(idx);

   if (ans == solve2(idx-1)){
      trace2(idx-1);
      return ;
   }

   else{
      assert(ans == 1 + solve2(idx-c-1));
      tt2.push_back(idx);
      trace2(idx-c-1);
   }
}

#define left fcefdce
#define right fef

int left[N], right[N];

int32_t main(){_
   

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

   int prev = -1;
   for (int i = 1; i <= n; ++i)
   {
      left[i] = prev;
      if (a[i] == 'o'){
         prev = i;
      }
   }

   prev = -1;
   for (int i = n; i >= 1; --i)
   {
      right[i] = prev;
      if (a[i] == 'o'){
         prev = i;
      }
   }

   memset(dp, -1, sizeof dp);
   
   int mx = solve(1);  

   if (mx > k){
      return 0;
   }

   trace(1);

   memset(dp, -1, sizeof dp);
   int mx2 = solve2(n);

   assert(mx == mx2);

   trace2(n);
   reverse(tt2.begin(), tt2.end());

   for (int i = 0; i < mx; ++i)
   {
      if (tt[i] == tt2[i]){
         cout<<tt[i]<<endl;
      }
   }


   return 0;
}


Measured memory_bytes: 15984
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
vector<pair<int,int>> E[405];
vector<int> dist(405);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int r;
    cin>>r;
    cout << r*r << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int a, b, c, d;
cin >> a >> b >> c >> d;
if (a <= b) {
	cout << a * c << endl;
}
else {
	cout << ((a - b) * d) + (b * c) << endl;
}
return 0;
}


Measured memory_bytes: 256
#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, c, k;
    cin >> n >> c >> k;
    int t[n];
    rep(i, n) cin >> t[i];
    sort(t, t + n);

    ll ans = 1, cnt = 0, time = t[0];
    rep(i, n) {
        if (cnt < c && t[i] - time <= k)
            cnt++;
        else
            cnt = 1, time = t[i], ans++;
    }

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


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){

  int n, x, y;
  int c=0;

  while(cin>>n>>x && !(n==0 && x==0)){
    int c=0;

    for(int i=1; i<=n-2; i++){
      for(int j=i; j<=n-1; j++){
        for(int k=j; k<=n; k++){
          if(!(i==j || j==k || k==i)){
            y = i+j+k;
            if(y==x){
              c++;
            }
          }
        }
      }
    }
    cout<<c<<endl;
  }

}

Measured memory_bytes: 3068
N = int(input())
X = list(map(int, input().split()))

lmax = max(X)
lmin = min(X)

res = 99999999
for i in range(lmin, lmax+1):
    p = 0
    for n in X:
        p += (n-i)**2

    if p < res:
        res = p

print(res)

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

using namespace std;

long long n;

int main()
{
	cin>>n;
	int s=sqrt(n);
	while(s!=0)
	{
		if(n%s==0)
		{
			cout<<s+n/s-2<<endl;
			break;
		}
		else
		{
			s--;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
const int MX=205;
const int mod=998244353;
const double pi=3.1415926535897932384;
double isp=1e-13;
using namespace std;
ll qpow(ll a,ll b,ll MOD=mod){for(ll ans=1;;a=a*a%MOD,b>>=1){if(b&1)ans=ans*a%MOD;if(!b)return ans;}}
ll inv(ll a,ll MOD=mod){return qpow(a,MOD-2,MOD);}
ll __gcm(ll a,ll b){return a*b/__gcd(a,b);}
const int bzmax = 60;
ll b[MX];
typedef class LinearBasis {
  public:
    ll a[MX];
    void insert(ll x) {
      for (int i = bzmax; i+1;i-- ) {
        if (!(x >> i)) {
         continue;
        }
        if (!a[i]) {
          a[i] = x;
          break;
        }
        x^=a[i];
      }
    }
    bool query(ll x) {
      for (int i = bzmax; i-- && x; ) {
        if ((x >> i) & 1) {
          x ^= a[i];
        }
      }
      return !x;
    }

    void reset() {
      memset(a, 0, sizeof(a));
    }
} LinearBasis;
int  solve()
{
    LinearBasis ls;
    ls.reset();
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
         cin>>b[i];
    }
    string s;
    cin>>s;
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='1')
        {
            if(!ls.query(b[i]))
                return 1;
        }
        ls.insert(b[i]);
    }
    return 0;
}
int main()
{
  ios::sync_with_stdio(0),cin.tie(0);
  int t;
  cin>>t;
  while(t--)
  {
     cout<<solve()<<endl;;
  }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = min(a, b), cnt = 0; ; i--) {
    if (b % i == 0 && a % i == 0) {
      cnt++;
    }
    if (cnt == c) {
      cout << i << endl;
      return 0;
    }
  }
}

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

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

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

    int n; cin >> n;
    string s = to_string(n);
    for(auto c: s){
        if(c=='7'){
            cout << "Yes\n"; return 0;
        }
    }


    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3724
x = int(input())
if x % 11 == 0:
    print(x // 11 * 2)
else:
    cnt = x // 11 * 2
    x -= cnt // 2 * 11
    assert(x < 11)
    if x <= 6:
        print(cnt + 1)
    else:
        print(cnt + 2)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mo=2019;
int a[200005];
string s;
int k;
int jojo;
int dio;
int gg;
int ans;
int main(){
	cin>>s;
	a[0]=1;
	k=1;
	for (int i=s.size()-1;i>=0;i--){
		jojo=s[i]-'0';
		dio=jojo*k+dio;
		dio%=mo;
		gg=dio%mo;
		a[gg]++;
		ans+=a[gg]-1;
		k*=10;
		k%=mo;
	}
	cout<<ans<<endl;
}

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

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				Out += __gcd(i, __gcd(j, k));
			}
		}
	}
	printf("%lld\n", Out);
	return 0;
}

Measured memory_bytes: 3816
h, w = map(int, input().split())
a = [None for _ in range(h)]
for i in range(h):
    a[i] = [s == '.' for s in input()]

MOD = 10 ** 9 + 7
dp = [[0 for j in range(w + 1)] for i in range(h + 1)]
dp[1][1] = 1
for i in range(h):
    for j in range(w):
        if a[i][j]:
            dp[i + 1][j + 1] += (dp[i][j + 1] + dp[i + 1][j]) % MOD
            dp[i + 1][j + 1] %= MOD
print(dp[-1][-1])


Measured memory_bytes: 52372
#include<bits/stdc++.h>
using namespace std;
vector <long long> a;
int main(){
   int n;
   cin>>n;
   for (int i=0;i<n;i++){
	   int t;
       scanf("%lld",&t);
	   a.push_back(t); 
	}
    bool f=1;
    for(int i=n-1;i>0;i--)
	{	  
    	if (a[i-1]-a[i]>1)
        {
         	f=0;
         	break;
		}
	    else if (a[i-1]-a[i]==1)
	    	a[i-1]--;
	}  
    if (f==1)
       cout<<"Yes"<<endl;
	else 
	   cout<<"No"<<endl;   
  
   return 0;
}

Measured memory_bytes: 1400
N = int(input())
A = list(map(int, input().split()))
total = abs(A[0]) + abs(A[1]-A[0])
lst = [abs(A[0]) + abs(A[1]-A[0]) - abs(A[1])]
for i in range(1, len(A)-1):
    total += abs(A[i+1] - A[i])
    lst += [abs(A[i+1] - A[i]) + abs(A[i] - A[i-1]) - abs(A[i+1] - A[i-1])]
total += abs(A[-1]) 
lst += [abs(A[-1]) + abs(A[-2]-A[-1])-abs(A[-2])]
for j in lst:
    print(total - j)

Measured memory_bytes: 14048
import java.util.*;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String args[]) {

        String s = sc.nextLine();

        int l = s.length();

        String ans1, ans2;

        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();

        for (int i=0; i < l; i++) {
            sb1.append(i % 2 == 0 ? "1" : "0");
            sb2.append(i % 2 != 0 ? "1" : "0");
        }

        ans1 = sb1.toString();
        ans2 = sb2.toString();

        int d1 = distance(s, ans1);
        int d2 = distance(s, ans2);

        System.out.println(d1 > d2 ? d2 : d1);

    }

    private static int distance(String s, String target) {
        int c = 0;
        char[] s1 = s.toCharArray();
        char[] s2 = target.toCharArray();
        for (int i=0; i < s.length(); i++) {
            if (s1[i] != s2[i])
                c++;
        }
        return c;
    }

}


Measured memory_bytes: 30396
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    using pii=tuple<string,int,int>;
    int N;
    string s;
    int n;
    cin>>N;
    vector<pii> sp(N);
    for(int i=0;i<N;i++){
        cin>>s>>n;
        n=100-n;
        sp.at(i)=make_tuple(s,n,i+1);
    }
    sort(sp.begin(),sp.end());
    for(int i=0;i<N;i++){
        cout<<get<2>(sp.at(i))<<endl;
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int h, w, k, t = 1e9;
  cin >> h >> w >> k;
  vector<string> s(h); v2i v(h, v1i(w));
  rep(i, h) cin >> s[i];
  rep(i, h){
    rep(j, w){
      if(j == 0) v[i][j] = s[i][j] - '0';
      else v[i][j] = v[i][j-1] + s[i][j] - '0';
    }
  }
  rep(i, 1 << (h-1)){
    int tmp = __builtin_popcount(i), x = -1;
    rep(j, w){
      int y = 0;
      rep(l, h){
        if(l > 0 && i & 1 << (l-1)) y = 0;
        if(j == 0 || x == -1) y += v[l][j];
        else y += v[l][j] - v[l][x];
        if(j == 0 && y > k){
          tmp = 1e9;
          break;
        }
        else if(y > k){
          x = j-1;
          ++tmp;
          break;
        }
      }
    }
    t = min(t, tmp);
  }
  cout << t << endl;
  return 0;
}

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

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

  std::string s;
  std::cin >> s;
  int counter = 0;
  if (s[0] == '1') counter += 1;
  if (s[1] == '1') counter += 1;
  if (s[2] == '1') counter += 1;
  std::cout << counter << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,tot,e[100010],nt[100010],hd[1000010],a[100010];
void build(int x,int y){
	tot++;
	e[tot]=y;
	nt[tot]=hd[x];hd[x]=tot;
}
int dfs(int x,int fa){
	int i,flag=0;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		if(a[x]>a[e[i]]&&!dfs(e[i],x))flag=1;
	}
	return flag;
}
int main(){
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		build(x,y);build(y,x);
	}
	for(i=1;i<=n;i++)if(dfs(i,0))printf("%d ",i);
}

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

int main() {
	int h1, s1, h2, s2;
	cin >> h1 >> s1 >> h2 >> s2;
	int t1 = ceil((float)h2 / s1);
	int t2 = ceil((float)h1 / s2);
	// printf("%d %d %f\n", t1, t2, float(h2 / s1));
	if (t1 <= t2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void printArray (List<Integer> list){
		StringBuilder sb = new StringBuilder();
		sb.append(list.get(0));
		for (int i = 1; i < list.size();i++) {
			sb.append(" ").append(list.get(i));
		}
		System.out.println(sb.toString());
	}

	public static int howManyIncluded3(List<Integer> sArray, List<Integer> tArray) {

		// search elem in T, exits in S.
		int howMany = 0;
		sArray.add(1);

		for (int j = 0; j< tArray.size(); j++) {
			int key = tArray.get(j);
			sArray.set(sArray.size()-1, key);
			int i = 0;
			while(sArray.get(i) != key) {
				i++;
			}
			if (i == sArray.size()-1) {
				continue;
			}

			howMany++;
		}
		return howMany;
	}


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sNum = sc.nextInt();
		List<Integer> sArrays = new ArrayList<Integer>();
		for (int i = 0; i < sNum; i++) {
			sArrays.add(sc.nextInt());
		}
		List<Integer> qArrays = new ArrayList<Integer>();
		int qNum = sc.nextInt();
		for (int i = 0; i < qNum; i++) {
			qArrays.add(sc.nextInt());
		}
		//List<List<Integer>> arrays = acceptNArray(System.in);
		int howMany = howManyIncluded3(sArrays, qArrays);
		System.out.println(howMany);
	}
}

Measured memory_bytes: 32788
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC156B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = RInt;
            var K = RInt;

            int digit = 1;
            while (N / K > 0)
            {
                N /= K;
                digit++;
            }
            Console.WriteLine(digit);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 11220
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.Scanner;

/**
 * Created by Harry on 5/10/20.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        long N = scanner.nextLong();
        long M = scanner.nextLong();
        long K = scanner.nextLong();
        long mod = 998244353;
        long[] fac = new long[(int)N+1];
        long[] modInv = new long[(int)N+1];
        fac[0] = 1;
        modInv[0] = 1;
        for(int i=1; i<=N; i++){
            fac[i] = (fac[i-1]*i)%mod;
            modInv[i] = pow(fac[i], mod-2, mod);
        }

        long res = 0;
        for(int k=0; k<=K; k++){
            res = (res + ((M * pow(M-1, N-1-k, mod)%mod)*comb(N-1, N-1-k, fac, modInv, mod))%mod)%mod;
        }
        System.out.println(res);
    }

    public static long comb(long n, long m, long[] fac, long[] modInv, long mod){
        return ((fac[(int)n] * modInv[(int)(n-m)])%mod*modInv[(int)m])%mod;
    }

    public static long pow(long num, long pow, long mod){
        if(pow==0){
            return 1;
        }
        if(pow==1){
            return num;
        }
        long half = pow(num, pow/2, mod);
        return ((half*half)%mod * (pow%2==1 ? num : 1))%mod;
    }
}


Measured memory_bytes: 39180
import operator
import functools


@functools.lru_cache(10**9)
def dynamic_planning(item_taken, target_weight):
    if item_taken == 0 or target_weight == 0:
        return 0
    value, weight = items[item_taken-1]
    if weight <= target_weight:
        ret = max(dynamic_planning(item_taken-1, target_weight-weight) + value, dynamic_planning(item_taken-1, target_weight))
    else:
        ret = dynamic_planning(item_taken-1, target_weight)
    return ret


N, W = map(int, input().split(" "))
items = list()
for _ in range(N):
    items.append(list(map(int, input().split(" "))))
items = sorted(items, key=operator.itemgetter(0))
print(dynamic_planning(N, W))




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

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<int>a(n);
  rep(i,0,n){
    cin >> a[i];
    a[i] -= i+1;
  }
  sort(a.begin(),a.end());
  int b = a[n/2];
  rep(i,0,n) ans += abs(a[i]-b);
  cout << ans << endl; 
}

Measured memory_bytes: 1024
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl (map read . words) >>= putStrLn

solve :: [Int] -> String
solve [a, b]
  | a == b = "Draw"
  | a == 1 = "Alice"
  | b == 1 = "Bob"
  | a > b = "Alice"
  | otherwise = "Bob"

getl :: (String -> a) -> IO a
getl f = f <$> getLine



Measured memory_bytes: 508
s = input()
a, z = 0, 0

for i in range(len(s)):
    if 'A' == s[i]:
        a = i
        break
for i in range(len(s) - 1, -1, -1):
    if 'Z' == s[i]:
        z = i
        break
        
print(z - a + 1)


Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
struct node{
    int p,y,i;
    int id;
}a[100005];
bool cmp(node a,node b){
    if(a.p==b.p)return a.y<b.y;
    return a.p<b.p;
}
bool cp(node a,node b){
    return a.i<b.i;
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d %d",&a[i].p,&a[i].y);
        a[i].i=i;
    }
    sort(a+1,a+m+1,cmp);
    a[0].p=999999;
    for(int i=1;i<=m;i++){
        if(a[i].p!=a[i-1].p)a[i].id=1;
        else a[i].id=a[i-1].id+1;
    }
    sort(a+1,a+m+1,cp);
    for(int i=1;i<=m;i++){
        printf("%06d%06d\n",a[i].p,a[i].id);
    }
    return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<cstring>
using namespace std;
string s;
long long flag=0;
int main()
{
    cin>>s;
    for(int i=0;i<=s.size()-1;i++)
    {
        if(flag==0&&s[i]=='C')
        {
            flag=1;
        }
        if(flag==1&&s[i]=='F')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

//cout<<setprecision(20)<<endl;
int main(){
    ll x,y;
    cin>>x>>y;
    ll now = x;
    ll count = 1;
    while(1)
    {
        if(now*2>y)
        {
            cout<<count<<endl;
            return 0;
        }
        now *= 2;
        count++;
    }
}

Measured memory_bytes: 256
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let abx = readn::<usize>(" ");
    let a = abx[0];
    let b = abx[1];
    let x = abx[2];

    let s = (a + x - 1) / x;
    let e = b / x;
    println!("{}", e + 1 - s);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

lli dp[100];

int main(){
    // cout << fixed << setprecision(5);

    dp[0]=1000;
    lli n;
    cin>>n;
    vector<lli> a(n);
    REP(i,0,n)cin>>a[i];

    REP(i,1,n){
        dp[i]=dp[i-1];
        REP(j,0,i){
            lli money = dp[j];
            lli kabu = money/a[j];
            lli nowMoney = money%a[j] + kabu*a[i];
            chmax(dp[i],nowMoney);
        }
    }

    cout<<dp[n-1]<<endl;

    return 0;
}

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

int main(void){
    int n, m;
    cin>>n>>m;
    int ans=m*(m-1)/2+n*(n-1)/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    long long n,k,num,ans=0;
    cin>>n>>k;
    vector <long long> v;
    for(long long i =0;i<n;i++)
    {
        cin>>num;
        v.push_back(num);
    }
    sort(v.begin(),v.end());
    for(long long i =0;i<k;i++)
    {
        ans+=v[i];
    }
    cout<<ans;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

struct UnionFind {
  vector<int> par;

  UnionFind(int size) : par(size, -1){}
  void init(int n){ par.assign(n, -1); }

  int find(int x){
    if(par[x] < 0) return x;
    else return par[x] = find(par[x]);
  }
  bool same(int x, int y){
    return find(x)==find(y);
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return 0;
    if(par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return 1;
  }
  int size(int x){
    return -par[find(x)];
  }
};

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

	int N, M, K; cin >> N >> M >> K;
	UnionFind uf(N);
	vector<vector<int>> G(N);
	REP(i, M){
		int a, b; cin >> a >> b;
		a--; b--;
		uf.unite(a, b);
		G[a].eb(b); G[b].eb(a);
	}
	REP(i, K){
		int c, d; cin >> c >> d;
		c--; d--;
		G[c].eb(d); G[d].eb(c);
	}
	REP(i, N){
		int ans = uf.size(i)-1;
		for(auto nx : G[i]){
			if(uf.same(i, nx)) ans--;
		}
		cout << ans << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 10496
s = str(input())
a,b,c = 0,0,0
for i in range(len(s)):
    if s[i] == "a":
        a += 1
    elif s[i] == "b":
        b += 1
    else:
        c += 1
if max(a,b,c) - min(a,b,c) <= 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int res = (a-b);
	if(k%2)res*=-1;
	if(res<=1e18)cout<<res<<endl;
	else cout<<"Unfair"<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import namedtuple
import pdb

H, W = map(int, input().split())
s = []
visited = []
step = []

Prev = namedtuple('Prev', ('row', 'col', 'num'))
default_black = 0

for _ in range(H):
    line = input()
    for c in line:
        if c=='#':
            default_black += 1
    s.append(line)
    visited.append([0 for _ in range(W)])
    step.append([0 for _ in range(W)])
    

queue = []

step[0][0] = 1

Point = namedtuple('Point', ('row', 'col'))
st = Point(0, 0)
en = Point(H-1, W-1)



def valid(p):
    return (0 <= p.row and p.row < H and 0 <= p.col and p.col < W)

def around_p(p):
    around = [Point(p.row-1, p.col), Point(p.row+1, p.col), Point(p.row, p.col-1), Point(p.row, p.col+1)]
    for a in around:
        yield a

def goal(p):
    return p.row == H-1 and p.col == W-1

def bfs():
    queue = [st]

    while queue:
        cur_p = queue[0]
        queue = queue[1:]
        if goal(cur_p):
            return step[cur_p.row][cur_p.col]
        if visited[cur_p.row][cur_p.col] == 1:
            continue
        cur_step = step[cur_p.row][cur_p.col]
        visited[cur_p.row][cur_p.col] = 1

        for next_p in around_p(cur_p): 
            if not valid(next_p):
                continue
            if s[next_p.row][next_p.col] == '#':
                continue
            if visited[next_p.row][next_p.col] == 1:
                continue
            queue.append(next_p)
            step[next_p.row][next_p.col] = cur_step + 1
                        
    return -1

def main():
    ans = bfs()
    if ans == -1:
        print(ans)
    else:
        print(H*W - default_black - ans)


main()
    


Measured memory_bytes: 5392
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array;

bool p(string s) {
  for(int i=0; i<s.length/2; i++) {
    if(s[i] != s[$-1-i]) return false;
  }
  return true;
}

bool q(string s) {
  return p(s) && p(s[0..$/2]);
}

void main() {
  string s = readln[0..$-1];
  if(q(s)) writeln("Yes");
  else writeln("No");
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <stdlib.h>

using namespace std;

char dx[] = {0,1,1,0,-1,-1};
char dy[] = {-1,-1,0,1,1,0};

set< vector<int> > prev;
vector< vector<int> > cur, next; 
int x[8], y[8], u[100], v[100], n, k, X, Y, ans;

void move(int step, int pos){
	if(ans != 20) return;
	if(pos >= n) {
		for(int i=0;i<n;i++)
			for(int j=i+2;j<n;j++)
				for(int k=0;k<6;k++)
					if(x[i]+dx[k]==x[j]&&y[i]+dy[k]==y[j]) return;
		vector<int> v;
		for(int i=0;i<n;i++) v.push_back(x[i]), v.push_back(y[i]);
		if(x[0]==X&&y[0]==Y) ans = step;
		if(prev.find(v) == prev.end()){
			prev.insert(v);
			next.push_back(v);
		}
		return;
	}
	int px = x[pos], py = y[pos];
	for(int i=0;i<6;i++){
		int nx = x[pos]+dx[i], ny = y[pos]+dy[i];
		bool check = false, flagF = false, flagB = false;
		if(pos == 0 && step+max(abs(X-nx),abs(Y-ny)) > 19) continue;
		if(pos == 1 && step+max(abs(X-x[0]),abs(Y-y[0]))+abs(max(abs(X-nx),abs(Y-ny))-1) > 19) continue;
		for(int j=0;j<min(pos+1,n);j++){
			if(j==pos) continue;
			if(x[j]==nx&&y[j]==ny) check = true;
		}
		if(check) continue;
		if(pos>0){
			for(int k=0;k<6;k++)
				if(x[pos-1]+dx[k] == nx && y[pos-1]+dy[k] == ny) flagF = true;
			if(!flagF) continue;
		}
		if(pos<n-1){
			for(int k=0;k<6;k++)
				if(x[pos+1]+dx[k] == nx && y[pos+1]+dy[k] == ny) flagB = true;
			if(!flagB) continue;
		}
		for(int j=0;j<k&&!check;j++)
			if(u[j] == nx && v[j] == ny) check = true;
		if(check) continue;

		x[pos] = nx, y[pos] = ny;
		move(step, pos+2);
		x[pos] = px, y[pos] = py;
	}
	move(step, pos+1);
}

int main(){
	set< vector<int> >::iterator it;
	while(cin >> n, n){
		for(int i=0;i<n;i++) cin >> x[i] >> y[i];
		cin >> k;
		for(int i=0;i<k;i++) cin >> u[i] >> v[i];
		cin >> X >> Y;
		ans = 20;
		vector<int> v;
		for(int i=0;i<n;i++) v.push_back(x[i]), v.push_back(y[i]);
		prev.clear();   cur.clear();
		prev.insert(v); cur.push_back(v);
		for(int i=1;ans==20&&i<=19;i++){
			next.clear();
			for(int k=0;k<cur.size();k++){
				for(int j=0;j<n;j++) x[j] = cur[k][2*j], y[j] = cur[k][2*j+1];
				move(i, 0);
			}
			cur = next;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 5556
#coding:utf-8

N, M, X = map(int, raw_input().split())

a = map(int, raw_input().split())

p1 = 0
p2 = 0
for i in a:
    if X > i:
        p1 += 1
    else:
        p2 += 1

print min(p1, p2)


Measured memory_bytes: 2568
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(1e7, 0);

    for(ll i = 1; i <= n; i++){
        for(ll j = i; j <= n; j += i){
            a[j]++;
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ans += a[i] * i;
    }
    cout << ans << endl;


}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

   	vector<ll> A(5), B(5);
   	REP(i, 5) cin >> A[i];
   	ll ma = 0;
   	ll res = 0;
   	REP(i, 5){
   		res += (((A[i]-1)/10) + 1) * 10;
   		if(A[i]%10 != 0) ma = max(ma, 10-(A[i]%10));
   	}
   	res -= ma;
   	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    for(int R, N; cin >> R >> N, R;){
        map<int, int>H;
        for(int i = 0; i < N; i++){
            int l, r, h;
            cin >> l >> r >> h;
            for(int x = l; x < r; x++){
                H[x] = max(H[x], h);
            }
        }
        double ans = 1234567;
        for(int X = -R; X < R; X++){
            int x = X;
            if(X < 0)x = X + 1;
            double h = sqrt(R * R - x * x);
            ans = min(ans, H[X] + (R - h));
        }
        printf("%.10f\n", ans);
    }

    return 0;
}


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

int gcd(int a, int b)
{
    if (b == 0) return a;
    return gcd(b, a%b);
}
int sp(int a, int b, int c)
{
    return gcd(a, gcd(b, c));
}
int main()
{
    int k;
    cin >> k;
    int cnt = 0;

    for (int i = 1; i <= k; i++) {
        for (int j = 1;j <= k; j++) {
            for (int m = 1; m <= k; m++) cnt += sp(m, j, i);
        }
    }
    cout << cnt << "\n";
}


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

using namespace std;
int main(){
  string s; cin >> s;
  vector<bool> C(30,false);
  for(int i=0;i<s.length();i++){
  	C[s[i]-'a']=true;
  }
  string ans="None" ;
  for(char x='a';x<='z';x++){
  	if(C[x-'a']) continue;
    else {ans=x; break;}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll r = n/k;
    ll t = n%k;
    if(t==0)
    {
    	cout<<0<<endl;
    }
    else
    {
    	cout<<1<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 1e5 + 5;
ll n, m, sum, ans[N], parent[N], size[N];
void make_set(int v)
{
    parent[v] = v;
    size[v] = 1;
}
int find_set(int v)
{
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b)
{
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (size[a] < size[b])
            swap(a, b);
        parent[b] = a;
        sum -= size[a] * size[b];
        size[a] += size[b];
    }
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    vector<pair<int, int>>edges(m);
    for(int i = 0;i < m;++i)
        cin >> edges[i].F >> edges[i].S;
    for(int i = 1;i <= n;++i)
        make_set(i);
    sum = (n * (n - 1)) / 2;
    for(int i = m - 1;i >= 0;--i)
    {
        ans[i] = sum;
        int u = edges[i].F,  v = edges[i].S;
        union_sets(u, v);
    }
    for(int i = 0;i < m;++i)
        cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 4480
package main

import "fmt"

func main(){
	var a,b,v,w,t int
	fmt.Scan(&a,&v)
	fmt.Scan(&b,&w)
	fmt.Scan(&t)
	if v <= w {
		fmt.Println("NO")
	} else {
		var dis int
		if a < b {
			dis = b-a
		} else {
			dis = a-b
		}
		if (v-w)*t >= dis {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


Measured memory_bytes: 1820
s=input()
k=int(input())

ans = []
rem = k
for si in s[:-1]:
    if si == 'a':
        to_a = 0
    else:
        to_a = ord('z') - ord(si) + 1

    if to_a <= rem:
        rem -= to_a
        ans.append('a')
    else:
        ans.append(si)
        # next_s = chr(ord(si) + rem)
        # ans.append(next_s)
        # rem = 0


last_s_ord = (ord(s[-1]) + rem - ord('a'))%26
last_s = chr(ord('a') + last_s_ord)
ans.append(last_s)
ans = ''.join(ans)
print(ans)

Measured memory_bytes: 79708
#include <stdio.h>

int main()
{
	int A[6];
	char B[101];
	int C[3] = { 0,1,2 };
	int i, w;

	for (i = 0; i < 6; i++) scanf("%d", &A[i]);

	scanf("%100s", B);

	for (i = 0; B[i] != '\0'; i++)
	{
		switch (B[i])
		{
		case 'S':
			w = C[0];
			C[0] = 5 - C[1];
			C[1] = w;
			break;
		case 'N':
			w = C[1];
			C[1] = 5 - C[0];
			C[0] = w;
			break;
		case 'E':
			w = C[0];
			C[0] = 5 - C[2];
			C[2] = w;
			break;
		case 'W':
			w = C[2];
			C[2] = 5 - C[0];
			C[0] = w;
			break;
		}
	}

	printf("%d\n", A[C[0]]);
	
	return 0;
}

Measured memory_bytes: 1856
let n = (stdin.ReadLine >> int) ()
let hs = stdin.ReadLine().Split(' ') |> Array.map int

let mutable cash = hs.[0]
let mutable result = true
for h in hs do
    if cash <= h-1 then
        cash <- h-1
    elif cash = h then
        cash <- h
    else
        result <- false
if result then
    printfn "Yes"
else
    printfn "No"

Measured memory_bytes: 30296
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,i;double f,s;cin >> n;
  double a[n];
  for (i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  f = a[0];
  for (i=1;i<n;i++) f = (f+a[i])/2;
  cout << f << endl;
}

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

long long int n, a, b;

int main(void){
  cin >> n >> a >> b;
  if(a > b){
    cout << 0 << endl;
    return 0;
  }
  else if(n == 1 && a != b){
    cout << 0 << endl;
    return 0;
  }
  else{
    cout << b *(n - 1) + a - a * (n - 1) - b  + 1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int a,b,c;
int main() {
    cin>>a>>b>>c;
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a%2==0||b%2==0||c%2==0) puts("0");
    else printf("%lld\n",1ll*a*b);
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 256