akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser" };

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    queue<int> q;
    q.push(0);
    uint32_t idx;
    bool ret = false;
    while(!q.empty()){
        idx = q.front();
        if(idx == s.size()){
            ret = true;
            break;
        }
        q.pop();
        for(int i=0;i<4;++i){
            if(s.substr(idx,divide[i].size())==divide[i]){
                q.push(idx+divide[i].size());
            }
        }
    }
    ret ? cout << "YES" << endl: cout << "NO"<< endl;
    
    // /* code */
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int  main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int s = a * b;
	if(s%2 == 0) printf("Even\n");
	else printf("Odd\n");
	return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

ll choose2(ll n) {
  return n*(n-1)/2;
}

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

  vector<int> cnt(n);
  rep(i, n) cnt[a[i]]++;

  ll tot = 0;
  rep(i, n) {
    tot += choose2(cnt[i]);
  }
  rep(i, n) {
    ll ans = tot;
    ans -= choose2(cnt[a[i]]);
    ans += choose2(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4096
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	static long N;
	public static void main(String[] args) {
		int a=sc.nextInt();
		int b=sc.nextInt();
		for(int i=1;i<=3;i++) {
			if(i==a||i==b) {
				continue;
			}
			p(i);
		}
	}
	

	
	
	
}


Measured memory_bytes: 22612
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define forj(j,n) for(int j=n; j>=0; j--)
#define forx(x,v) for(auto &x:v)
#define sz(v) (int)(v).size()
#define rz(n) resize(n)
#define vec(x) vector < x >
using int64 = long long;
using vi = vector < int >;
using vi64 = vector < int64 >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
//const string yo = "Yes\n", no = "No\n";


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n, x, t;
	cin >> n >> x >> t;
	int a = (n / x);
	if (n % x) a++;
	cout << a*t;






	return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MOD 1e9+7
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

ll dp[101][100001];

int main(){
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    REP(i, N) REP(j, W+1) {
        if(j < w[i]) {
            dp[i+1][j] = dp[i][j];
        } else {
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
        }
    } 

    cout << dp[N][W] << endl;

    return 0;
}

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




class Solution {
  int n;
  vector<int> A;
  const long long INF = 1e18;
  long long costA, costB;
  long long dp[5000];
public:
  void run() {
    cin >> n >> costA >> costB;
    A.resize(n);
    long long ans = INF;
    for (int i = 0; i < n; ++i) cin >> A[i];
    for (int i = 0; i < n; ++i) {
      long long tmp = 0;
      dp[i] = INF;
      for (int j = i - 1; j >= 0; --j) {
        if (A[j] < A[i]) dp[i] = min(dp[j] + tmp, dp[i]);
        tmp += A[j] < A[i] ? costB : costA;
      }
      dp[i] = min(dp[i], tmp);
      tmp = 0;
      for (int j = i + 1; j < n; ++j) {
        if (A[j] > A[i]) {
          tmp = INF;
          break;
        }
        tmp += costB;
      }
      ans = min(ans, dp[i] + tmp);
    }
    cout << ans << '\n';
  }     
};


int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  Solution().run();
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,S;
  cin>>K>>S;
  int ans=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      int k=S-i-j;
      //cout<<i<<" "<<j<<" "<<k<<endl;
      if(k>=0&&k<=K){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


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

int main(){
    char c;
    scanf("%c",&c);
    if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u') {
        printf("vowel\n");
    }else{
        printf("consonant\n");
    }
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long s = sc.nextLong();
        long c = sc.nextLong();
        long ans = Math.min(s,c/2);
        c -= ans*2;
        System.out.print(ans + c/4);
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include<map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef unsigned int ui;
typedef unsigned short us;
typedef unsigned long long ull;

using namespace std;


int inputValue() {
  int a;
  scanf("%d", &a);
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  p->clear();
  p->shrink_to_fit();
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, ui r, ui c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}

template<template <class...> class Map, typename T_0, typename T_1, typename... Args>
void inputMap(Map<T_0, T_1, Args...>& mp) {
  T_0 a;
  T_1 b;
  while (cin >> a && a != -1) {
    cin >> b;
    mp.insert(make_pair(a, b));
  }
}

template<template <class...> class Vec, typename T, typename U, typename... Args>
void numberToBoolenVector(Vec<T, Args...>& vec, U a) {
  ui i = 0;
  T amari;
  do {
    if (a % (ull)pow(2, i + 1)) {
      amari = 1;
      vec.push_back(amari);
      a -= (ull)pow(2, i);
    }
    else {
      amari = 0;
      vec.push_back(amari);
    }
    i++;
  } while (a);
}

template<template <class...> class Vec, typename T, typename... Args>
ull boolenVectorToNumber(Vec<T, Args...>& vec) {
  ull r = 0;
  for (size_t i = 0; i < vec.size(); i++)
  {
    r += vec[i] * (ull)pow(2, i);
  }
  return r;
}

int main(int argc, const char * argv[]) {
  
  ui n;
  int k;
  int q;
  scanf("%d %d %d", &n, &k, &q);

  int ac = k - q; // 1<=ac => Yes
  auto v = vector<int>(n, ac);

  int a;
  while (cin >> a) {
    if (a == -1)break;
    v[a - 1]++;
  }

  for (size_t i = 0; i < n; i++)
  {
    if (v[i] > 0) {
      printf("Yes\n");
    }
    else {
      printf("No\n");
    }
  }
  return 0;
}

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

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

    vector<tuple<string, int, int>> res(N);
    for (int i = 0; i < N; i++) {
        string s;
        int p;
        cin >> s >> p;
        res[i] = make_tuple(s, -p, i + 1);
    }

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

    for (int i = 0; i < N; i++) {
        int x;
        tie(ignore, ignore, x) = res[i];
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
n,m = map(int, input().split())
x = sorted(map(int, input().split()))
y = sorted(map(int, input().split()))
x = [i-x[0] for i in x]
y = [i-y[0] for i in y]
sumx = sum(x)
sumy = sum(y)
allx = sumx
ally = sumy
for i in range(1,n):
    sumx -= (n-i)*(x[i]-x[i-1])
    allx = (allx+sumx)%mod
for i in range(1,m):
    sumy -= (m-i)*(y[i]-y[i-1])
    ally = (ally+sumy)%mod
print(allx*ally%mod)

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

int main(){

    string a, b;

    cin>>a>>b;

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

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

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

  // cout<<a<<endl<<b<<endl;
    if(a<b) puts("Yes");
    else puts("No");

    return 0;


}


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

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

	int cnt = 700;

	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o') {
			cnt += 100;
		}
	}

	cout << cnt << endl;

	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
long long  dp[1000010][2];


long long solve(string s){

fill((long long *)dp,(long long*)dp+sizeof(dp)/sizeof(long long ),INF);
    
    const int n=s.size();

    dp[0][0]=0;
    rep(i,n)
    {
        rep(k,2)
        {
        int D=s[i]-'0';
        D+=k;
            for(int d=0;d<10;d++)
            {
                int nj=0;
                int x=d-D;

                if(x<0){
                    nj=1;
                    x+=10;
                }
            dp[i+1][nj]=min(dp[i+1][nj],dp[i][k]+x+d);
            }
        }
    }

    return dp[n][0];


}

int main(){

    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    s+='0';
    cout<<solve(s)<<endl;
    
    

    return 0;

}
/*


*/


Measured memory_bytes: 17924
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
const LI MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LI x,y,i,j;cin>>x>>y;
      fo(i,0,x+1){
        LI leg=2*i+4*(x-i);
        if(leg==y){
          cout<<"Yes";
          return 0;
        }
      }
      cout<<"No";
    }
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	
	int a, b, c;cin >> a >> b >> c;
	cout << min(b / a , c) << endl;
	
	return 0;
}


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

using namespace std;

int main() {

	int a,b;
	cin >> a >> b;
	
	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}

}


Measured memory_bytes: 3016
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
using namespace std;

long long int N;
int num[100000];
int fig[100000];
long long int ans;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> num[i];
		fig[num[i]]++;
	}
	if (N % 2 == 1) {
		if (fig[0] != 1) {
			cout << "0\n";
			return 0;
		}
		for (int i = 2; i < N; i += 2) {
			if (fig[i] != 2) {
				cout << "0\n";
				return 0;
			}
		}
		ans = 1;
		for (int i = 0; i < N / 2; i++) {
			ans *= 2;
			ans %= 1000000007;
		}
		cout << ans << "\n";
		return 0;
	}
	for (int i = 1; i < N; i += 2) {
		if (fig[i] != 2) {
			cout << "0\n";
			return 0;
		}
	}
	ans = 1;
	for (int i = 0; i < N / 2; i++) {
		ans *= 2;
		ans %= 1000000007;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, T) = Slice2<long>();
            var ct = new List<(long c, long t)>();
            for (var i = 0; i < N; ++i)
                ct.Add(Slice2<long>());
            ct = ct.Where(c => c.t <= T).ToList();
            if (ct.Any())
                WriteLine(ct.Min(c => c.c));
            else
                WriteLine("TLE");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28152
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    deque<char> s;
    rep(i,S.size()){
        s.push_back(S[i]);
    }
    int q;
    cin >> q;
    bool top = true;
    rep(i,q){
        int t;
        cin >> t;
        if(t == 1){
            if(top) top = false;
            else top = true;
        }
        if(t == 2){
            int f;
            char c;
            cin >> f >> c;
            if((top && f == 1) || (!top && f == 2)){
                s.push_front(c);
            }
            if((top && f == 2) || (!top && f == 1)){
                s.push_back(c);
            }
        }
    }
    if(!top) reverse(all(s));
    rep(i,s.size()){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int AB, BC, CA;
		Scanner sc = new Scanner(System.in);

		AB = sc.nextInt();
		BC = sc.nextInt();
		CA = sc.nextInt();

		System.out.println((AB * BC) / 2);

		sc.close();
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <map>

using namespace std;


int main()
{
	map<char, char> d;
	d['A'] = 'T';
	d['C'] = 'G';
	d['G'] = 'C';
	d['T'] = 'A';

	char b;
	cin >> b;

	cout << d[b] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  string S;
  cin>>S;
  ll AGCT=0;
  ll num=0;
  FORi(S.size()){
    if(S[i]=='A'||S[i]=='G'||S[i]=='C'||S[i]=='T'){
      AGCT++;
      if(num<AGCT)num=AGCT;
    }else{
      AGCT=0;
    }
  }
  cout<<num<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    string s;
    cin >> n >> s;
    lli cr = 0, cw = 0;
    rep(i,n){
        if(s[i]=='R'){
            cr++;
        }
        else{
            cw++;
        }
    }
    lli wr = 0, ww = 0;
    rep(i,n){
        if (s[i] == 'R')
        {
            if (i > cr - 1){
                wr++;
            }
        }
        else
        {
            if(i<n-1-cw){
                ww++;
            }
        }
    }
    lli ans = 0;
    ans += min(ww, wr);
    ww -= ans;
    wr -= ans;
    ans += max(ww, wr);
    out(ans);
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define ll long long
#define MAXN 100010

using namespace std;

int a[MAXN];
string s;

int main() {
	int n, m;
	cin >> n;
	cin >> s;
	if (n >= 3200) cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t,a,b,i,j,k,n;
    string s;
    cin>>s;
    map<char,ll>m;
    for(i=0;i<s.length();i++)
    {
        m[s[i]]++;
    }
    for(i=0;i<s.length();i++)
    {
        if(m[s[i]]%2==1)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 20000;

char t[N];
string s;
bool can[N];
VI wekx, weky;
int x, y, act, i, j, a, sumx, sumy, bat[2*N], ind, revx;

int main() {
scanf("%s", t);
scanf("%d %d", &x, &y);
revx = 0;
if (x < 0) {
	x = -x;
	revx = 1;
}
if (y < 0) y = -y;
s = t;
wekx.resize(0);
weky.resize(0);
a = 0;
act = 0;
if (s[0] == 'T') revx = 2;
for (i=0;i<s.size();i++) {
	if (s[i] == 'T') {
		if (act > 0) {
			if (a == 0) wekx.pb(act); else weky.pb(act);
			act = 0;
		}
		a = 1 - a;
	} else act++;
}
if (act > 0) {
	if (a == 0) wekx.pb(act); else weky.pb(act);
}
sumx = 0;
sumy = 0;
for (i=0;i<wekx.size();i++) sumx+= wekx[i];
for (i=0;i<weky.size();i++) sumy+= weky[i];
if (x > sumx || y > sumy) {
	printf("No\n");
	return 0;
}
for (i=0;i<=2*sumx;i++) can[i] = false;
can[sumx] = true;
for (i=0;i<wekx.size();i++) {
	ind = 0;
	for (j=0;j<=2*sumx;j++) if (can[j]) {
		if (i != 0 || revx != 1) bat[ind++] = j + wekx[i];
		if (i != 0 || revx != 0) bat[ind++] = j - wekx[i];
	}
	for (j=0;j<=2*sumx;j++) can[j] = false;
	for (j=0;j<ind;j++) can[bat[j]] = true;
}
if (!can[x + sumx]) {
	printf("No\n");
	return 0;
}
for (i=0;i<=2*sumy;i++) can[i] = false;
can[sumy] = true;
for (i=0;i<weky.size();i++) {
	ind = 0;
	for (j=0;j<=2*sumy;j++) if (can[j]) {
		bat[ind++] = j + weky[i];
		bat[ind++] = j - weky[i];
	}
	for (j=0;j<=2*sumy;j++) can[j] = false;
	for (j=0;j<ind;j++) can[bat[j]] = true;
}
if (!can[y + sumy]) printf("No\n"); else printf("Yes\n");
return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<stack>
using namespace std;
int main(){
    stack<int>s;
    int n,a,c;
    cin>>n;
    while(n--){
        cin>>a;
        while(s.size()&&s.top()>a){
            c++;
            s.pop();
        }
        if(!s.size()||s.top()!=a)
            s.push(a);
    }
    cout<<c+s.size()<<endl;
}

Measured memory_bytes: 1800
from heapq import heappop, heappush

N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0

for left in range(min(N, K) + 1):
    for right in range(min(N, K) - left + 1):
        heap = []
        for v in V[:left]:
            heappush(heap, v)

        for v in V[N - right:]:
            heappush(heap, v)

        cnt = left + right

        v = 0
        while cnt < K and len(heap) > 0:
            v = heappop(heap)

            if v >= 0:
                heappush(heap, v)
                break
            cnt += 1

        ans = max(ans, sum(heap))
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();

        int sum=n/2;
        if(n%2!=0){
            sum++;
        }
        System.out.println(sum);
        sc.close();
    }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#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)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int a,b,t; cin >> a >> b >> t;
    cout << (t/a * b) << endl << endl;;
    return 0;
}


















Measured memory_bytes: 256
#include <stdio.h>



void max_heapify(int *a, int i, int n)

{

  int j, temp;

  temp = a[i];

  j = 2 * i;

  while (j <= n)

    {

      if (j < n && a[j+1] > a[j])

	j = j + 1;

      if (temp > a[j])

	break;

      else if (temp <= a[j])

        {

	  a[j / 2] = a[j];

	  j = 2 * j;

        }

    }

  a[j/2] = temp;

  return;

}

void build_maxheap(int *a,int n)

{

  int i;

  for(i = n/2; i >= 1; i--)

    {

      max_heapify(a,i,n);

    }

}

int main()

{

  int n, i, x;

    

  
  scanf("%d",&n);
  int a[500001];

  for (i = 1; i <= n; i++)

    {

       
      scanf("%d",&a[i]);

    }

  build_maxheap(a,n);

    

  for (i = 1; i <= n; i++)

    {

      printf(" %d",a[i]);

    }
  printf("\n");
  return 0;
}



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

#define P pair<int, ll>

int main(){
  int X,Y,Z,K;cin>>X>>Y>>Z>>K;
  vll A(X),B(Y),C(Z);
  rep(i,X)cin>>A[i];
  rep(i,Y)cin>>B[i];
  rep(i,Z)cin>>C[i];
  vll bc(1001000,0);
  rep(i,Y)rep(j,Z){
    bc[i*1000+j] = B[i] + C[j];
  }
  sort(all(bc),greater<ll>());
  sort(all(A),greater<ll>());
  auto compare = [&](auto const& a,auto const& b){ return a.second < b.second;};
  priority_queue <P, vector<P>, decltype(compare)> pos_sum{compare};
  rep(i,X){
    int pos = 0;
    ll sum = A[i] + bc[0];
    pos_sum.push(make_pair(pos,sum));
  }
  rep(i,K){
    P p = pos_sum.top();pos_sum.pop();
    if(p.first >= Y * Z) continue;
    cout << p.second << endl;
    p.first += 1;
    p.second -= bc[p.first - 1] - bc[p.first];
    pos_sum.emplace(p.first, p.second);
  }
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
///////////////////////////////////////////
int x,y;
int xc[]={1,3,5,7,8,10,12};
int yc[]={4,6,9,11};
int main(){speed
    cin>>x>>y;
    if(x==2||y==2){
        if(x!=y){
            cout<<"No";
            return 0;
        }
    }
    int okx,oky;
    for(int i=0;i<7;i++){
        if(xc[i]==x) okx=1;
        if(xc[i]==y) oky=1;
    }
    for(int i=0;i<4;i++){
        if(yc[i]==x) okx=2;
        if(yc[i]==y) oky=2;
    }
    if(okx!=oky){
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
}


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

typedef int_fast64_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18 + 5;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,k;
  cin >> n >> k;
  vector<int32> p(n);
  vector<int64> c(n);
  REP(i,n)cin >> p[i],p[i]--;
  REP(i,n)cin >> c[i];
  vector<vector<int64>> dp(n+1,vector<int64>(n,-llinf));
  REP(j,n)dp[0][j] = 0;
  REP(i,n)REP(j,n){
    chmax(dp[i+1][p[j]], dp[i][j] + c[p[j]]);
  }
  if(k <= n){
    int64 ans = -llinf;
    FOR(i,1,k+1)REP(j,n)chmax(ans,dp[i][j]);
    ANS(ans);
    return 0;
  }
  int64 ans = -llinf;
  REP(j,n){
    vector<pll> dist(n,pll(-1,-1));
    queue<int32> que;
    que.push(j);
    dist[j] = pll(0,0);
    while(!que.empty()){
      int32 cur = que.front();que.pop();
      int32 nxt = p[cur];
      if(dist[nxt].fi != -1){
        dist[nxt] = pll(dist[cur].fi + 1, dist[cur].se + c[nxt]);
        break;
      }else{
        dist[nxt] = pll(dist[cur].fi + 1, dist[cur].se + c[nxt]);
        que.push(nxt);
      }
    }
    int32 l = dist[j].fi;
    REP(i,n+1){
      if(i != 0)
        chmax(ans, dp[i][j]);
      chmax(ans, dp[i][j] + ((k-i)/l)*dist[j].se);
    }
  }
  ANS(ans);
  return 0;
}


Measured memory_bytes: 199096
#include<iostream>
using namespace std;
int main()
{

	
	char op;
	int a, b;
	
	while (1){
		cin >> a >> op >> b;
		if (op == '?'){ break; }
		if (op == '+'){ cout << a + b<<endl; }
		if (op == '-'){ cout << a - b<<endl; }
		if (op == '*'){ cout << a*b<<endl; }
		if (op == '/'){ cout << a / b << endl; }
	}

	return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

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

		while (true) {
			int money = sc.nextInt();
			
			if(money == 0){
				break;
			}
			
			money = 1000 - money;
			
			int[] coins = { 500, 100, 50, 10, 5, 1 };

			int count = 0;
			for (int coin : coins) {
				int m = money / coin;
				count += m;
				money -= coin * m;
			}

			System.out.println(count);
		}
	}

}

Measured memory_bytes: 12000
from math import log
N = int(input())

hiki9 = []
hiki6 = []
n = int(log(N) / log(9) + 1)  # log9の計算に誤差があるので一つ多めに取っておく
for i in range(n+1):
    hiki9.append(9**i)
n = int(log(N) / log(6) + 1)
for i in range(n+1):
    hiki6.append(6**i)
hiki9.sort(reverse=True)
hiki6.sort(reverse=True)
x = []
for i in range(N+1):
    n9 = i
    tmpx = 0
    for h in hiki9:
        while h <= n9:
            n9 -= h
            tmpx += 1
    n6 = N - i
    for h in hiki6:
        while h <= n6:
            n6 -= h
            tmpx += 1
    x.append(tmpx)
x.sort()
print(x[0])

Measured memory_bytes: 4308
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        StringBuffer sb = new StringBuffer("");
        int n = Integer.parseInt(br.readLine().trim());
        char s[] = br.readLine().trim().toCharArray();
        int r=0,w=0;
        for(int i=0;i<n;i++) {
            if(s[i]=='W')++w;
            else ++r;
        }
        int ans = 0;
        if(w<=r) {
            for(int i=n-1;i>=n-w;--i) {
                if(s[i]!='W') ++ans;
            }
        } else {
            for(int i=0;i<r;++i) {
                if(s[i]!='R') ++ans;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 36512
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> memo(N, 0);
  for (int i = 1; i < N; i++) {
    cin >> A[i];
    memo[A[i]-1]++;
  }

  for (int i = 0; i < N; i++) {
    cout << memo[i] << endl;
  }
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vi a(n);
    cin >> a;
    for (int& i : a)
        i--;
    mask used(n);
    int v = 0, pr = 0;
    while (!used[v] && k)
        used[v] = true, v = a[v], k--;
    if (!k)
    {
        cout << v + 1 << endl;
        GAME_OVER;
    }
    pr = v;
    int len = 0;
    while (v != pr || !len)
        v = a[v], len++;
    k %= len;
    for (int i = 0; i < k; i++)
        v = a[v];
    cout << v + 1 << endl;
    GAME_OVER;
}

Measured memory_bytes: 4776
// --------------
// Tejas Pandey  |
// 12 - 01 - 20  |
// ABC #151      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

ll solve(char a[20][20],int h,int w,int x,int y){
	int vis[20][20];
	memset(vis,0,sizeof(vis));
	queue<tuple<int,int,ll>> pt;
	pt.push(make_tuple(x,y,0));
	ll ans = 0;
	while(!pt.empty()){
		tuple<int,int,int> t = pt.front();
		pt.pop();
		pair<int,int> p = make_pair(get<0>(t),get<1>(t));
		if(!vis[p.first][p.second] && a[p.first][p.second] == '.'){
			ll f =get<2>(t);
			ans = max(ans,f);
			vis[p.first][p.second] = 1;
			if(p.first + 1 < h){
				pt.push(make_tuple(p.first+1,p.second,get<2>(t) + 1));
			}
			if(p.first - 1 > -1){
				pt.push(make_tuple(p.first-1,p.second,get<2>(t) + 1));
			}
			if(p.second + 1 < w){
				pt.push(make_tuple(p.first,p.second+1,get<2>(t) + 1));
			}
			if(p.second - 1 > -1){
				pt.push(make_tuple(p.first,p.second-1,get<2>(t) + 1));
			}
		}
	}
	return ans;
}

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int h,w;
		cin >> h >> w;
		char a[20][20];
		for(int i = 0;i < h;i++)
			for(int j = 0;j < w;j++)
				cin >> a[i][j];
		ll ans = 0;
		for(int i = 0;i < h;i++)
			for(int j = 0;j < h;j++)
				if(a[i][j] == '.')
					ans = max(ans,solve(a,h,w,i,j));
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
A = list(map(int, input().split()))

x = []
x_append = x.append

for a in A:
    x_append(a-1)
    x_append(a)
    x_append(a+1)
    
X = collections.Counter(x)

print(X.most_common()[0][1])

Measured memory_bytes: 30940
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	ll n, a[100000], b=MOD, t;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]<b){
			b=min(b, a[i]);
			t=i;
		}
	}
	bool flag=false;
	while(!flag){
		flag=true;
		for(int i=0; i<n; i++){
			if(i!=t){
				a[i]=a[i]%b;
			}
		}
		for(int i=0; i<n; i++){
			if(a[i]!=0 && i!=t){
				flag=false;
				if(a[i]<b){
					b=min(b, a[i]);
					t=i;
				}
			}
		}
	}
	cout << b << endl;

	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string s;
	cin >>s;
	int n=s.size();
	int C=n;
	for (int i=0; i<C; i++)
		if (s.at(i)=='C') {
			C=i;
			break;
		}
	if (n==C) {
		cout <<"No" <<endl;
		return 0;
	}
	int F=-1;
	for (int i=n-1; i>=0; i--)
		if (s.at(i)=='F') {
			F=i;
			break;
		}
	if (n==0) {
		cout <<"No" <<endl;
		return 0;
	}
	if (C<F) {
		cout <<"Yes" <<endl;
		return 0;
	}
	cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 256
<?php
list($x,$k,$d)=explode(" ",trim(fgets(STDIN)));
$r=(int)$d-(abs($x)/$k);
if($r<=0){
  echo ($x>0)? $x-(int)$k*$d:-$x-(int)$k*$d;
}else{
  if($x<0){
    $x*=-1;
  }
  $q=ceil($x/$d);
  $ans1=(int)$q*$d-$x;
  if(($k-$q)%2==0){
    echo $ans1;
  }else{
    echo (int)($d-$ans1);
  }
}

Measured memory_bytes: 16168
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
/*
 execution in cmd of windows:
 
 
  c
  
  
  p1
 
 */
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define all(v) v.begin(), v.end()
#define fsort(v) sort(all(v))  
#define rsort(v) sort(v.rbegin(),v.rend())
#define rev(v) reverse(all(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sumv(v,x) accumulate(v.begin(),v.end(),x);
const ll mod = 1000000007;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define cs ll t;cin>>t;while(t--)
#define cs1 ll t;t=1;while(t--)


int main()
{
        io;
        //////////////////////////////////
        cs1{
            ll i,j,k,l,s=0,p=0,q=0;
            ll n;
            cin>>n;
            vll v(n);
            for(i=0;i<n;i++) cin>>v[i];
            ll max=v[0];
            for(i=1;i<n;i++){
                if(v[i]<max) {s=s+(max-v[i]);
                }
                else max=v[i];
            }
            cout<< s nl;
        }
        //////////////////////////////////
       
}

Measured memory_bytes: 4776
import sys

fin = sys.stdin.readline

l, r = map(int, fin().split())

if (r - l) > 700:
    print(0)

else:
    num = list(range(l, r + 1))
    num = [n % 2019 for n in num]
    mul = [(num[i] * num[j]) % 2019 for i in range(len(num) - 1) for j in range(i + 1, len(num))]
    print(min(mul))


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

main(){
  double a, b,x;
  int x1;
  
  cin >> a >> b;
  x = (a+b)/2;
  x1= (a+b)/2;
  if (x-x1 >= 0.5){
    x1 = x1+1;
    cout << x1;
  }
  else{
    cout << x1;
  }
  
  
}


Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;

#define ll long long

void solve()
{

    ll K, A, B;
    cin >> K;
    cin >> A >> B;

    string okng = "NG";
    for (ll i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            okng = "OK";
        }
    }

    cout << okng << endl;

    return;
}

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


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;
const int N = 200020;
int parent[N];
int sum[N];  //记录当前结点到根结点的距离
int root(int x)
{
    if(parent[x]==x) return x;//一直到寻找到根节点
    int t=parent[x];           //存贮中间节点
    parent[x]=root(parent[x]);
    sum[x]+=sum[t];
    return parent[x];
}
void merge(int x,int y,int a,int b,int v)
{
        parent[x]=y;
        sum[x]=v+sum[b]-sum[a];

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)==2)
    {
        for(int i=0;i<=n;i++)
            parent[i]=i;
        memset(sum,0,sizeof(sum));
        int a,b,v,re=0;
        while(m--){
            scanf("%d%d%d",&a,&b,&v);
            int x=root(a);
            int y=root(b);
            if(x==y&&sum[a]-sum[b]!=v){  //同根节点，但值不为之前的事实
                re++;
            }
            else if (x!=y){
              merge(x,y,a,b,v);
            }
        }
        if(re>0)
        printf("No\n");
        else
        printf("Yes\n");
    }
}


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

int h, w;
char grid[2000][2000];

int dp[2000][2000];

int main(){
	scanf("%d %d", &h, &w);
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			scanf(" %c", &grid[i][j]);
		}
	}
	dp[1][1] = 1;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(grid[i][j] == '#') continue;
			dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= 1000000007;
		}
	}
	printf("%d\n", dp[h][w] % 1000000007);
}

Measured memory_bytes: 12544
package main

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

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var n, k int
	if scanner.Scan() {
		tmp := scanner.Text()
		n, _ = strconv.Atoi(tmp)
	}
	if scanner.Scan() {
		tmp := scanner.Text()
		k, _ = strconv.Atoi(tmp)
	}

	var xs []int
	for i := 0; i < n; i++ {
		if scanner.Scan() {
			tmp := scanner.Text()
			x, _ := strconv.Atoi(tmp)
			xs = append(xs, x)
		}
	}

	min := math.MaxInt32
	for i := 0; i < n-k+1; i++ {
		var v int
		if xs[i] >= 0 && xs[i+k-1] >= 0 {
			v = xs[i+k-1]
		} else if xs[i] < 0 && xs[i+k-1] > 0 {
			if -xs[i] < xs[i+k-1] {
				v = xs[i+k-1] - 2*xs[i]
			} else {
				v = 2*xs[i+k-1] - xs[i]
			}
		} else {
			v = -xs[i]
		}
		if min > v {

			min = v
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 5504
import sys
n = int(input())
s = input()
a = ""
b = ""
if n % 2 != 0:
  print("No")
  sys.exit()
else:
  for i in range(n):
    if i <= n / 2 - 1:
      a += s[i]
    else:
      b += s[i]
if a == b:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;
int main(void){
	int N;
	cin >> N;
	string S;
	cin >> S;
	if(N%2==1){
	    cout << "No" << endl;
	    return 0;
	}
	if(S.substr(0,N/2)==S.substr(N/2,N/2)){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

#define MAX_N 2000005

ll factorial[MAX_N];
void make_factorial_tableMOD(){
    factorial[0] = 1;
    for(int i = 1; i < MAX_N; i++){
        factorial[i] = factorial[i-1]*i%MOD;
    }
}

ll bisection_powerMOD(ll x,ll y){
    if(y==0)        { return 1; }
    ll t = bisection_powerMOD(x*x%MOD,y/2);
    if(y%2==1)      { t = t*x%MOD; }
    return t;
}

ll nCrMOD(int n, int r){
    if(n<r || n<=0 || r<0){return 0;}
    ll a = factorial[n];
    ll b = a*bisection_powerMOD(factorial[r],(MOD-2))%MOD;
    ll c = b*bisection_powerMOD(factorial[n-r],MOD-2)%MOD;
    return c % MOD;
}


int main(){
    ll r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    make_factorial_tableMOD();
    ll ru = 0;
    for(int i = 0; i <= r2; i++){
        ru += nCrMOD(i+c2+1,i+1);
        ru %= MOD;
    }
    //dbg(ru);
    ll lu = 0;
    for(int i = 0; i <= r2; i++){
        lu += nCrMOD(i+c1,i+1);
        lu %= MOD;
    }
//    dbg(lu);
    ll rd = 0;
    for(int i = 0; i <= c2; i++){
        rd += nCrMOD(i+r1,i+1);
        rd %= MOD;
    }
//    dbg(rd);
    ll ld = 0;
    for(int i = 0; i < c1; i++){
        ld += nCrMOD(i+r1,i+1);
        ld %= MOD;
    }
    //dbg(ld);

    ll ans = ru-lu-rd+ld+4*MOD;
    ans %= MOD;
    cout << ans << endl;


    return 0;

}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

typedef long long int ll;


int f(vector<vector<int> > &vec, vector<vector<int> > &dp,int r, int c){
	if(dp[r][c] != 0){
		return dp[r][c];
	}
	
	if(r == vec.size()-1){
		dp[r][c] = vec[r][c];
	}
	else{
		dp[r][c] = vec[r][c] + max(f(vec,dp,r+1,(c+1)%3), f(vec,dp,r+1,(c+2)%3));
	}
	return dp[r][c];
}

void solve(){
	int N;
	cin >> N;
	vector<vector<int> > vec(N,vector<int>(3)), dp(N,vector<int>(3,0));
	for(int i = 0; i < N; i++){
		cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
	}
	
	cout << max(f(vec,dp,0,0), max(f(vec,dp,0,1), f(vec,dp,0,2))) << endl;
}

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

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}




Measured memory_bytes: 20608
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const N = inputStr[0];
  //パラメータNを配列に持ち込む
  var ARR = [];
  for(var i=0 ; i<4 ; i++){
    ARR.push(Number.parseInt(N.substr(i,1)));
  }
  //bit値を0～3迄
  for(var i=0 ; i<8 ; i++){
    var str = "";
    //1桁目
    if( (i&1) === 1 ){
      str = ARR[0] + "+" + ARR[1]
    } else {
      str = ARR[0] + "-" + ARR[1]
    }
    //2桁目
    if( (i&1<<1) === (1<<1) ){
      str += "+" + ARR[2]
    } else {
      str += "-" + ARR[2]
    }
    //3桁目
    if( (i&1<<2) === (1<<2) ){
      str += "+" + ARR[3]
    } else {
      str += "-" + ARR[3]
    }
    //結果判断
    if(eval(str) ===7){
      break;
    }
  }
  console.log(str+"=7");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500