akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    vector<ll> accum(N+1);
    rep(i,0,N)accum[i+1] = accum[i] + V[i];
    map<ll,int> mp;
    rep(i,0,N+1)mp[accum[i]]++;

    ll ans = 0;
    //ans += max(mp[0]-1, 0);
    for(auto p:mp){
        ll num = p.second;
        //cout << p.first << "," << num << endl;
        ans += num * (num-1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15104
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    int res = 0;
    int sqrtx = int(sqrt(x));

    if (x < 4) {
        cout << "1" << endl;
        return 0;
    }

    for (int b = 2; b <= int(sqrt(x)); b++) {
        int bp = 1;
        for (int p = 0; ; p++) {
            bp *= b;
            if (bp > x) {
                break;
            }
            res = max(res, bp);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
r = 0
x=float(N/2.0)
r_f=False
if x.is_integer():
  halfN=int(x)
else:
  halfN=int((N-1)/2)
for s in S:
  if s == "R":
    r+=1
  if halfN < r:
    r_f = True
    break
if r_f:
  print("Yes")
else:
  print("No")
    

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

int main(){
    int n,a[101];
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }
    for(int j = n;j > 0;j--){
        if(j != 1){
            cout << a[j] << " ";
        }
        else if(j == 1){
            cout << a[j] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main()
{
    int n;
    string q;
    cin >> n >> q;
    for (int w = 0; w < q.size(); w++)
    {
        cout << (char)((((int)(q[w])-65+n)%26)+65);
    }
    return 0;
}


Measured memory_bytes: 256
// A - Wanna go back home
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> s;
  set<char> g;
  rep(i, 0, s.size())
  {
    g.insert(s[i]);
  }
  if (g.count('S') != g.count('N') || g.count('E') != g.count('W'))
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}

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

using namespace std;
typedef long long llint;
#define inf 1e18

llint r;
void solve(){
	cin >> r;
	string ans;
	if(r<1200)ans="ABC";
	else if(r<2800)ans="ARC";
	else ans="AGC";
	cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()
#define int long long
typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    for (int i = 60; i >= 0; i--) {
        int h = ((ll)1 << i);
        if (h & n) {
            cout << h * 2 - 1;
            return 0;
        }
    }
    cout << 0;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n+1);
    int x=0;
    rep(i,n){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]>n){
            ans++;
        }
        else{
            b[a[i]]++;
        }
    }
    for(int i=1;i<=n;i++){
        if(b[i]>i){
            ans+=(b[i]-i);
        }
        else if(b[i]<i){
            ans+=b[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
while 1:
    m = int(raw_input())
    if m == 0:
        break
    mxys = [map(int, raw_input().split()) for i in range(m)]
    nxys = set(tuple(map(int, raw_input().split())) for i in range(int(raw_input())))
    for nxy in nxys:
        dx = nxy[0] - mxys[0][0]
        dy = nxy[1] - mxys[0][1]
        txys = set((mxy[0] + dx, mxy[1] + dy) for mxy in mxys)
        if txys.issubset(nxys):
            print dx, dy
            break

Measured memory_bytes: 4484
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception {

        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int i = 0; i < N; i++) {
            int a = sc.nextInt();

            if(map.get(a) == null) {
                map.put(a, 1);
            } else {
                map.put(a, map.get(a) + 1);
            }

            if(map.get(a - 1) == null) {
                map.put(a - 1, 1);
            } else {
                map.put(a - 1, map.get(a - 1) + 1);
            }

            if(map.get(a + 1) == null) {
                map.put(a + 1, 1);
            } else {
                map.put(a + 1, map.get(a + 1) + 1);
            }
        }

        int result = 0;
        for(Entry<Integer, Integer> entry : map.entrySet()) {
            result = Math.max(result, map.get(entry.getKey()));
        }
        System.out.println(result);
    }
}


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

int a[100][100];
int b[100];
int c[100];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			scanf("%d", &a[i][j]);
	for(int i = 0; i < m; i++)
		scanf("%d", &b[i]);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
	}
	for(int i = 0; i < n; i++)
		printf("%d\n", c[i]);
}



Measured memory_bytes: 3224
while True:
    m, f, r = map(int, input().split())
    if m + f + r == -3:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')



Measured memory_bytes: 5592
/*
─────────▄▄▄▄▄▄▄▄▄▄▄▄─────────
─────▄▄▀▀░░░░░░░░░░░░▀▀▄▄─────
───▄▀░░░░░░░░░░░░░░░░░░░░▀▄───
──█░░░░░▄▄▄▄▄░░░░▄▄▄▄▄░░░░░█──
─█░░░░░██░█░██▄▄██░█░██░░░░░█─
█░░░░░░░▀▀▀▀▀░░░░▀▀▀▀▀░░░░░░░█
█░░░░▄▄▄░░░░░░░░░░░░░░▄▄▄░░░░█
█░░░░██▀█▄▄▄▄▄▄▄▄▄▄▄▄██▀█░░░░█
─█░░░▀██▄████████▄▄▄▄██▄▀░░░█─
──█░░░░▀██▀▀▀▀████████▀░░░░█──
───▀▄░░░░▀▄▄▄▄██████▀░░░░▄▀───
─────▀▀▄▄░░░░░░░░░░░░▄▄▀▀─────
─────────▀▀▀▀▀▀▀▀▀▀▀▀─────────
*/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int n;
	cin >> n;
	vector<int> ans(n);
	for (int i = 0; (1 << i) <= n; ++i) {
		for (int j = (1 << i) - 1; j < n; j += (1 << (i + 1))) {
			ans[j] = i + 1;
		}
	}
	for (int i = 0; i < n - 1; ++i) {
		if (i) {
			cout << '\n';
		}
		for (int j = 0; j < n - 1 - i; ++j) {
			if (j) {
				cout << ' ';
			}
			cout << ans[j];
		}
	}

	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
        v[i]--;
    }

    const int VMAX = 100'000;
    vector<vector<int>> w(2, vector<int>(VMAX, 0));
    rep(i, n)
    {
        w[i % 2][v[i]]++;
    }

    using P = tuple<int, int>;
    vector<vector<P>> x(2, vector<P>(VMAX));
    rep(i, 2)
    {
        rep(j, VMAX)
        {
            x[i][j] = P(w[i][j], j);
        }
        sort(x[i].begin(), x[i].end());
    }

    int result = numeric_limits<int>::max();
    rep(i, 2) rep(j, 2)
    {
        int n0, v0, n1, v1;
        tie(n0, v0) = x[0][VMAX - 1 - i];
        tie(n1, v1) = x[1][VMAX - 1 - j];
        if (v0 != v1) {
            result = min(result, n - n0 - n1);
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 3704
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n;
  vector<int> v;
  vector<int> ans;

  cin >> n;

  for(int i=0;i<n;i++){
    int b;
    cin >> b;
    v.push_back(b);
  }

  for(int i=0;i<n;i++){

    for(int j=n-1-i;j>=0;j--){
      if(v[j] == j+1) {
        ans.push_back(v[j]);
        v.erase(v.begin() + j);
        break;
      }

      if(j == 0){
        puts("-1");
        return 0;
      }
    }
  }

  reverse(ans.begin(), ans.end());

  for(int p : ans){
    cout << p << endl;
  }


  return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    ll ret = 0;
    for(int i = 1; i < N; ++i){
        if(A[i-1] > A[i]){
            ret += A[i-1] - A[i];
            A[i] = A[i-1]; 
        }
    }
    cout << ret << '\n';
    return 0;
}

Measured memory_bytes: 3972
N,M,C= map(int,input().split())
B= list(map(int,input().split()))
A = [0]*N

count = 0
for i in range(N):
    A[i] = list(map(int,input().split()))
    ab = [A[i][j]*B[j] for j in range(M)]
    if sum(ab)+C>0:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
   int k,n;
    scanf("%d %d",&k,&n);
    int max1=0,i,t;
    int a[200005];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(i!=0)
        {
            if(a[i]-a[i-1]>k/2)
            t=k-(a[i]-a[i-1]);
            else
            t=a[i]-a[i-1];
            if(t>max1)
            max1=t;
        }

    }
    if(a[i-1]-a[0]>k/2)
        t=k-(a[i-1]-a[0]);
    else
        t=a[i-1]-a[0];
    if(t>max1)
        max1=t;
    printf("%d",k-max1);
    return 0;
}


Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      StrSplitToInt str;
      int n = Integer.parseInt(br.readLine());
      int[] seqA = new int[n];
      str = new StrSplitToInt(br.readLine(), " ");
      for(int i=0; i<n; i++) {
        seqA[i] = str.nextInt();
      }

      int q = Integer.parseInt(br.readLine());
      str = new StrSplitToInt(br.readLine(), " ");
      StringBuilder result = new StringBuilder();
      for(int i=0; i<q; i++) {
        if( solve(n, seqA, 0, str.nextInt()) )
          result.append("yes\n");
        else
          result.append("no\n");
      }
      System.out.print(result);
    }
  }

  private static boolean solve(int n, int[] a, int i, int m) {
    if( m == 0 ) return true;
    if( i >= n ) return false;

    boolean res = solve(n, a, i+1, m) || solve(n, a, i+1, m-a[i]);

    return res;
  }
}
 
class StrSplitToInt {
  final String s;
  final String split;
  final int endPos;
  final int splitLen;
  int currentPos;
  int nextPos;
 
  public StrSplitToInt(String s,String split) {
    this.s = s;
    this.split = split;
    currentPos = 0;
    nextPos = s.indexOf(split, currentPos);
    endPos = s.length();
    splitLen = split.length();
  }
 
  public int nextInt() {
    if( currentPos < endPos ) {
      int ret = Integer.parseInt( s.substring(currentPos, nextPos) );
      currentPos = nextPos + splitLen;
      nextPos = s.indexOf(split, currentPos);
      if(nextPos == -1) nextPos = endPos;
 
      return ret;
    }
    else
      return -1;
  }
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;

int main(){
  int n;
  cin>>n;
  
  
  int m= (n+1)*100/108;
  bool judge=true;
  
  while(judge){
    if(m*108/100==n){
      cout<<m<<endl;
      judge=false;
      break;
    }
    
    if(m*108/100==n-1){
      cout<<":("<<endl;
      return 0;
    }
     m--; 
      
    
    
    
  }
  
  


}


Measured memory_bytes: 256
X, N = map(int,input().split())
p = sorted(list(map(int, input().split())))
P = list(range(-1, 103))
[P.remove(pp) for pp in p]
p_min_abs = 10000000

for pp in P:
    if abs(pp - X) < p_min_abs:
        p_min_abs = abs(pp - X)
        p_min = pp
print(p_min)

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

const ll mod = 1e9 + 7;
ll mypow(ll x, ll y, ll m = mod)
{
    ll ans = 1;
    ll q = x;
    while (y > 0)
    {
        if (y % 2 == 1)
        {
            ans *= q;
            ans %= m;
        }
        q = q * q;
        q %= m;
        y = y / 2;
    }
    return ans % m;
}

ll permulation(ll x, ll y, ll m = mod)
{
    ll ans = 0;
    if (x >= y)
    {

        ans = 1;
        for (ll i = x - y + 1; i <= x; i++)
        {
            ans = (ans * i) % m;
        }
    }
    return ans;
}

ll combination(ll x, ll y, ll m = mod)
{
    ll ans = 0;
    if (y == 0 || y == x)
        ans = 1;
    else
    {
        ans = 1;
        for (ll i = x - y + 1; i <= x; i++)
        {
            ans = (ans * i) % m;
        }
        for (ll i = 1; i <= y; i++)
        {
            ans = (ans * mypow(i, m - 2, m)) % m;
        }
    }
    return ans;
}

ll fractual(ll x, ll m = mod)
{
    if (x == 0)
        return 0;
    else
        return permulation(x, x, m);
}

ll multi_choose(ll x, ll y, ll m = mod)
{
    return combination(x + y - 1, y - 1, m);
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    ll n, k;
    cin >> n >> k;
    cout << ( (n <= k) ? 1 : 0 ) << endl;
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair <int, int>;
using vii = vector <pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    string s;
    cin>>s;

    int ans = 0, cnt = 0;
    for(int i = 0; i < s.size(); i++) {
        cnt += (s[i] == 'W');
        if(s[i] == 'W') ans += (i - (cnt - 1));
    }

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


Measured memory_bytes: 720
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let mut a: Vec<u32> = scan.next_vec(n);
    a.sort();

    let mut s: HashSet<u32> = HashSet::new();
    let mut ans = 0;
    let mut prev = 0;
    for x in &a {
        if prev == *x {
            ans -= 1;
            prev = 0;
        }
        if s.contains(x) {
            continue;
        }
        prev = *x;
        ans += 1;
        for i in 1.. {
            if *x * i > 1000_000 {
                break;
            }
            s.insert(*x * i);
        }
    }
    println!("{}", ans);
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 19804
#include <stdio.h> 
 #include <stdbool.h> 
 
 
 int main(){ 
     int i, j, n; 
     char mark; 
     char marks[4]={'S', 'H', 'C', 'D'}; 
     int num; 
     bool cards[4][13]={false}; 
 
 
     scanf("%d ", &n); 
     for(i=0;i<n;i++){ 
         scanf("%c %d ", &mark, &num); 
         for(j=0;j<4;j++){ 
             if(mark==marks[j]){ 
                 cards[j][num-1]=true; 
                 break; 
             } 
         } 
     } 
     for(i=0;i<4;i++){ 
         for(j=0;j<13;j++){ 
             if(!cards[i][j]){ 
                 printf("%c %d\n", marks[i], j+1); 
             } 
         } 
     } 
     return 0; 
 } 



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

int main() {
  int n;
  while(cin >> n){
    if(n==0) return 0;
    int a[26]={};
    vector<char> v(n);
    rep(i, n) cin >> v[i];
    rep(i, n){
      a[v[i]-'A'] += 1;
      int first=0, second=0, t;
      char c;
      rep(j, 26){
        if(a[j]>first){
          first = a[j];
          t = j;
          c = 'A'+j;
        }
      }
      rep(j, 26){
        if(a[j]>second && j!=t){
          second = a[j];
        }
      }
      if(first>n-i-1+second){
        cout << c << " " << i+1 << endl;
        break;
      }
      if(i==n-1) puts("TIE");
    }
  }
  return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int N,M,l,r;

ll bit0[300010] = {0},bit1[300010] = {0};
ll sum(ll *b,ll i){
	ll s = 0;
	while(i>0){
		s += b[i];
		i -= i&-i;
	}
	return s;
}

void add(ll *b,int i,ll v){
	while(i<=M){
		b[i] += v;
		i += i&-i;
	}
}

void seg_add(int l,int r, ll x){
	add(bit0,l,-x*(l-1));
	add(bit1,l,x);
	add(bit0,r+1,x*r);
	add(bit1,r+1,-x);	
}

ll seg_sum(int l, int r){
	ll res = 0;
	res += sum(bit0,r) + sum(bit1,r)*r;
	res -= sum(bit0,l-1) + sum(bit1,l-1)*(l-1);
	return res;
}


int main(){
	cin >> N >> M;
	vector<vector<P>> v(M+1);
	for(int i=0;i<N;i++){
		cin >> l >> r;
		v[r-l+1].push_back({l,r});
	}
	int sum = N;
	for(int i=1;i<=M;i++){
		int ans = sum;
		for(int j=1;j*i<=M;j++){
			ans += seg_sum(i*j,i*j);
		}
		cout << ans << endl;
		for(int j=0;j<v[i].size();j++){
			seg_add(v[i][j].first,v[i][j].second,1);
			sum--;
		}
	}
}

Measured memory_bytes: 10496
var
    a,b,p:longint;
    s:string;
    minus:boolean;//FALSE
begin
    readln(s);
    p:=pos('+',s);//找+号
    if p=0 then begin p:=pos('-',s); minus:=true; end;
            //找不到+找-，标记为true
    val(copy(s,1,p-2),a);//取a
    val(copy(s,p+2,length(s)-p-1),b);//取b
    if minus then writeln(a-b) else writeln(a+b);//输出
end.

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

int main()
{
  long long N,M;
  cin>>N>>M;

  if(2*N>=M){
    cout<<M/2<<endl;
  }
  else{
    cout<<N+(M-2*N)/4<<endl;
  } 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

int main() {
	string s;
	cin >> s;
	set<string> ans;
	rep(i, 0, 3) {
		string a;
		a = s[i];
		ans.insert(a);
	}
	if (ans.size() == 3) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<ctime>
#include<cstdlib>
#include<unordered_map>
#include<string.h>
#include<iostream>
using namespace std;

signed main() {
	int n, a; cin >> n >> a;
	if (n % 500 <= a)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 764
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int n;cin>>n;
 cout<<(n%2==0 ? n:2*n);
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long k = sc.nextLong();

		long answer;

		if(k % 2 == 0 || k == 0){
			answer = a-b;
		}else{
			answer = b -a;
		}


		if(answer > Math.pow(10,18)){
			System.out.println("Unfair");
		}else{
		System.out.println(answer);
		}

	}

}


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

struct T
{
	int in , valeur;
	string s;
	bool operator < (const T & autre) const
	{
		for (int i = 0 ; i < min((int)s.size() , (int)autre.s.size()) ; i++)
		{
			if (s[i] < autre.s[i])
			{
				return true;
			}
			else if (s[i] > autre.s[i]) return false;
		}
		if (s.size() < autre.s.size())
		{
			return true;
		}
		else if (s.size() > autre.s.size()) return false;
		return valeur > autre.valeur;
	}
};

int main()
{
	int N;
	cin>>N;
	T tab[N];
	for (int i = 0 ; i < N ; i++)
	{
		cin>>tab[i].s>>tab[i].valeur;
		tab[i].in = i + 1;
	}
	sort(tab , tab + N);
	for (int i = 0 ; i < N ; i++)
	{
		cout<<tab[i].in<<endl;
	}
}

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


int main(void){
	int n;
	int b[100];
	int i;
	int x;

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

	x = b[0];
	for(i=1;i<n-1;i++){
		if(b[i-1] > b[i]){
			x += b[i];
		}
		else{
			x += b[i-1];
		}
	}

	x += b[n-2];

	printf("%d\n",x);

	return 0;
}




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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;

int main() {
	string a; cin >> a;
	ll ans = 0;
	
	int f = 0;
	string e = "";

	for (int i = 0; i < a.length(); i++) {
		if (e != a.substr(f, i - f + 1)) {
			ans++;
			e = a.substr(f, i - f + 1);
			f = i + 1;
		}
	}
	cout << ans << "\n";
}


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

long double l, h, w;

const long double g = 981;
const long double eps = 1e-10;
const int MaxN = 1e6 + 16;

long long a[MaxN];

int main()
{
    int n;
    long long ans = 1e9 * 1ll * 1e9, sum = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        sum += a[i];
        a[i] += a[i - 1];
    }
    for(int i = 1; i < n; ++i)
        ans = min(ans, abs(2 * a[i] - sum));
    cout << ans << '\n';
    return 0;
}


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

using namespace std; 
#define fr for(int i = 0;i < n;i++)
#define pb push_back
void printVector(vector<char>x){
    for(auto i:x){
        cout << i << " ";
    }
    cout << endl;
}


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

    cout << ((a) + (a * a) + (a * a *a)) << endl;
    


}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int a,b;
	cin >> a >> b;
	cout << a*b << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3608
import math

n = int(input())
p = list()
m = int(math.sqrt(n)+1)
for i in range(2,m):
    if n%i == 0:
        c = 0
        while n%i == 0:
            c += 1
            n //= i
        p.append(c)
if n != 1:
    p.append(1)
maxi = 1
for x in p:
    maxi *= (x+1)
print(len(p),maxi-1)



Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int mx=0;
    int count=0;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        if(x==y){
            count++;
        }
        else{
            mx = max(count,mx);
            count=0;
        }
    }
    if(max(count,mx)>=3)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3632
#!/usr/bin/env python3

def rec(i, j):
    if (i, j) in dp:
        return dp[(i, j)]

    if i == N:
        res = 0
    elif j < w[i]:
        res = rec(i + 1, j)
    else:
        res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i])

    dp[(i, j)] = res
    return res


N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = {}
print(rec(0, W))


Measured memory_bytes: 20708
#include <stdio.h>
#include <math.h>
#define EPS (1e-12)

int main() {
    double xA, yA, xB, yB, xC, yC, xD, yD;
    while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
                &xA, &yA, &xB, &yB, &xC, &yC, &xD, &yD) != EOF) {
        const double x1 = xB-xA, y1 = yB-yA;
        const double x2 = xD-xC, y2 = yD-yC;
        puts(fabs(x1*x2+y1*y2) < EPS ? "YES" : "NO");
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

namespace NyaGadgetCpp17
{
	/**
	@brief 最大公約数を計算する関数
	@note
	 aとbの最大公約数を返す
	**/
	long long Gcd(long long a, long long b)
	{
		return b ? Gcd(b, a % b) : a;
	}
	/**
	@brief 最小公倍数を計算する関数
	@note
	 aとbの最小公倍数を返す
	**/
	long long Lcm(long long a, long long b)
	{
		return a / Gcd(a, b) * b;
	}
};

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

using namespace NyaGadgetCpp17;

int main(void)
{
	ll a, b; cin >> a >> b;

	if (a <= b * 2)
		cout << 0;
	else
		cout << a - (b * 2);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

vector<int> ans;

void make(int a){
  if(a==0){
    rep(i,9){
      ans.push_back(i+1);
      make(i+1);
    }
  }else{
    int num=a%10;
    a*=10;
    if(num!=0){
      if(a+num-1 <= 3234566667){
	ans.push_back(a+num-1);
	make(a+num-1);
      }
    }
    if(a+num <= 3234566667){
      ans.push_back(a+num);
      make(a+num);
    }
    if(num!=9){
      if(a+num+1 <= 3234566667){
	ans.push_back(a+num+1);
	make(a+num+1);
      }
    }
  }
}

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int k;
  cin>>k;
  make(0);
  sort(ans.begin(),ans.end() );
  cout<<ans[k-1]<<endl;
  

  return 0;
}


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

int main(void){
    int x,y;
    double a,b;
    cin >> x >> y;

    a = (4.0 * x - y) / 2.0;
    b = (y - 2.0 * x) / 2.0;

    if(a >= 0 && b >= 0 && ceil(a) == floor(a) && ceil(b) == floor(b) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };

};

int a,b,c,d,i,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
long long o[251010],o1[251010];
int l[251011];
long long s[251011],re[251010];
long long s1[251011],re1[251010];
long long x,y,z,mod=1000000007,hf=(mod+1)/2;

//string r,r1;
char r[251011];
 vector<int> v[1],v1;
P u[1];
queue<int> q;
//set<int> s[2];
//stack<long long> s;
map<long long,int> p;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng()
bool as(P a,P b)
{
  return a.x<b.x;
}

long long po1(long long x,long long y)
{
  long long p=1;
  for(;y;y/=2,x*=x,x%=mod)
  if(y%2)
  {
    p*=x,p%=mod;
  }
  return p;
}

long long po(long long x,long long y)
{
  long long p=1;
  for(;y;y/=2,x*=x,x%=z)
  if(y%2)
  {
    p*=x,p%=z;
  }
  return p;
}

long long f1(int n)
{
  if(n<0) return re1[abs(n)];
  return s1[n];
}

long long f(int n)
{
  if(n<0) return re[abs(n)];
  return s[n];
}

int main()
{
  scanf("%d %s",&a,r+1);
  z=1000000021;
  s[0]=re[0]=s1[0]=re1[0]=1;
  for(int t=1;t<=a;t++)
  {
    s[t]=s[t-1]*3*a%z,re[t]=po(s[t],z-2);
    s1[t]=s1[t-1]*3*a%mod,re1[t]=po1(s1[t],mod-2);
  }
  long long x1=0;
  for(int t=1;t<=a;t++)
  {
    if(r[t]=='+') x+=f(n),x%=z,x1+=f1(n),x1%=mod;
    else if(r[t]=='-') x+=(-f(n)+z),x%=z,x1+=(-f1(n)+mod),x1%=mod;
    else if(r[t]=='>') n++;
    else n--;
    l[t]=n;
    o[t]=x;
    o1[t]=x1;
  }
  long long k=0,y1=x1;
  y=x;
  for(int t=a;t;t--)
  {
    p[o[t]*mod+o1[t]]++;
    k+=p[(o[t-1]+y*f(l[t-1])%z)%z*mod+(o1[t-1]+y1*f1(l[t-1])%mod)%mod];
    //printf("%lld %lld %lld\n",k,o1[t],(o1[t-1]+y1*f1(l[t-1])%mod)%mod);
  }
  printf("%lld",k);
}


Measured memory_bytes: 44416
n = int(input())
x_list = list(map(int,input().split()))
x_list.sort()
cost_tot_min = 1000000000

for p in range(x_list[0],x_list[-1]+1):
    cost_tot = 0
    for x in x_list:
        cost = (x-p)**2
        cost_tot += cost
    if cost_tot < cost_tot_min:
        cost_tot_min = cost_tot

print(cost_tot_min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main() {
    	long int s, c;
    	scanf("%ld %ld", &s, &c);
    	if (c / 2 > s) {
    		long int aux = (c / 2 - s);
    		printf("%ld\n", s + aux / 2);
    	} else {
    		printf("%ld", c / 2);
    	}
    	return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
//#define for(i, a, b) for(int i=a; i<b; i++)

void solve(){
	int n, m=3;
	cin>>n;
	int a[n], b[n], c[n];
	for(int i=0;i<n;i++) {
		cin>>a[i]>>b[i]>>c[i];
	}
	vector< vector<int> > dp(n, vector<int> (3));
	dp[0] = {a[0], b[0], c[0]};
	for(int i=1;i<n;i++){
		dp[i] = {a[i]+max(dp[i-1][1], dp[i-1][2]), b[i]+max(dp[i-1][0], dp[i-1][2]), c[i]+max(dp[i-1][0], dp[i-1][1])};
	}
	cout<<*max_element(dp[n-1].begin(), dp[n-1].end())<<endl;
}

signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 8064
program sentou
  implicit none
  integer :: n, t, s(200000) = 0, i, x = 0
  read(*,*) n, t
  read(*,*) s(1:n)
  x = t
  do i = 1, n-1
    x = x+min(s(i+1)-s(i),t)
  end do
  write(*,'(i0)') x
end program sentou

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

string s;

int main()
{
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'C')
        {
            for(int j = i+1; j < s.size(); j++)
            {
                if(s[j] == 'F')
                {
                    printf("Yes");
                    return 0;
                }
            }
        }
    }
    printf("No");
}

Measured memory_bytes: 256
/*
* @Author: Kabid
* @Date:   2020-04-26 18:01:07
* @Last Modified by:   Kabid
* @Last Modified time: 2020-05-02 18:24:50
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<set>
#include<map>
#include<algorithm>
#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');
using namespace std;

int t;       //test cases
int i = 1, j=0;	 //iterators
int n=0, k; //variables
long long w,x;
ll a, b, d;
double c;
double p=100.0;
string s;
set<string>st;
int main() {
	cin>>x;
	while(1){
		j++;
		c=floor(p*(1.01));
		if(c>=x){
			cout<<j;
			break;
		}
		p=c;

	}

	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define loop(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll a[n],b[n],c[n];
	loop(i,0,n) cin>>a[i]>>b[i]>>c[i];
	loop(i,1,n)
	{
		a[i]+= max(b[i-1],c[i-1]);
		b[i]+= max(a[i-1],c[i-1]);
		c[i]+= max(a[i-1],b[i-1]);
	}
	cout<<max(a[n-1],max(b[n-1],c[n-1]));	
	return 0;
}

Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

/***************************************************************
stackによる深さ優先探索を実装する。
***************************************************************/

const (
	N     = 100
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

var (
	n            int
	Adj          [N][N]int
	statusColor  [N]int
	discoverTime [N]int
	finishTime   [N]int
	clock        int
	nt           [N]int
)

/***************************************************************
Stackの定義:
- field
	container: ノードの格納されたスライス
	sp: スタックポインタ
- method
	size(): スタックに積まれているノードの個数を返す
	top(): スタックの一番上に積まれているノードを返す
	isEmpty(): スタックが空かどうかを返す
	pop(): スタックの要素をポップし削除する
	push(): スタックに要素を積む
***************************************************************/

type Stack struct {
	container []int
	sp        int
}

func (s *Stack) size() int {
	return len(s.container)
}

func (s *Stack) top() int {
	return s.container[s.sp]
}

func (s *Stack) isEmpty() bool {
	return s.sp == 0
}

func (s *Stack) pop() int {
	_pop := func() {
		s.container = s.container[:len(s.container)-1]
	}
	defer _pop()
	if s.isEmpty() {
		panic("There is no elements in stack!")
	}
	s.sp--
	return s.container[s.sp]
}

func (s *Stack) push(n int) {
	s.sp++
	s.container[s.sp] = n
}

func next(u int) int {
	for v := nt[u]; v < n; v++ {
		nt[u] = v + 1
		if Adj[u][v] == 1 {
			return v
		}
	}
	return -1
}

func _DFS(target int) {
	for i := 0; i < n; i++ {
		nt[i] = 0
	}
	stack := new(Stack)
	stack.container = make([]int, N+1)
	stack.push(target)
	statusColor[target] = GRAY
	clock++
	discoverTime[target] = clock
	for !stack.isEmpty() {
		u := stack.top()
		v := next(u)
		if v != -1 {
			if statusColor[v] == WHITE {
				statusColor[v] = GRAY
				clock++
				discoverTime[v] = clock
				stack.push(v)
			}
		} else {
			stack.pop()
			statusColor[u] = BLACK
			clock++
			finishTime[u] = clock
		}
	}
}

func DFS() {
	for i := 0; i < n; i++ {
		statusColor[i] = WHITE
		nt[i] = 0
	}
	clock = 0
	for i := 0; i < n; i++ {
		if statusColor[i] == WHITE {
			_DFS(i)
		}
	}
	for i := 0; i < n; i++ {
		fmt.Printf("%d %d %d\n", i+1, discoverTime[i], finishTime[i])
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			Adj[i][j] = 0
		}
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		u--
		for j := 0; j < k; j++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			v--
			Adj[u][v] = 1
		}
	}

	DFS()
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  deque<int> dq;
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    if(i%2 == 0)dq.push_back(x);
    else dq.push_front(x);    
  }
  if(n%2==1){
    for(auto it = dq.rbegin(); it != dq.rend(); ++it)
      cout << *it << endl;
  } else {
    for(auto it = dq.begin(); it != dq.end(); ++it)
      cout << *it << endl;
  }
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    for (auto& c : S) {
        if (c == ',') {
            c = ' ';
        }
    }
    cout << S << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 52;
int n, a;
ll ans;
int num[N];
ll dp[N][N * N];

void init() {
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = n - 1; j >= 0; --j) {
            for (int k = 2500; k >= 0; --k) {
                if (dp[j][k] != 0 && k + num[i] <= 2500) {
                    dp[j + 1][k + num[i]] += dp[j][k];
                }
            }
        }
    }
}


int main() {
    cin >> n >> a;
    for (int i = 0; i < n; ++i) {
        cin >> num[i];
    }
    init();
    for (int i = 1; i <= n; ++i) {
        if (i * a <= 2500)
            ans += dp[i][i * a];
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    string s;
    cin>>s;
    int cnt=0,m=0;
    for(int i=0; i<s.size(); i++) {
        if(s[i]=='R') {
            cnt++;
            m=max(m,cnt);
        } else
            cnt=0;
    }
    cout<<m<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 402 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e18 + 15;
ll dp[maxn][maxn];
int main(){
    ios::sync_with_stdio(false);
    memset(dp,0,sizeof dp);
    cin.tie(0);
    int n;
    cin>>n;
    ll vet[maxn];
    auto sum = [&](int L,int R){
      ll s=0;
      rep(i,L,R+1){
        s+=vet[i];
      }
      return s;
    };
    rep(i,0,n)cin>>vet[i];  
    per(L,n,0){
      rep(R,L,n){
        if(L==R)dp[L][R]=0;
        else{
          dp[L][R] = INF;
          ll soma = sum(L,R);
          rep(i,L,R){
            dp[L][R]=min(dp[L][R],dp[L][i]+dp[i+1][R] + soma);
          }
        }
      }
    }
    cout<<dp[0][n-1]<<'\n';
    return 0;   
}


Measured memory_bytes: 1536
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int before = sc.nextInt();
        int count = 0;
        Set<Integer> set = new HashSet<>();
        for (int i = 1; i < n; i++) {
            int now = sc.nextInt();
            if (now <= before) {
                count++;
            } else {
                set.add(count);
                count = 0;
            }
            before = now;
        }
        set.add(count);
        System.out.println(set.stream().mapToInt(m -> m).max().getAsInt());
    }
}


Measured memory_bytes: 50680