akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD = (int)1e9 + 7;
const int MX = (int)1e6 + 10;

void add_self(int &x, int y, int md = MOD){x += y; if(x >= md) x -= md;}
void sub_self(int &x, int y, int md = MOD){x -= y; if(x < 0) x += md;}
void mul_self(int &x, int y, int md = MOD){x = x * 1LL * y % md;}
inline int mul(int x, int y, int md = MOD){return x * 1LL * y % md;}
inline int add(int x, int y, int md = MOD){x += y; if(x >= md) x -= md; return x;}
inline int sub(int x, int y, int md = MOD){x -= y; if(x < 0) x += md; return x;}

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

vector<int> read(int n, int k){
	vector<int> vec(n);
	for(int i = 0; i < k; ++i) cin >> vec[i];
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for(int i = k; i < n; ++i)
		vec[i] = (a * 1ll * vec[i - 2] + b * 1ll * vec[i - 1] + c) % d;
	return vec;
}

void solve(){
	int n;
	cin >> n;
	
	std::vector<int> cnt(MX, 2);
	cnt[0] = 0, cnt[1]--;

	for(int i = 2; i < MX; ++i){
		for(int j = i + i; j < MX; j += i){
			cnt[j]++;
		}
	}

	ll res = 0;
	for(int c = 1; c < n; ++c){
		int N = n - c;
		res += cnt[N];
	}
	cout << res << "\n";
	return;
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	// freopen("input.in", "r", stdin);
	// freopen("output.out", "w", stdout);

	int t;
	t = 1;
	// cin >> t;
	// pre();
	for(int i = 1; i <= t; ++i){
		// cout << "Case #" << i << ": ";
		solve();
		// cout << '\n';
		// cout << endl;
	}

	return 0;
}

Measured memory_bytes: 7156
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
      try(Scanner sc = new Scanner(System.in)){
            int w =sc.nextInt();
            int n =sc.nextInt();
            int[] values = new int[w];

            for(int i = 0; i<values.length; i++){
                values[i] = i + 1;
            }
            for(int i = 0; i<n; i++){
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;

                int c = values[a];
                values[a] = values[b];
                values[b] = c;
            }
            for(int i = 0; i<w; i++){
                System.out.printf("%d\n", values[i]);
            }
      }
  }
}



Measured memory_bytes: 26212
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>a>>b>>c;
    if(a!=b && b!=c)
        cout<<b;
    else if(a!=b && a!=c)
    {
        cout<<a;
    }
    else
    {
        cout<<c;
    }
    
    
	
	return 0;
}
	

Measured memory_bytes: 256
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}

template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}

int main() {
  init();

  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> xy(M);
  cin >> xy;

  vvi path(100001, vi(0));
  vi in(N + 1, 0);

  rep(i, M) {
    path[xy[i].first].push_back(xy[i].second);
    in[xy[i].second]++;
  }

  deque<int> q;
  rep(i, 1, N + 1) if (in[i] == 0) q.push_back(i);

  vi dp(N + 1, 0);
  int ans = 0;
  while (!q.empty()) {
    int i = q.front();
    q.pop_front();
    for (int j : path[i]) {
      in[j]--;
      if (in[j] == 0) {
        q.push_back(j);
        chmax(dp[j], dp[i] + 1);
        chmax(ans, dp[j]);
      }
    }
  }
  out(ans);
}


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

int main() {
	int n;
	cin>>n;
	long long int h[n][3];
	for( int i=0; i<n; i++)
	{
	    cin>>h[i][0]>>h[i][1]>>h[i][2];
	}
	
	long long int dp[n][3];
	dp[n-1][0]=h[n-1][0];
	dp[n-1][1] = h[n-1][1];
	dp[n-1][2] = h[n-1][2];
	
	long long int answer;
	
	for( int i=n-2; i>=0; i--)
	{
	    dp[i][0]=h[i][0] + max(dp[i+1][1],dp[i+1][2]);
	    dp[i][1]=h[i][1] + max(dp[i+1][0],dp[i+1][2]);
	    dp[i][2]=h[i][2] + max(dp[i+1][1],dp[i+1][0]);
	}
	
	answer = max(dp[0][0], max(dp[0][1],dp[0][2]));
	
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main(){
    int N,K,P,i;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d %d",&K,&P);
        if(K%P==0){
            printf("%d\n",P);
        }else{
            printf("%d\n",K%P);
        }
    }
    return 0;
}


Measured memory_bytes: 2132
N = int(input())
As = []
Bs = []

for _ in range(N):
  a,b = map(int,input().split())
  As.append(a)
  Bs.append(b)
  
As.sort()
Bs.sort()

if N%2 == 1:
  ma = As[N//2]
  mb = Bs[N//2]
  print(mb-ma+1)
else:
  ma = (As[N//2-1] + As[N//2])/2
  mb = (Bs[N//2-1] + Bs[N//2])/2
  print(int((mb-ma)*2)+1)

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

namespace program
{
    class Program
    {
        static void Main()
        {
            int[] input = Input.ScanIntArray();
          Array.Sort(input);
          if(input[0]==5 && input[1] ==5 && input[2] ==7) Console.WriteLine("YES");
          else Console.WriteLine("NO");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n;
	cin >> n;
	n %= 10;
	switch (n) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon\n";
		break;
	case 3:
		cout << "bon\n";
		break;
	default:
		cout << "pon\n";
	}
}


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

int main(){
   string s;
   cin >> s;
   if(((s[0]==s[1]) && (s[1] == s[2])) || ((s[1] == s[2]) && (s[2] == s[3]))){
      cout << "Yes";
   }else{
      cout << "No";
   }
   return 0;
}

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

using namespace std;

int main()
{
    ll nr,mx,j;
    cin >> nr>>mx;
    ll pr = 2,ans=1;
    ll ff = mx / nr;
    while(ff >= 1){
        if(mx%ff==0){
            cout<<ff<<endl;
            return 0;
        }
        ff--;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int e = sc.nextInt();
		int s = sc.nextInt();
		int d = sc.nextInt();
		int f = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		System.out.println(f-a>k ? ":(" : "Yay!");
	}
}

Measured memory_bytes: 23252
import math
a = list(map(int,input().split()))
b = a[2] * 30 + a[3]/2
c = a[3]*6
d = math.sqrt(a[0]**2 + a[1]**2 - 2*a[0]*a[1]*math.cos(math.radians((abs(b-c)))))
print(d)

Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << " " << x << endl;
#define ll long long
ll pows[100005];
string s;
ll n;
ll dp[100005][15];
ll m = 1000000007;
ll call(ll pos,ll pre)
{
	if(pos == n)
		{
			if(pre == 5)
				return 1;
			else 
			return 0;
		}
	if(dp[pos][pre]!=-1)return dp[pos][pre];
	ll ret = 0;
	if(s[pos]=='?')
	for(ll i=0;i<=9;i++)
	{
		ll spre = (pre+i*pows[pos])%13;
		ret += call(pos+1,spre);
	}
	else
		ret = call(pos+1,pre);
	return dp[pos][pre] = ret%m;
}
int main()
{
	memset(dp,-1,sizeof dp);
	ll p = 1;
	for(ll i=0;i<=100000;i++)pows[i] = p%13,p*=10,p%=13;
	cin >> s;
	n = s.size();
	reverse(s.begin(),s.end());
	ll pre = 0;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]!='?')
			pre = (pre+(s[i]-'0')*pows[i])%13; 
	}
	cout << call(0,pre) << endl;
}

Measured memory_bytes: 19200
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
//#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

string alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

int na = 62;
int L = 128;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>> pq;
    vector<int> cnt(na);
    int sum = 0;
    rep(i, na) {
        string s = "";
        rep(j, L) s += alp[i];
        cout << "? " << s << endl;
        int a;
        cin >> a;
        cnt[i] = L - a;
        sum += L - a;
    }
    rep(i, na) {
        string t = "";
        rep(j, cnt[i]) t += alp[i];
        if(cnt[i] > 0) pq.push(mp(t.size(), t));
    }
    while(pq.size() > 1) {
        string s = pq.top().second; pq.pop();
        string t = pq.top().second; pq.pop();
        string u = s;
        int cur = 0;
        rep(i, t.size()) {
            rep(j, cur, u.size() + 1) {
                string v = u.substr(0, j) + t[i] + u.substr(j, u.size() - j);
                cout << "? " << v << endl;
                int c;
                cin >> c;
                if (c == sum - v.size()) {
                    u = v;
                    cur = j + 1;
                    break;
                }
            }
        }
        pq.push(mp(u.size(), u));
    }
    
    cout << "! " << pq.top().second << endl;
    
    
    return 0;
}


Measured memory_bytes: 3744
while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0):
        break
    cnt = 0
    for a in range(1, n-1):
        for b in range(a+1, n):
            for c in range(b+1, n+1):
                if a + b + c == x:
                    cnt += 1

    print(cnt)


Measured memory_bytes: 5600
import java.util.*;

/**
 * Created by khrom on 2017/06/15.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<Integer> numList = new ArrayList<>();
        for (int i = 0; i < n; i++)
            numList.add(scanner.nextInt());
        Collections.sort(numList);
        long sum = 0;
        for (Integer integer : numList)
            sum += integer;
        System.out.println(numList.get(0) + " " + numList.get(numList.size() - 1) + " " + sum);
    }
}

Measured memory_bytes: 41032
N = int(input())
src = list(map(int,input().split()))
S = sum(src)
M = N*(N+1)//2

if S%M:
    print('NO')
    exit()

K = S//M
mem = [src[i+1] - src[i] - K for i in range(N-1)]
mem.append(src[0] - src[N-1] - K)

print('YES' if all(map(lambda x:x<=0 and x%N==0, mem)) else 'NO')

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

int main() {
	int N, H, W, A, B, count = 0;
	cin >> N >> H >> W;
	for (int i = 0; i < N; i++) {
		cin >> A >> B;
		if (A >= H && B >= W) count++;
	}
	cout << count << endl;
}

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

typedef long long ll;

int main(void){
    string word="MARCH";
    
    ll num[5]={0};
    
    int N;
    cin>>N;
    
    string X;
    
    for(int i=0;i<N;i++){
        cin>>X;
        if(word.find(X[0])!=-1){
            num[word.find(X[0])]++;
        }
    }
    
    ll sum=0;
    
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                sum+=num[i]*num[j]*num[k];
            }
        }
    }
    
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
const  long INF = 1e9;
const  long MOD = 1e9 + 7;
#define repi(i,n,init) for(int i=init;i<int(n);i++)

int main()
{
    double t,x;
    cin >> t >> x;
    cout << fixed << setprecision(10) << t/x << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
MOD = 10**9 + 7
arr = np.arange(0, N + 1)
# print(arr[-K:], arr[:K])
_max = arr[-K:].sum()
_min = arr[:K].sum()
# print('_max, _min', _max, _min)
ans = _max - _min + 1
for k in range(K, N + 1):
    # print('k, arr[-k], arr[k]', k, arr[-(k + 1)], arr[k])
    _max += arr[-(k + 1)]
    _min += arr[k]
    # print('_max, _min', _max, _min)
    ans += _max - _min + 1
    ans = ans % MOD
print(ans)


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

int n, m;
string s;

int main(){
  cin >> n >> m >> s;
  
  vector<int> res(0);
  bool flag = true;
  int pos = n;
  while(pos){
    bool nukeru = false;
    
    for(int i = m; i >= 0; i--){
      //cerr << i <<" ";
      if(i == 0){
        nukeru = true;
        flag = false;
      }
      if(i > pos){
        continue;
      }
      int num = s.at(pos - i) - '0';
      if(num == 0){
        pos -= i;
        res.push_back(i);
        break;
      }
    }//cerr << endl;
    
    if(nukeru){
      break;
    }
  }
  reverse(res.begin(), res.end());
  if(flag){
    for(int x : res){
      cout << x << endl;
    }
  }else{
    cout << -1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A[i]=a-i-1;
  }
  sort(A.begin(),A.end());
  int mid=A[N/2];
  ll ans=0ll;
  for(int i=0;i<N;i++){
    ans += abs(A[i]-mid);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) range(i,0,b)
#define rangei(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) rangei(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T>
ostream & operator << (ostream &os, tuple<T...> const &t){
    _ot<0>(os, t); return os;
}
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // #define endl '\n'
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,l+n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;
int const inf = numeric_limits<int>::max()/8;

const int MAX_D = 100010;
const int MAX_C = 30;

double dp[MAX_D][MAX_C]; // i日目にj回連続で得る確率
double ans[MAX_D];


int main(){
    memset(dp,0,sizeof(dp));
    memset(ans,0,sizeof(ans));
    dp[1][1] = 1;
    for(int i = 1; i < MAX_D; i++){
        double p = 1;
        double today = 0;
        for(int j = 1; j < MAX_C; j++){
            today += dp[i][j]*p;
            dp[i+1][j+1] += dp[i][j] * p;
            dp[i+1][1] += dp[i][j] * (1-p);
            p /= 2;
        }
        ans[i] = today + ans[i-1];
    }
    int n;
    while(scanf("%d", &n), n != 0){
        printf("%.10lf\n", ans[n]);
    }
}

Measured memory_bytes: 25432
N = int(input())
S = input()
 
num_E, num_W = 0, 0
# num_E_list = [0] * (N + 1)
# num_W_list = [0] * (N + 1)
min_sum_operation = N
argmin_i = 0
for i, c in enumerate(S):
    if i == 0:
        # This operation is safe because N is larger than 2
        right = S[i + 1:]
        num_E = right.count('E')
        num_W += 1 if c == 'W' else 0
        # num_E_list[i] = num_E
        # num_W_list[i] = num_W
    elif c == 'W':
        num_W += 1
        # num_W_list[i + 1] = num_W
    elif c == 'E':
        num_E -= 1
        # num_E_list[i] = num_E
    if min_sum_operation > num_E + num_W:
        min_sum_operation = min(min_sum_operation, num_E + num_W)
        argmin_i = i
 
    # print(min_sum_operation, num_E, num_W)
 
if argmin_i == 0:
    print(min_sum_operation - 1)
else:
    print(min_sum_operation)

Measured memory_bytes: 3828
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int K[100], S[100][100], P[100];
signed main() {
  int N, M;
  cin>>N>>M;
  for (int i = 0; i < M; i++) {
    cin>>K[i];
    for (int j = 0; j < K[i]; j++) {
      cin>>S[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    cin>>P[i];
  }
  
  int ans = 0;
  //for (int i = 0; i < (int)pow(2,N); i++) { //same as below
  for (int i = 0; i < (1<<N); i++) {
    int s = 0;
    for (int j = 0; j < M; j++) {
      int sum = 0;
      for (int k = 0; k < K[j]; k++) {
        if ((1<<(S[j][k]-1)) & i) sum++;
      }
      if (sum % 2 == P[j]) s++;
    }
    if (s == M) ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
N, A, B, C, D = [int(i) for i in input().split()]
S = input()

def solve():
    ac, bd = S[A - 1:C], S[B - 1:D]
    if A < B < D < C:
        bd = S[B - 2:D + 1]
        return ("..." in bd and "##" not in ac)
    else:
        return ("##" not in ac and "##" not in bd)

if solve():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int H, W;
  cin >> H >> W;
  long long ans = INT64_MAX;

  rep(cnt, 2)
  {
    FOR(i, 1, W - 1)
    {
      long long w1 = i;
      long long w2 = W - w1;
      long long h1 = H / 2;
      long long h2 = H - h1;
      long long S_max = max({w1 * H, w2 * h1, w2 * h2});
      long long S_min = min({w1 * H, w2 * h1, w2 * h2});
      ans = min(ans, S_max - S_min);
    }

    FOR(i, 1, W - 1)
    {
      long long w1 = i;
      long long w2 = (W - w1) / 2;
      long long w3 = W - w1 - w2;
      long long S_max = max({w1 * H, w2 * H, w3 * H});
      long long S_min = min({w1 * H, w2 * H, w3 * H});
      ans = min(ans, S_max - S_min);
    }

    swap(H, W);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    power = 1
    for i in range(1, N + 1):
        power = (i * power) % (10 ** 9 + 7)
    return power


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Measured memory_bytes: 3060
// ===========================================
// 20.03.12 Atcdoer DP まとめコンテスト. E - Knapsack 2 (knapsack dp)
// 
// 
// ===========================================
/*
N個の品物があります。 品物には 1,2,…,N と番号が振られています。 各 i
i(1≤i≤N1≤i≤N) について、品物 ii の重さは wi で、価値は vi です。

太郎君は、N 個の品物のうちいくつかを選び、ナップサックに入れて持ち帰ることにしました。 
ナップサックの容量は W であり、持ち帰る品物の重さの総和は W 以下でなければなりません。

太郎君が持ち帰る品物の価値の総和の最大値を求めてください。

1 <= w <- 10e9
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=1; i<=n; i++)
#define rez(i,n) for(int i = 0; i<n; i++)
#define ET "\n"
#define CLR(arr) memset(&arr, 0, sizeof(arr))
#define PAIR pair<int, int>
const ll INF = 1LL << 50;
const int mini = 10e5+5;



int main(){
    
    int n; cin >> n;
    int maxWght; cin >> maxWght;
    
    
    int w[n+1];
    int v[n+1];
    rep(i,n) cin >> w[i] >> v[i];
    
    int maxVal = n*3020;
    ll dp[maxVal+1];
    fill(dp, dp+maxVal+1, INF);
    dp[0] = 0;
    
    for(int i=1; i<=n; i++){
        for(int j=maxVal; j-v[i]>=0; j--){
            dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
        }
    }
    
    ll ans = 0;
    for(int i=1; i<=maxVal; i++){
        if(dp[i] <= maxWght) ans = max(ans, (ll)i);
    }
    cout << ans;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;}
#define in hmt()
#define ins ({string x;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) x+=c;x;})
#define forinc(i,a,b) for(int i=a,_b=b;i<=_b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forb(i,BS) for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i))
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
const int N=1e5+2;
int sum[N],Sum[N],q,n,m;
string s,t;
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	//freopen("F.inp","r",stdin);
	string s,t;
	cin>>s>>t>>q;
	n=s.size(),m=t.size();
	s=' '+s;
	t=' '+t;
	forinc(i,1,n) sum[i]=sum[i-1]+(s[i]-'A'+1);
	forinc(i,1,m) Sum[i]=Sum[i-1]+(t[i]-'A'+1);
	while(q--)
    {
        int i,j,k,l;
		cin>>i>>j>>k>>l;
		if((sum[j]-sum[i-1])%3==(Sum[l]-Sum[k-1])%3) cout<<"YES\n";
		else cout<<"NO\n";
	}
}


Measured memory_bytes: 1644
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
#include <iomanip>
#include <limits>
#include <type_traits>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main()
{
    ll A, B;
    ll C, D;
    cin >> A >> B >> C >> D;

    ll number = B - A + 1;
    ll GCD = euclidean_gcd(C, D);
    ll LCM = C*D/GCD;
    // cout << LCM << endl;
    ll C_min, C_max, D_min, D_max, LCM_min, LCM_max;
    C_min = (A+(C-1)) / C;
    C_max = B / C;
    D_min = (A+(D-1)) / D;
    D_max = B / D;
    LCM_min = (A+(LCM-1)) / LCM;
    LCM_max = B / LCM;

    cout << number - (C_max - C_min + 1) - (D_max - D_min + 1) + (LCM_max - LCM_min + 1) << endl;
}

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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;


int main(){
  ll x,y,z;
  //string s;
  cin >> x >> y >> z;
  
  cout << z  <<" "<< x <<" " << y << endl;
}



Measured memory_bytes: 256
//
// Created on 2020/05/02.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

long long ans = 0;

void search(vector<int> a,int cnt,int n,int now,int m,vector<vector <int> >q_d){
    a[cnt] = now;
    if(cnt == n - 1){
        long long temp = 0;
        for (int i = 0; i < q_d.size(); ++i) {
            if(a[q_d[i][1] - 1] - a[q_d[i][0] - 1] == q_d[i][2]){
                temp += q_d[i][3];
            }
        }
        ans = max(temp,ans);

    }else{
    for (int i = now ; i <= m; ++i) {
        search(a,cnt+1,n,i,m,q_d);
    }
    }
}

int main() {

    int n,m,q;
    cin>>n>>m>>q;

    vector<vector <int > > Q (q,vector<int >(4));
    for (int i = 0; i < q; ++i) {
        cin>>Q[i][0]>>Q[i][1]>>Q[i][2]>>Q[i][3];
    }
    vector<int>A(n);
    for (int j = 1; j <= m; ++j) {
        search(A,0,n,j,m,Q);
    }

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


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> vec;
    for(int i = 0; i < 2*n; i ++) {
        int x;
        cin >> x;
        vec.push_back(x);
    }
    sort(vec.begin(), vec.end());
    int sum = 0;
    for(int i = 0; i < 2*n; i +=2) sum += vec[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
def main():
    length, repeat = map(int, input().split())
    sequence = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    base_inversion = 0
    inter_inversion = 0
    count = [0] * 2001
    for i in range(length):
        count[sequence[i]] += 1
        for j in range(i + 1, length):
            if sequence[i] > sequence[j]:
                base_inversion += 1
    for i in range(length):
        inter_inversion += sum(count[:sequence[i]])
    print((base_inversion * repeat + inter_inversion * repeat * (repeat - 1) // 2) % mod)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 1;

        if(x >= 4){
            for(int i=2; i*i <= x; i++)
            {
                int j=1;
                double num = 1;
                while(num <= x){
                    j++;
                    num = Math.pow(i, j);
                }
                num = num/i;
                if(num > ans && num <= x){
                    ans = (int)(num);
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21076
#include <stdio.h>
#include <math.h>

int main(){
  int i,j,t,num,m,cnt=0;

  scanf("%d",&num);
  for(i=0;i<num;i++){
    t=0;
    scanf("%d",&m);
    for(j=2;j<=sqrt(m);j++){
      if(m%j==0)t=1;
    }
    if(t==0)cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}




Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a) printf("%lld\n",a)
using namespace std;


int main()
{
    char c;
    cin>>c;
    if(isupper(c))
    {
        cout<<"A";
    }
    else
        cout<<"a";
}



Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
struct Point{
    int x, y;
    Point() {x = y = -1;}
    Point(int x, int y): x(x), y(y) {}
    bool operator== (const Point &p) const { return x == p.x && y == p.y; }
    bool operator!= (const Point &p) const { return x != p.x || y != p.y; }
    bool operator< (const Point &p) const { return x == p.x ? y < p.y : x < p.x;}
};
Point hasi[2];
typedef pair<int, int> pint;
int fld[33][33];
int h, w, s, sum;
pint dp[33][33][33][33];//dp[i][j][k][l] := (j, i) ????????? (l, k) ?????????(????????????)???????????¢?????????????????´????????°
pint dfs(Point a, Point b){
    if(a < hasi[0] || hasi[1] < a || b < hasi[0] || hasi[1] < b) return pint(0, 0);
    if(dp[a.y][a.x][b.y][b.x] != pint(-1, -1)) return dp[a.y][a.x][b.y][b.x];
    int bubunwa = 0;
    REP(i, a.y, b.y)
      REP(j, a.x, b.x)
        bubunwa += fld[i][j];
    if(sum - bubunwa > s)
      return dp[a.y][a.x][b.y][b.x] = pint(0, s - (sum - bubunwa));
    pint res(1, s - (sum - bubunwa));
    REP(i, a.x + 1, b.x){
        pint temp1 = dfs(a, Point(i, b.y)), temp2 = dfs(Point(i, a.y), b);
        pint temp(temp1.first + temp2.first, min(temp1.second, temp2.second));
        res = max(temp, res);
    }
    REP(i, a.y + 1, b.y){
        pint temp1 = dfs(a, Point(b.x, i)), temp2 = dfs(Point(a.x, i), b);
        pint temp(temp1.first + temp2.first, min(temp1.second, temp2.second));
        res = max(temp, res);
    }
    return dp[a.y][a.x][b.y][b.x] = res;
}

int main(){
    while(scanf("%d%d%d", &h, &w, &s) && h){
        sum = 0;
        rep(i, h) rep(j, w){
            scanf("%d", &fld[i][j]);
            sum += fld[i][j];
        }
        rep(i, 33) rep(j, 33) rep(k, 33) rep(l, 33) dp[i][j][k][l] = pint(-1, -1);
        hasi[0] = Point(0, 0);
        hasi[1] = Point(w, h);
        pint ans = dfs(Point(0, 0), Point(w, h));
        printf("%d %d\n", ans.first, ans.second);
    }
    return 0;
}

Measured memory_bytes: 12396
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>
#include <unordered_set>

using namespace std;
using ll = long long;
const int BIG = 100000007;


int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n,0);
    vector<ll> c(n,0);

    for(ll i = 0;i < n;++i){
        cin >> p[i];
        --p[i];
    }

    for(ll i = 0;i < n;++i){
        cin >> c[i];
    }



    vector<vector<ll>> cloop;
    vector<ll> countedvec(n,0);
    for(ll i = 0;i < n;++i){
        if(countedvec[i] > 0)continue;
       // cout << "new loop:i = " << i << endl;
        vector<ll> loop;
        countedvec[i] = 1;
        loop.push_back(c[i]);

        ll genesis = i;
        ll next = p[i];
        while(next != genesis){
            //cout << next << endl;
            loop.push_back(c[next]);
            countedvec[next] = 1;
            next = p[next];
        }
        cloop.push_back(loop);
    }

    ll mx = LLONG_MIN;
    for(ll l = 0;l < cloop.size();++l){
        ll siz = cloop[l].size();
        ll lsum = 0;

       // cout << "l = " << l << ",sum = " << lsum << ",size =" << siz << endl;

        for(ll i = 0;i < siz;++i){
           // cout << "i = " << i << ",val = " << cloop[l][i] << endl;
            lsum += cloop[l][i];
        }

        vector<ll> maxes(siz,LLONG_MIN);

        for(ll i = 0;i < siz;++i){
            ll t = 0;

            for(ll j = 0;j < siz;++j){
                t += cloop[l][(i + j) % siz];
              //  cout << "i = " << i << ",j = " << j << ",t = " << t << endl;
                if(t > maxes[j])maxes[j] = t;
            }
        }

        ll mmx = LLONG_MIN;

        if(k >= siz){
            for(ll i = 0;i < siz;++i){
                //cout << "i = " << i << ",max = " << maxes[i] << endl;
                if(lsum > 0) {
                    //cout << "loop detected" << endl;
                    ll t = maxes[i] + lsum * ((k - i - 1) / siz);
                    if(t > mmx)mmx = t;
                }
                else{
                    if(maxes[i] > mmx)mmx = maxes[i];
                }
            }
        }
        else{
            for(ll i = 0;i < k;++i){
                if(maxes[i] > mmx)mmx = maxes[i];
            }

        }



        if(mmx > mx)mx = mmx;
    }

    cout << mx << endl;
}




Measured memory_bytes: 3380
# -*- coding:utf-8 -*-
from fractions import gcd

def lcm(a, b):
    """ aとbの最小公倍数を返す """
    return a*b // gcd(a, b)

def solve():
    A, B = list(map(int, input().split()))

    print(lcm(A, B))

if __name__ == "__main__":
    solve()


Measured memory_bytes: 5048
'use strict';
const main = arg => {
  const input = arg.trim().split('\n');
  const input1 = input[0].split(' ').map(n => parseInt(n, 10));
  const input2 = input[1].split(' ').map(n => parseInt(n, 10));

  const days = input1[0];
  const works = input1[1];

  const add = (a, b) => {
    return a + b
  };

  const daysToFinish = input2.reduce((a, x) => add(a, x));
  const answer = days - daysToFinish >= 0
    ? days - daysToFinish
    : -1 ;

  console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		List<Integer> l = new ArrayList<Integer>();
		List<Integer> check = new ArrayList<Integer>();
		for(int i=0;i<3;i++) {
			l.add(sc.nextInt());
		}
		check.add(5);
		check.add(5);
		check.add(7);
		Collections.sort(l);
		Collections.sort(check);
	//	System.out.println(l);
	//	System.out.println(check);
		String ans = "NO";
		if(l.get(0)==check.get(0)) {
			if(l.get(1)==check.get(1)) {
				if(l.get(2)==check.get(2)) {
					ans = "YES";
				}
			}
		}
		System.out.println(ans);
	}
}

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

int main(){
  int n,y;cin>>n>>y;
  int a,b,c;
  rep(i,n+1){
    rep(j,n-i+1){
      if(y==10000*i+5000*j+1000*(n-i-j)){
        cout<<i<<" "<<j<<" "<<n-i-j;
        return 0;
      }
    }
  }      
  cout<<-1<<" "<<-1<<" "<<-1;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int count=0;
  
  for (int i = 0; i<=s.length(); i++)
  {
    if(s[i]!=t[i])
    {
      count ++;
    }
  }
  cout<<count;
  return 0;
}

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

double minkovsky(int a[],int b[],int n,double p){
    double sum = 0.0;
    for(int i=0;i<n;i++){
        sum += pow(abs(a[i] - b[i]),p);
    }
    return pow(sum,1/p);
}

double minkovsky_max(int a[],int b[],int n){
    double sum[n],max = 0;
    for(int i=0;i<n;i++){
        if(max < abs(a[i] - b[i])){
            max = abs(a[i] - b[i]);
        }
    }
    return max;
}

int main(){

    int n;
    cin >> n;
    int x[n],y[n];
    for(int i= 0;i<n;i++){
        cin >> x[i];
    }
     for(int i= 0;i<n;i++){
        cin >> y[i];
    }


    cout << fixed << minkovsky(x,y,n,1) << endl;
    cout << fixed << minkovsky(x,y,n,2) << endl;
    cout << fixed << minkovsky(x,y,n,3) << endl;
    cout << fixed << minkovsky_max(x,y,n) << endl;
}


Measured memory_bytes: 3424
import collections

n=int(input())
string_list=[input() for i in range(3)]

a = string_list[0]
b = string_list[1]
c = string_list[2]

ans = 0
for ac, bc, cc in zip(a, b, c):
    tmp = ac+bc+cc
    c = collections.Counter(tmp)
    ans += 3 - c.most_common()[0][1]

print(ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n; cin >> n;
    vector<pair<string, int>> playlist;
    for (int i = 0; i < n; ++i) {
        string s;
        int t;
        cin >> s >> t;
        playlist.emplace_back(s, t);
    }
    string x; cin >> x;
    int ans = 0;
    bool found = false;
    for (int i = 0; i < n; ++i) {
        if (found) {
            ans += playlist[i].second;
        }
        else {
            if (playlist[i].first == x) found = true;
        }
    }

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

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

using namespace std;

struct cards
{
	int num = 0;
	char mrk = 'D';
	int idx = 0;
};

int partition(vector<cards>& ary, int p, int r) {
	cards x, sw;
	int  i = 0;
	x = ary[r];
	i = p - 1;

	for (int j = p;j < r;j++) {
		if (ary[j].num <= x.num) {
			i = i + 1;
			sw = ary[i];
			ary[i] = ary[j];
			ary[j] = sw;
		}
	}
	sw = ary[i + 1];
	ary[i + 1] = ary[r];
	ary[r] = sw;
	return i + 1;
}

void quickSort(vector<cards>& ary, int p, int r) {
	int q = 0;
	if (p < r) {
		q = partition(ary, p, r);
		quickSort(ary, p, q - 1);
		quickSort(ary, q + 1, r);
	}
	return;
}

int main() {

	int n = 0, cnt = 0, mid = 0;
	cin >> n;
	vector<cards> ary(n);

	for (int i = 0;i < n;i++) {
		cards crd;
		cin >> crd.mrk >> crd.num;
		crd.idx = i;

		ary[i] = crd;
	}

	quickSort(ary, 0, n - 1);
	bool stable = true;
	for (int i = 0;i < n - 1;i++) {
		if (ary[i].num == ary[i + 1].num && ary[i].idx > ary[i + 1].idx) stable = false;
	}

	if (stable)		cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	for (int i = 0;i < n;i++) {

		cout << ary[i].mrk << " " << ary[i].num << endl;
	}

	return 0;
}



Measured memory_bytes: 3796
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll D;
    cin >> D;
    vector<ll> c(27,0);
    for(ll i=0;i<26;++i)cin>>c[i+1];
    vector<vector<ll>> S(D+1, vector<ll>(27, 0));
    for(ll i=0;i<D;++i)
        for(ll j=0;j<26;++j)cin>>S[i+1][j+1];
    vector<ll> last(27,0);
    for(ll i=1;i<=D;++i){
        set<P> hoge;
        for(ll j=1;j<=26;++j){
            hoge.insert(P(S[i][j]+c[j]*30,j));
        }
        prt((*--hoge.end()).second);
    }fl

    return 0;
}



Measured memory_bytes: 3748
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N, h[100];

    scanf("%zu\n", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%zu", &(h[i]));
    }

    size_t cnt = 0;

    for (size_t i = 0; i < 100; i++) {
        for (size_t pos = 0; pos < N; pos++) {
            if ((0 < pos && i < h[pos - 1] && h[pos] <= i) ||
                (pos == N - 1 && i < h[pos])) {
                cnt++;
            }
        }
    }

    printf("%zu", cnt);

    return 0;
}

Measured memory_bytes: 128
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

from itertools import combinations_with_replacement, permutations, product
n = int(input())
def sub(n):
    s = set()
    for nums in product(*[[3,5,7] for _ in range(n)]):
        if not all(item in nums for item in [3,5,7]):
            continue
        v = 0
        b = 1
        for c in nums:
            v += c*b
            b *= 10
        s.add(v)
    return sorted(list(s))
from bisect import bisect_right as br
l = len(str(n))
ans = 0
for i in range(1, l+1):
    ans += br(sub(i), n)
print(ans)

Measured memory_bytes: 80704