akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, K;
  cin >> N >> K;
  VL xs(N);
  cin >> xs;

  int ix = lower_bound(ALL(xs), 0) - begin(xs);
  LL ans = (ix+K-1 < N ? xs[ix+K-1] : 1e18);
  if(0 <= ix-K)
	mini(ans, -xs[ix-K]);

  for(int i=max(0,ix-K+1);i+K-1<N&&i<ix;++i){
	int rix = i + K - 1;
	LL acc = min(-xs[i]*2 + xs[rix], -xs[i] + xs[rix]*2);
	mini(ans, acc);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    int n,b,f,r,v;
    int oh[4][3][10] = {};

    scanf("%d",&n);
    while(n){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        oh[b-1][f-1][r-1] = oh[b-1][f-1][r-1] + v;
        n--;
    }
    for(b=0;b<4;b++){
        for(f=0;f<3;f++){
            for(r=0;r<10;r++){
                printf(" %d",oh[b][f][r]);
            }
            printf("\n");
        }
        if(b<3) printf("####################\n");
    }
    return(0);
}

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


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


    // 全探索
    set<string> subs;
    for( int i = 0; i < (int) s.size(); ++i ){
        for( int j = 1; j <= min(K, (int) s.size()-i); j++ ){
            subs.insert( s.substr(i,j) ); // substr(i,j): i 番目から j 要素抜き出す
        }
    }
    
    auto itr = subs.begin();
    for( int i = 1; i < K; ++i ) ++itr;
    cout << *itr << endl;

    return 0;

}

Measured memory_bytes: 1664
N, T = map(int, input().split())
lst = list(map(int, input().split()))

ans = T #最後の人の分
for i in range(N-1):
    if lst[i+1] -lst[i] >= T:
        ans += T
    else:
        ans += lst[i+1] - lst[i]
print (ans)

Measured memory_bytes: 25200
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    ll n, h; cin >> n >> h;
    vpl ab(n); ll ma = -1;
    REP(i, n){
        ll a, b; cin >> a >> b;
        ma = max(ma, a);
        ab[i] = PL(a,b);
    }
    sort(ab.begin(), ab.end(), p_comp_sg);
    ll ans = 0;
    REP(i, n){
        if(h <= 0) break;
        if(ab[i].ss > ma){
            h -= ab[i].ss; ans++;
        }
    }
    if(h > 0) ans += (h + ma - 1) / ma;
    cout << ans << endstr;
    return 0;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    int cnt=0;
    for(int i = A;i <= B; i++){
        int reverse = 0;
        for(int j = i;;){
            int maind = j % 10;//%10で一桁目を取り出す
            reverse = reverse * 10 + maind;
            j /= 10;
            if(j==0)break;
        }
        if(i==reverse)cnt++;
    }
    cout<<cnt<<endl;
}

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

int main(void){

  int A,B,K;
  scanf("%d %d %d", &A, &B, &K);

  for(int i=0; i<K; i++){
    if(i%2==0){
      B += A/2;
      A /= 2;
    }else{
      A += B/2;
      B /= 2;
    }
  }

  printf("%d %d\n", A, B);

  return 0;
}


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

int d, day = 1;
vector<int> c(26), t, last(26, -1);
vector<vector<int>> s;
int score;

void input() {
    cin >> d;
    t = vector<int>(d);
    s = vector<vector<int>>(d, vector<int>(26));

    for (int& i : c) cin >> i;
    for (auto& v : s)
        for (int& i : v) cin >> i;
    for (int& i : t) cin >> i, --i;
}

int f(int contest) {
    int k = 0;
    for (int i = 0; i < 26; ++i) {
        if (i == contest) k += s[day][i], last[i] = day;
        k -= c[i] * (day - last[i]);
    }
    return k;
}

int main() {
    input();
    for (day = 0; day < d; ++day) { cout << (score += f(t[day])) << endl; }
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scanner = new Scanner(System.in);
		long W = scanner.nextLong();
		long H = scanner.nextLong();
		long x = scanner.nextLong();
		long y = scanner.nextLong();
		System.out.println(W*H/2.0);
		if(2*x == W && 2*y == H) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
	}
}

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

int main() {
  int N, li, ri;
  int i;
  int sum = 0;

  cin >> N;

  for (i = 0; i < N; i++){
    cin >> li >> ri;
    sum += (ri - li + 1);
  }

  cout << sum;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count=0;
        for(int i = 1; i <= n; i++){
            if(i%2==1){count++;}
        }
        System.out.println((double)count/(double)n);
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int[] players = new int[101];
            int[] rank = new int[31];
            bool[] isSame = new bool[31];

            while (true)
            {
                string[] input1 = Console.ReadLine().Split(',');
                int p = int.Parse(input1[0]);
                int s = int.Parse(input1[1]);

                if (p == 0 && s == 0) break;

                players[p] = s;

                if (!isSame[s])
                {
                    for (int i = 0; i <= s; i++) rank[i]++;
                    isSame[s] = true;
                }
            }

            string input2;

            while (!string.IsNullOrEmpty(input2 = Console.ReadLine()))
            {
                int q = int.Parse(input2);

                sb.AppendLine(rank[players[q]].ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9204
import java.util.*;
import java.lang.*;

class Main {
    
    public static void main(String[] areg) {
        Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
        
        int num = 0;
        if (b < 10)
            num = a * 10 + b;
        if (b >= 10 && b < 100)
            num = a * 100 + b;
        if (b == 100)
            num = a * 1000 + b;
        
        double sqrt = Math.sqrt(num);
        
        System.out.println((sqrt - Math.floor(sqrt) == 0) ? "Yes" : "No");
    }
}

Measured memory_bytes: 22100
def q(a,k):
 d[a]=k
 for b in t[a]:
  if'-1'!=b:q(b,k+1)
def n(a,k):
 h[a]=max(h[a],k)if a in h else k
 if'-1'!=p[a]:n(p[a],k+1)
t,p,s,d,h={},{},{},{},{}
N=int(input())
for _ in[0]*N:
 x,y,z=input().split()
 t[x]=set([y,z])-{'-1'}
 p[y]=p[z]=x
 s[y],s[z]=z,y
r=(set(t)-set(p)).pop()
p[r]=s[r]='-1'
q(r,0)
for i in t:
 if not t[i]:n(i,0)
for i in map(str,range(N)):
 print(f"node {i}: parent = {p[i]}, sibling = {s[i]}, degree = {len(t[i])}, depth = {d[i]}, height = {h[i]}, {'root'if d[i]==0else'internal node'if t[i]else'leaf'}")


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

int main() {
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        int j=1;
        while(i-j>=0&&j<=k)
        {
            dp[i] = min(dp[i-j]+abs(h[i ]-h[i-j]),dp[i]);
            j++;
        }
    }
    cout<<dp[n-1];
	return 0;
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

struct P {
    int x, y, c;
};

int32_t main() { fastio;
    time_t start = now();

    int A, B, M;
    cin >> A >> B >> M;
    vector<int> arr(A), brr(B);
    int mA = INF;
    for (int i = 0; i < A; i++) {
        cin >> arr[i];
        mA = min(mA, arr[i]);
    }
    int mB = INF;
    for (int i = 0; i < B; i++) {
        cin >> brr[i];
        mB = min(mB, brr[i]);
    }

    int res = mA + mB;
    int x, y, c;
    for (int i = 0; i < M; i++) {
        cin >> x >> y >> c;
        res = min({ brr[y - 1] + arr[x - 1] - c, res });
    }
    cout << res << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 1792
from functools import reduce
mod = 10**9+7

def P(n, k):
  return reduce(lambda x, y:x*y%mod, range(n-k+1, n+1))

def factorial(n):
  return 1 if n == 0 else P(n, n)

X, Y = map(int, input().split())
L, S = max(X, Y), min(Y, X)
if (S-(L-S))%3 != 0 or S-(L-S) < 0:
  print(0)
else:
  s = (S-(L-S))//3
  l = (S-(L-S))//3+(L-S)
  bunshi = factorial(s+l)
  bunbo = (factorial(s)*factorial(l))%mod
  print((bunshi*pow(bunbo,mod-2, mod))%mod)
  
  

Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N;
long long A[100001];
long long dp[100001];
long long INF = pow(10, 12);

void input() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        A[i] *= -1;
    }
    rep(i, 100001) {
        dp[i] = INF;
    }
}

void solve() {
    rep(i, N) {
        int key = upper_bound(dp, dp + N, A[i]) - dp;
        dp[key] = A[i];
    }
    int ans = 0;
    ans = lower_bound(dp, dp + N, INF) - dp;

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

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


Measured memory_bytes: 5216
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int main(){
	int q;
	ll rc = 0, lc = 0;
	cin >> q;
	rep(i,q){
		int a, c; char b;
		scanf("%d %c%d", &a, &b, &c);
		if(b == '(') lc += c;
		else rc += c;
		if(rc == lc) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 1208
#include<iostream>
using namespace std ;
int main()
{
    int  n,x=0,z,m;
    cin >> n ;
    for(int i=1;i<=n;i++)
    {
        cin >> z ;
        if(z>x)
        {
            z--;
        }
        else if (x>z)
        {
            cout << "No" << endl; return 0;
        }
        x=z;
    }
    cout << "Yes" << endl;
    return 0;
}


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

class Mondai
{
    static void Main()
    {
        var nk= Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).ToArray();
        var N = nk[0];
        var K = nk[1];
        var V= Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var ans = 0;
        //捨てられる宝石の数
        for (int i=0;i<=K/2;++i)
        {
            var count = K - i;
            //左
            for (int j=0;j<=count;++j)
            {
                //右
                for (int k=0;k<=count-j;++k)
                {
                    if (N < j + k) break;
                    var jewels = new List<int>();
                    jewels.AddRange(V.Take(j));
                    jewels.AddRange(V.Skip(N-k));
                    jewels.Sort();

                    var sum = 0;
                    for (int l=0;l<jewels.Count;++l)
                    {
                        if (l < i && jewels[l] < 0) continue;
                        sum += jewels[l];
                    }
                    if (ans < sum) ans = sum;
                }
            }
        }
        Console.WriteLine(ans);
    }
}   

Measured memory_bytes: 17488
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a = 0, b = 0, c = 0, d = 0;
    cin >> n;
    string st;
    while (n--) {
        cin >> st;
        if (st == "AC") {
            a++;
        } else if (st == "WA") {
            b++;
        } else if (st == "TLE") {
            c++;
        } else {
            d++;
        }
    }

    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            long A = in.nextLong();
            long B = in.nextLong();

            long xorA = f(A);
            long xorB = f(B);

            System.out.println(A ^ xorA ^ xorB);
        }
    }

    private static long f(long n) {
        long xor = 0;
        for (int shift = 0; shift <= 40; shift++) {
            if (shift == 0) {
                long remainder = n % 4;
                if (remainder == 1 || remainder == 2) {
                    xor |= 1L << shift;
                }
                continue;
            }
            long remainder = n % (2L << shift);
            if (remainder >= (1L << shift)) {
                if ((remainder - (1L << shift)) % 2 == 0) {
                    xor |= 1L << shift;
                }
            }
        }
        return xor;
    }

}


Measured memory_bytes: 22868
import java.util.*;

class Main{
  static class UnFd{
    int n;
    int forest;
    int[] parent;
    int[] size;
    UnFd(int n){
      forest=this.n=n;
      parent=new int[n];
      size=new int[n];
      for(int i=0;i<n;i++){
        parent[i]=i;
        size[i]=1;
      }
    }
    boolean isRoot(int i){
      return i==parent[i];
    }
    int rootOf(int i){
      if(isRoot(i)){
        return i;
      }
      return parent[i]=rootOf(parent[i]);
    }
    int sizeOf(int i){
      return size[rootOf(i)];
    }
    boolean same(int i,int j){
      return rootOf(i)==rootOf(j);
    }
    void merge(int i,int j){
      i=rootOf(i);
      j=rootOf(j);
      if(i==j){
        return;
      }
      size[i]=size[j]=size[i]+size[j];
      parent[Integer.max(i,j)]=Integer.min(i,j);
      forest--;
    }
    int[] parents(){
      return parent;
    }
    int[] sizes(){
      return size;
    }
    int forest(){
      return forest;
    }
    int length(){
      return n;
    }
  }
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int k=sc.nextInt();
    UnFd uf=new UnFd(n);
    int[] minus=new int[n];
    for(int i=0;i<m;i++){
      int a=sc.nextInt()-1;
      int b=sc.nextInt()-1;
      uf.merge(a,b);
      minus[a]++;
      minus[b]++;
    }
    for(int i=0;i<k;i++){
      int c=sc.nextInt()-1;
      int d=sc.nextInt()-1;
      if(uf.same(c,d)){
        minus[c]++;
        minus[d]++;
      }
    }
    for(int i=0;i<n-1;i++){
      System.out.print((uf.sizeOf(i)-minus[i]-1)+" ");
    }
    System.out.println((uf.sizeOf(n-1)-minus[n-1]-1));
  }
}

Measured memory_bytes: 95328
n,m=map(int,input().split())
edge=[[] for _ in range(n+1)]
eab=[]
for i in range(m):
    a,b=map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    eab.append([a-1,b-1])
 
def dfs(visited,count,node):
    visited[node]=True
    count+=1
    ev=edge[node]
    for node in ev:
        if visited[node]:
            continue
        else:
            count=dfs(visited,count,node)
    return count

ans=0
for i in range(m):
    a,b=eab[i]
    edge[a].remove(b)
    edge[b].remove(a)
    ci=dfs([False for _ in range(n)],0,0)
    if ci!=n:
        ans+=1
    edge[a].append(b)
    edge[b].append(a)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll n, i, a;
    cin >> n;
    ll s[n+1];
    
    for(i=0; i<=n; i++)
        s[i]=0;
    for(i=1; i<=n; i++) {
        cin >> a;
        s[i]=s[i-1]+a;
    }
    sort(s, s+n+1);
    
    
    ll k=-1, ans=0, cnt[n+1];
    for(i=0; i<=n; i++)
        cnt[i]=0;
    for(i=0; i<n; i++) {
        if(s[i]==s[i+1]) {
            k++;
            cnt[k]=1;
            while(s[i]==s[i+1]) {
                cnt[k]++;
                i++;
            }
        }
    }
    
    for(i=0; i<=k; i++) {
        ans+=cnt[i]*(cnt[i]-1)/2;
    }
    cout << ans << endl;
}


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

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

const int N = 2e5 + 5;

double ans[N], dp[N];
int n, p[N], k;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cout << fixed << setprecision(6);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		ans[i] = (double)(p[i] + 1) / 2;
	}
	dp[0] = ans[0];
	for (int i = 1; i < n; i++)
		dp[i] = dp[i - 1] + ans[i];
	double ans = dp[k - 1];
	for (int i = k; i < n; i++) {
		ans = max(ans, dp[i] - dp[i - k]);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 4224
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    int64_t sum = 0;
    for (int i = 0; i < N; i++) {
        int64_t a;
        cin >> a;
        sum += a;
    }
    if (sum % 2 == 0) cout << "YES" << endl; else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;

int main(){
    ll N, P;
    string S;
    cin >> N >> P >> S;
    if (P == 2 || P == 5 ) {
        ll ans = 0;
        rep(i, N) {
            if ((S[i] - '0') % P == 0) {
                ans += i+1;
            }
        }

        cout << ans << endl;

    } else {
        ll T[N + 1];
        T[0] = 0;
        ll ind = 1;
        rep(i, N) {
            T[i + 1] = (S[N - i - 1] - '0') * ind + T[i];
            ind *= 10;
            ind %= P;
            T[i+1] %= P;

        }

        ll c[P+1];
        rep(i, P+1){
            c[i] = 0;
        }
        rep(i, N+1){
            c[T[i]]++;
        }

        ll ans = 0;
        rep(i, P+1) {
            ans += (c[i] * (c[i]-1))/2;
        }

        cout << ans << endl;


    }




}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> v[100005];
int main()
{
	ll n, m, sum = 0, x, y;
	cin >> n >> m;
	for (ll i = 0, a, b; i < n; ++i)
		{
			cin >> a >> b;
			if (a <= m) v[a].push_back(b);
		}
	for (ll i = 1; i <= m; i++)
		sort(v[i].begin(), v[i].end(), greater<ll>());
	priority_queue<ll> pq;
	for (ll i = 1; i <= m; i++)
		{
			for (ll j = 0; j < min(m, (ll)v[i].size()); j++)
				pq.push(v[i][j]);
			if (pq.empty()) continue;
			sum += pq.top();
			pq.pop();
		}
	cout << sum << endl;
}

Measured memory_bytes: 5632
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Dec  1 12:46:21 2018
//
package main

import "fmt"

var n int

func main() {
	fmt.Scan(&n)
	if n == 1 {
		fmt.Println("Hello World")
	} else {
		var a, b int
		fmt.Scan(&a, &b)
		fmt.Println(a + b)
	}
}


Measured memory_bytes: 512
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]

sa=[a[i]-b[i] for i in range(n)]

p=0
m=0
for i in sa:
  if 0<i:
    m+=i
  else:
    p+=abs(i)//2

if m<=p:
  print("Yes")
else:
  print("No")

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

typedef long long int ll; 

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

	ll ans = n%1000;
	if(ans == 0)
		cout << "0" << endl;
	else
		cout << 1000 - ans << endl;



	return 0;
}

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

using namespace std;

struct activity
{
    int A,B,C;
};

int solve(vector<activity>arr, int n)
{
    int dp[n+1][3];
    dp[1][0] = arr[1].A;
    dp[1][1] = arr[1].B;
    dp[1][2] = arr[1].C;

    for (int i=2;i<=n;i++)
    {
        dp[i][0] = arr[i].A + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = arr[i].B + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = arr[i].C + max(dp[i-1][0],dp[i-1][1]);
    }

    return max(dp[n][0],max(dp[n][1],dp[n][2]));
}

int main()
{
    int n; cin >> n;
    vector<activity> arr(n+1);

    for (int i=1;i<=n;i++)
    {
        cin >> arr[i].A >> arr[i].B >> arr[i].C;
    }

    cout<<solve(arr,n);
}


Measured memory_bytes: 3712
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
using ll = int_fast64_t; using namespace std;

#ifndef __GNUC__
string text =
R"X(33
ABCCABCBABCCABACBCBBABCBCBCBCABCB)X";
stringstream iss{text};
#endif

ll cnt;
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	ll N; iss >> N;
	string s; iss >> s;
	for (ll i = 0; i < N - 2; ++i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ++cnt;
	}
	cout << cnt << "\n";
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
typedef long long ll;
using namespace std;
ll ans=0,N;
void check(ll d)
{
    if(d!=0&&N/d==N%d) ans+=d;
}
int main()
{
    cin>>N;
    for(ll d=1;d*d<=N;++d)
    {
        if(d*d==N) check(d-1);
        else if(N%d==0) {check(d-1);check(N/d-1);}
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
    	ios::sync_with_stdio(0); int N; cin >> N; int pre = 0 , cnt = 0;
    	for(int i = 1 ; i <= N ; ++i){
    		int x; cin >> x;
    		if(pre == x){++cnt; x = 10001;}
    		pre = x;
    	}
    	cout << cnt; return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()

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

using namespace std;
typedef long long ll;

int n, m, q;
vector<int> a, b, c, d;

int score(const vector<int> &A) {
    int ans = 0;
    for(int i = 0; i < q; ++i) {
        if(A[b[i]] - A[a[i]] == c[i]) {
            ans += d[i];
        }
    }
    return ans;
}

int dfs(vector<int> &A) {
    if(A.size() == n) {
        return score(A);
    }
    int ans = 0;
    int prev = (A.empty() ? 0 : A.back());
    for(int i = prev; i < m; ++i) {
        A.push_back(i);
        ans = max(ans, dfs(A));
        A.pop_back();
    }
    return ans;
}



int main() {
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q); 
    c.resize(q);
    d.resize(q);

    for(int i = 0; i < q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];
        --b[i];
    }
    vector<int> A;
    cout << dfs(A) << endl;

}

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

bool search(vector<int> a, int key) {
  a.push_back(key);
  int i = 0;
  while(a.at(i) != key) i++;
  return i != a.size()-1;
}

int main() {
  int n, q, in; cin >> n;
  vector<int> s, t;
  for (int i=0; i<n; i++){
    cin >> in;
    s.push_back(in);
  }
  cin >> q;
  for (int i=0; i<q; i++){
    cin >> in;
    t.push_back(in);
  }

  int count = 0;
  for (int i=0; i<q; i++) {
    int key = t.at(i);
    if (search(s, key)) count++;
  }
  cout << count << endl;
}




Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int n, mi, ma;
map<int, int> m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  mi = iinf;
  FOR(i, 0, n){
    int t;
    cin >> t;
    m[t]++;
    mins(mi, t);
    maxs(ma, t);
  }
  int d = 0;
  switch (m[mi]){
    case 1:
      d = mi*2;
      break;
    case 2:
      d = mi*2-1;
      break;
    default:
      break;
  }
  if(d == ma){
    FOR(i, mi+1, ma+1)if(m[i] < 2){
      cout << "Impossible" << endl;
      return 0;
    }
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
vector<int> dp(500100, -1);
string s;
int n;
int rec(int node)
{
    if (dp[node] >= 0)
    {
        return dp[node];
    }
    else
    {
        int res = 0;
        if (node > 0 && node <= n && s[node - 1] == '<')
        {
            res = max(res, rec(node - 1) + 1);
        }
        if (node < n && s[node] == '>')
        {
            res = max(res, rec(node + 1) + 1);
        }
        return dp[node] = res;
    }
}
int main()
{
    cin >> s;
    n = s.length();
    rep(i, n + 2)
    {
        dp[i] = -1;
    }
    rep(i, n+2)
    {
        if (dp[i] == -1)
        {
            rec(i);
        }
    }
    ll ans = 0;
    rep(i, n + 1)
    {
        ans += dp[i];
    }
    cout << ans << endl;
    return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// kを[n,2n]で動かして Σmax[0,k) - Σmin[k,3n) の最大値を探す

ll n, a[300300], sl, sr, res = -linf, mx[300300], mn[300300];
priority_queue<ll,vector<ll>,greater<ll> > ql;
priority_queue<ll> qr;

int main() {
	cin >> n;
	rep(i,3*n) cin >> a[i];
	rep(i,3*n) {
		sl += a[i], ql.push(a[i]);
		if (ql.size()==n+1) sl -= ql.top(), ql.pop();
		mx[i] = sl;
		int j = 3*n-i-1;
		sr += a[j], qr.push(a[j]);
		if (qr.size()==n+1) sr -= qr.top(), qr.pop();
		mn[j] = sr;
	}
	reps(k,n,2*n+1) chmax(res, mx[k-1]-mn[k]);
	cout << res;
}

Measured memory_bytes: 9068
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    x = int(input())

    for a in range(-200, 200):
        for b in range(-200, 200):
            if (a ** 5) - (b ** 5) == x:
                print(a, b)
                exit()

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums() {
	return readln().chomp.split.map!(to!int);
}

void main() {
	auto nums = readNums();
	immutable x = nums[0];
	immutable a = nums[1];
	immutable b = nums[2];
	writefln("%s", abs(x - a) < abs(x - b) ? 'A' : 'B');
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int H,W;
string s[505];
string a[505],b[505];
int main(){
	cin >> H >> W;
	for(int i=0;i<H;i++){
		cin >> s[i];
		a[i]=b[i]=s[i];
	}
	for(int i=0;i<H;i++){
		if(i%2==0){
			for(int j=1;j<W-1;j++){
				a[i][j]='#';
			}
		}else{
			for(int j=1;j<W-1;j++){
				b[i][j]='#';
			}
		}
		a[i][0]='#';
		b[i][W-1]='#';
	}
	for(int i=0;i<H;i++)cout << a[i] << endl;
	cout << endl;
	for(int i=0;i<H;i++)cout << b[i] << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
string s;
int flag[3];
int main() {
	cin >> s;
	for(int i = 0; i < s.size(); ++i) {
		if (s[i] == 'C') flag[1] = 1;
		if (s[i] == 'F' && flag[1] == 1)  flag[2] = 1;
	}
	if (flag[2] == 0) cout<<"No" << '\n';
	else cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

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

ans = 0

for i in range(len(p)-2):
    if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i+2] < p[i+1] and p[i+1] < p[i]):
        ans = ans + 1
    else:
        continue

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i)
    cin >> p[i];
  cout << accumulate(p.begin(), p.end(), 0) - *max_element(p.begin(), p.end()) / 2 << "\n";
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int D;
        D=s.nextInt();
        if(D==25){
            System.out.println("Christmas");
        }
        else if(D==24){
            System.out.println("Christmas Eve");
        }
        else if(D==23){
             System.out.println("Christmas Eve Eve");
        }
        else{
             System.out.println("Christmas Eve Eve Eve");
        }
    }  
}

Measured memory_bytes: 23124
N = int(input())
a = [[int(i) for i in input().split()] for _ in range(N)]
dp = [[0]*3 for __  in range(N)]
dp[0] = a[0]
for i in range(1,N):
    for j in range(3):
        dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j]
print(max(dp[N-1]))

Measured memory_bytes: 74072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

    int64_t n; cin>>n;

    string ans;

    while(n!=0){
        if(n%26!=0){
            ans.push_back((char)'a'-1+n%26);
            n-=n%26;
        }
        else{
            ans.push_back('z');
            n-=26;
        }
        n/=26;
    }

    reverse(all(ans));

    cout<<ans<<endl;

}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

A, B, C, D = read_ints()

while True:
    C -= B
    if C <= 0:
        print('Yes')
        exit()
    A -= D
    if A <= 0:
        print('No')
        exit()


Measured memory_bytes: 67068
#include <stdio.h>

int main(void)
{
    int n;
    int i ,j;
    int maxv, minv;
    
    scanf("%d" , &n);
    
    int A[n];
    
    for (i = 0 ; i < n ; i++)
            scanf("%d" ,&A[i]);
    
    minv = A[0];
    maxv = -1999999999; /*ここの値を変えるとなぜかWrong_Answerになる(~~;)*/
    
    for (j = 1 ; j < n ; j++)
    {
        maxv = (maxv > A[j] - minv) ? maxv : A[j] - minv ;
        minv = (minv < A[j]) ? minv :A[j];
        
    }
    printf("%d\n" ,maxv);
    return (0);
    
}



Measured memory_bytes: 2576
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int> > pipii;
typedef priority_queue<pii,vector<pii>,greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;
int cnt =0;








int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i =0;i <  s.length();i++){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;




	
	
	
}

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

//i = 0~n-1
//1000000000, 1

int main(void) {

	int n;
	cin >> n;
	int R[n];
	cin >> R[0];
	int minv = R[0];
	int maxv = -1000000000;
	//10^9??§?????¨?????????

	for (int j = 1; j < n; j++) {
		cin >> R[j];
		maxv = max(maxv, R[j]-minv);
		minv = min(minv, R[j]);
	}

	cout << maxv << endl;


	return 0;
}

/*
r0 = 10000 00000
r1 = 1

max = max(-10^9, 1- 10^9) = 1-10^9
min = min (10^9, 1) = 1
*/

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

int main(){
    long long n, k;
    cin >> n >> k;
    map<long long, long long> position_in_loop;
    vector<long long> np(n);
    for (long i = 0; i < n; i++)
    {
        cin >> np[i];
        np[i] --;
    }
    long loopsp = 0;
    vector<long long> loop;
    long long p = 0;
    do{
        position_in_loop[p] = loop.size();
        loop.push_back(p);
        p = np[p];
        if(position_in_loop.find(p) != position_in_loop.end())
        {
            loopsp = position_in_loop[p];
            break;
        }
    }while (true);
    long long looplen = loop.size() - loopsp;
    long long fans = 0;
    if (k < loopsp)
    {
        fans = loop[k];
    }
    else
    {
        k -= loopsp;
        fans = loop[k%looplen + loopsp];
    }

//    long long fans = loop[k%loop.size()];
    cout << fans+1;

}

Measured memory_bytes: 18644
class Main {

	void run(){
		int p, q;
		for(p=1;p<=9;p++){
			for(q=1;q<=9;q++){
				System.out.printf("%dx%d=%d\n", p, q, p*q);				
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17988
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5;
signed main(){
	string s;cin>>s;int sum=0;int maxn=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R')sum++,maxn=max(sum,maxn);
		else sum=0;
	}
	cout<<maxn<<"\n";
} 

Measured memory_bytes: 3624
int main()
{
   int a, b;
   scanf("%d %d", &a , &b);
   if(a<b){
    printf("a < b\n"); }
   if(a>b){
    printf("a > b\n"); }
   if(a==b){
    printf("a == b\n"); }
return 0 ;
}


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

#define yes "Yes\n"
#define no "No\n"
//int m,n;
//int i,j,k,l;
//int a,b,c,d,e,f,g;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];

int main()
{
    int i, k, a[5];
    for (size_t i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    for (size_t i = 0; i < 5; i++)
    {
        if (a[i] == 0)
        {
            cout << i + 1 << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    LL N,A,B;
    cin>>N>>A>>B;
    if(A>B || (N==1 && A!=B))
        cout<<0<<endl;
    else
        cout<<(B*(N-1)+A) - (A*(N-1)+B) + 1 << endl;
     return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int ret = 0;
    for(;;){
        string s;
        if(!(cin >> s)){
            cout << ret << endl;
            return 0;
        }
        
        string s1 = s;
        reverse(s1.begin(), s1.end());
        if(s == s1)
            ++ ret;
    }
}

Measured memory_bytes: 596
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut dishes: Vec<i32> = Vec::new();

    for _ in 0..5{
        dishes.push(read_as_vec()[0]);
    }
    //println!("{:?}", dishes);
    dishes.sort_by_key(|x| {

        if *x%10 == 0{
            return -10;
        }else{
            return -*x%10;
        }

        //(*x+9)/10*10
    });
    //println!("{:?}", dishes);
    //let last = ((dishes[4]/10)+1)*10 - dishes[4];
    let last = (dishes[4]+9)/10*10 - dishes[4];
    println!("{}",dishes.iter().map(|x| ((*x+9)/10)*10).sum::<i32>() - last);
}


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

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

ll max(ll a, ll b) {
    if (a > b) return a;
    return b;
}

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

    ll N, K;
    cin>>N>>K;
    vector<ll> as(N);
    vector<ll> fs(N);
    rep(i, N) cin>>as[i];
    rep(i, N) cin>>fs[i];

    sort(as.begin(), as.end());
    sort(fs.begin(), fs.end());
    reverse(fs.begin(), fs.end());

    ll l = -1;
    ll r = 1001001001001;
    while (l + 1 < r) {
        ll m = (l + r) / 2;
        ll k = 0;
        rep(i, N) {
            k += max(0, as[i] - m / fs[i]);
        }
        if (k > K) l = m;
        else r = m;
    }
    cout<<r<<endl;
}

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

int main() {
    ll N; cin >> N;
    string ans = "";
    while ((N > 0)){
        N -= 1;
        ans += ('a' + N%26);
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3628