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

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define all(v) (v).begin(),(v).end()
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll N, M;
    cin >> N >> M;
    vector<string> S(N);
    for (ll i = 0; i < N; i++) {
        cin >> S[i];
    }

    ll s = N*M, t = N*M+1;
    mf_graph<ll> graph(N*M+2);
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < M; j++) {
            if (S[i][j] == '#') continue;
            ll v = i*M + j;
            if ((i + j) % 2 == 0) graph.add_edge(s, v, 1);
            else graph.add_edge(v, t, 1);
        }
    }

    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < M; j++) {
            ll v = i*M + j;
            if ((i + j) % 2 != 0) continue;
            if (S[i][j] == '#') continue;
            if (i-1 >= 0 && S[i-1][j] == '.') graph.add_edge(v, (i-1)*M+j, 1);
            if (i+1 < N  && S[i+1][j] == '.') graph.add_edge(v, (i+1)*M+j, 1);
            if (j-1 >= 0 && S[i][j-1] == '.') graph.add_edge(v, i*M+(j-1), 1);
            if (j+1 < M  && S[i][j+1] == '.') graph.add_edge(v, i*M+(j+1), 1);
        }
    }

    cout << graph.flow(s, t) << endl;

    for (auto&& e : graph.edges()) {
        ll i0 = e.from / M, j0 = e.from % M;
        ll i1 = e.to / M, j1 = e.to % M;
        if (e.from == s || e.to == t || e.flow == 0) continue;
        if (i0 == i1 - 1)      S[i0][j0] = 'v', S[i1][j1] = '^';
        else if (i0 == i1 + 1) S[i0][j0] = '^', S[i1][j1] = 'v';
        else if (j0 == j1 - 1) S[i0][j0] = '>', S[i1][j1] = '<';
        else                   S[i0][j0] = '<', S[i1][j1] = '>';
    }

    for (auto&& a : S) {
        cout << a << endl;
    }

    return 0;
}


Measured memory_bytes: 5900
/*Bismillahir Rahmanir Rahim
->>Code by aimon
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define f(a,b,x) for(int a=b;a<x;a++)
#define pb push_back
#define endl "\n"
#define MX INT_MAX
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define vi vector<int>

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

    string s;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        cout<<s[i];
    }
    cout<<endl;
}


Measured memory_bytes: 3556
#include<stdio.h>
int main()
{
     int W,H,x,y,r;
     scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
     if(W>0&&W<=100&&H>0&&H<=100&&r>0&&r<=100&&x>=-100&&x<=100&&y>=-100&&y<=100)
     {
           if(x>=r&&x<=W-r&&y>=r&&y<=H-r)
           {
                 printf("Yes\n");
           }
           else
           {
                 printf("No\n");
           }
     }
     return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <string>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)

#define MOD 1000000007

using namespace std;

int mod = 1000000007;
struct mint{
    ll x;
    //コンストラクタ
    mint(ll x=0):x((x%mod+mod)%mod){}

    // %は若干遅いから，%を使わないようにしている
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x-= mod;
        return *this;
    }

    mint& operator-=(const mint a){
        if((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint power(ll t) const { // x^t
        if(!t) return 1;
        mint ans = power(t >> 1);
        ans *= ans;
        if(t&1) ans *= *this;
        return ans;
    }

    //素数が絡むやつ
    mint inv() const{
        return power(mod-2);
    }
    mint& operator/=(const mint a){
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res /= a;
    }
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination{
    vector<mint> factorial, ifactorial;
    combination(int n) :factorial(n+1), ifactorial(n+1){
        factorial[0] = 1;
        //分子　そのまま計算
        for(int i = 1; i <= n; i++) factorial[i] = factorial[i-1] * i;

        //分母　処理が重いので一発で済ませたい
        ifactorial[n] = factorial[n].inv();
        for(int i = n; i >= 1; i--) ifactorial[i-1] = ifactorial[i] * i;
    }
    mint operator()(int n , int k){
        if(k < 0 || n < k) return 0;
        return factorial[n] * ifactorial[k] * ifactorial[n-k];
    }
};

int main(void){
    //abc171F

    int k;
    string s;
    cin >> k >> s;

    int n = s.size();
    mint ans = 0;
    combination c(n+k);
    for(int i = 0; i <= k; i++){
        mint tmp = mint(26).power(k-i);
        tmp *= mint(25).power(i);
        tmp *= c(n+i-1, n-1);
        ans += tmp;
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
  int N,K,sum = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++){
     if (sum <= K){
       sum *= 2;     
     }
     else{
       sum += K;     
     }
  }
  cout << sum << endl;
}

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

using namespace std;
typedef long long ll;

int ketawa(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

  if (N % ketawa(N) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

constexpr ll LNF = 1e15;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<char> s(n);
    rep(i,0,n) cin >> s[i];
    rep(i,0,n){
        if(s[i]=='Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int v2[]=new int[n];
			int sum=0;
			boolean judge=false;
			for(int i=0;i<n;i++)
			{
				int a=in.nextInt();
				v2[i]=a;
				sum+=a;
			}
			for(int i=1;i<=1000000;i++)
			{
				if((i*(i+1))/2==sum)
				{
					judge=true;
					break;
				}
			}
			if(!judge)
			{
				System.out.println(-1);
				continue;
			}
			int cnt=0;
			for(;;)
			{
				int v[]=v2.clone();
				if(cnt>10000)
					break;
				//debug(v);
				if(v[0]==1)
					if(check(v))
						break;
				int block=0;
				int zero=0;
				for(int i=0;i<v.length;i++)
				{
					block++;
					v[i]--;
					if(v[i]==0)
						zero++;
				}
				v2=new int[v.length-zero+1];
				int I=0;
				for(int i=0;i<v.length;i++)
				{
					if(v[i]!=0)
						v2[I++]=v[i];
				}
				cnt++;
				v2[v2.length-1]=block;
			}
			System.out.println(cnt>10000 ? -1:cnt);
		}
	}

	static boolean check(int v[])
	{
		boolean res=true;
		for(int i=0;i<v.length-1;i++)
		{
			if(v[i]+1!=v[i+1])
				res=false;
		}
		return res;
	}
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 152248
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        String s = sc.next();

        int ans = 0;
        for (int i = 0; i < s.length() - 2; i++) {
            if(s.charAt(i) == 'A' && s.charAt(i+1) == 'B' && s.charAt(i+2) == 'C')ans++;
        }

        System.out.println(ans);


    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}



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

int main(){
    long int N,A,B;
    cin >> N >> A >> B;

    long int count,reg;
    count = N/(A+B);
    reg = N%(A+B);

    if(reg<=A)
    {
        count = count*A + reg;
    }
    else
    {
        count = count*A + A;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

public static void main(String[] args) {

// ?¨??????\???????????????????????????????????????

Scanner sc = new Scanner(System.in);

// 2?????????????????????????????????????????´??°?????¨????????????????????????

int a = sc.nextInt();

int b = sc.nextInt();

int area = a*b/* ????????????????????¢???????±?????????? */;

int length = 2*a+2*b/* ????????????????????¨????????????????±?????????? */;

System.out.println(area + " " + length); 

}

}

Measured memory_bytes: 26192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[5000000],br[5000000];
int main()
{
    int i,j,k,e,r,n,s,d,g;
    cin >> n;
    k=0;
        int ck=0,max1=0;
    for(i=1;i<=n;i++)
    {
        cin >> ar[i];
        if(ck==0)
        {

            ck=1;
            r=i;
        }
        else
        {
            if(ar[i]>ar[r])
            {
                max1=max(max1,k);
                k=0;
                r=i;
            }
            else
            {
                k++;
                r=i;
                //cout << r << endl;
            }
        }
    }
    max1=max(max1,k);

    cout << max1 << endl;
}


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

int main() {
  ll ans;
  int n,x;
  cin >> n >> x;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  for (int i = 1; i < n; i++) {
    int over = a[i] + a[i-1] - x;
    if (over > 0) {
      ans += over;
      if (a[i] - over < 0) {
        a[i-1] -= over - a[i];
        a[i] = 0;
      } else {
        a[i] -= over;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import Control.Applicative
import Data.Fixed (Pico)

readInt s = read s :: Int
main :: IO ()
main = do
    [a,b] <- map readInt . words <$> getLine
    putStr $ show  (a `div` b) ++ " "
    putStr $ show  (a `mod` b) ++ " "
    putStrLn . show $ ((fromIntegral a / fromIntegral b) :: Pico)


Measured memory_bytes: 4120
fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let (mut x, mut y) = (vec![0i64; n], vec![0i64; n]);
    for i in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        x[i] = iter.next().unwrap().parse().unwrap();
        y[i] = iter.next().unwrap().parse().unwrap();
    }

    let ans = {
        [
            (0..n).map(|i| x[i] + y[i]).max().unwrap() -
            (0..n).map(|i| x[i] + y[i]).min().unwrap(),
            (0..n).map(|i| x[i] - y[i]).max().unwrap() -
            (0..n).map(|i| x[i] - y[i]).min().unwrap(),    
            (0..n).map(|i| -x[i] + y[i]).max().unwrap() -
            (0..n).map(|i| -x[i] + y[i]).min().unwrap(),    
            (0..n).map(|i| - x[i] - y[i]).max().unwrap() -
            (0..n).map(|i| - x[i] - y[i]).min().unwrap(),    
        ].iter().max().unwrap().clone()
    };
    println!("{}", ans);
}

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define ps(ch) printf("%s",ch)
#define Afridi 0
#define NL printf("\n")
#define debug(x) printf("wow  %d !!\n",x)
#define Max 8005
#define INF (LL)1e18
#define mod 1000000007

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << x << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;


LL bigmod(LL b,LL p,LL m)
{
    if(p == 0)return 1;
    LL my = bigmod(b,p/2,m);
    my*=my;my%=m;
    if(p & 1)my*=b,my%=m;
    return my;
}
int setb(int n,int pos){return n=n | (1 << pos);}
int resb(int n,int pos){return n=n & ~(1 << pos);}
bool checkb(int n,int pos){return (bool)(n & (1 << pos));}

LL LCM(LL x,LL y)
{
	LL g = __gcd(x,y);
	return (x / g) * y;
}

int main()
{
	LL n,i,x;
	sl(n);
	LL ret = 1;
	rep(i,n)
	{
		sl(x);
		if(i == 1)ret = x;
		else
		{
            ret = LCM(ret,x);
		}
	}
	pl(ret); NL;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int n,m;
	char s[20000];
	scanf("%d",&n);
	scanf("%s",s);
	m=strlen(s);
	for(int i=0;i<m;i++)
	{
		s[i]=s[i]+n;
		if(s[i]>'Z')
		s[i]=s[i]-26;
	}
	for(int i=0;i<m;i++)
	printf("%c",s[i]);
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順


int main(){
  ll a,v,b,w,t;cin>>a>>v>>b>>w>>t;
  ll dis=abs(a-b);
  ll vs=abs(v-w);
  if(v<=w){cout<<"NO"<<endl;return 0;}

  if(vs*t>=dis){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}


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

using namespace std;

#define ll long long
#define pb push_back

string s, s1, s2;
int a[505];

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

    cin >> s;

    for(int i = 0; i < s.size(); ++i){
        a[s[i]] = 1;
    }
    if(s.size() == 26){
         for(int i = 24; i >= 0; --i){
            for(char c = s[i] + 1; c <= 'z'; ++c){
                for(int j = i + 1; j <= 25; ++j){
                    if(s[j] == c) {
                        for(int r = 0; r < i; ++r){
                            cout << s[r];
                        }
                        cout << c;
                        return 0;
                    }
                }
            }
        }
        cout << -1;
    }
    else{
        cout << s;
        for(char i = 'a'; i <= 'z'; ++i){
            if(a[i] == 0) {cout << i; return 0;}
        }
    }

    return 0;

}


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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int n;
    cin >> n;

    vector<vector<int>> adj(n);
    for (int i = 0, a, b; i + 1 < n; ++i) {
        cin >> a >> b;
        adj[a - 1].push_back(b - 1);
        adj[b - 1].push_back(a - 1);
    }

    vector<int> c(n);
    for (auto &c_i : c) cin >> c_i;
    sort(c.begin(), c.end(), greater<int>());

    const int root = 0;
    int max_sum = 0, idx = 0;
    vector<int> max_w(n, -1);
    queue<int> que;
    que.push(root);
    max_w[root] = c[idx++];

    while (!que.empty()) {
        int cur = que.front(); que.pop();
        for (auto u : adj[cur]) {
            if (max_w[u] != -1) continue;
            max_w[u] = c[idx++];
            max_sum += min(max_w[cur], max_w[u]);
            que.push(u);
        }
    }

    cout << max_sum << endl;
    for (int v = 0; v < n; ++v)
        cout << max_w[v] << " \n"[v == n - 1];

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include <algorithm>
#include <functional>

using namespace std;

int main (void){
    int N,temp;
    vector<int> d;

    cin >> N;
    for(int i=0;i<N;i++){
        cin >> temp;
        d.push_back(temp);
    }

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

    int center = N/2;
    int count = d[center] - d[center-1];
    cout << count << endl;


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



    return 0; 
}

Measured memory_bytes: 892
#include <stdio.h>
#define N 100000

int main(void){
    int n;
    int a[N];
    int memo[N];
    int i,j,k,tmp;
    for(i = 0; i < N; i++){
        memo[i] = -1;
    }
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    
    memo[0] = a[0];
    for(i = 1; i < n; i++){
        j = 0;
        while(a[i] <= memo[j]){
            j++;
        }
        memo[j] = a[i];
        tmp = memo[j];
        k = j;
        while(tmp > memo[k] && k >= 1){
            memo[k] = memo[k-1];
            k--;
        }
        memo[k] = tmp;
    }
    
    for(i = 0; i < n; i++){
        if(memo[i] == -1){
            break;
        }
    }
    
    printf("%d", i);
    return 0;
}

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

int main()
{
    string s,t;

    cin>>s;
    cin>>t;

    int c=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i])c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100100
using namespace std;
int seg[maxn],n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%d",&seg[i]);
	sort(seg+1,seg+1+n);
	priority_queue<int>Q;
	for(int i=n;i>=2;i--){
		if(seg[i]==seg[i-1]){
			Q.push(seg[i]);
			i--;
		}
		if(i>=4&&seg[i]==seg[i-1]&&seg[i]==seg[i-3]){
			Q.push(seg[i]);
			Q.push(seg[i]); 
			i-=3;
		}
	}
	long long ans=0;
	if(Q.size()<2){
		cout<<0;
	}
	else{
		ans=Q.top();
		Q.pop();
		ans=ans*Q.top();
		cout<<ans;
	}
	return 0;
	
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>

int main()
{

    int N = 0;
    std::cin >> N;

    float answer = 0.0f;
    if (N % 2 == 1)
    {
        answer = (N / 2 + 1.0f) / N;
    }
    else
    {
        answer = (N / 2.0f) / N;
    }

    std::cout << std::fixed;
    std::cout << std::setprecision(16) << answer << "\n";

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> value2count;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        value2count[A[i]]++;
    }

    ll target = 1;
    while (target <= 2 * 1e9) {
        target *= 2;
    }
    target /= 2;

    ll ans = 0;
    while (target > 0) {
        for (auto itr = value2count.rbegin(); itr != value2count.rend(); itr++) {
            ll opp = target - itr->first;
            if (value2count.count(opp)) {
                ll add = (itr->first != opp ? min(itr->second, value2count[opp])
                    : itr->second / 2 );
                ans += add;
                itr->second -= add;
                value2count[target - itr->first] -= add;
            }
        }

        target /= 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 14336
n = int(input())
h = list(map(int, input().split()))
c_prev = 0
c = abs(h[0] - h[1])
for i in range(2, n):
    c_prev, c = c, min(c_prev + abs(h[i - 2] - h[i]), c + abs(h[i - 1] - h[i]))

print(c)

Measured memory_bytes: 13980
#include <bits/stdc++.h>
#define ll long long
#define ulli unsigned long long int
#define ld long double  
#define endl "\n"
using namespace std; 


void solve() {
    string s;
    cin >> s;

    if (s.size() < 2) {
        cout << 0 << endl;
        return;
    }

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

    cout << ans << endl;
}

int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    //cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 


Measured memory_bytes: 720
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, len;
    cin >> n >> len;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    int maxLen = 0;
    int k = -1;
    for(int i=0; i<n-1; ++i){
        int x = a[i] + a[i+1];
        if(maxLen < x){
            maxLen = x;
            k = i;
        }
    }
    if(maxLen < len){
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;
    for(int i=0; i<k; ++i)
        cout << (i+1) << endl;
    for(int i=n-2; i>k; --i)
        cout << (i+1) << endl;
    cout << (k+1) << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
 
    int i,end,ANS;
    int x,y,z;
 
    for(i=1;i<=N;i++){
      int ans=0;
      end = sqrt(i);
 
      for(x=1;x<=end;x++){
        if(x*x > i){
          break;
        }
        for(y=1;y<=end;y++){
          if(x*x+y*y+x*y > i){
            break;
          }
          for(z=1;z<=end;z++){
            ANS = x*x+y*y+z*z+x*y+y*z+z*x;
            if(ANS > i){
              break;
            }
            //cout << x << " " << y << " " << z << " " << ANS << endl;
            if(ANS == i)ans++;
          }
        }
      }
      cout << ans << endl;
    }
 
}

Measured memory_bytes: 3672
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut xs: [i32; n],
    };
    xs.sort();
    let mut a: i32 = 0;
    let mut b: i32 = 0;
    loop {
        if let Some(i) = xs.pop() {
            a += i;
        } else {
            break;
        }
        if let Some(j) = xs.pop() {
            b += j;
        } else {
            break;
        }
    }
    println!("{}", a - b);
}


Measured memory_bytes: 2164
def kaibun(S):
    ok=True
    for i in range(len(S)//2):
        if S[i]!=S[-1-i]:
            ok=False
            break
    return ok

S=input()
N=len(S)
ok=True
if not kaibun(S):
    ok=False

if not kaibun(S[0:(N-1)//2]):
    ok=False

if not kaibun(S[(N+1)//2:N]):
    ok=False

print("Yes" if ok else "No")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int sumL[2][100010], sumR[2][100010];
int ansL[2][100010], ansR[2][100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    int x[100010], v[100010];
    x[0] = v[0] = 0;
    rep(i, N) cin >> x[i + 1] >> v[i + 1];
    x[N + 1] = C; v[N + 1] = 0;
    rep(i, N) {
        int add1 = v[i + 1] - (x[i + 1] - x[i]);
        int add2 = v[i + 1] - (x[i + 1] - x[i]) * 2;
        sumL[0][i + 1] = sumL[0][i] + add1;
        sumL[1][i + 1] = sumL[1][i] + add2;
    }
    RREP(i, N, 1) {
        int add1 = v[i] - (x[i + 1] - x[i]);
        int add2 = v[i] - (x[i + 1] - x[i]) * 2;
        //cout << "*" << i << " " << v[i] << " " << x[i + 1] << " " << x[i] << endl;
        sumR[0][i - 1] = sumR[0][i] + add1;
        sumR[1][i - 1] = sumR[1][i] + add2;
    }
    rep(j, 2) rep(i, N) ansL[j][i + 1] = max(sumL[j][i + 1], ansL[j][i]);
    rep(j, 2) RREP(i, N, 1) ansR[j][i - 1] = max(sumR[j][i - 1], ansR[j][i]);
    // rep(i, N + 1) cout << ansL[0][i] << " ";
    // cout << endl;
    // rep(i, N + 1) cout << ansR[0][i] << " ";
    // cout << endl;
    // rep(i, N + 1) cout << ansL[1][i] << " ";
    // cout << endl;
    // rep(i, N + 1) cout << ansR[1][i] << " ";
    // cout << endl;
    int ans = 0;
    rep(i, N + 1) {
        ans = max(ans, ansL[0][i] + ansR[1][i]);
        ans = max(ans, ansL[1][i] + ansR[0][i]);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 8064
#include<cstdio>
const int N=5005,md=1000000007;
int n,i,j,d[N],f[N][N][2],ans,inv[N],jc[N],rjc[N];
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d",d+i);
	inv[0]=inv[1]=1;
	for(i=2;i<=n;++i)
		inv[i]=1ll*inv[md%i]*(md-md/i)%md;
	jc[0]=rjc[0]=1;
	for(i=1;i<=n;++i)
		jc[i]=1ll*jc[i-1]*i%md,rjc[i]=1ll*rjc[i-1]*inv[i]%md;
	f[0][0][0]=1;
	for(i=1;i<=n;++i)
		for(j=0;j<=n;++j)
		{
			f[i][j][0]=((j>=1&&d[i]>=2?1ll*f[i-1][j-1][0]*rjc[d[i]-2]%md:0)+1ll*f[i-1][j][0]*rjc[d[i]-1]%md)%md;
			f[i][j][1]=((j>=1&&d[i]>=2?1ll*f[i-1][j-1][1]*rjc[d[i]-2]%md:0)+(j>=1&&d[i]>=3?1ll*f[i-1][j-1][0]*rjc[d[i]-3]%md:0)+1ll*f[i-1][j][1]*rjc[d[i]-1]%md)%md;
		}
	for(i=3,j=1;i<n;++i)
	{
		ans=(ans+1ll*f[n][i][1]*j%md*jc[n-i-1]%md)%md;
		j=1ll*j*i%md;
	}
	for(i=1;i<=n;++i)
		if(d[i]!=2)
			break;
	if(i>n)
		ans=(ans+j)%md;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    vector<int> ai(100001, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ++ai[a[i]];
    }
    set<int> s(a.begin(), a.end());
    int ans = 0;
    for (auto x : s) {
        int tmp = ai[x - 1] + ai[x] + ai[x + 1];
        if (tmp > ans) ans = tmp;
    }
        
    cout << ans << endl;

    return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    string res = "No";
    if (a == b && a != c) res = "Yes";
    if (b == c && a != b) res = "Yes";
    if (a == c && b != c) res = "Yes";

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3584
import math
N=int(input())

def get_circle_2p(p1,p2):
  x1,y1=p1
  x2,y2=p2
  
  x=(x1+x2)/2
  y=(y1+y2)/2  
  rad=math.sqrt((x1-x2)**2+(y1-y2)**2)/2
  return x,y,rad

def get_circle_3p(p1,p2,p3):
  x1,y1=p1
  x2,y2=p2
  x3,y3=p3
  d=2*((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))  
  
  if d==0:
    rad1=math.sqrt((x1-x2)**2+(y1-y2)**2)/2
    rad2=math.sqrt((x1-x3)**2+(y1-y3)**2)/2
    rad3=math.sqrt((x2-x3)**2+(y2-y3)**2)/2
    
    if rad1>=rad2 and rad1>=rad3:
      x=(x1+x2)/2
      y=(y1+y2)/2
      return x,y,rad1
    elif rad2>=rad1 and rad2>=rad3:
      x=(x1+x3)/2
      y=(y1+y3)/2
      return x,y,rad2
    elif rad3>=rad1 and rad3>=rad2:
      x=(x2+x3)/2
      y=(y2+y3)/2
      return x,y,rad3      
  else:
    x=((y1-y3)*(y1**2-y2**2+x1**2-x2**2)-(y1-y2)*(y1**2-y3**2+x1**2-x3**2))/d
    y=((x1-x3)*(x1**2-x2**2+y1**2-y2**2)-(x1-x2)*(x1**2-x3**2+y1**2-y3**2))/-d
    r=math.sqrt((x-x1)**2+(y-y1)**2)
    return (x,y,r)
  
xylist=[]
for i in range(N):
  xi,yi=map(int,input().split())
  xylist.append((xi,yi))
  
#print(xylist)

if N==2:
  x,y,r=get_circle_2p(xylist[0],xylist[1])
  print(r)
else:
  min_radius=float("inf")
  for i in range(N):
    for j in range(i+1,N):
      #print(xylist[i],xylist[j])
      x,y,r=get_circle_2p(xylist[i],xylist[j])
      #print(x,y,r)
      if r>min_radius:
        continue
      
      for l in range(N):
        if l==i or l==j:
          continue
          
        xl,yl=xylist[l]
        diff_xl=xl-x
        diff_yl=yl-y
        if math.sqrt(diff_xl**2+diff_yl**2)>r:
          break
      else:
        if r<min_radius:
          min_radius=r
  
  for i in range(N):
    for j in range(i+1,N):
      for k in range(j+1,N):
        #print(xylist[i],xylist[j],xylist[k])
        x,y,r=get_circle_3p(xylist[i],xylist[j],xylist[k])
        #print(x,y,r)
        if r>min_radius:
          continue
        
        for l in range(N):
          if l==i or l==j or l==k:
            continue
            
          xl,yl=xylist[l]
          diff_xl=xl-x
          diff_yl=yl-y
          if math.sqrt(diff_xl**2+diff_yl**2)>r:
            break
        else:
          if r<min_radius:
            min_radius=r
  
  print(min_radius)

Measured memory_bytes: 3192
S = input()
T = input()
ind = 0
cmax = 0
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(i, i+len(T)):
        if(S[j] == T[j-i]):
            count += 1
    if(count > cmax):
        ind = i
        cmax = count
print(len(T)-cmax)

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

int main()
{
	long long int p, q;
  cin>>p;
  q = p;
  int a = 0;
  while(p>0)
  {
   a = a + p%10;
    p = p/10;
  }
  if(q%a!=0)
    cout<<"No";
  else
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n+2,0);
  for(int i=1;i<n+1;i++){
    cin >> A.at(i) ;
  }
  int length = 0;
  for(int i=0;i<n+1;i++){
    length += abs(A.at(i)-A.at(i+1));
  }
  for(int i=1;i<n+1;i++){
    int change = abs(A.at(i-1)-A.at(i+1))-abs(A.at(i)-A.at(i+1))-abs(A.at(i)-A.at(i-1));
    cout << length+change <<endl;
  }
}




Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
 int n,w;
 cin>>n>>w;
 vector<int>weight(n),val(n);
 for(int i=0;i<n;i++)   cin>>weight[i]>>val[i];
 vector<vector<int> > dp(n+1,vector<int>(w+1));
 dp[0][0]=0;
 for(int i=1;i<=n;i++){
     for(int j=0;j<=w;j++){
         dp[i][j]=dp[i-1][j];
         int left = j- weight[i-1];
         if(left>=0)    dp[i][j]= max(dp[i][j],dp[i-1][left]+val[i-1]);
     }
 } 
 cout<<dp[n][w]<<endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <functional>
#include <queue>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int data[9];
		for (int j = 0; j < 9; j++) {
			cin >> data[j];
		}
		priority_queue< P, vector<P>, greater<P> > pq;
		char c;
		for (int j = 0; j < 9; j++) {
			cin >> c;
			P p;
			p.second = data[j];
			if (c == 'R') {
				p.first = 1;
			} else if (c == 'B') {
				p.first = 2;
			} else {
				p.first = 3;
			}
			pq.push(p);
		}
		bool hantei = true;
		while (!pq.empty()) {
			P p1, p2, p3;
			p1 = pq.top();
			pq.pop();
			p2 = pq.top();
			pq.pop();
			p3 = pq.top();
			pq.pop();
			if (p1.first == p2.first && p1.first == p2.first) {
				if (p1.second == p2.second && p1.second == p3.second) {
				} else if (p1.second+1 == p2.second && p2.second+1 == p3.second) {
				} else {
					P p4, p5, p6;
					p4 = pq.top();
					pq.pop();
					p5 = pq.top();
					pq.pop();
					p6 = pq.top();
					pq.pop();
					if (p1.second+1 == p3.second && p3.second+1 == p5.second && p2.second+1 == p4.second && p4.second+1 == p6.second) {
					} else {
						hantei = false;
						break;
					}
				}
			} else {
				hantei = false;
				break;
			}
		}
		if (hantei) {
			cout << 1 << endl;
		} else {
			cout << 0 << endl;
		}
	}
	return 0;
}

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

int main(){
  int n; cin >> n;
  int p[n];
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int count=0;
  for(int i=1;i<n-1;i++){
    if((p[i-1] < p[i] && p[i] < p[i+1])  || (p[i-1] > p[i] && p[i] > p[i+1])){
      count++;
    }
  }
  cout << count << endl;
}
  

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

class Main{
  public static void main(String args[]){
    BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
    String str;
    String[] array=new String[2];
    int num;

    LinkedList list=new LinkedList();
    try{
      int n=Integer.parseInt(reader.readLine());
      num=-1;

      for(int i=0;i<n;i++){
        str=reader.readLine();
        if(str.charAt(0)=='i'){
          array=str.split(" ");
          num=Integer.parseInt(array[1]);
          list.insert(num);
        }else if(str.charAt(6)=='F'){
          list.deleteFirst();
        }else if(str.charAt(6)=='L'){
          list.deleteLast();
        }else{
          array=str.split(" ");
          num=Integer.parseInt(array[1]);
          list.delete(num);
        }
      }
      list.outputAll();
    }catch(IOException e){
      ;
    }
  }//main
}

class LinkedList{
  static class Node{
    int data;
    Node prev;
    Node next;

    Node(int data, Node prev, Node next){
      this.data=data;
      this.prev=prev;
      this.next=next;
    }
  }

  Node ptr, head, tail;

  LinkedList(){
    ptr=head=tail=null;
  }

  void insert(int num){
    ptr=head;
    head=new Node(num, null, ptr);
    if(ptr==null)tail=head;//????????????tail????????§????¨????
    if(ptr!=null){
      ptr.prev=head;
    }

  }

  void delete(int num){
    ptr=head;
    if(head.next==null&&ptr.data==num)head=null;
    else{

    while(ptr.data!=num){
    	if(ptr.next==null)break;//?????¨?????????
    	else ptr=ptr.next;//?????¨????????????????????????
    	}

       if(ptr.data!=num);//?????¨?????????????????°???????????????
       else if(ptr.prev==null){
          deleteFirst();
        }else if(ptr.next==null){
          deleteLast();
        }else{
          Node Prev=ptr.prev;
          Node Next=ptr.next;
          Prev.next=ptr.next;
          Next.prev=ptr.prev;
        }ptr=head;
    }
  }

  void deleteFirst(){
    if(head.next==null){
      head=null; //???????????????????????¨????????\??????
    }else{
      head=head.next;
      head.prev=null;
    }
  }

  void deleteLast(){
    ptr=head;
    if(head.next==null){
      head=null; //?????????????????????????????\??????
    }else{
    	ptr=tail.prev;
    	ptr.next=null;
    	tail.prev=null;
    	tail=ptr;
    }
  }

  void outputAll(){
    ptr=head;
    while(ptr.next!=null){
      System.out.print(ptr.data+" ");
      ptr=ptr.next;
    }
    System.out.println(ptr.data);
  }
}

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

int main() {
  std::string S; std::cin >> S;
  int min_diff = 999;
  for (size_t i = 0; i < S.length() - 2; ++i) {
    auto digits = S.substr(i, 3);
    int diff = std::abs(stoi(digits) - 753);
    min_diff = std::min(min_diff, diff);
  }
  std::cout << min_diff << std::endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner in=new Scanner(System.in);
        int a=in.nextInt();
        int b=in.nextInt();
        int ans=0;
        for(int i=a;i<=b;i++){
            if(((i/10000)==(i%10))&&((i/1000)%10==(i/10)%10)){
                ans++;
            }
        }
    System.out.println(ans);
     }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
      string s;
      cin>>s;

      std::vector<int> dp(2020,0);
      ll ans=0ll;
      dp[s[0]-'0']=1;
      for(int i=1;s[i];++i){
        std::vector<int> tem(2020,0);
        tem[s[i]-'0']=1;
        for(int j=0;j<2019;++j){
          if(dp[j]>0){
            int r =(10*j + (s[i]-'0'))%2019;
            if(r==0)ans+=(ll)dp[j];
            tem[r]+=dp[j]; 
          }
        }
        for(int j=0;j<2019;++j){
          dp[j]=tem[j];
        }
      }
      printf("%lld\n", ans);

        //printf("Case %d: ",++te);
    }
    return 0;
}






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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	char c;
	
	cin >> c;
	
	if(c >= 'A' && c <= 'Z'){
		cout << "A" << endl;
	}
	else{
		cout << "a" << endl;
	}
	
	return 0;
}

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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (A.at(j).at(k) == B.at(i)) {
          A.at(j).at(k) = 0;
        }
        else {
          continue;
        }
      }
    }
  }
  
  int jud = 0;
  int sum1 = 0, sum2 = 0, sum3 = 0;
  
  for (int j = 0; j < 3; j++) {
    sum1 += A.at(0).at(j);
    sum2 += A.at(1).at(j);
    sum3 += A.at(2).at(j);
  }
  if (sum1 == 0 || sum2 == 0 || sum3 == 0) {
      jud += 1;
  }
  
  int sum4 = 0, sum5 = 0, sum6 = 0;
  for (int i = 0; i < 3; i++) {
    sum4 += A.at(i).at(0);
    sum5 += A.at(i).at(1);
    sum6 += A.at(i).at(2);
  }
  if (sum4 == 0 || sum5 == 0 || sum6 == 0) {
      jud += 1;
  }
  
  
  int s = A.at(0).at(0) + A.at(1).at(1) + A.at(2).at(2);
  int ss = A.at(0).at(2) + A.at(1).at(1) + A.at(2).at(0);
  
  if (s == 0 || ss == 0) {
    jud += 1;
  }
  
  if (jud == 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }

}

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

import bisect
import copy
import collections
import heapq
import itertools
import math
import numpy as np
from operator import itemgetter
import scipy.misc
import sys

"""
#### 入力例 ####
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
"""


N=int(input())
S = [input() for n in range(N)]
s_counter = collections.Counter(S)
def main():
    cases = ["AC", "WA", "TLE", "RE"]
    for case in cases:
        cnt = 0
        if case in s_counter.keys():
            cnt =s_counter[case]
        print(case+" x "+str(cnt))
        
    return
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 38148