akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    map<int, int> mp;
    int N;
    cin >> N;

    for(int i=0; i<N; i++){
        int a; cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        if((itr->second)%2 == 1) ans++;
    }

    cout << ans << endl;
}

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

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

  string ans = "No";
  for(int i = 0; i <= A; ++i) {
    int num = N - i;
    if(num % 500 == 0) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}

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


int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  int lower = max(a, c);
  int upper = min(b, d);
  printf("%d", max(0,upper-lower));
  return 0;
  
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n,h;cin>>n>>h;
  vector<ll> a(n),b(n);
    
  rep(i,n){
    cin>>a[i]>>b[i];
  }
  // 基本的にこいつで攻撃
  auto maxIt = max_element(all(a));
  // 投げつけるのは，
  ll ans=0;
  sort(all(b),greater<ll>());
  rep(i,n){
    if(*maxIt<b[i]){
      h-=b[i];
      ans++;
      if(h<=0){
        cout<<ans<<endl;
        return 0;
      }
    }
  }
  ans+=h/(*maxIt)+(h%(*maxIt)?1:0);
  cout<<ans<<endl;
  return 0;
}

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

int main() {
	int n; cin >> n;
	vector<char> s(n);	for (int i = 0; i < n; i++) { cin >> s[i]; }
	if (s.size() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}

	int mid = n / 2;
	for (int i = 0; i < mid; i++) {
		if (s[i] != s[mid + i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

struct Edge {
  int to;
  i64 cost;

  Edge(int _to, i64 _cost) : to(_to), cost(_cost) {}
};

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

  int n;
  cin >> n;
  vt<int> a(n), b(n), c(n);
  rep(i, 0, n) cin >> a[i] >> b[i] >> c[i];

  vvt<int> dp(n + 1, vt<int>(3, 0));
  rep(i, 0, n) {
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i];
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i];
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i];
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}


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

int main(){
    int n,x,t;cin>>n>>x>>t;
    int ans=1;
    int tmp=x;
    while(1){
        if(tmp>=n)break;
        tmp+=x;
        ans++;
    }
    cout<<ans*t<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 
#include <set>

using namespace std;

int n;
char s[100010];
long long counts[30];	//1~26
long long f[30][30];

const long long MOD = 1000000007;

int main()
{
	scanf("%d\n", &n);
	scanf("%s", s);
	
	for (int i = 0 ; i < n ; i++)
		counts[s[i] - 'a' + 1]++;
		
	for (int i = 1 ; i <= 26 ; i++)
		f[1][i] = counts[i];
		
	for (int i = 2 ; i <= 26 ; i++)
	{
		for (int j = i ; j <= 26 ; j++)
		{
			long long sum = 0;
			for (int k = 1 ; k < j ; k++)
				sum = (sum + (counts[j] * f[i - 1][k]) % MOD) % MOD;
			f[i][j] = sum;
		}
	}
	
	long long total = 0;
	for (int i = 1 ; i <= 26 ; i++)
		for (int j = 1 ; j <= 26 ; j++)
			total = (total + f[i][j]) % MOD;
	
	printf("%lld\n", total);
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        boolean[][] g = input();
        Boolean[] visited = new Boolean[g[0].length];
        Arrays.fill(visited,false);
        visited[0] = true;
        System.out.println(dfs(g,0,visited));
    }

    private static boolean[][] input(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[][] ret = new boolean[n][n];
        for(int i = 0; i < m;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            ret[a-1][b-1] = ret[b-1][a-1] = true;
        }
        sc.close();
        return ret;
    }

    private static int dfs(boolean[][] g, int s, Boolean[] bools){
        if(!Arrays.asList(bools).contains(false)){
            return 1;
        }
        int ans = 0;
        for(int i = 0; i < bools.length; i++){
            if(!g[s][i] || bools[i]) continue;
                bools[i] = true;
                ans += dfs(g,i,bools);
                bools[i] = false;
        }
        return ans;
    }
}

Measured memory_bytes: 23508
import collections
cd = collections.defaultdict
S = input()
N = len(S)
dp = cd(lambda: cd(int))
dp[0][0] = 1
dp[0][1] = -1
for i in range(1, N):
    l1 = dp[i - 1][1] + 1
    if not (i and S[i - 1] == S[i]):
        l1 = max(l1, dp[i - 1][0] + 1)
    dp[i][0] = l1
    if i:
        l2 = dp[i - 2][0] + 1
        if not (2 < i and S[i - 3:i - 1] == S[i - 1:i + 1]):
            l2 = max(l2, dp[i - 2][1] + 1)
        dp[i][1] = l2
print(max(dp[N - 1].values()))


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

#define M_PI        3.14159265358979323846264338327950288
using namespace std;
typedef long long ll;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double am = 2 * M_PI * m / 60;
    double ah = 2 * M_PI * (60 * h + m) / 720;
    double xh = a * sin(ah), yh = a * cos(ah);
    double xm = b * sin(am), ym = b * cos(am);
    double ans = sqrt(pow(xh - xm, 2) + pow(yh - ym, 2));
    printf("%.17g\n", ans);
}


Measured memory_bytes: 4100
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
#include <map>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
std::map<char, int> mp;

int main() {
  std::string s;
  std::cin >> s;
  for(int i = 0; i < s.size(); i++)
    mp[s[i]]++;

  if(0 < mp['N'] && 0 == mp['S'])
    std::cout << "No";
  else if(0 == mp['N'] && 0 < mp['S'])
    std::cout << "No";
  else if(0 < mp['E'] && 0 == mp['W'])
    std::cout << "No";
  else if(0 == mp['E'] && 0 < mp['W'])
    std::cout << "No";
  else
    std::cout << "Yes";
  return 0;
}


Measured memory_bytes: 3644
#include<string>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = -1 << 30;

int main() {
    int n, m;
    string s;
    cin >> n >> m >> s;
    string r(s);
    for (int i=0, x, y; i<m; i++) {
        cin >> x >> y;
        sort(s.begin() + x - 1, s.begin() + y, less<char>());
        sort(r.begin() + x - 1, r.begin() + y, greater<char>());
    }
    int pmin[n + 1] = { 0 }, pmax[n + 1] = { 0 };
    for (int i=1; i<=n; i++) {
        pmin[i] = pmin[i - 1] + (s[i - 1] == '1');
        pmax[i] = pmax[i - 1] + (r[i - 1] == '1');
    }
    int dp[n + 1][n + 1]; // dp[character][# of 1s]
    dp[0][0] = 1;
    fill(*dp + 1, *dp + n + 1, 0);
    int ones = count(s.begin(), s.end(), '1');
    for (int i=1; i<=n; i++) {
        for (int j=0; j<=ones; j++) {
            dp[i][j] = (pmin[i] <= j and j <= pmax[i])
                     ? (dp[i - 1][j] + 
                             (j ? dp[i - 1][j - 1] : 0)
                       ) % MOD : 0;
        }
    }
    cout << dp[n][ones] << endl;
    return 0;
}


Measured memory_bytes: 30592
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int d[]={0,1,-1};
#define piii pair<pii,int>
piii _pi(pii t,int h) {piii hoge; hoge.first=t; hoge.second=h; return hoge;}
int main(){
    int t,n;
    while(cin>>t>>n, t+n){
        map<pii,int>mp;
        rep(i,n){
            pii temp; cin>>temp.first>>temp.second;
            temp=pii(temp.first+300,temp.second+300);
            mp[temp]++;
        }
        pii s; cin>>s.first>>s.second;
        vvi visit(1001,vi(1001,INF));
        queue<pii>que;
        que.push(pii(s.first+300,s.second+300));
        visit[s.first+300][s.second+300]=0;
        int ans=1;
        while(!que.empty()){
            pii now=que.front(); que.pop();
            if(visit[now.first][now.second]+1>t)continue;
            rep(i,3)rep(j,3){
                if(d[i]+d[j]==0)continue;
                pii hoge=pii(now.first+d[i],now.second+d[j]);
                if(mp[hoge])continue;
                if(visit[hoge.first][hoge.second]==INF)ans++;
                else continue;
                if(visit[hoge.first][hoge.second]<visit[now.first][now.second]+1)continue;
                visit[hoge.first][hoge.second]=visit[now.first][now.second]+1;
                que.push(hoge);
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 7188
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String word = sc.next();
    if (String.valueOf(word.charAt(word.length()-1)).equals("s")) {
      System.out.println(word + "es");
    } else {
      System.out.println(word + "s");
    }
    sc.close();
  }
}


Measured memory_bytes: 38348
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		int[] A = na(N);
		boolean[] filter = new boolean[1000001];
		Arrays.sort(A);
		int result = 0;
		
		for(int i = 0; i < N; i++) {			
			int thisA = A[i];
			if(!filter[thisA]) {
				if(i < N -1 && A[i] == A[i + 1]) {
						filter[thisA] = true;
					} else {
						result++;
					}
			} else {
				continue;
			}
			
			int tmp = thisA;
			while(tmp <= 1000000) {
				filter[tmp] = true;
				tmp += thisA;
			}
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 48632
/*
 * DATE : 2017-07-29
 * Algo :
*/
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define FOR(I,A,B)              for(long long i=0; i < n ; i++ )
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
    register char c = getchar();x = 0;
    int neg = 0;
    for(; ((c<48 || c>57) && c != '-'); c = getchar());
    if(c=='-'){neg = 1;c = getchar();}
    for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 1001;
int n;
LL a[N], sum = 0;
LL k;
vector<LL> coin[N];
unordered_map<LL,bool> dp[N];

bool Find(int idx, LL k)
{
    if(idx == n) return k == 0;
    if(dp[idx].count(k)) return dp[idx][k];
    if(coin[idx].size() == 0) return dp[idx][k] = 0;
    bool ret = 0;
    for(int i = 0; i < coin[idx].size() && ret == 0; i ++ ){
        ret |= Find(idx + 1, k - coin[idx][i]);
    }
    return dp[idx][k]= ret;
}
bool solve(LL k)
{
    for(int i = 0; i < n;i ++) dp[i].clear();
    for(int i = 0;i < n;i ++) coin[i].clear();
    for(int  i = 0; i < n; i ++ ) {
        for(int j = 0; j < n; j ++ ) {
            LL nk = a[i] + k - j;
            if(nk >= 0 && nk % (n+1) == 0) {
                coin[i].push_back(nk / (n+1));
            }
        }
        //db(coin[i].size());
        //cout << coin[i][0] << endl;
    }
    if(Find(0,k)) {
            cout << k << endl;
        return 1;
    }
    return 0;
}
int main()
{
    cin >> n;
    LL sum = 0;
    for(int i =0 ;  i < n ;i ++) cin >> a[i], sum += a[i];

    for(int i = n*(n-1); i>= (n-1) ; i --)  {
        k = sum - i;
        if(solve(k)) {
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;
int n;

int main() {
    scanf("%d", &n);
    vector<vector<int>> h(n, vector<int>(3, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            scanf("%d", &h[i][j]);
        }
    }

    vector<vector<int>> dp(n, vector<int>(3, 0));
    for (int j = 0; j < 3; ++j) {
        dp[0][j] = h[0][j];
    }

    // dp[i][j] := maximum possible happiness until day i, with the last activity j
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + h[i][j]);
            }
        }
    }

    int ans = max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 14340
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	ll n;
	cin>>n;
	std::map<string, ll> m1;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin>>s;
		m1[s]++;
	}

	ll max1=-1;
	for (auto i = m1.begin(); i != m1.end(); ++i)
	{
		max1 = max(max1, i->S);
	}

	set<string> s1;
	for (auto i = m1.begin(); i != m1.end(); ++i)
	{
		if(i->S==max1){
			s1.insert(i->F);
		}
	}

	for (auto i = s1.begin(); i != s1.end(); ++i)
	{
		cout<<*i<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 33280
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll line = (ll)pow(10, 18);

int main(){
  ll N;
  cin >> N;
  vl A(N);
  rep(i, N) cin >> A[i];

  stable_sort(A.begin(), A.end());

  if(A[0] == 0){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  ll tmp;

  rep(i, N){
    if(ans > line / A[i]){
      cout << -1 << endl;
      return 0;
    }

    ans *= A[i];
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4324
s = input()
n = len(s)
ans = [0]*n
idx = 1
now = 'R'
for i in range(n):
    if i == n-1:
        # print(Ridx, aidx, idx)
        if now == 'R':
            Ridx = idx-1
            aidx = i-1
            # print(Ridx, aidx, idx)

        if idx % 2 == 1:  # 区間の長さが奇数
            if Ridx % 2 == 0:
                ans[aidx] = idx // 2
                ans[aidx+1] = idx // 2 + 1
            else:
                ans[aidx] = idx // 2 + 1
                ans[aidx+1] = idx // 2
            # print('6')
        else:
            ans[aidx] = idx // 2
            ans[aidx+1] = idx // 2
            # print('7', aidx, idx)  
        break
    if now == 'R' and now != s[i]:
        now = 'L'
        Ridx = idx-1
        aidx = i-1
        # print('!')
    if now == 'L' and now != s[i]:
        if idx % 2 == 0: # 区間の長さが奇数
            if Ridx % 2 == 0:
                ans[aidx] = (idx-1) // 2
                ans[aidx+1] = (idx-1) // 2 + 1
            else:
                ans[aidx] = (idx-1) // 2 + 1
                ans[aidx+1] = (idx-1) // 2
        else:
            ans[aidx] = (idx-1) // 2
            ans[aidx+1] = (idx-1) // 2
        # print(*ans, i, aidx)
        now = 'R'
        idx = 1
    idx += 1

print(*ans)


Measured memory_bytes: 6512
#include <stdio.h>
int main(void){
    int N, i, cnt = 1;
    int a[1000];
    
    scanf("%d", &N);
    
    for(i = 0; i < N; i++){
        scanf("%d\n", &a[i]);
    }
    
    for(i = 0; i < N; i++){
        if(a[i]%2 == 0){
            if(!(a[i]%3 == 0 || a[i]%5 == 0)){
                cnt = cnt - 1;
            }
        }
    }
    if(cnt  <= 0){
        printf("DENIED\n");
    }else{
        printf("APPROVED\n");
    }
}


Measured memory_bytes: 1652
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	string S;
	cin >> S;
	int ans = 0;
	for(int i = 0; i < S.size(); i++){
		if(S[i] != S[S.size() - 1 - i]){
			S[i] = S[S.size() - 1 - i];
			ans += 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	if (x <= y) {
		cout << min(min(a * x + b * y, c * 2 * y), c * 2 * x + b * (y - x)) << endl;
	}
	else cout << min(min(a * x + b * y, c * 2 * x), c * 2 * y + a * (x - y)) << endl;
	return 0;
}

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

using namespace std;


inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}


struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;

    UnionFind (int n = 1 ) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); siz.resize(n);
        for (int i = 0; i < n; i++) par[i] = i, rank[i] = 0, siz[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
            siz[y] += siz[x];
        }
        else {
            par[y] = x;
            siz[x] += siz[y];
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    int size(int x) {
        return siz[root(x)];
    }
};



long long COM(long long n, long long k) {
    long long mul = 1;
    long long div = 1;
    for (long long i = 0; i < k; i++) {
        mul = (mul * (n - i));
        div = (div * (i + 1));
    }
    return mul / div;
}


void solve() {
    int N, M; cin >> N >> M;
    vector<pair<int, int>> bridge(M);
    for (int i = 0; i < M; i++) {
        int A, B; cin >> A >> B; 
        A--; B--;
        bridge[i] = make_pair(A, B);
    }

    UnionFind uf(N);

    vector<long long> ans(M+1);

    ans[M] = COM(N, 2);

    for (int i = M-1; i >= 0; i--) {
        int A = bridge[i].first, B = bridge[i].second;
        
        //print(uf.size(A), uf.size(B));

        if (uf.same(A, B)) {
            ans[i] = ans[i+1];
        }
        else {
            ans[i] = ans[i+1] - uf.size(A) * uf.size(B);
        }
        
        uf.unite(A, B);
    }

    for (int i = 1; i < M+1; i++) cout << ans[i] << endl;
    
}


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

Measured memory_bytes: 5820
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    fastio;
    
    char c;
	cin >> c;
	cout << char(c + 1);
    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

L = [A, B, C, D, E]
M = [l // 10 * 10 if l % 10 == 0 else (l // 10 + 1) * 10 for l in L]
N = [l % 10 for l in L]
N = [n if n != 0 else 10 for n in N]

zipped = zip(L, M, N)
zipped = sorted(zipped, key=lambda x: [x[2]], reverse=False)
L, M, N   = map(list, zip(*zipped))

print(L[0] + sum(M[1:]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
V G[100010];
int N, M;
int ans;
int c[100010];

void s(int n)
{
    if (c[n])
        return;
    c[n] = 1;
    for (int i = 0; i < (int)G[n].size(); i++) {
        if (!c[G[n][i]])
            s(G[n][i]);
    }
}

void solve()
{
    FOR(i, 1, N + 1)
    {
        if (c[i] == 0) {
            s(i);
            ans++;
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin >> N >> M;
    FOR(i, 0, M)
    {
        int x, y, z;
        cin >> x >> y >> z;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    solve();
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int n;
struct edge{
    int to,cost;
};
vector<edge> g[100010];
vector<int> col(100010,-1);

void dfs(int v,int c){
    //cout << v << " " << c << endl;

    col[v] = c;
    rep(i,g[v].size()){
        if(col[g[v][i].to] == -1){
            if(g[v][i].cost % 2 == 0){
                dfs(g[v][i].to, c);
            }else{
                dfs(g[v][i].to, (c+1)%2);
            }
        }
    }
}

int main(){
    cin >> n;
    int u,v,w;
    rep(i,n-1){
        cin >> u >> v >> w;
        u--; v--;
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }
    rep(i,n){
        if(col[i] == -1){
            dfs(i,0);
        }
    }

    rep(i,n) cout << col[i] << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int colors[8] = {};
  int above_3200 = 0;

  for(int i = 0;i < N;i++){
    int a;
    cin >> a;
    if(a <= 399)colors[0] = 1;
    else if(a >= 400 && a <= 799)colors[1] = 1;
    else if(a >= 800 && a <= 1199)colors[2] = 1;
    else if(a >= 1200 && a <= 1599)colors[3] = 1;
    else if(a >= 1600 && a <= 1999)colors[4] = 1;
    else if(a >= 2000 && a <= 2399)colors[5] = 1;
    else if(a >= 2400 && a <= 2799)colors[6] = 1;
    else if(a >= 2800 && a <= 3199)colors[7] = 1;
    else if(a >= 3200)above_3200++;
  }

 int ans = 0;
  for(int i = 0;i < 8;i++)ans += colors[i];

  cout << max(1,ans) << " " << ans + above_3200 << endl;
}


Measured memory_bytes: 256
n,a,b = map(int, input().split())
M = 10**9 + 7
from math import factorial
from functools import reduce
A = pow(2,n,M) - 1

q = r = 1
for i in range(a):
    q = q * (n - i) %  M
for j in range(b):
    r = r * (n - j) %  M

B = q * pow(factorial(a), M - 2, M) % M
C = r * pow(factorial(b), M - 2, M) % M
print((A-B-C)%M)

Measured memory_bytes: 73436
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>

using namespace std;

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

int main() {
	long long int n;
	cin >> n;
	vector<long long int> v(n);
	for (long long int i = 0; i < n; i++) {
		cin >> v[i];
	}
	vector<P> pp;
	for (long long int i = 0; i < n; i++) {
		pp.push_back(P(v[i], i));
	}
	sort(pp.begin(), pp.end());
	set<long long int> st;
	long long int sum = 0;
	st.insert(-1);
	st.insert(n);
	for (long long int i = 0; i < n; i++) {
		st.insert(pp[i].second);
		set<long long int>::iterator ite = st.find(pp[i].second);
		set<long long int>::iterator item = ite;
		set<long long int>::iterator itep = ite;
		item--;
		itep++;
		//cout << *item << ' ' << *itep << endl;
		sum += (pp[i].second-(*item))*((*itep)-pp[i].second)*(i+1);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 14316
#include <bits/stdc++.h>
#define REP(i, n) REPI(i, 0, n)
#define REPI(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)

#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vector{
    double x, y;
};

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;
}
using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    uint count = 0;
    for(int i = 0; i < S.length() ; i++)
    {
        if (S[i] != T[i])
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3808
// 2011/05/25 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int y, m, d;
		cin >> y;
		if(cin.eof())
			break;
		cin >> m >> d;

		int ymd = y*10000+m*100+d;

		if(ymd<18680908)
			cout << "pre-meiji" << endl;
		else if(ymd<19120730)
			cout << "meiji " << y-1867 << " " << m << " " << d << endl;
		else if(ymd<19261225)
			cout << "taisho " << y-1911 << " " << m << " " << d << endl;
		else if(ymd<19890108)
			cout << "showa " << y-1925 << " " << m << " " << d << endl;
		else
			cout << "heisei " << y-1988 << " " << m << " " << d << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
int main(int argc, const char *argv[]) {
  long long n, a, b;
  cin >> n >> a >> b;
 
  if (a + b == 0) {
    cout << 0 << '\n';
    return 0;
  }
  
  long long ans = 0;
  ans += n / (a + b) * a;
  ans += min(a, n % (a + b));
  cout << ans << '\n';
  return 0;
}

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

public class Main{
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		ArrayList<Integer> N = new ArrayList<Integer>();

		while(N.size() < n){
			int l = sc.nextInt();
			N.add(l);
		}		

		Collections.sort(N);
		Collections.reverse(N);

		while(k>0){
			ans = ans + N.get(k-1);
			k = k-1;
		}


		System.out.print(ans);
		
		sc.close();
	}
}

Measured memory_bytes: 23764
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n = int(input().strip())
    v = []
    ra = 0
    rb = 0
    both = 0
    ans = 0
    for i in range(n):
        s = input().strip()
        for j in range(len(s)-1):
            if s[j] == 'A' and s[j+1] == 'B':
                ans += 1
        if s[0] != 'B' and s[-1] == 'A':
            ra += 1
        elif s[0] == 'B' and s[-1] != 'A':
            rb += 1
        elif s[0] == 'B' and s[-1] == 'A':
            both += 1

    if ra + rb == 0 and both > 0:
        ans += both - 1
    else:
        ans += min(ra+both, rb+both)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42352
package main

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

func main() {
	var N int
	var S string
	fmt.Scan(&N)
	var sc = bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		S = sc.Text()
	}
	a := make([]int, N)
	for i, v := range strings.Split(S, " ") {
		a[i], _ = strconv.Atoi(v)
	}
	sort.Ints(a)
	fmt.Println(a[len(a)-1] - a[0])
}


Measured memory_bytes: 640
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005

#define bs binary_search
#define lb lower_bound
#define ub upper_bound

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli a[3];
    cin>>a[1]>>a[2]>>a[0];
    sort(a,a+3);
    cout<<a[0]+a[1];
}


Measured memory_bytes: 256
a,b,c,d = map(int, input().split())
takahashi = 1
while True:
    if takahashi:
        c -= b
    else:
        a -= d
    takahashi = 1- takahashi 
    if c <= 0:
        print("Yes")
        exit()
    if a <= 0:
        print("No")
        exit()

Measured memory_bytes: 61780
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long n;
    cin>>n;
    map<long , long> m;
    long cnt = 0;
   // long arr[n];
    vector < long > arr;
    for(long i = 0 ; i < n; i++){
        long x;
        cin>>x;
        if(m[x]==0)
            arr.push_back(x);
        m[x]++;

    }
    long a = 0;
    for(long i = 0 ; i < arr.size(); i++){
        long u = arr[i];
        if(u == m[u])
            continue;
            else if(u < m[u])
                cnt += m[u] - u;
        else
            cnt += m[u];

    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 7028
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int a[1000000], n;

int main() {
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }

    int q, k, sum = 0;
    cin >> q;
    rep(i, q) {
        cin >> k;
        if(*lower_bound(a, a+n, k) == k) {
            sum++;
        }
    }

    cout << sum;

    cout << endl;
    return 0;
}


Measured memory_bytes: 3376
using System;
using System.Collections;

namespace ABC124_C
{
    class Program
    {
        static void Main(string[] args) {
            string s = Console.ReadLine();
            BitArray tilesBit = new BitArray(s.Length);

            for(int i = 0; i < s.Length; i++) {
                if (s.Substring(i, 1) == "1")
                    tilesBit[i] = true;
            }

            int drawCount = 0;
            for(int i = 0; i < s.Length - 1; i++) {
                bool nowTile = tilesBit[i];
                bool nextTile = tilesBit[i + 1];

                if (nowTile == nextTile) {
                    tilesBit[i + 1] = !tilesBit[i + 1];
                    int tileChangeCount = 1;
                    for (int j = i; j < s.Length - 1; j++) {
                        if (tilesBit[j] == tilesBit[j + 1]) {
                            tileChangeCount++;
                            tilesBit[j + 1] = !tilesBit[j + 1];
                        }
                    }
                    drawCount = tileChangeCount;
                    break;
                }
            }

            Console.WriteLine(drawCount);
        }
    }
}

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

int main(){
    int N;
    int Ws[100] = {0};
    cin >> N;
    int S1 = 0, S2 = 0;
    for(int i=0; i<N; i++){
        cin >> Ws[i];
        S2 += Ws[i];
    }
    S1 = Ws[0];
    S2 -= S1;
    int min = abs(S2-S1);
    for(int i=1;i<N-1;i++){
        S1 += Ws[i];
        S2 -= Ws[i];
        if(min >= abs(S2-S1)) min = abs(S2-S1);
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int n,k,q;
int a[100010];
int main(){
	scanf("%d%d%d",&n,&k,&q);
	rep(i,0,q){
		int t;
		scanf("%d",&t);
		a[t-1]++;
	}
	rep(i,0,n)puts(k-q+a[i]>0?"Yes":"No");
}

Measured memory_bytes: 896
{-# LANGUAGE OverloadedStrings, ViewPatterns #-}
import Data.List
import Data.Ord
import Data.Function 
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B 

main :: IO ()
main = B.getLine >>= main'
    where
        main' s = readLn >>= B.putStrLn . solve s 

-- |
-- >>> B.unpack $ solve (B.pack "aba") 4
-- "b"
-- >>> B.unpack $ solve (B.pack "atcoderandatcodeer") 5
-- "andat"
-- >>> B.unpack $ solve (B.pack "z") 1
-- "z"
solve :: B.ByteString -> Int -> B.ByteString 
solve ss k = dat . head . drop (k - 1) . S.toAscList $ generate S.empty ss
    where
        generate acc xxs@(B.uncons -> Just (_, xs)) = generate acc' xs
            where
                acc' = foldl' (flip S.insert) acc ys
                ys = map wrap . tail . B.inits $ B.take k xxs
        generate acc _ = acc 

newtype S = S { dat :: B.ByteString }
    deriving (Eq)

wrap :: B.ByteString -> S 
wrap = S 

instance Ord S where
    compare = cmp `on` dat

cmp :: B.ByteString -> B.ByteString -> Ordering
cmp (B.uncons -> Just (x, xs)) (B.uncons -> Just (y, ys)) = compare x y `mappend` cmp xs ys
cmp (B.uncons -> Just _) _ = GT
cmp _ (B.uncons -> Just _) = LT
cmp _ _ = EQ

Measured memory_bytes: 3708
A = []
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.sort(key=lambda x: x % 10)
ans = 0
isMin = True
for a in A:
  if a % 10 == 0:
    ans += a
  else:
    if isMin:
      ans += a
      isMin = False
    else:
      ans += a // 10 * 10 + 10
print(ans)

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

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

    int n;
    n = 5;

    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    int k;
    cin >> k;

    bool f = true;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(A[j] - A[i] <= k) continue;
            else{
                f = false;
                break;
            }
        }
    }

    if(f) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li l[1010];

int main() {
	li a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) {
		puts("Zero");
		return 0;
	}
	if (a > 0) {
		puts("Positive");
		return 0;
	}
	if ((a - b) % 2 == 0) {
		puts("Negative");
		return 0;
	}

	puts("Positive");


	return 0;
}

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

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

vector<long long> a(1,{1});
vector<long long> p(1,{1});

long gcd(long a, long b) {
 	if ( a % b == 0 ) return b;
 	return gcd(b, a%b);
 }

map<long, int> prime_factor(long n) {
    map< long, int > ret;
    for(long i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

void buger(int level){
    // cout << level << endl;
    if (level == 0) {
        a.push_back(a.back()+1);
        return;
    }
    a.push_back(a.back());
    buger(level-1);
    a.push_back(a.back()+1);
    buger(level-1);
    a.push_back(a.back());
}

long f(int n, long x){
    if (n == 0) {
        return x <= 0 ? 0 : 1;
    }else if(x <= 1+ a[n-1]){
        return f(n-1, x-1);
    }else{
        return p[n-1] + 1 + f(n-1, x-2-a[n-1]);
    }
}

int main () {
    int n;
    long x;
    cin >> n >> x;
    rep(i,n){
        a.push_back(a[i]*2 + 3);
        p.push_back(p[i]*2 + 1);
    }
    cout << f(n,x) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int res = 0;
  while(a > 0 && c > 0){
    c -= b;
    if(c <= 0){
      res = 1;
      break;
    }
    a -= d;
    if(d <= 0){
      res = 2;
      break;
    }
    //cout << c << " " << d << endl;
  }
  if(res == 1)cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

int main() {
 int a,b;
  cin>>a>>b;
  if(a>0) cout<<"Positive"<<endl;
  else if(a==0) cout<<"Zero"<<endl;
  else if(a<0&&b>=0) cout<<"Zero"<<endl;
  else {
    if((b-a+1)%2==0) cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
#define MAX 300000
bool sosu[MAX];
int main(){
  memset(sosu,1,MAX);
  for(int i=4;i<MAX;i+=2)sosu[i]=false;
  for(int i=3;i<MAX;i+=2)
    for(int j=i*3;j<MAX;j+=2*i)sosu[j]=false;

  int n;
  while(cin>>n,n){
    int co=0;
    loop(i,n+1,2*n+1)if(sosu[i])co++;
    cout<<co<<endl;
  }
}

Measured memory_bytes: 1464
N = int(input())
# 1.08で割る,小数点切り捨て
sp_n = int(N / 1.08)

if int(sp_n * 1.08) == N:
    print(sp_n)
elif int((sp_n+1) * 1.08) == N:
    print(sp_n + 1)
else:
    print(':(')


Measured memory_bytes: 2940