akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  in(s);
  if(s[0] == s[2])
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define debug cout<<"****************"<<endl
using namespace std;
typedef long long ll;
inline void ju() {
	freopen("***.in","r",stdin);
	freopen("***.out","w",stdout);
}
inline ll rd() {
	ll x=0,f=1; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') {
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
bool b[10];
int main() {
	int n=rd(),k=rd();
	for(int i=1;i<=k;++i) b[rd()]=1;
	for(int i=n;i<=n*10+10;++i) {
		int t=i; bool f=1;
		while(t) {
			if(b[t%10]) f=0;
			t/=10;
		}
		if(f) {
			printf("%d\n",i); break;
		}
	}
	return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B; cin >> A >> B;
    cout << (A^B) << endl;
    return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

#define rep(i, n) for(lli i = 0; i < (lli)(n); i++)

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
lli n;
vector<lli> L;

int main(void){
    int ti = clock();
    cin >> n;
    rep(i, n){
        lli tmp;
        cin >> tmp;
        L.push_back(tmp);
    }
    sort(L.begin(), L.end());

    lli res = 0;
    lli t1, t2;
    lli cmax;
    for(lli i = 0; i < n; i++){
        for(lli j = i+1; j < n; j++){
            t1 = L.at(i);
            t2 = L.at(j);
            cmax = lower_bound(L.begin()+j+1, L.begin()+n, t1+t2)-L.begin();
            res += max(0LL, cmax-(j+1));
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A, B;
    scanf("%d %d", &A, &B);
    if(A>=13)
    {
        printf("%d\n", B);
    }
    else if(A>=6 && A<=12)
    {
        printf("%d\n", B/2);
    }
    else if(A<=5)
    {
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char S[1000010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	scanf("%s",S+1);int n=strlen(S+1);
	for(int i=1;i<=n;++i)S[i]-='0';
	std::reverse(S+1,S+n+1);
	n<<=1;
	for(int i=1;i<=n;++i)S[i]*=9;
	for(int i=1;i<=n;++i)if(S[i]>=10)S[i+1]+=S[i]/10,S[i]%=10;
	ll sum=0;for(int i=1;i<=n;++i)sum+=S[i];
	for(int i=1;i<=n;++i){
		S[1]+=9;sum+=9;
		for(int j=1;j<=n;++j)if(S[j]>=10)sum+=S[j]%10+S[j]/10-S[j],S[j+1]+=S[j]/10,S[j]%=10;else break;
		if(sum<=9*i){printf("%d\n",i);break;}
	}
	return 0;
}


Measured memory_bytes: 1280
n,k,q = map(int,input().split())
A = [int(input()) for i in range(q)]
C = [0 for i in range(n)]

for i in range(q):
    C[A[i]-1] += 1

for i in range(n):
    if C[i]+k-q<=0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 8640
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1000000000;
const int N = 100000000;

bitset<N + 10> pr;

int main() {FIN
    
    int n, i, j, e, c = 0;
    pr.set();
    pr[0] = 0, pr[1] = 0;
    for (i = 4; i <= N; i += 2) pr[i] = 0;
    for (i = 3; i * i <= N; i++) {
		if (pr[i]) {
			for (j = i * i; j <= N; j += 2 * i)
				pr[j] = 0;
		}
	}
    
    cin >> n;
	
	for (i = 0; i < n; i++) {
		cin >> e;
		if (pr[e]) c++;
	}
	cout << c << "\n";
    
    return 0;
}



Measured memory_bytes: 15364
typedef unsigned long long ll;
#include <bits/stdc++.h>
using namespace std;
template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};

int main() {
    ll n;
    std::cin >> n;
    string s;
    std::cin >> s;
    ll q;

    std::cin >> q;
    SegTree<int> seg(n, [](int a, int b){ return a | b; }, 0);
    for (int i = 0; i < n; i++) {
        seg.update(i,1<<(s[i]-'a'));
    }
    for (int i = 0; i < q; i++) {
        ll t;
        std::cin >> t;
        if(t==1){
            ll k;
            char c;
            std::cin >> k>>c;
            seg.update(k-1,1<<(c-'a'));
        }else{
            ll l,r;
            std::cin >> l>>r;
            l--;
            r--;
            
            std::cout << __builtin_popcount(seg.get(l,r+1)) << std::endl;
        }
    }
}


Measured memory_bytes: 4996
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vi x(m);
    REP(i, m) cin >> x[i];
    SORT(x);
    vl y(m - 1);
    REP(i, m - 1) y[i] = x[i + 1] - x[i];
    SORT(y);
    ll ans = 0;
    REP(i, m - n) ans += y[i];
    cout << ans << endl;
}


Measured memory_bytes: 4500
def oddstirng(s):
    if len(s)%2!=0:
        return 0
    else:
        s1 = s[:len(s)//2]
        s2 = s[len(s)//2:]
        if s1!=s2:
            return 0
        else:
            return len(s)
            
S = input()[:-1]
while(True):
    # print(S)
    j = oddstirng(S)
    if j!=0:
        print(j)
        break
    else:
        S=S[:-1]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int x,a;
    cin >> x >> a;
    if(x<a){
        cout << 0 << endl;
        return 0;
    }
    else cout << 10 << endl;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long m = in.nextLong();
			long[] a = new long[n+1];
			long[] sum = new long[n+1];
			Map<Long, Long> map = new HashMap<>();
			for (int i = 1; i < n+1; i++) {
				a[i] = in.nextLong();
				sum[i] = sum[i-1] + a[i];
				sum[i] %= m;
			}
			for (long l : sum) {
				map.merge(l, 1L, Long::sum);
			}

			long ans = 0;
			for (long l : map.keySet()) {
				long v = map.get(l);
				if (v >= 2) {
					ans += v * (v-1) / 2;
				}
			}
			out.println(ans);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 46520
# -*- coding: utf-8 -*-
"""
Created on Sun Sep  1 21:55:48 2019

@author: Yamazaki Kenichi
"""


N = int(input())
A = [list(map(int,input().split())) for i in range(N)]

T = [0 for i in range(N)]
today = [True for i in range(N)]
yesterday = [i for i in range(N)]

ans = 0
counta = 0
while counta < N:
    today = set([])
    today_p = []
    for i in yesterday:
        if not i in today:
            vs = A[i][T[i]] - 1
            if A[vs][T[vs]] == i + 1 and not vs in today:
                T[i] += 1
                T[vs] += 1
                if T[i] == N - 1:
                    T[i] = 0
                    counta += 1
                if T[vs] == N - 1:
                    T[vs] = 0 
                    counta += 1
                today.add(i)
                today.add(vs)
                today_p.extend([i,vs])
    yesterday = today_p
#        print(i,vs,today,T)
    if len(today_p) == 0:
        ans = -1
        break
    ans += 1
print(ans)



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

using namespace std;

typedef long long ll;

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

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

    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++) {
        reverse(divide[i].begin(), divide[i].end());
    }

    bool flag = true;
    for (int i = 0; i < s.length();) {
        bool can = false;

        for (int j = 0; j < 4; j++) {
            if (s.substr(i, divide[j].length()) == divide[j]){
                can = true;
                i += divide[j].length();
            }
        }

        if (!can) {
            flag = false;
            break;
        }
    }

    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

int alpha[30];

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

  int num=0;
  for(int i=0;i<s.size();i++){
    if(alpha[s[i]-'a'] == 0) num++;
    alpha[s[i]-'a']++;
  }

  int tmp=-1;
  for(int i=0;i<30;i++){
    if(alpha[i]>0){
      tmp=i;
      break;
    }
  }

  set<string> st;
  for(int i=0;i<s.size();i++){
    if(s[i]-'a' != tmp) continue;
    for(int j=1;j<=k;j++){
      st.insert(s.substr(i,j));
    }
  }

  while(st.size()<k){
    alpha[tmp]=0;
    for(int i=0;i<30;i++){
      if(alpha[i]>0){
	tmp=i;
	break;
      }
    }
    for(int i=0;i<s.size();i++){
      if(s[i]-'a' != tmp) continue;
      for(int j=1;j<=k;j++){
	st.insert(s.substr(i,j));
      }
    }
  }
  
  tmp=1;
  for(auto itr=st.begin(); itr!=st.end();++itr){
    if(tmp!=k) tmp++;
    else{
      cout<<*itr<<endl;
      break;
    }
  }
  return 0;
}


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



using namespace std;


int main() {
	long long n;
	cin >> n;
	
	long long solve = n *( n - 1) / 2;
	//solve -= n;
	
	cout << solve << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#define SIZE 1000
int main()
{
    int i, n, a[SIZE], max = -1, sum=0;
    scanf("%d\n", &n);
    for(i=0;i<=n-1;i++)
    {
        scanf("%d", &a[i]);
        if(a[i]>= max)
        {
            max = a[i];
        }
        sum += a[i];
    }
    sum = sum - max;
    if(max < sum)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1616
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

int main()
{
    long int N, W;
    cin >> N >> W;
    vector<pair<long int, long int> > vw(N);//vw[0][i]は重さ、vw[1][i]は価値
    vector<long int> w_nums(4);
    fill(w_nums.begin(), w_nums.end(), 0);

    for(long int i=0; i<N; i++){
        long int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        vw[i] = make_pair(tmp1, tmp2);
        w_nums[vw[i].first-vw[0].first]++;
    }
    sort(vw.begin(), vw.end());
    vector<long int> value[4];
    
    long int tmp=0;
    for(int i=0; i<4; i++){
        value[i].push_back(0);
        for(int j=0; j<w_nums[i]; j++){//重さが重いものから埋めていく
            value[i].push_back(value[i][j]+vw[w_nums[i]+tmp-j-1].second);
        }
        tmp+=w_nums[i];
    }
    
    long int ans=0;
    for(int a=0; a<min(w_nums[0], N)+1; a++){
        long int wa=a*vw[0].first;
        if(wa>W) continue;
        for(int b=0; b<min(w_nums[1], N-a)+1; b++){
            long int wb=wa+b*(vw[0].first+1);
            if(wb>W) continue;
            for(int c=0; c<min(w_nums[2], N-a-b)+1; c++){
                long int wc=wb+c*(vw[0].first+2);
                if(wc>W) continue;
                for(int d=0; d<min(w_nums[3], N-a-b-c)+1; d++){
                    long int wd=wc+d*(vw[0].first+3);
                    if(wd>W) continue;
                    ans=max(ans, value[0][a]+value[1][b]+value[2][c]+value[3][d]);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>

struct cmp {
  size_t k;
  cmp(size_t k): k(k) {}

  bool operator ()(std::string const& s, std::string const& t) const {
    return s.compare(0, k, t, 0, k) < 0;
  }
};

int main() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);

  std::vector<std::string> word(n), wrev(n);
  for (size_t i = 0; i < n; ++i) {
    char buf[256];
    scanf("%s", buf);
    word[i] = buf;
    wrev[i] = std::string(word[i].rbegin(), word[i].rend());
  }

  std::sort(word.begin(), word.end());
  std::sort(wrev.begin(), wrev.end());

  for (size_t i = 0; i < m; ++i) {
    char buf[256];
    scanf("%s", buf);
    std::string s = buf;

    bool rev = false;
    bool fixed = true;
    if (s[0] == '*') {
      std::reverse(s.begin(), s.end());
      rev = true;
      fixed = false;
      s.pop_back();
    } else if (s.back() == '*') {
      fixed = false;
      s.pop_back();
    }

    size_t q = -1;
    for (size_t j = 0; j < s.length(); ++j)
      if (s[j] == '?') q = j;

    std::vector<std::string> const& crit = (rev? wrev:word);
    int res = 0;
    if (fixed) {
      if (q+1 == 0) {
        auto lb = std::lower_bound(crit.begin(), crit.end(), s);
        auto ub = std::upper_bound(crit.begin(), crit.end(), s);
        // fprintf(stderr, "%td:%td\n", lb-crit.begin(), ub-crit.begin());
        res = ub-lb;
      } else {
        for (size_t c = 'a'; c <= 'z'; ++c) {
          s[q] = c;
          auto lb = std::lower_bound(crit.begin(), crit.end(), s);
          auto ub = std::upper_bound(crit.begin(), crit.end(), s);
          // fprintf(stderr, "%td:%td\n", lb-crit.begin(), ub-crit.begin());
          res += ub-lb;
        }
      }
    } else {
      if (q+1 == 0) {
        auto lb = std::lower_bound(crit.begin(), crit.end(), s, cmp(s.length()));
        auto ub = std::upper_bound(crit.begin(), crit.end(), s, cmp(s.length()));
        // fprintf(stderr, "%td:%td\n", lb-crit.begin(), ub-crit.begin());
        res = ub-lb;
      } else {
        for (size_t c = 'a'; c <= 'z'; ++c) {
          s[q] = c;
          auto lb = std::lower_bound(crit.begin(), crit.end(), s, cmp(s.length()));
          auto ub = std::upper_bound(crit.begin(), crit.end(), s, cmp(s.length()));
          // fprintf(stderr, "%td:%td\n", lb-crit.begin(), ub-crit.begin());
          res += ub-lb;
        }
      }
    }

    printf("%d\n", res);
  }
}



Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  rep(i, N) cin >> v[i];

  sort(all(v));
  repp(i, 1, N - 1) {
    v[i] = (v[i] + v[i - 1]) / 2.0;
  }

  cout << v[N - 1] << endl;
}

Measured memory_bytes: 256
gets.to_i
arr = gets.split(' ').map(&:to_i)
hash = arr.group_by(&:itself)

comb_ans = {}
comb_count = 0
hash.each{|key, val|
  comb = val.size * (val.size - 1) / 2
  comb_ans.store(key, comb)
  comb_count += comb
}
 
arr.each do |val|
  tmp = hash[val].size
  puts (comb_count - comb_ans[val] + (tmp - 1) * (tmp - 2) / 2)
end

Measured memory_bytes: 47236
#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>;

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

    int N;
    cin>>N;

    bool flag = false;
    rep(i, 9) {
        rep(j, 9) {
            if ((i + 1) * (j + 1) == N) flag = true;
        }
    }
    if (flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 2e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll n, a[N]; ll ans=0;

void solve()
{
    cin >> n;
    for (int i=0; i<n; ++i) cin >> a[i];
    for (int i=1; i<n; ++i) {
        if (a[i]<a[i-1]) {
            ans += a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}           

Measured memory_bytes: 5168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
   int n, k;
   cin >> n >> k;
   vector<int> cnt(k, 0);

   int i = 0;
   while(n){
      cnt[i]++;
      n--;
      i++;
      if(i == k){i=0;}
   }

   sort(cnt.begin(), cnt.end());
   cout << abs(cnt.back() - cnt[0]) << endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long long int N=0;
	long long int power=1;
	scanf("%lld",&N);
	for(long long int i=1;i<=N;i++)
	{
		power=power*i%1000000007;
	}

	printf("%lld",power);
	return 0;
 } 


Measured memory_bytes: 128
#include <iostream>
 
using namespace std;
 
int main() {
 
        int height[10];
        
        for(int i=0;i<10;++i){
                cin >> height[i];
        }
 
        int temp;
        for(int i=0;i<10;++i){
                for(int j=0;j<i;++j){
                        if(height[i]>height[j]){
                                temp = height[j];
                                height[j] = height[i];
                                height[i] = temp;
                        }
                }
        }
 
        cout << height[0] << "\n";
        cout << height[1] << "\n";
        cout << height[2] << "\n";
        
        
        return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
deque<int>d;
int n,ans,a;
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a;
		if(i & 1)
			d.push_back(a);
		else
			d.push_front(a);
	}
	if(n & 1)
		reverse(d.begin(),d.end());
	deque<int>::iterator it;
	for(it = d.begin(); it != d.end(); it++)
		cout << *it << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, p;
int pos;
char str[10000];
map<string, vector<int> > mapto;
map<vector<int>, string> mapfrom;
map<string, string> convert;
vector<int> error;

vector<int> formula();
vector<int> factor() {
  vector<int> lhs;
  if (str[pos] == '(') {
    pos++;
    lhs = formula();
    pos++;
  } else {
    string s;
    while (isalpha(str[pos])) { s += str[pos++]; }
    if (!convert.count(s)) { return error; }
    if (!mapto.count(convert[s])) { return error; }
    lhs = mapto[convert[s]];
  }
  return lhs;
}

vector<int> term() {
  vector<int> lhs = factor();
  if (lhs == error) { return error; }
  while (str[pos] == '*' || str[pos] == '/') {
    int s = str[pos] == '*' ? 1 : -1;
    pos++;
    vector<int> rhs = factor();
    if (rhs == error) { return error; }
    REP(i, n) {
      lhs[i] += s * rhs[i];
    }
  }
  return lhs;
}

vector<int> formula() {
  vector<int> lhs = term();
  if (lhs == error) { return error; }
  while (str[pos] == '+' || str[pos] == '-') {
    pos++;
    vector<int> rhs = term();
    if (rhs == error) { return error; }
    REP(i, n) {
      if (lhs[i] != rhs[i]) { return error; }
    }
  }
  return lhs;
}

int main() {
  error = vector<int>(1, -1000000000);
  while (scanf("%d %d %d", &n, &m, &p), n|m|p) {
    pos = 0;
    mapto.clear();
    mapfrom.clear();
    REP(i, m) {
      string s;
      cin >> s;
      vector<int> vect(n, 0);
      REP(i, n) {
        scanf("%d", &vect[i]);
      }
      mapto[s] = vect;
      mapfrom[vect] = s;
    }
    scanf("%s", str);
    REP(i, p) {
      string from, to;
      cin >> from >> to;
      convert[from] = to;
    }
    vector<int> ans = formula();
    if (ans[0] <= -100000) {
      puts("error");
    } else if (mapfrom.count(ans)) {
      printf("%s\n", mapfrom[ans].c_str());
    } else {
      puts("undefined");
    }
  }
}

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

int main() {
  int n;
  std::cin >> n;
  std::list<int> l(n);

  for (auto &i : l) {
    std::cin >> i;
  }

  std::vector<int> ans(n);
  auto index = n - 1;

  l.reverse();
  auto itr = l.begin();
  do {
    auto i = l.size();
    for (itr = l.begin(); itr != l.end(); itr++) {
      if (i == *itr) {
        ans[index] = *itr;
        index--;
        l.erase(itr);
        break;
      } else if (i < *itr) {
        std::cout << "-1" << std::endl;
        return 0;
      } else {
        i--;
      }
    }
  } while (itr != l.end());

  if (l.empty()) {
    for (const auto i : ans) {
      std::cout << i << std::endl;
    }
  } else {
    std::cout << "-1" << std::endl;
  }
  return 0;
}


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

int main(void){
  string s,t; cin >> s >> t;

  t.erase(t.end()-1);
  
  if(s==t) cout << "Yes" << endl;
  else cout << "No" << endl;
    
  return 0;
}


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

int main()
{
	int n, m, sum=0, ai=0;
	cin >>n >> m;
  
  	for (int i=0; i<m; i++)
    {
      cin >> ai;
      sum += ai;
    }
  	int result = (n - sum) >= 0 ? n - sum  : -1;
  	cout << result << endl;
	return 0;
 } 


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int s[200010];
vector<vector<int>> G;

void dfs(int v,int p,int x){
    s[v]+=x;
    for(auto u : G[v]){
        if(u==p) continue;
        dfs(u,v,s[v]);
    }
}

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

    G.resize(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i,q){
        int p,x;
        cin>>p>>x;
        p--;
        s[p]+=x;
    }

    dfs(0,-1,0);

    rep(i,n) cout<<s[i]<<" ";
    cout<<endl;
}



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

using namespace std;
int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int result = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        int s = 500 * i + 100 * j + 50 * k;
        if (s == x) result++;
      }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8

from copy import deepcopy


def main():
    global ans
    H, W, K = map(int, input().split())
    c = [None] * H
    for i in range(H):
        c[i] = [1 if x == "#" else 0 for x in input()]

    ans = 0

    def rec(i, j, c_, H, W, K):
        global ans

        c_1 = deepcopy(c_)
        c_2 = deepcopy(c_)

        if i < H:
            c_1[i] = [0] * W
            rec(i+1, j, c_1, H, W, K)
            rec(i+1, j, c_2, H, W, K)
        elif j < W:
            for h in range(H):
                c_1[h][j] = 0
            rec(i, j+1, c_1, H, W, K)
            rec(i, j+1, c_2, H, W, K)
        else:
            if sum([sum(row) for row in c_]) == K:
                ans += 1

    rec(0, 0, c, H, W, K)

    return ans


print(main())


Measured memory_bytes: 9352
from itertools import groupby
class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i - 1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod
        
def iparse():
    return list(map(int, input().split()))


# RUN LENGTH ENCODING str -> tuple


def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res


if __name__ == "__main__":
    n = int(input())
    i = 1
    ans = 0
    for i in range(1, n - 1):
        if n % i == 0:
            ans -= 1
        ans += n // i
    print(ans+1)
        

    


Measured memory_bytes: 9256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val i = readLine()!!.split(" ").map { it.toInt() }
    var c = 0
    for (u in i){
        c += check(u)
    }
    print(c)
}

fun check(value: Int) : Int {
    return if (value % 2 == 1) 0
    else check(value/2) + 1
}


Measured memory_bytes: 42064
N = int(input())

L = [2,1]

if N == 1:
    ans = L[N]
else:
    old_L = L[0]
    new_L = L[1]
    for _ in range(1, N):
        tmp = old_L + new_L
        old_L = new_L
        new_L = tmp
    ans = new_L

print(ans)


Measured memory_bytes: 2940
n, k = list(map(int, input().split()))

if k == 0:
    print(n**2)
    exit()
    
ans = 0
for b in range(k+1, n+1):
    ans_bk = (n-k)//b+1
    ans_b = ans_bk*(b-k)
    
    mod_k_max = ((n-k)//b)*b+k
    if n-mod_k_max+1 < b-k:
        ans_b -= ((b-k) - (n-mod_k_max+1))
    # print(ans_b)
    ans += ans_b
            
print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(void){
    // Your code here!
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int cnt;
    cnt=0;
    rep(i,n+1)rep(j,n+1){
        int q,m;
        q=(n-i*r-j*g)/b;
        m=(n-i*r-j*g)%b;
        if(q>=0 && m==0)cnt++;  
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Char8 (ByteString)
import qualified Data.Map as M
import Data.Map (Map)
import Data.List (sortBy)
 
main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  as <- B.words <$> B.getLine
  print $ solve k $ count as
 
count :: [ByteString] -> Map ByteString Int
count = foldr ins M.empty
  where ins k m = M.insertWith (+) k 1 m
 
solve :: Int -> Map ByteString Int -> Int
solve k = sum . drop k . descSort . M.elems

descSort :: [Int] -> [Int]
descSort = sortBy (flip compare)

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

int main(void) {
    using namespace std;

    long n;
    cin >> n;
    vector<long> l(n);
    for(auto &x: l) cin >> x;
    sort(l.begin(), l.end());
    l.push_back(2e9);

    map<long,long> m;
    for(auto &x: l) m[x]++;

    long r = 0;
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++) {
            // |a-b| < c < a+b
            auto lb = upper_bound(l.begin(), l.end(), abs(l[i]-l[j])) - l.begin();
            auto ub = lower_bound(l.begin(), l.end(), abs(l[i]+l[j])) - l.begin();
            // [lb, ub)
            r += ub - lb;
            r -= (l[lb] <= l[i] && l[i] < l[ub]);
            r -= (l[lb] <= l[j] && l[j] < l[ub]);
        }

    cout << r/3 << endl;
}

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

ll N, M, K, L;
vector<ll> E[200000];
bool used[200000];

ll dfs(ll v) {
  if(used[v]) return 0;
  used[v] = true;

  ll ret = v < N;
  REP(i, 0, E[v].size()) ret += dfs(E[v][i]);
  return ret;
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, N) {
    cin >> K;
    REP(j, 0, K) {
      cin >> L; L--;
      E[i].push_back(N + L);
      E[N + L].push_back(i);
    }
  }

  REP(i, 0, N + M) used[i] = false;
  cout << (dfs(0) == N ? "YES" : "NO") << endl;
}


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

#define fi first
#define se second
typedef pair<int,int> PII;

const long long  MOD = 1e9 + 7;

int n;
long long A, B, dpA[1<<17], dpB[1<<17], s[1<<17], cA[1<<17], cB[1<<17];

int main() {
    cin >> n >> A >> B;
    s[0] = -(1LL<<60);
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
        cA[i] = cA[i-1] + (s[i] < s[i-1] + A);
        cB[i] = cB[i-1] + (s[i] < s[i-1] + B);
    }
    dpA[1] = dpB[1] = 1;
    for (int i = 2, jA = 0, jB = 0; i <= n; i++) {
        while (s[jA+1] + A <= s[i]) jA++;
        if (jA == i-1) dpA[i] = (dpA[i-1] + dpB[i-1]) % MOD;
        else if (cB[i-1] - cB[jA+1] == 0) dpA[i] = dpB[jA+1];

        while (s[jB+1] + B <= s[i]) jB++;
        if (jB == i-1) dpB[i] = (dpA[i-1] + dpB[i-1]) % MOD;
        else if (cA[i-1] - cA[jB+1] == 0) dpB[i] = dpA[jB+1];
    }

    cout << (dpA[n] + dpB[n]) % MOD;
}


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

int max(int x, int y) {
    if (x >= y) return x;
    else return y;
}

int min(int x, int y) {
    if (x <= y) return x;
    else return y;
}

int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int ans;
    ans = min(b, d) - max(a, c);
    if (ans >= 0) printf("%d\n", ans);
    else printf("0\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
 
int main()
{
  int n;
  std::string s;
  std::cin >> n >> s;
  
  if(n < s.length())
  {
    std::cout << s.substr(0, n) << "...";
  }
  else
  {
    std::cout << s;
  }
  
  return 0;
}

Measured memory_bytes: 3576
N = int(input())
le = list(map(int, input().split()))

player = [0,0]
turn = 0
count = 0

while(1):
    count+=1
    mx = max(le)
    player[turn]+=mx
    le.remove(mx)
    if count==N:
        break
    if turn==0:
        turn=1
    else:
        turn=0


print(player[0]-player[1])


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::vec::*;
use std::cmp::*;
use std::iter::*;

fn main() {
    let n: u32 = read();

    let mut s0: String = read();
    let mut s: Vec<char> = Vec::new();

    for i in 0..n {
        let c = s0.pop().expect("");
        s.push(c);
    }

    let mut k = 0;
    for i in 1..n {
        let mut ki = 0;
        let (x, y) = s.split_at(i as usize);
        let mut xs = x.to_vec();
        let mut ys = y.to_vec();
        xs.sort();
        xs.dedup();
        ys.sort();
        ys.dedup();
        while xs.len() > 0 && ys.len() > 0 {
            if xs[0] == ys[0] {
                ki += 1;
                xs.remove(0);
                ys.remove(0);
            }
            else if xs[0] < ys[0] {
                xs.remove(0);
            }
            else {
                ys.remove(0);
            }
        }
        for j in 0..xs.len() {
            // print!("{}{} ", xs[j], ys[j]);
            if ys.len() <= j {break}
            if xs[j] == ys[j] {
                ki += 1;
            }
            else {
                break
            }
        }
        k = max(k, ki);
    }

    println!("{}", k);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };

int H, W;
vv<char> A;
queue<pair<int, int>> que;
vv<int> dist;

void bfs() {
    while (!que.empty()) {
        const auto p = que.front(); que.pop();

        for (int d = 0; d < 4; ++d) {
            int ny = p.first + dy[d];
            int nx = p.second + dx[d];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
            else if (A[ny][nx] == '.') {
                if (dist[p.first][p.second] + 1 < dist[ny][nx]) {
                    que.emplace(ny, nx);
                    dist[ny][nx] = dist[p.first][p.second] + 1;
                }
            }
            else if (dist[p.first][p.second] < dist[ny][nx]) {
                que.emplace(ny, nx);
                dist[ny][nx] = dist[p.first][p.second];

            }
        }
    }
}

int main() {
    cin >> H >> W;
    A = vvec<char>(H, W, 0);
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
        }
    }

    dist = vvec(H, W, INF);
    rep(i, H) {
        rep(j, W) {
            if (A[i][j] == '#') {
                que.emplace(i, j);
                dist[i][j] = 0;
            }
        }
    }
    bfs();

    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            chmax(ans, dist[i][j]);
        }
    }
    write(ans);
}

Measured memory_bytes: 13456
#include <cstdio>

int main() {
	int n, temp, min = 1000000, max = -1000000;
	long sum = 0;
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &temp);
		if (min > temp) min = temp;
		if (max < temp) max = temp;
		sum += temp;
	}

	printf("%d %d %ld\n", min, max, sum);
}

Measured memory_bytes: 1028
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

ll a[200005],b[200005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n,m,k;
	cin>>n>>m>>k;
	
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	for (int i = 0; i < m; ++i)
	{
		cin>>b[i];
	}
	for (int i = 1; i < n; ++i)
	{
		a[i]+=a[i-1];
	}
	for (int i = 1; i < m; ++i)
	{
		b[i]+=b[i-1];
	}
	ll count=0,ap=0,bp=0;
	for (int i = 0; i < n && a[i]<=k; ++i)
	{
		auto it= upper_bound(b,b+m, k-a[i]);
		bp=it-b;
		count=max(count, i+1+bp);
	}
	for (int i = 0; i < m && b[i]<=k; ++i)
	{
		auto it= upper_bound(a,a+n, k-b[i]);
		ap=it-a;
		count=max(count, i+1+ap);
	}


	cout<<count<<endl;

	return 0;
}


Measured memory_bytes: 6744
import math

a, b, c, d, e, f = map(int, input().split())

highest = 0
sugarwater = 0
maxsugar = 0
amax = math.ceil(f / (100 * a))
bmax = math.ceil(f / (100 * b))
cmax = math.ceil(30 * e / c)
dmax = math.ceil(30 * e / d)
for aa in range(amax):
    for bb in range(bmax):
        water = 100 * (aa * a + bb * b)
        if water == 0 or water > f:
            continue
        for cc in range(cmax):
            for dd in range(dmax):
                sugar = cc * c + dd * d
                if sugar / (water / 100) > e or water + sugar > f:
                    continue
                density = 100 * sugar / (water + sugar)
                if density >= highest:
                    highest = density
                    sugarwater = sugar + water
                    maxsugar = sugar
print(sugarwater, maxsugar)


Measured memory_bytes: 42220
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		String week[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int m = stdIn.nextInt();
			int d = stdIn.nextInt();
			if(m == 0 && d == 0)
			{
				break;
			}
			int sum = 0;
			for(int i = 1; i < m; ++i)
			{
				sum += days[i - 1];
			}
			sum += d - 1;
			System.out.println(week[sum % 7]);
		}
	}
}

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

int main(){
int N,K;
  cin>>N>>K;
  vector<int>l(N);
  for(int i=0; i<N; i++){
   cin>>l[i];
  }
  
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans=0;
  for(int i=0; i<K; i++){
   ans+=l[i];
  }
  cout<<ans<<endl;
}

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

int main() {
  int N; cin >> N;
  vector<long long> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);
  long long num = 0, one = 0;
  for (int i = 0; i < N; i++) {
    one += max(A.at(i) - B.at(i), 0LL);
    num += max((B.at(i) - A.at(i)) / 2, 0LL);
  }
  if (num >= one) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 384
n = int(input())
arr = [[0,0,0]]
flg = 0
for i in range(n):
  arr.append(list(map(int, input().split())))
  if arr[i+1][0]-arr[i][0] < arr[i+1][1] + arr[i+1][2] - arr[i][1] - arr[i][2] or (arr[i+1][0]-arr[i][0]) % 2 != (arr[i+1][1] + arr[i+1][2] - arr[i][1] - arr[i][2]) % 2:
    flg = 1
if flg == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 27300
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a,c,x,y;

void Compless(){
	vi A,B;
	for(int i=0;i<n;i++){
		if(x[i]!=inf) A.push_back(x[i]);
		if(y[i]!=inf) B.push_back(y[i]);
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	A.erase(unique(A.begin(),A.end()),A.end());
	B.erase(unique(B.begin(),B.end()),B.end());
	map<int,int> ma,mb;
	ma[inf]=inf;mb[inf]=inf;
	for(int i=0;i<A.size();i++) ma[A[i]]=i*2;
	for(int i=0;i<B.size();i++) mb[B[i]]=i*2;
	for(int i=0;i<n;i++) x[i]=ma[x[i]];
	for(int i=0;i<n;i++) y[i]=mb[y[i]];
}

int main(){
	cin>>n;
	a=c=vi(n,-1);
	x=y=vi(n,inf);
	int t=0;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		if(A==270) a[i]=1,t++;
	}
	if(n%2!=0||n/2-2!=t){
		cout<<-1<<endl;
		return 0;
	}
	int b[4],id=0,d=0,D=1;
	for(int i=0;i<n;i++){
		d+=a[i];
		D=(D+(a[i]==1?3:1))%4;
		c[i]=D;
		if(d==-1&&id<4) b[id++]=i,d=0;
	}
	for(int i=0;i<4;i++){
		x[b[i]]=(0<i&&i<3?2:0);
		y[b[i]]=(1<i?2:0);
	}
	for(int i=(b[0]+1)%n;i!=b[0];i=(i+1)%n) if(x[i]==inf){
		d=0;
		int j=i;
		while(1){
			d+=a[j];
			if(d==0) break;
			j=(j+1)%n;
		}
		int J=j;
		while(x[J]==inf) J=(J+1)%n;
		int I=(c[J]+(a[j]==a[J]?2:0))%4,cx=dx[I],cy=dy[I],I_=(c[J]+(a[J]==1?3:1))%4,cx_=dx[I_],cy_=dy[I_];
		x[i]=x[J]+cx_;y[i]=y[J]+cy_;
		x[j]=x[i]+cx;y[j]=y[i]+cy;
		x[J]+=cx;y[J]+=cy;
		Compless();
	}
	for(int i=0;i<n;i++) cout<<x[i]<<' '<<y[i]<<endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 10**9+7


def solve3():
    L = input()[:-1]
    # dp[smaller?][上からi桁目まで見た] = 何通りあるか?
    dp = [0]*2
    dp[0] = 1  # 0

    for c in L:
        tmp = [0]*2
        tmp[0] = (dp[0]*(int(c)+1)) % MOD
        tmp[1] = (dp[1]*3+dp[0]*int(c)) % MOD
        dp = tmp

    print(sum(dp) % MOD)


solve3()


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main() {
  int H, W;
  cin >> H >> W;
  string canvas[H];
  REP(i, H) {
    { cin >> canvas[i]; }
  }

  REP(i, H) {
    REP(j, W) {
      bool flag = false;
      if (canvas[i].at(j) == '#') {
        int x = i, y = j, nx, ny;
        REP(k, 4) {
          int nx = x + dx[k], ny = y + dy[k];
          if (0 <= nx && nx < H && 0 <= ny && ny < W &&
              canvas[nx].at(ny) == '#')
            flag = true;
        }
      } else
        flag = true;

      if (!flag) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}

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

int main()
{
    string str;
    int count[26];

    for(int i=0;i<26;i++){
        count[i]=0;
    }

    int j;

    cin >> str;

    for(int i=0;i<4;i++){
        char ch = (int)str[i] - 'A';
        count[ch]++;
    }

    int counter=0;
    for(int i=0;i<25;i++){
        //cout << i << ' ' << count[i] << endl;
        if(count[i]==2){
            counter++;
        }
    }

    if(counter == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256