akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

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

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

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1e9+7;
LL dp[3005][3005] = {0};
LL sum[3005][3005] = {0};

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

    LL n;
    cin>>n;
    string s;
    cin>>s;

    dp[0][n] = 1;
    REP(i,n){
        dp[1][i] = 1;
        sum[1][i+1] += sum[1][i] + 1;
    }
    FOR(i,1,n){
        char c = s[i-1];
        REP(j,n){
            if(c == '<'){
                dp[i+1][j] = sum[i][n-i+1] - sum[i][j+1] + MOD;
            }
            else {
                dp[i+1][j] = sum[i][j+1] - sum[i][0] + MOD;
            }
            dp[i+1][j] %= MOD;
        }
        REP(j,n){
            sum[i+1][j+1] += sum[i+1][j] + dp[i+1][j];
            sum[i+1][j+1] %= MOD;
        }
    }

    PUTS(dp[n][0]);
}


Measured memory_bytes: 141312
n = str(input())
length = int(len(n))
num = int(n[length-1])
if num == 2 or num == 4 or num == 5 or num == 7 or num == 9:
  print("hon")
elif num == 0 or num == 1 or num == 6 or num == 8:
  print("pon")
else:
  print("bon")

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

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

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

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int N, T;
	cin >> N >> T;

	vector<int> t(N);
	FOR(i, 0, N) cin >> t[i];
	for (int i = N - 1; i > 0; i--) t[i] -= t[i - 1];

	lint ans = T;

	FOR(i, 1, N) {
	
		if (t[i] > T) ans += T;
		else ans += t[i];
	}

	cout << ans;
}

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

int main() {
	unsigned int menu[5];
	unsigned int ans = 0;
	int min10index = 0;

	for (int i = 0; i < 5; i++) {
		cin >> menu[i];

		if ((menu[i] % 10 != 0) && ( (menu[i] % 10) < (menu[min10index] % 10) ) ) min10index = i;
	}

	for (int i = 0; i < 5; i++) {
		if (i == min10index) continue;
		ans += menu[i];
		if ((ans % 10) != 0) ans += 10 - (ans % 10);
	}

	cout << ans + menu[min10index];

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 1000000009
bool f=0;
ll a[2];int k;
int main(){
	ios::sync_with_stdio(false);
	cin>>a[0]>>a[1]>>k;
	while(k--){
		if (a[f]%2) a[f]-=1;
		a[f]/=2;
		a[!f]+=a[f];
		f=!f;
	}
	cout<<a[0]<<" "<<a[1];
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintStream printStream = new PrintStream(System.out);
        new ProblemE().solve(scanner, printStream);
    }

    static class Utils {
        public static int[] readIntArray(Scanner scanner, int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = scanner.nextInt();
            }
            return res;
        }

        public static void println(PrintStream printStream, List<Integer> a) {
            for (int x : a) {
                printStream.print(x + " ");
            }
            printStream.println();
        }

        public static void println(PrintStream printStream, int[] a) {
            for (int x : a) {
                printStream.print(x + " ");
            }
            printStream.println();
        }
    }

    static class ProblemE {

        long qpow(long a, long b, long mod) {
            long res = 1;
            while (b != 0) {
                if (b % 2 == 1) {
                    res = res * a % mod;
                }
                a = a * a % mod;
                b >>= 1;
            }
            return res;
        }

        long mul(long mod, long... arr) {
            long res = 1;
            for (long x : arr) {
                res = res * x % mod;
            }
            return res;
        }

        void solve(Scanner scanner, PrintStream printStream) {
            final long mod = (long) (1e9 + 7);
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            long[] fac = new long[(m + 10)];

            fac[0] = 1;
            for (int i = 1; i <= m; i++) {
                fac[i] = fac[i - 1] * i % mod;
            }

            long[] d = new long[(m + 10)];
            d[0] = 1;
            d[1] = 0;
            d[2] = 1;
            for (int i = 3; i <= m; i++) {
                d[i] = (i - 1) * (d[i - 1] + d[i - 2]) % mod;
            }


            long[] inv = new long[m + 1];
            inv[m] = qpow(fac[m], mod - 2, mod);
            for (int i = m - 1; i >= 0; i--) {
                inv[i] = inv[i + 1] * (i + 1) % mod;
            }

            long ans = 0;
            for (int i = 0; i <= m - n; i++) {
                ans += mul(mod, d[m - i], inv[m - n - i], inv[i]);
                ans %= mod;
            }
            printStream.println(ans * fac[m] % mod * inv[m - n] % mod);
        }
    }
}


Measured memory_bytes: 64148
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int_fast64_t; using ld = long double;

// -----------------------------------------------------------------------------

void solve() {
    string s; cin >> s;
    int n = s.length();
    int a = 0, b = 1;
    for (int i = 0; i < n; ++i) {
        int d = s[i] - '0';
        int a2, b2;
        a2 = min(a + d, b + 10 - d);
        if (d == 9) {
            d = 0;
            b2 = b;
        } else {
            ++d;
            b2 = min(a + d, b + 10 - d);
        }
        a = a2; b = b2;
    }
    cout << a << '\n';
}


int main() {
    fast_io; cin_exception;
    int t = 1; // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Possible" : "Impossible") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<int> cnt(N);
  REP(i, N) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  int min = -1;
  int max = -1;
  IREP(i, N) {
    if(max == -1 && cnt[i] > 0) {
      max = i;
      min = (max+1) / 2;
    }
    if(max == -1) continue;
    if(i != min) {
      if(cnt[i] <= 1) {
        cout << "Impossible" << "\n";
        return 0;
      }
    } else {
      yes((max%2 == 0 && cnt[i] == 1) || (max%2 != 0 && cnt[i] == 2));
      return 0;
    }
  }

}

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

int main() {
  int N, M;
  cin >> N;
  string s[N];
  for(int i=0; i<N; i++){
    cin >> s[i];
  }
  cin >> M;
  string t[M];
  for(int i=0; i<M; i++){
    cin >> t[i];
  }

  map<string, int> map;
  for(int i=0; i<N; i++){
    if(map.count(s[i]) == 0){
      map[s[i]] = 1;
    }else{
      map[s[i]]++;
    }
  }
  for(int i=0; i<M; i++){
    if(map.count(t[i]) == 0){
      map[t[i]] = -1;
    }else{
      map[t[i]]--;
    }
  }

  int ans = 0;
  for(auto pair : map){
    ans = max(pair.second, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int N, M, X, Y;
    std::cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    for (int i = 0; i < N; i++) {
        std::cin >> x[i];
    }
    for (int i = 0; i < M; i++) {
        std::cin >> y[i];
    }
    int Max_X, Min_Y;
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    Max_X = max(x[N-1], X);
    Min_Y = min(y[0], Y);
    //printf("MX = %d\nMY = %d\n", Max_X, Min_Y);
    if (Min_Y-Max_X > 0) {
        std::cout << "No War" << std::endl;
    } else {
        std::cout << "War" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    read(arr);
    int ans = INF;
    for(int i = 1; i <= 100; ++i){
        int res = 0;
        for(int j = 0; j < n; ++j){
            res += (arr[j] - i) * (arr[j] - i);
        }
        ans = min(ans, res);
    }
    cout << ans ;
}

Measured memory_bytes: 3592
N,W = map(int, input().split())
item = [[None,None]]
for i in range(N):
    v,w = map(int, input().split())
    item.append([v,w])
C = [[0 for i in range(W+1)]] + [[0] + [None for i in range(W)] for i in range(N)]

for i in range(1, N+1):
    for w in range(1, W+1):
        if item[i][1] <= w:
            if item[i][0] + C[i-1][w - item[i][1]] > C[i-1][w]:
                C[i][w] = item[i][0] + C[i-1][w - item[i][1]]
            else:
                C[i][w] = C[i-1][w]
        else:
            C[i][w] = C[i-1][w]
print(str(C[N][W]))

Measured memory_bytes: 27592
n = int(input())
x = input()
popcount_x = x.count("1")
popcount_x1 = popcount_x + 1
popcount_x2 = popcount_x - 1

if popcount_x2 == 0: popcount_x2 = -1

div1 = [0]*n
div2 = [0]*n
cur1 = 1
cur2 = 1
for i in range(n):
    cur1 %= popcount_x1
    cur2 %= popcount_x2
    div1[i] = cur1
    div2[i] = cur2
    cur1 *= 2
    cur2 *= 2


fn = [0]*n
for i in range(1,n):
    popcount = bin(i)[2:].count("1")
    fn[i] = fn[(i)%popcount] + 1

    
x_div1 = sum(int(x[i]) * div1[-i-1] for i in range(n)) % popcount_x1
x_div2 = sum(int(x[i]) * div2[-i-1] for i in range(n)) % popcount_x2

for i in range(n):
    if x[i] == "0": 
        xi_div = (x_div1 + div1[-i-1]) % popcount_x1
        print(fn[xi_div] + 1)
    else:
        if popcount_x2 == -1:
            print(0)
        else:
            xi_div = (x_div2 - div2[-i-1]) % popcount_x2
            print(fn[xi_div] + 1)

Measured memory_bytes: 26820
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  unsigned long long r, D; cin>>r>>D;
  unsigned long long x;	cin>>x;
  for(int i = 1; i <= 10; i++) {
    x =	r * x -	D;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}

ll sum[120];

int main(void){
    ll n;
    cin>>n;
    vector<ll>a1(n),a2(n);
    for(ll i=0;i<n;i++)cin>>a1[i];
    for(ll i=0;i<n;i++)cin>>a2[i];
    for(ll i=0;i<n;i++){
        sum[i+1] = sum[i]+a2[i];
    }
    ll  ans = 0,s = 0;
    for(ll i=0;i<n;i++){
        s+=a1[i];
        ans = max(ans,s+sum[n]-sum[i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

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

    int ans = 0;
    for (int i = 0; i < (int)s.length(); i++) {
        if (s.at(i) != t.at(i)) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)

using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;

int main()
{
    ll n,m;
    cin>>n>>m;
    ll h[n+1];

    for(ll i=1;i<=n;i++){
        cin>>h[i];
    }
    ll a,b;
    bool good[n+1];
    memset(good,true,sizeof(good));
    for(ll i=0;i<m;i++){
        cin>>a>>b;
        if(h[a]==h[b]){
            good[a]=false;
            good[b]=false;
        }else if(h[a]<h[b]){
            good[a]=false;
        }else{
            good[b]=false;
        }
    }
    ll cnt=0;
    for(ll i=1;i<=n;i++){
        if(good[i]==true) cnt++;
    }
    cout<<cnt<<endl;



}


Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

string s;

int main() {
  cin >> s;
  string t;
  
  if (s == "Sunny") t = "Cloudy";
  if (s == "Cloudy") t = "Rainy";
  if (s == "Rainy") t = "Sunny";
  
  cout << t;
}


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

  typedef long long int ll;

  int main(){
     
    int n;
    cin>>n;
    string s[n+1];
    
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }
    int count=0;
    int startb=0;
    int enda=0;
    int both=0;
    for(int i=1;i<=n;i++){
        int len=s[i].length();
      for(int j=0;j<len-1;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B') count++;
      }
      
    
      if(s[i][0]=='B') startb++;
      if(s[i][len-1]=='A') enda++;
      if(s[i][0]=='B'&&s[i][len-1]=='A') both++;
   } 
     

    
    if(startb==enda&&both==startb) startb--;
    cout<<count+max(0,min(startb,enda))<<endl;

  }

Measured memory_bytes: 768
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;




signed main() {
    string s1;
    cin >> s1;
    string s2;
    cin >> s2;
    
    Sort(s1);
    rSort(s2);
    
    if (s1 < s2) {
        mes("Yes");
    } else {
        mes("No");
    }
    
    
}

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

vector<char> alpha = {
    'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
    'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
};

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

    string ans;
    for (; 0 < N;) {
        ans = alpha[N % 26] + ans;
        N = (N - 1) / 26;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3540
#include <iostream>
#include <string>
using namespace std;
#define int long long
int plas(int N){
	if(N<0)	return N*-1;
	return N;
}
signed main(){
	int N;
	cin >> N;
	int a[200010];
	int sum=0;

	for(int i=0;i<N;i++){
		cin >> a[i];
		sum += a[i];
	}
	int sunuke,alaiguma;
	//初期値
	sunuke=a[0];
	alaiguma=sum-a[0];
	int min = plas(alaiguma-sunuke);
	int sa;
	if(N!=2){
		for(int i=1;i<N-1;i++){
			sa = plas(alaiguma-sunuke);
			if(min > sa){
				min = sa;
			}
			sunuke+=a[i];
			alaiguma-=a[i];
		}
	}
	cout << min;
	cout << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,c=0;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  bool odd=false;
  while(1){
    for(int i=0;i<N;i++){
      if(!(a.at(i)%2)){
        a.at(i)/=2;
      }else{
        odd=true;
        break;
      }
      }
      if(odd){
      break;
    }
    c++;
    }
cout<<c<<endl;
}

Measured memory_bytes: 256
s[50],j,p,q;
main(i){for(;j=i=atoi(gets(s));printf("%d\n",i)){
for(;i;s[j-i--]=strlen(gets(s+j)));
for(;q>0||(j?p=i++,q=j=117933:0);j/=9)for(q=j%9;q>1;)q-=s[p++];
}}

Measured memory_bytes: 532
import sys

*I, = map(int, sys.stdin.read().split())
n, m, Q = I[:3]
lr = zip(*[iter(I[3:3+m*2])] * 2)
pq = zip(*[iter(I[3+m*2:])] * 2)

def main():
    res = [[0] * (n + 2) for _ in range(n+2)]
    
    for l, r in lr:
        res[1][r] += 1
        res[1][n+1] -= 1
        res[l+1][r] -= 1
        res[l+1][n+1] += 1
    
    for i in range(1, n+2):
        for j in range(1, n+1):
            res[i][j+1] += res[i][j]

    for j in range(1, n+2):
        for i in range(1, n+1):
            res[i+1][j] += res[i][j]

    for p, q in pq:
        yield res[p][q]

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 57624
#!/usr/bin/env python3
import sys


def solve(X: int):
    primes = get_prime_numbers_array(2 * (10**5))
    for i, v in enumerate(primes):
        if v and i >= X:
            print(i)
            return
    return


def get_prime_numbers_array(n: int):
    """エラトステネスのふるいを用いてnまでの素数判定を行うための配列を返す"""
    N = n + 1
    is_prime = [1] * N
    is_prime[0] = is_prime[1] = 0
    for i in range(2, N):
        if not is_prime[i]:
            continue
        for j in range(i * 2, N, i):
            is_prime[j] = 0
    return is_prime


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4596
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n;
P p[100010];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> p[i].first;
		p[i].second = i + 1;
	}
	sort(p, p + n);
	rep(i, n - 1)cout << p[i].second << " ";
	cout << p[n - 1].second << endl;
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[100000];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int dp[100000];
  int inf=1111111111;
  for(int i=0;i<100000;i++)dp[i]=inf;
  int ans=0;
  for(int i=0;i<n;i++){
    int lb=-1,ub=99999;
    while(ub-lb>1){
      int m=(lb+ub)/2;
      if(dp[m]<a[i])lb=m;
      else ub=m;
    }
    dp[ub]=a[i];
    ans=max(ans,ub);
  }
  cout<<ans+1<<endl;
  return 0;
}


Measured memory_bytes: 3852
sx, xy, tx, ty = map(int, input().split())
print('U' * (ty - xy) + 'R' * (tx - sx), end='')
print('D' * (ty - xy) + 'L' * (tx - sx), end='')
print('D' + 'R' * (tx - sx + 1) + 'U' * (ty - xy + 1) + 'L', end='')
print('U' + 'L' * (tx - sx + 1) + 'D' * (ty - xy + 1) + 'R')

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

int main()
{
	long long a, b, c;
	cin >> a >> b >> c;
	if ((a&1) && (b&1) && (c&1)) {
		long long x = min(min(a, b), c), y = a+b+c-x-max(max(a, b), c);
		cout << x*y << endl;
	} else cout << 0 << endl;
	return 0;
}


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

using namespace std;

#define lli  long long int
#define pb   push_back

int main(){
    string s;
    int n, flag =0;
    cin >> s;
    n = s.size()-1;

    for(int i=0; i<=n/4; i++){
        //cout << s[i] << " " << s[n-i] << " " << s[((n-2)/2)-i] << " " << s[((n+2)/2)+i] << endl;
        if(s[i]==s[n-i] && s[i]==s[((n-2)/2)-i] && s[n-i]==s[((n+2)/2)+i]) flag =1;

        else{
            flag = 0;
            break;
        }

    }
    if (flag == 1) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, n) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = min((a), (b))

struct Info {
  ll A, B;
};

bool operator<(const Info &left, const Info &right) { return left.A < right.A; }

unsigned long long XOR(unsigned long long A, unsigned long long B) {
  return A ^ B;
}

int main() {
  ll A, B;
  cin >> A >> B;

  ll a = 0, b = 0, c;
  if (A % 2 != 0) {
    a = A;
    A++;
  }

  if ((B - A + 1) % 2 != 0) {
    b = B;
    B--;
  }

  c = ((B - A + 1) / 2) % 2;

  cout << (a ^ b ^ c) << endl;

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector < int > a(100001, 0);
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                ll v = x*x + y*y + z*z + x*y + y*z + z*x;
                if(v <= 10000){
                    a[v]++;
                }
            }
        }
    }

    for(int n = 1; n <= N; n++){
        cout << a[n] << "\n";
    }
    return 0;
}


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

using namespace std;

const int N = 1e5 + 5;
vector<pair<int , int> > adj[N];
int col[N];

void dfs (int node , int par , long long s) {
    col[node] = s % 2 == 0;
    for (auto &e : adj[node])
        if (e.first != par)
            dfs(e.first , node , s + e.second);
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    cin >> n;

    for (int i = 0 ;i < n - 1 ;i++) {
        int u , v , w;
        cin >> u >> v >> w;
        adj[u].push_back({v , w});
        adj[v].push_back({u , w});
    }

    dfs(1 , 1 , 0);

    for (int i = 1 ;i <= n ;i++)
        cout << col[i] << '\n';
}


Measured memory_bytes: 11452
def main():
    input()
    s = [int(i) for i in input().split()]
    input()
    t = [int(i) for i in input().split()]
    number = 0
    for ti in t:
        start, stop = 0, len(s)-1
        while stop - start > 1:
            center = int((start + stop) / 2)
            if ti < s[center]:
                stop = center
            elif ti > s[center]:
                start = center
            else:
                number += 1
                break
        else:
            if ti == s[start] or ti == s[stop]:
                number += 1
    print(number)


if __name__ == '__main__':
    main()



Measured memory_bytes: 16896
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
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);
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll p = (a1 - b1) * t1;
    ll q = (a2 - b2) * t2;
    if (p < 0) p = -p, q = -q;
    ll ans = 0;
    if (p + q > 0) ans = 0;
    else if (p + q == 0) {
        cout << "infinity" << endl;
        return 0;
    } else {
        ans = p / (-(p + q)) * 2;
        if (p % (-(p+q)) != 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	long long x;
	scanf("%d %lld",&n,&x);
	long long int a[100005];
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	long long int ans=0;
	for(int i=1;i<n;i++){
		if(a[i]+a[i-1]>x){
			ans+=(a[i]+a[i-1]-x);
			a[i]=x-a[i-1];
			if(a[i]<0){
				a[i-1]+=a[i];
				a[i]=0;
			}
		}
	//	printf("%d",ans);
	}
	printf("%lld\n",ans);
} 

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

int main()
{
	int a,b,c,tab[10];
	for (a=1;a<=3;a++)
	{
		cin>>b;
		tab[b]++;
	}
	if (tab[5]==2 && tab[7]==1)
	 cout<<"YES\n";
	else
	 cout<<"NO\n";
}


Measured memory_bytes: 256
import re
S2=input().strip().replace("?",".")
T=input()
ans="UNRESTORABLE"
if len(S2)<len(T):
    pass
else:
    for i in range(len(S2)-len(T)+1):
        m=re.match(S2[len(S2)-len(T)-i:len(S2)-i],T)
        if m != None:
            ans=S2[:len(S2)-len(T)-i]+ T + S2[len(S2)-i:]
            ans=ans.replace(".","a")
            break

print(ans)

Measured memory_bytes: 3188
import Foundation

func main() {
    let split = readLine()!.components(separatedBy: " ").map{Int(String($0))!}
    let n = split[0]
    let k = split[1]
    let points = readLine()!.components(separatedBy: " ").map{Int(String($0))!}

    var nowPoint:Int64 = 1
    for i in k ... n-1 {
        if (points[i]>points[i-k]) {
            print("Yes") 
        } else {
            print("No")
        }
    }
}

main()

Measured memory_bytes: 22768
import java.util.Scanner;

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

		int x = sc.nextInt();
		int y = sc.nextInt();

		while (!(x == 0 && y == 0)) {
			System.out.print(Math.min(x, y) + " ");
			System.out.println(Math.max(x, y));

			x = sc.nextInt();
			y = sc.nextInt();

		}
	}
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s == u)
        a--;
    else
        b--;
    cout << a << " " << b << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

using namespace std;
int main(){
    int w,h,t,p;
    while(cin>>w>>h>>t>>p){
        if(w+h+t+p==0)break;
        vector<vector<int>> v(1000,vector<int>(1000,0)); //適当に大きく取る
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                v[1000-i-1][j]=1;
            }
        }
        int x0=0,y0=999; //現状の原点
        auto debug=[&](int y,int x){
            for(int i=0;i<y;i++){
                for(int j=0;j<x;j++){
                    cout<<" "<<v[1000-i-1][j];
                }
                cout<<endl;
            }
            cout<<"x0,y0= "<<x0<<" "<<y0<<endl;
        };
        for(int i=0;i<t;i++){
            int d,c;
            cin>>d>>c;
            if(d==1){ //横向きに折る
                for(int j=0;j<y0+1;j++){
                    int idx=x0+c;
                    //cout<<idx<<endl;
                    for(int k=0;k<c;k++){
                        v[j][idx+k]+=v[j][idx-k-1];
                    }
                }
                x0=x0+c;
            }else { //縦向きに折る
                for(int j=x0;j<1000;j++){
                    for(int k=0;k<c;k++){
                        int idx=y0-c;
                        v[idx-k][j]+=v[idx+k+1][j];
                    }
                }
                //debug(5,5);
                y0=y0-c;
            }
        }
        
        //debug(5,5);
        for(int i=0;i<p;i++){
            int x,y;
            cin>>x>>y;
            cout<<v[y0-y][x0+x]<<endl;
        }
    }

}


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
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; }

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;

//const ll M=1000000007ll;
//const ll MOD=1000000007ll;
const ll MOD=2019ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

//const int mod = 1000000007;
const int mod = 2019;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
   return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint g(ll n, ll x){
  if(x==0) return 1;
  mint ans = g(n, x/2);
  ans *= ans;
  if(x%2==1) ans*= n;
  return ans;  
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
ll fff(ll n, vector<ll>& v, ll i, ll j, ll rl){
  ll can = 0;
  ll can_i = 0;

  cout << v[0]<<endl;
  
  // right
  if(rl == 0){
    rep(k, n){
      if(v[k]*(j-k)>can){
	can = v[k]*(j-k);
	can_i = k;
      }
      //cout << can<<endl;
    }
    v[can_i] = 0;
    return can;
  }
  // left
  else{
    rep(k, n){
      if(v[k]*(k-i)>can){
	can = v[k]*(k-i);
	can_i = k;
      }
      //cout << can<<endl;

    }
    v[can_i] = 0;
    return can;
  }
  
}

ll ff(ll x){
  return x * (x+1) / 2;
}

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

  map<ll, ll> m;
  ll tmp;
  rep(i, n){
    cin>>tmp;
    m[tmp]++;
  }
  ll M;
  cin>>M;
  rep(i, M){
    cin>>tmp;
    if(m[tmp]) m[tmp]--;
    else {
      cout<<"NO"<<endl;
      return 0;
    }
  }
  
  cout<<"YES"<<endl;
  //cout<<ans<<endl;
}


Measured memory_bytes: 12800
def pre_make_prime(N):
    is_prime = [True for _ in range(N + 1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, N + 1):
        if is_prime[i]:
            for j in range(i * 2, N + 1, i):
                is_prime[j] = False
    return is_prime


def resolve():
    N = 10**5
    is_prime = pre_make_prime(N)

    arr_2017 = [0] * (N + 2)
    for i in range(1, N, 2):
        arr_2017[i + 2] = arr_2017[i] + \
            (1 if is_prime[i] and is_prime[(i + 1) // 2] else 0)

    Q = int(input())
    for _ in range(Q):
        L, R = [int(i) for i in input().split()]
        print(arr_2017[R + 2] - arr_2017[L])


resolve()


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
int mod = 1e9+7;
int mul(int a,int b)
{
    return ((a%mod)*(b%mod))%mod;
}
int add(int a,int b)
{
    return ((a%mod)+(b%mod))%mod;
}
int power(int a,int b)
{
    int res = 1;
    while(b>0)
    {
        if(b&1)
        {
            res = mul(res,a);
        }
        b = b/2;
        a = mul(a,a);
    }
    return res;
}
int sub(int a,int b)
{
    return ((a%mod)-(b%mod)+mod)%mod;
}
int div(int a,int b)
{
    return mul(a,power(b,mod-2));
}
signed main() 
{ 
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans = 0; 
    for(int i=0;i<=60;i++) 
    { 
        int zeros = 0; 
        int ones = 0; 
        int temp = 0; 
        for(int j=0;j<n;j++) 
        { 
            if (a[j]%2 == 0) 
                zeros++; 
            else
                ones++; 
            a[j] = a[j]/2; 
        }  
        temp = mul(ones,mul(zeros,((int)1<<i))); 
        ans = add(ans,temp); 
    }
    cout<<ans; 
    return 0; 
} 



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
//約数列挙配列生成
vector<int> divisor(int n){
    vector<int> ret;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    int d,x; cin >> d >> x;
    vi a(n); rep(i,n) cin  >> a[i];

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += (d-1)/a[i] + 1;
    }
    cout << ans + x << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static long INF = 1000000000;

    // b and e are indices of the original array as
    // possible return values are b + 1, b + 2, ..., e - 1
    public static int findBreak(long[] accl_as, int b, int e) {
        // find first point where (sum left) - (sum right) >= 0
        if (e - b < 2) {
            return -1;
        }
        long diff = 0;
        int le = b, ri = e - 1;
        while (ri > le + 1) {
            final int m = (ri + le) / 2;
            diff = (accl_as[m] - accl_as[b]) - (accl_as[e] - accl_as[m]);
            if (diff >= 0) {
                ri = m;
            } else {
                le = m;
            }
        }
        int res = ri;
        diff = (accl_as[ri] - accl_as[b]) - (accl_as[e] - accl_as[ri]);
        // also look at the point before ri
        if (ri > b + 1) {
            final long diff2 = (accl_as[ri - 1] - accl_as[b]) - (accl_as[e] - accl_as[ri - 1]);
            if (Math.abs(diff2) < Math.abs(diff)) {
                res = ri - 1;
                diff = diff2;
            }
        }
        // System.out.printf("b = %d, e = %d, res = %d, diff = %d\n", b, e, res, diff);
        return res;
    }

    public static void main(String[] args) {
        // read inputs
        Scanner in = new Scanner(System.in);
        final int N = in.nextInt();
        long[] as = new long[N];
        for (int i = 0; i < N; i++) {
            as[i] = in.nextLong();
        }

        // calculate prefix sum
        long[] accl_as = new long[N + 1];
        accl_as[0] = 0;
        for (int i = 0; i < N; i++) {
            accl_as[i + 1] = accl_as[i] + as[i];
        }

        // try all positions for the 2nd breaking point
        long ans = INF;
        for (int e2 = 2; e2 < N - 1; e2++) {
            // binary search to find the best position for the 1st breaking point
            final int e1 = findBreak(accl_as, 0, e2);
            // binary search to find the best position for the 3rd breaking point
            final int e3 = findBreak(accl_as, e2, N);
            // calculate P, Q, R, S and the difference between the min and max
            final long P = accl_as[e1] - accl_as[0], Q = accl_as[e2] - accl_as[e1],
                    R = accl_as[e3] - accl_as[e2], S = accl_as[N] - accl_as[e3];
            final long mn = Math.min(P, Math.min(Q, Math.min(R, S))),
                    mx = Math.max(P, Math.max(Q, Math.max(R, S)));
            ans = Math.min(ans, mx - mn);
        }
        System.out.printf("%d\n", ans);
    }
}


Measured memory_bytes: 86148
//A 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
const int INF = 1e9+10;
int raw[maxn],f[maxn];
int main(){
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> raw[i];
		f[i] = INF;
	}
	f[1] = 0;
	for(int i = 1;i <= n;i++){
		if(i-1 > 0)f[i] = min(f[i],f[i-1] + abs(raw[i] - raw[i-1]));
		if(i-2 > 0)f[i] = min(f[i],f[i-2] + abs(raw[i] - raw[i-2]));
	}
	cout << f[n];
	return 0;
}


Measured memory_bytes: 4300
use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

type Mat = Vec<Vec<char>>;

fn bit(num: usize, pos: usize) -> usize {
    (num & (1 << pos)) >> pos
}

fn make_moves(mat: &Mat, rows: usize, cols: usize) -> Mat {
    let mut res = mat.to_owned();
    for i in 0..mat.len() {
        if bit(rows, i) == 1 {
            (0..mat[0].len()).for_each(|j| res[i][j] = '_');
        }
    }
    for j in 0..mat[0].len() {
        if bit(cols, j) == 1 {
            (0..mat.len()).for_each(|i| res[i][j] = '_');
        }
    }
    res
}

fn count_black(mat: &Mat) -> usize {
    mat.iter().map(|row| row.iter().filter(|&ch| *ch == '#').count()).sum()
}

fn solve(mat: &Mat, left: usize) -> usize {
    let rows = mat.len();
    let cols = mat[0].len();

    let mut res = 0;
    for i in 0..(1 << rows) {
        for j in 0..(1 << cols) {
            let new = make_moves(mat, i, j);
            res += if count_black(&new) == left { 1 } else { 0 };
        }
    }
    res
}

fn main() {
    let mut reader = TokenReader::new();
    let rows = reader.next::<usize>();
    let _ = reader.next::<usize>();
    let left = reader.next::<usize>();
    let mat = (0..rows).map(|_| reader.next::<String>().chars().collect()).collect();

    let res = solve(&mat, left);
    println!("{}", res);
}


Measured memory_bytes: 2144
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	for (int n = 1; ; n++) {
		int cnt = 0;
		for (int d = 1; d <= n; d++)
			if (n % d == 0)
				cnt++;
		if (cnt == N) {
			cout << n << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <vector>
using namespace std;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    vector<bool> red(n);
    vector<int> cnt(n, 1);
    red[0] = true;
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a; --b;
        red[b] = (red[b] || red[a]);
        cnt[a] -= 1;
        cnt[b] += 1;
        if (cnt[a] == 0) red[a] = false;
    }

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

Measured memory_bytes: 640