akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;
  cin >> n;

  vi a(n),b(n),c(n-1);

  rep(i,n)
    cin >> a[i];
  rep(i,n)
    cin >> b[i];
  rep(i,n-1)
    cin >> c[i];
  
  int l = -1;
  int sum = 0;

  rep(i,n)
  {
    sum += b[a[i] - 1];
    if(l != -1)
      if(a[i] == l + 1)
        sum += c[l - 1];
    l = a[i];
  }

  cout << sum;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll W, a, b;
    cin >> W >> a >> b;
    if (a < b)
    {
        cout << max((ll)0, b - a - W) << endl;
    }
    else
    {
        cout << max((ll)0, a - b - W) << endl;
    }
}

Measured memory_bytes: 3608
b1,b2,b3=map(int,input().split())
if b1==1 and b2==0 and b3==0:
    print('Close')
elif b1==0 and b2==1 and b3==0:
    print('Close')
elif b1==1 and b2==1 and b3==0:
    print('Open')
elif b1==0 and b2==0 and b3==1:
    print('Open')
else:
    print('Close')


Measured memory_bytes: 5596
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int tax(int v, int w)
{
	return (int)(v*(100.0 + (double)w) / 100.0);
}

int main()
{
	int p, q, r,s;
	vector<int>x, y;
	while (1)
	{
		cin >> p >> q >> r;
		if (p == 0 && q == 0)break;
		x.clear();
		y.clear();
		for (size_t i = 0; i <= r; i++)
		{
			x.push_back(tax(i, p));
			
		}
		int i=1, j=x.size()-2;
		while (i <= j)
		{
			if (x[i] + x[j] == r)
			{
				y.push_back(tax(i, q) + tax(j, q));
				i++;
				j--;
			} else if (x[i] + x[j] < r)
			{
				i++;
			} else
			{
				j--;
			}

		}
		sort(y.rbegin(), y.rend());
		cout << y[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int bingo[3][3] = {};
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			int a;
			cin >> a;
			bingo[i][j] = a;
		}
	}
	int n;
	cin >> n;
	bool panti[3][3] = {};
	for (int i = 0; i < n; i++) {
		int b;
		cin >> b;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (bingo[j][k] == b) {
					panti[j][k] = 1;
				}
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		int counttate = 0;
		int countyoko = 0;
		for (int j = 0; j < 3; j++) {
			if (panti[i][j] == 1) {
				counttate++;
			}
			if (panti[j][i] == 1) {
				countyoko++;
			}
		}
		if (counttate == 3 || countyoko == 3) {
			cout << "Yes";
			return 0;
		}
	}
	if (panti[0][0] == 1 && panti[1][1] == 1 && panti[2][2] == 1) {
		cout << "Yes";
		return 0;
	}
	if (panti[0][2] == 1 && panti[1][1] == 1 && panti[2][0] == 1) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    ll n, q;
    string s;
    cin >> n >> q >> s;
    vector<ll> dp(n, 0);
    for(ll i = 0; i < n-1; i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            dp[i+1] = (dp[i] + 1);
        }
        else{
            dp[i+1] = dp[i];
        }
    }

    while(q){
        ll l,r;
        cin >> l >> r;
        cout << dp[r-1] - dp[l-1] << endl;
        q--;
    }
    
 
}

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

int main() {
    array<int, 3> strsize;
    cin >> strsize[0] >> strsize[1] >> strsize[2];
    int cnt5 = 0, cnt7 = 0;

    for (int i = 0; i < strsize.size(); i++) {
        if (strsize[i] == 5) cnt5++;
        else if (strsize[i] == 7) cnt7++;
    }

    if (cnt5 == 2 && cnt7 == 1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  

int main(){
  string s; cin >> s;
  ll k; cin >> k;
  int n=s.size();

  int bc=0, fc=0;
  for(int i=n-1; 0<=i; i--){
    if(s[0]!=s[i]) break;
    bc += 1;
  }
  if(0<bc && bc<n){
    for(int i=0; i<n; i++){
      if(s[0]!=s[i]) break;
      fc += 1;
    }
  }
  
  ll cnt=1, sum=0;
  for(int i=fc; i<n-bc-1; i++){
    if(s[i]==s[i+1]){
      cnt += 1; 
      if(i<n-bc-2) continue;
    }
    sum += cnt/2; cnt=1;
  }
  if(bc!=n){
    sum = sum*k+(fc+bc)/2*(k-1)+fc/2+bc/2;
  }else sum = bc*k/2;
  cout << sum<< endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,k,i;
	cin>>a>>b>>k;
	for(i=0;i<k;i++){
		if(i%2==1){
			b/=2;
			a+=b;
		}else{
			a/=2;
			b+=a;
		}
	}
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (100010)
struct V{
	int x, y, z;
};
int n;
vector<V>a;
vector<V>con;
bool z;
bool compare(const V& v1, const V& v2){
	if (v1.y != v2.y)return v1.y < v2.y;
	else return v1.x < v2.x;
}

void convex_make(void){
	sort(a.begin(), a.end(), compare);
	int k = 0;
	V co[N];
	f(i, n){
		z = true;
		while (k > 1 && z){
			if ((co[k - 1].x - co[k - 2].x)*(a[i].y - co[k - 1].y) > (co[k - 1].y - co[k - 2].y)*(a[i].x - co[k - 1].x))k--;
			else z = false;
		}
		co[k] = a[i];
		k++;
	}
	int t = k;
	for (int i = n - 2; i >= 0; i--){
		z = true;
		while (k > t&&z){
			if ((co[k - 1].x - co[k - 2].x)*(a[i].y - co[k - 1].y) > (co[k - 1].y - co[k - 2].y)*(a[i].x - co[k - 1].x))k--;
			else z = false;
		}
		co[k] = a[i];
		k++;
	}
	con.clear();
	f(i, k - 1)con.push_back(co[i]);
	return;
}

int main(void){
	int x, y;
	int ssss;
	scanf("%d", &n);
	f(i, n){
		scanf("%d %d", &x, &y);
		a.push_back({ x, y, i });
	}
	convex_make();
	ssss = con.size();
	printf("%d\n", ssss);
	printf("%d %d\n", con[0].x, con[0].y);
	f(i, ssss-1){
		printf("%d %d\n", con[ssss - i - 1].x, con[ssss - i - 1].y);
	}

	return 0;
}


Measured memory_bytes: 6536
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int A = scan.nextInt();
        int B = scan.nextInt();

        int answer = 0;
        int prev = 1;
        int now = 1;
        while(now < B) {
            prev = now;
            now = prev - 1 + A;
            answer++;
        }

        os.println(answer);
    }
}

Measured memory_bytes: 23764
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(2e3+5)], DP[int(2e3+5)][int(2e3+5)];
Pll P[int(2e3+5)];

int main(){
  scanf("%d", &N);
  for (int i = 1; i <= N; i++){
    scanf("%lld", A + i);
    P[i] = mp(A[i], i);
  }
  sort(P + 1, P + N + 1, greater<Pll>());

  ll ans = 0;
  for (ll i = 1; i <= N; i++){
    for (ll j = 0; j <= i; j++){
      ll now = 0;

      if (j >= 1){
        now = max(now, DP[j-1][i-j] + P[i].fi * abs(P[i].se - j));
      }
      if (i - j - 1 >= 0){
        now = max(now, DP[j][i-j-1] + P[i].fi * abs(P[i].se - (N - (i - j) + 1)));
      }
      DP[j][i-j] = now;
      ans = max(ans, DP[j][i - j]);
    }
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 26520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n;
    vector<pair<string ,P> > ls;
    cin >> n;
    ls.resize(n);
    REP(i,n){
        cin >> ls[i].first >> ls[i].second.first;
        ls[i].second.second = i+1;
        ls[i].second.first *= -1;

    }
    SORT(ls);
    REP(i,n){
        cout << ls[i].second.second << endl;
    }
    return 0;
}

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

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

    vector<pair<int, int>> odd(100100, make_pair(0, 0)), even(100100, make_pair(0, 0));
    rep (i, n)
    {
        int v;
        cin >> v;
        if (i % 2)
        {
            odd[v].first++;
            odd[v].second = v;
        }
        else
        {
            even[v].first++;
            even[v].second = v;
        }
    }

    sort(odd.rbegin(), odd.rend());
    sort(even.rbegin(), even.rend());

    if (odd[0].second != even[0].second)
        cout << (n / 2 - odd[0].first) + (n / 2 - even[0].first) << endl;
    else
        cout << min((n / 2 - odd[0].first) + (n / 2 - even[1].first), (n / 2 - odd[1].first) + (n / 2 - even[0].first)) << endl;
}

Measured memory_bytes: 4760
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ull MOD = 998244353;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  int x[5];
  int ans = 0;
  REP(i, 5){
    cin >> x[i];
    if(x[i]==0){
      ans = i+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    IOS;
   int l,r,d,c=0;
   cin>>l>>r>>d;
   for(int i=l;i<=r;i++)
   {
       if(i%d==0){c++;}
   }
   cout<<c;
   return 0;
 }



Measured memory_bytes: 3624
import functools as F
 
H, W = map(int, input().split())
S = F.reduce(lambda x, y: x + y, [input() for i in range(H)])
s = []
for c in S:
    s.append(0 if c == '.' else -10)
for idx, i in enumerate(s):
    if i < 0:
        if idx >= W and idx % W > 0:
            s[idx - W - 1] += 1
        if idx >= W:
            s[idx - W] += 1
        if idx >= W and idx % W < W - 1:
            s[idx - W + 1] += 1
        if idx % W > 0:
            s[idx - 1] += 1
        if idx % W < W - 1:
            s[idx + 1] += 1
        if idx + W < H * W and idx % W > 0:
            s[idx + W - 1] += 1
        if idx + W < H * W:
            s[idx + W] += 1
        if idx + W < H * W and idx % W < W - 1:
            s[idx + W + 1] += 1
 
for i in range(H):
    for j in range(W):
        print(s[j + i * W] if s[j + i * W] >= 0 else '#', end='')
    print()

Measured memory_bytes: 4068
#include <iostream>
#include <cmath>


int GetJustLog(int num)
{
	int res = 0;
	while (num % 2 == 0)
	{
		res += 1;
		num /= 2;
	}
	return res;
}



int main()
{
	int arrSize;
	std::cin >> arrSize;

	int logSum = 0;

	for (int i = 0; i < arrSize; i++)
	{
		int num;
		std::cin >> num;
		logSum += GetJustLog(num);
	}

	std::cout << logSum;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double dx = a*cos((h+m/60.0)*(PI/6.0)) - b*cos((m*PI)/30.0);
	double dy = a*sin((h+m/60.0)*(PI/6.0)) - b*sin((m*PI)/30.0);
	double ans = sqrt(dx*dx+dy*dy);
	printf("%.15f", ans);
	return 0;
}


Measured memory_bytes: 4088
using System;
using System.Linq;
using System.Collections.Generic;

public static class Program {
    static int N;
    static int[]table;
    static int mod=1000000007;
    public static void Main() {
        int n=int.Parse(Console.ReadLine());
        String s=Console.ReadLine();
        N=1;
        while(N<n)N*=2;
        table=new int[2*N];
        Update(0,1);
        for(int i=1;i<n;i++){
            if(s[i-1]=='<'){
                for(int j=i;j>=0;j--){
                    Update(j,Query(0,j));
                }
            } else {
                for(int j=0;j<=i;j++){
                    Update(j,Query(j,i));
                }
            }

            // Console.Write($"[i:{i}]");
            // for(int j=0;j<2*N;j++){
            //     if(j==N)Console.Write(" |");
            //     Console.Write($" {table[j]}");
            // }
            // Console.Write("\n");
        }
        Console.WriteLine(table[1]);
    }
    public static void Add(ref int x, int y){
        x+=y;
        if(mod<=x)x-=mod;
    }
    public static int Sum(int x, int y){
        Add(ref x,y);
        return x;
    }
    public static void Update(int i, int x){
        i+=N;
        table[i]=x;
        for(i/=2;1<=i;i/=2){
            table[i]=Sum(table[2*i],table[2*i+1]);
        }
    }
    public static int Query(int l, int r){
        int ans=0;
        for(l+=N,r+=N;l<r;l/=2,r/=2){
            if(l%2==1)Add(ref ans,table[l++]);
            if(r%2==1)Add(ref ans,table[--r]);
        }
        return ans;
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <list>

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

	std::list<int> A(N);
	for(int &a : A) {
		std::cin >> a;
	}

	int result;
	while(true) {
		const auto min = std::min_element(A.begin(), A.end());
		for(auto itr = A.begin(); itr != A.end();) {
			if(itr == min) {
				itr++;
				continue;
			}
			*itr %= *min;
			if(*itr == 1) {
				result = 1;
				goto RESULT;
			} else if(*itr == 0) {
				itr = A.erase(itr);
			} else {
				itr++;
			}
		}
		
		if(A.size() == 1) {
			result = *min;
			break;
		}
	}

RESULT:
	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int n, a, b, k;
        String temp, cmd;
        char[] str, stack;
        Scanner sc = new Scanner(System.in);
        temp = sc.next();
        n = sc.nextInt();
        str = new char[temp.length()];
        for(int i = 0; i < temp.length(); i++) 
            str[i] = temp.charAt(i);
        
        for (int i = 0; i < n; i++) {
            cmd = sc.next();
            a = sc.nextInt();
            b = sc.nextInt();
            switch (cmd) {
            case "print":
                for(int j = a; j <= b; j++) 
                    System.out.print(str[j]);
                System.out.println();
                break;
            case "reverse":
                k = 0;
                stack = new char[b - a + 1];
                for(int j = a; j <= b; j++) 
                    stack[k++] = str[j];
                for(int j = a; j <= b; j++) 
                    str[j] = stack[--k];
                break;
            case "replace":
                String tp = sc.next();
                k = 0;
                for(int j = a; j <= b; j++) 
                    str[j] = tp.charAt(k++);
                break;
            }
        }
    }
}


Measured memory_bytes: 33152
#include<cstdio>

int main(){
	long long a,b,g,l,t;
	while(scanf("%lld %lld", &a, &b) + 1){
		if(a > b){
			t = a;
			a = b;
			b = t;
		}

		if(b % a){
			t = a / 2;
			l = 1;
			for(int i = 2; i <= t; i++){
				if(!(a % i)){
					g = a / i;
					if(!(b % g)){
						printf("%lld %lld\n", g, a * b / g);
						i += t;
						l = 0;
					}
				}
			}
			if(l){
				printf("1 %lld\n", a * b);
			}

		}else{
			printf("%lld %lld\n", a, b);
		}
	}
	return 0;
}

Measured memory_bytes: 1020
#include <climits>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

void dijkstra(vector<vector<pair<int, int>>>& g, vector<int>& weights) {
    int n_vertex = weights.size();
    vector<bool> visited(n_vertex, false);

    auto pq_compare = [](pair<int, int>& a, pair<int, int>& b) {
        return a.second > b.second;
    };
    priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(pq_compare)>
        pq(pq_compare);

    weights[0] = 0;
    pq.push(make_pair(0, weights[0]));
    while (!pq.empty()) {
        pair<int, int> min_pair = pq.top();
        pq.pop();
        int min_idx = min_pair.first;

        if (min_pair.second > weights[min_idx])
            continue;

        visited[min_idx] = true;

        for (int i = 0; i < g[min_idx].size(); ++i) {
            int adj = g[min_idx][i].first;
            int weight_via_idx = weights[min_idx] + g[min_idx][i].second;
            if (!visited[adj] && weight_via_idx < weights[adj]) {
                weights[adj] = weight_via_idx;
                pq.push(make_pair(adj, weights[adj]));
            }
        }
    }
}

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

    vector<vector<pair<int, int>>> g(n);
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            g[i].push_back(make_pair(v, c));
        }
    }

    vector<int> weights(n, INT_MAX);
    dijkstra(g, weights);
    for (int i = 0; i < n; ++i)
        cout << i << ' ' << weights[i] << '\n';
}



Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
int f(int x) {
    int tmp = x;
    int ret = 0;
    while (x > 0) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}
/* main */
int main(){
    int x;
    cin >> x;
    int y = f(x);
    if (x % y == 0) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

i64 f(i64 n, i64 k)
{
    i64 ret = n % k;
    return (ret < k - ret) ? ret : k - ret;
}

int main()
{
    i64 n, k;
    cin >> n >> k;
    cout << f(n, k) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
signed main() {
	int r, c, n;
	scnaf("%d %d %d", &r, &c, &n);
	map<int, int> za;
	vector<pii> x, y;
	vector<pii> segs[4];
	REP(i, n) {
		int x1, y1, x2, y2;

		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		if ((x1 == 0 || x1 == r || y1 == 0 || y1 == c) && (x2 == 0 || x2 == r || y2 == 0 || y2 == c)) {
			if (y1 == 0) {
				segs[0].push_back({ x1, i });
			}
			else if (x1 == r) {
				segs[1].push_back({ y1, i });
			}
			else if (y1 == c) {
				segs[2].push_back({ x1, i });
			}
			else if (x1 == 0) {
				segs[3].push_back({ y1, i });
			}

			if (y2 == 0) {
				segs[0].push_back({ x2, i });
			}
			else if (x2 == r) {
				segs[1].push_back({ y2, i });
			}
			else if (y2 == c) {
				segs[2].push_back({ x2, i });
			}
			else if (x2 == 0) {
				segs[3].push_back({ y2, i });
			}
		}
	}

	stack<int> st;
	sort(ALL(segs[0]));
	sort(ALL(segs[1]));
	sort(ALL(segs[2]), greater<pii>());
	sort(ALL(segs[3]), greater<pii>());
	int al[100001] = {};
	REP(i, 4) {
		for (auto itr : segs[i]) {
			if (al[itr.second]) {
				int cur = st.top();
				st.pop();
				if (cur != itr.second) {
					printf("NO\n");
					return 0;
				}
			}
			else 
				st.push(itr.second);
			al[itr.second]++;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 2584
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

//#define __int64 long long
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int main(){
	int h,w,n,x,y;
	long long int ans[10] = {0};
	cin >> h >> w >> n;
	
	map<pair<int, int>, int> mp;
    
	rep(i,n){
		cin >> y >> x;
		y--;
		x--;
		
		for(int iy=-1; iy<=1; iy++){
			for(int ix=-1; ix<=1; ix++){
				if(y+iy >= 1 && y+iy < h-1 && x+ix >= 1 && x+ix < w-1){
					mp[make_pair(y+iy, x+ix)] ++;
				}
			}
		}
	}
	
	for(auto i: mp){
		ans[i.second] ++;
	}
	
	ans[0] = (long long int)(h-2) * (w-2);
	for(int i=1; i<10; i++){
		ans[0] -= ans[i];
	}
	
	rep(i,10){
		cout << ans[i] << endl;
	}
	
    return 0;
}

Measured memory_bytes: 56448
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

struct query{
  int a, b, c, d;
};

int get_value(const int& X_size, const vector<query>& X, const vector<int>& A) {
  int ans {};
  rep(i, X_size) {
    if (A[X[i].b] - A[X[i].a] == X[i].c) {
      ans += X[i].d;
    }
  }
  return ans;
}

int check(const int& index, const int& n, const int& M, const int& X_size, const int& now_value, const vector<query>& X, vector<int> A) {
  if (index == n) {
    return get_value(X_size, X, A);
  }
  int ans {};
  srep(i, now_value, M+1) {
    A[index] = i;
    maxs(ans, check(index+1, n, M, X_size, i, X, A));
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int N, M, Q;
  cin >> N >> M >> Q;
  vector<query> X(Q);
  rep(i, Q) {
    cin >> X[i].a >> X[i].b >> X[i].c >> X[i].d;
    --X[i].a;
    --X[i].b;
  }

  vector<int> A(N, 1);
  int ans = check(0, N, M, Q, 1,X, A);
  cout << ans << '\n';
}


Measured memory_bytes: 3632
#include <cstdio>
#include <vector>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

typedef long long ll;
typedef vector<int> prm;

//------------------------------------------------------------------------------
prm mul(prm &A, prm &B) {
  prm C = prm(A.size());
  REP(i, A.size()) C[i] = B[A[i]];
  return C;
}

prm pow(prm &A, ll n) {
  prm B = prm(A.size());
  REP(k, A.size()) B[k] = k;
  while(n > 0) {
    if (n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}

//------------------------------------------------------------------------------
const int N_MAX = 100000;
const int M_MAX = 100000;

int N;
int x[N_MAX];
int M;
ll K;
int a[M_MAX];

void solve() {
  prm P = prm(N - 1);
  REP(k, P.size()) P[k] = k;
  REP(j, M) swap(P[a[j] - 1], P[a[j]]);
  prm Q = pow(P, K);
  ll ans = x[0];
  printf("%lld\n", ans);
  REP(i, N - 1) {
    ans += x[Q[i] + 1] - x[Q[i]];
    printf("%lld\n", ans);
  }
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", x + i);
  scanf("%d%lld", &M, &K);
  REP(i, M) {
    scanf("%d", a + i);
    --a[i];
  }
}

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


Measured memory_bytes: 3176
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cmath>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

typedef unsigned int uint;
typedef long long ll;

using namespace std;
bool isSym(char *buff){
  int n = strlen(buff);
  for(int i=0; i<n/2; i++){
    if(buff[i] != buff[n-i-1]) return false;
  }
  return true;
}

int main(){
  char buff[256];
  int ans = 0;
  while(cin>>buff){
    if(isSym(buff))
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  vector<pair<int,int>> red(n), blue(n);
  rep(i, n) cin >>red[i].first >>red[i].second;
  rep(i, n) cin >>blue[i].first >>blue[i].second;
  
  // blueはx座標の小さい順、x座標が同じであればy座標の小さい順にソート
  sort(all(blue));

  // redはy座標の大きい順、y座標が同じであればx座標の小さい順にソート
  rep(i, n) swap(red[i].first, red[i].second);
  rep(i, n) red[i].first *= -1;
  sort(all(red));
  rep(i, n) red[i].first *= -1;
  rep(i, n) swap(red[i].first, red[i].second);

  // で、各blueについてgreedyにペアのredを決定していく
  vector<bool> redpair(n, false);
  // redpair[i] := red[i]がペアを形成しているかどうか
  rep(b, n){
    // blue[b]についてペアを探していく
    rep(r, n){
      if (redpair[r]) continue; // 既にペアを形成している
      if (red[r].second >= blue[b].second) continue; // y座標がblue以上である
      if (red[r].first < blue[b].first){
        // ペアを形成していないredのうち、y座標がblue未満でx座標もblue未満であればペア成立
        redpair[r] = true;
        break;
      }
    }
  }
  int res = 0;
  rep(i, n) res += redpair[i];
  cout <<res <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
//ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
//ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

ll gojo(ll x,ll y){
	if(y>x){
		ll w=x;
		x=y;
		y=w;
	}
	ll w=1;
	while(w!=0){
		w=x%y;
		x=y;
		y=w;
	}
	return x;
}

ll lcm(ll a,ll b){ll c=gojo(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N , M , L;
	cin >> N >> M;
	//cout << gojo(N,M);return 0;
	string S,T;
	cin >> S >> T;
	ll K;
	K = gojo(N,M);
	L = lcm(N,M);
	bool ans=true;
	ll j;
	map<ll,char> ma;
	FOR(i,0,N){
		j = (L/N) * i;
		ma[j] = S[i]; 
	}
	FOR(i,0,M){
		j = (L/M) * i;
		if(ma[j]<='z'&&ma[j]>='a')
			if(ma[j] != T[i])ans = false; 
	}
	if(ans){
		cout << L << endl;
	}else{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 10880
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int A, B, C, ans;
    cin >> A >> B >> C;
    ans = C > (A - B) ? C - (A - B) : 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int first=0,second=0;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>first){
            second=first;
            first=a[i];
        }else if(a[i]>second){
            second=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]!=first){
            cout<<first<<endl;
        }else{
            cout<<second<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2432
#include<stdio.h>
int main(void) {
	float t1, t2;

	while (scanf("%f %f",&t1,&t2)!=EOF) {
		if (t1 < 35.50 && t2 < 71.00)
			printf("AAA\n");
		else if (t1 < 37.50 && t2 < 77.00)
			printf("AA\n");
		else if (t1 < 40.00 && t2 < 83.00)
			printf("A\n");
		else if (t1 < 43.00 && t2 < 89.00)
			printf("B\n");
		else if (t1 < 50.00 && t2 < 105.00)
			printf("C\n");
		else if (t1 < 55.00 && t2 < 116.00)
			printf("D\n");
		else if (t1 < 70.00 && t2 < 148.00)
			printf("E\n");
		else
			printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 604
R,G,B,N = map(int,input().split(' '))
A,B,C = sorted([R,G,B])
if A==1 and B==1 and C ==1:
  print(int((N+2)*(N+1)/2))
  exit()
num = 0
E = int(N//C+1)
F = int(N//B+1)
for i in range(E):
  for j in range(F):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <sstream>

int main(){
    std::stack<int> val;
    std::vector<std::string> elem;
    std::string line;
    getline(std::cin, line);
    std::stringstream ss(line);
    std::string item;
    while(getline(ss, item, ' ')){
        if(!item.empty()){
            elem.push_back(item);
        }
    }
    for(auto iter = elem.begin(); iter != elem.end(); ++iter){
        int a = 0;
        int b = 0;
        switch(iter->c_str()[0]){
            case '+' :
                a = val.top();
                val.pop();
                b = val.top();
                val.pop();
                val.push(b + a);
                break;
            case '-' :
                a = val.top();
                val.pop();
                b = val.top();
                val.pop();
                val.push(b - a);
                break;
            case '*' :
                a = val.top();
                val.pop();
                b = val.top();
                val.pop();
                val.push(b * a);
                break;
            case '/' :
                a = val.top();
                val.pop();
                b = val.top();
                val.pop();
                val.push(b / a);
                break;
            default:
                int v = std::atoi(iter->c_str());
                val.push(v);
        }
    }

    std::cout << val.top() << "\n";
    return 0;
}


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

using namespace std;

int main(){


	int n;
	while(cin>>n&&n!=0){
		vector<int> v;
		for(int i = 1; i <= n; i++){
			v.push_back(i);
		}
		int sum=1;
		int begin=0;
		int end=0;
		
		int cnt=0;
		while(1){
			if(end==n-1)
				break;
			else if(sum==n){
				cnt++;
			}
			if(sum<n){
				end++;
				sum+=v[end];
			}
			else if(sum>=n){
				sum-=v[begin];
				begin++;
			}
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if x == (500 * i + 100 * j + 50 * k):
                cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <cstdint>
#include <stdexcept>
#include <utility>

using namespace std;

void selection_sort(int32_t array[], size_t size, void (*callback)(int32_t arrary[], size_t size))
{
  if (size == 0) throw runtime_error("array size is 0");
  if (array == nullptr) throw runtime_error("array is null");

  for (uint32_t i = 0; i < size; i++) {
    int32_t min = i;
    for (uint32_t j = i; j < size; j++) {
      if (array[j] < array[min]) {
        min = j;
      }
    }
    if(i != min){
      swap(array[i], array[min]);
    
      if (callback != nullptr) {
        callback(array, size);
      }
    }
  }
}

#if !defined(TEST)
#include <iostream>
static uint32_t cnt;

static void callback(int32_t arrary[], size_t size)
{
  cnt++;
}

int32_t main(void)
{
  int32_t len;

  cin >> len;

  int32_t array[128];
  for (uint32_t i = 0; i < len; i++) {
    cin >> array[i];
  }

  selection_sort(array, len, callback);

  for (uint32_t i = 0; i < len; i++) {
    if (i != 0) cout << " ";
    cout << array[i];
  }
  cout << endl;

  cout << cnt << endl;
  return 0;
}
#endif

Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>
int main()
{
	double 			input;
	std::vector<double> 	height;
	while (std::cin >> input) {
		height.push_back(input);
	}
	sort(height.begin(), height.end());
	std::cout << *(height.end()-1) - *(height.begin()) << std::endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 200001


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

    string str;
    cin >> str;
    int n = str.size();
    if (str[0] == '0' || str[n - 1] == '1') {
        cout << "-1" << endl;
        return 0;
    }
    for (int i = 1; i < n - 1; i++) {
        if (str[i] != str[n - i - 2]) {
            cout << "-1" << endl;
            return 0;
        }
    }
    int s = 0;
    cout << "1 2" << endl;
    for (int i = 1; i < n - 1; i++) {
        cout << s + 1 << " " << i + 2 << endl;
        if (str[i] == '1') {
            s = i + 1;
        }
    }

    return 0;
}


Measured memory_bytes: 1616
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()

    r = 0
    for c in a[::2]:
        r += c % 2

    return r


print(main())




Measured memory_bytes: 10964
#include <bits/stdc++.h>
using namespace std;
int main() {
       	int n;
       	long long int keep = 0, ans = 0;
       	cin >> n;
       	vector<int> a(n);
       	for(int i = 0; i < n; i++) {
       		cin >> a[i];
       		keep += a[i];
       		if(a[i] == 0) {
       			ans += keep / 2;
       			keep = 0;
       		}
       	}
       	ans += keep / 2;
       	cout << ans << endl;

       	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
int a,b,num1,num2,num3;
cin>>a>>b;
num1=a+b;
num2=a-b;
num3=a*b;
  if((num1 >= num2) && (num1 >= num3))
        cout <<num1;
    else if ((num2 >= num1) && (num2 >= num3))
        cout <<num2;
    else
        cout <<num3;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int min = sc.nextInt();
		int max = min;
		for (int i = 0; i < 4; i++) {
			int num = sc.nextInt();
			if (num < min) {
				min = num;
			} else {
				if (num > max) {
					max = num;
				}
			}
		}
		int dif = max - min;
		if (dif > sc.nextInt()) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
		sc.close();
	}
}

Measured memory_bytes: 21332
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

getKaiNum :: [[Int]] -> Int -> Int -> Int
getKaiNum [] a b = 0
getKaiNum (x : xs) a b = m + getKaiNum xs a b
  where
    s = show $ head x
    t = show $ last x
    n = read (s ++ t ++ reverse s) :: Int
    m = if n >= a && n <= b then 1 else 0

main = do
  [a, b] <- getIntList
  let xs = sequence [[10 .. 99], [0 .. 9]]
  print $ getKaiNum xs a b


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

typedef long long lint;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int h, w, d;
    cin >> h >> w >> d;
    vector<lint> y(h*w), x(h*w);
    rep(i, h){
        rep(j, w){
            int a;
            cin >> a;
            a--;
            y[a] = i;
            x[a] = j;
        }
    }
    vector<lint> dis(h*w);
    rep(i, h*w){
        if(i < d){
            dis[i] = 0;
        }else{
            dis[i] = dis[i-d] + abs(y[i] - y[i-d]) + abs(x[i] - x[i-d]);
        }
    }
    int q;
    cin >> q;
    rep(i, q){
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        lint ans = dis[r] - dis[l];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3200