akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

class Solver {
};
int main() {
	while (true) {
		int d,w;
		cin >> d >> w;
		if (d == 0)break;

		vector<vector<int>> grid(d, vector<int>(w, 0));
		for (int i =0 ; i < d; i++) {
			for (int j = 0; j < w; j++) {
				int val;
				cin >> val;
				grid[i][j] = val;
			}
		}

		int val = 0;
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < w; j++) {
				for (int k = i + 2; k < d; k++) {
					for (int l = j + 2; l < w; l++) {
						int bottom = 1e9;
						for (int y = i; y <= k; y++) {
							bottom = min(bottom, grid[y][j]);
							bottom = min(bottom, grid[y][l]);
						}
						for (int x = j; x <= l; x++) {
							bottom = min(bottom, grid[i][x]);
							bottom = min(bottom, grid[k][x]);
						}

						int sum = 0;
						bool valid = true;
						for (int y = i + 1; y < k; y++) {
							for (int x = j + 1; x < l; x++) {
								if (grid[y][x] >= bottom) valid = false;
								else sum += bottom - grid[y][x];
							}
						}
						if (valid)val = max(val, sum);
					}
				}
			}
		}

		cout << val << endl;
	}
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

struct edge {
  ll from;
  ll to;
  ll cost;
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // v=頂点数,e=辺の数,s=始点,g=終点
  ll v, e, s, g;
  cin >> v >> e;
  s = 0;
  g = v - 1;
  vector<ll> c(v, -INF);  // 0からiまでのコスト
  vector<edge> edges(e);
  c[s] = 0;
  REP(i, e) {
    cin >> edges[i].from >> edges[i].to >> edges[i].cost;
    edges[i].from--, edges[i].to--;
  }

  vector<bool> inf(v, false);
  REP(i, v) {
    REP(j, e) {
      if (c[edges[j].to] < c[edges[j].from] + edges[j].cost &&
          c[edges[j].from] != -INF) {
        c[edges[j].to] = c[edges[j].from] + edges[j].cost;
        if (i == v - 1) inf[edges[j].to] = true;
      }
    }
  }
  // DEBUGS(inf);

  REP(i, v) {
    REP(j, e) {
      if (inf[edges[j].from]) inf[edges[j].to] = true;
    }
  }
  // DEBUGS(inf);
  // DEBUGS(c);
  if (inf[g])
    cout << "inf" << endl;
  else
    cout << c[g] << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = numeric_limits<int>::max() / 2;

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

  int a,b;char op;
  cin>>a>>op>>b;
  if(op=='+') cout<<a+b<<endl;
  else cout<<a-b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<vector<int>> inp;
vector<int> dp;
 
void graph_dp(int i)
{
    int ans=0;
    for(auto ele:inp[i])
    {
        if(dp[ele] == -1) graph_dp(ele);
        ans = max(ans,1 + dp[ele]);
    }
    dp[i] = ans;
}  
 
int driver()
{
    dp.assign(n,-1);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(dp[i] == -1) graph_dp(i);
        ans = max(ans,dp[i]);
    }
    return ans;
}
 
 
 
int main()
{
    /*ifstream cinp;
    cinp.open("input.txt");
    ofstream coutp;
    coutp.open("output.txt");
*/
    //ios_base::sync_with_stdio(0); 
    //cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 
    cin>>n>>m;
    inp.resize(n);
 
    for(int i=0;i<m;i++)
    {
        int a, b;
        cin>>a>>b;
        inp[--a].push_back(--b);
    }
    
    cout<<driver()<<"\n";
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 101;
const ll MAX_K = 100001;
const ll MOD = 1000000007;

int N;
ll K, cum, a[MAX_N], dp[MAX_N][MAX_K];

ll add(ll a, ll b) {
  return (a + b) % MOD;
}
ll sub(ll a, ll b) {
  return (a - b + MOD) % MOD;
}

int main() {
  scanf("%d %lld", &N, &K);
  for(int i = 0; i < N; ++i) scanf("%lld", &a[i]);

  for(ll c = 0; c <= min(a[0], K); ++c) dp[0][c] = 1ll;
  cum = a[0];
  for(int i = 1; i < N; ++i) {
    ll r = 0ll;
    for(ll c = 0; c <= min(a[i], K); ++c) {
      r = add(r, dp[i - 1][c]);
      dp[i][c] = r;
    }
    cum += a[i];
    for(ll c = a[i] + 1; c <= min(cum, K); ++c) {
      r = add(r, dp[i - 1][c]);
      r = sub(r, dp[i - 1][c - a[i] - 1]);
      dp[i][c] = r;
    }
  }
  
  printf("%lld\n", dp[N - 1][K]);
  return 0;
}

Measured memory_bytes: 81896
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e5+7;
int n,c,w[N],v[N];

int dp[1000][N];

int32_t main()
{
	fast;

	cin>>n>>c;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];

	for(int i=1;i<=n;i++)
		dp[0][i] = 0;
	for(int i=0;i<=c;i++)
	{
		if(i<w[1])
			dp[1][i] = 0;
		else
			dp[1][i] = v[1];
	}

	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=c;j++)
		{
			dp[i][j] = dp[i-1][j];
			if(j>=w[i])
				dp[i][j] = max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
		}
	}

	cout<<dp[n][c];

	return 0;
}

Measured memory_bytes: 81408
using System;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var p = new Program();
        var s = Console.ReadLine();
        int ans = 0;
        switch (s)
        {
            case "SUN":
                ans = 7;
                break;

            case "MON":
                ans = 6;
                break;
            case "TUE":
                ans = 5;
                break;

            case "WED":
                ans = 4;
                break;

            case "THU":
                ans = 3;
                break;

            case "FRI":
                ans = 2;
                break;

            case "SAT":
                ans = 1;
                break;
        }
        //var N = int.Parse(Console.ReadLine());
        //var input = p.ConvertIntArray(p.ReadInput());
        //var A = input[0];
        //var B = input[1];
        //var ans = 0;

        Console.WriteLine(ans);

    }


    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }

}


Measured memory_bytes: 13152
import java.util.Scanner;

public class Main {

    private static long costEven(long A) {
        if (A == 0) return 2;
        return A % 2 == 0 ? 0 : 1;
    }

    private static long costOdd(long A) {
        if (A == 0) return 1;
        return A % 2 == 0 ? 1 : 0;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int L = sc.nextInt();
        final long[][] dp = new long[5][L];

        long A = sc.nextInt();
        dp[0][0] = A;
        dp[1][0] = costEven(A);
        dp[2][0] = costOdd(A);
        dp[3][0] = costEven(A);
        dp[4][0] = A;


        for(int i = 1; i < L; i++) {
            long min = dp[0][i-1];

            A = sc.nextInt();

            dp[0][i] = min + A;
            min = Math.min(min, dp[1][i-1]);
            dp[1][i] = min + costEven(A);
            min = Math.min(min, dp[2][i-1]);
            dp[2][i] = min + costOdd(A);
            min = Math.min(min, dp[3][i-1]);
            dp[3][i] = min + costEven(A);
            min = Math.min(min, dp[4][i-1]);
            dp[4][i] = min + A;
        }

        long ans = dp[0][L-1];
        for (int i = 1; i <= 4; i++) {
            ans = Math.min(dp[i][L-1], ans);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 99488
using System.Linq;
using static System.Console;

namespace practice01
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] a = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            int max = a.Max();
            int min = a.Min();
            WriteLine(max-min);
        }
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = X;
    int N = 0;
    while(Y > 0){
      N += Y%10;
      Y /= 10;
    } 
    System.out.println(X%N==0 ? "Yes" : "No");
  }
}

Measured memory_bytes: 23380
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		char input[] = sc.next().toCharArray();

		int l = 0;
		int r = n - 1;
		int count = 0;
		while(l < r){
			if(input[l] != 'W'){
				l++;
				continue;
			}

			if(input[r] != 'R'){
				r--;
				continue;
			}

			count++;
			l++;
			r--;
		}

		System.out.println(count);
	}
}

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

using namespace std;

int main()
{
    
    ll n = 0;cin >>n;
    ll arr[n] = {0};
    for(ll i = 0;i < n; i++ ) cin >> arr[i];
    ll p[n] ={0};
    p[0] = arr[0];
    for(ll i= 1; i < n; i++)
    {
        p[i] = p[i-1] + arr[i];
    }
    ll s[n] = {0};
    s[n-1]=arr[n-1];
    for(ll i=n-2; i >= 0;i--)
    {
        s[i] = s[i+1] + arr[i];
    }
    ll result = 500;
    for(ll i = 0;i < n-1; i++)
    {
        ll val = abs(p[i]-s[i+1]);
      result =    min(result,val);
    }
    cout << result << endl;
    
    return 0;
    
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = 998244353;//1e9+7

vector<int> cnt[201],sp;

void pre() {

}

void solve() {
  ll n; cin>>n;
  string s = "";
  ll k = 26;
  while(n>0) {
    if(n%k == 0)  {s =  'z' + s;n--;}
    else s = (char)('a'+ n%k - 1) + s;
    n = n/26;
  }
  cout<<s;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  #endif
  int t = 1;
  pre();
  //cin>>t;
  rep(i,t)  {
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> b(n-1),a(n);
	rep(i,n-1) cin >> b.at(i);
	a.at(n-1) = b.at(n-2);
	for(int i = n - 3; i >= 0; i--){
		a.at(i+1) = min(b.at(i), b.at(i+1));
	}
	a.at(0) = b.at(0);
	int ans = 0;
	rep(i,n) ans += a.at(i);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int ans[200001];

int32_t main()
{
	FIO;
	int n; cin >> n;

	for (int i = 2; i <= n; ++i)
	{
		int pi;
		cin >> pi;
		ans[pi]++;
	}

	for (int i = 1; i <= n; ++i)
		cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 5160
n, m = map(int, input().split())

xy = [i for i in range(n + 1)]


def root(x):
    i = x
    while i != xy[i]:
        i = xy[i]
    xy[x] = i
    return i


for _ in range(m):
    x, y = map(int, input().split()[:2])
    rx = root(x)
    ry = root(y)
    if rx < ry:
        xy[rx] = ry
    else:
        xy[ry] = rx

ans = sum(i == v for i, v in enumerate(xy)) - 1

print(ans)


Measured memory_bytes: 7088
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,h,m,s,ans,x,y,z;
	for(int i=0;i<3;i++){
		cin>>h>>m>>s;
		a=h*3600+m*60+s;
		cin>>h>>m>>s;
		ans=(h*3600+m*60+s)-a;
		x=ans/3600;
		y=(ans-x*3600)/60;
		z=ans-(x*3600+y*60);
		cout<<x<<' '<<y<<' '<<z<<endl;
	}
return 0;
}

Measured memory_bytes: 1160
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;

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

int main() {
	cin >> N;
	ll curr_a, curr_b;
	cin >> curr_a >> curr_b;
	rep(i, N-1) {
		cin >> A >> B;
		ll inc = max((curr_a - 1) / A + 1, (curr_b - 1) / B + 1);
		curr_a = inc * A;
		curr_b = inc * B;
	}
	cout << curr_a + curr_b;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%2==0){cout<<0.5<<endl;}
  else{double m=n;
  cout<<setprecision(10)<<(m+1)/(2*m)<<endl;}
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (unless)

main :: IO ()
main = do
  xs <- words <$> getLine
  unless (all (=="-1") xs) $ do
    print $ solve xs
    main

solve :: [String] -> Int
solve [a, b, c, d] = round $ r * (acos ((sin lat1) * (sin lat2) + (cos lat1) * (cos lat2) * (cos (lng1 - lng2))))
  where r = 6378.1
        lat1 = toRad (read a)
        lng1 = toRad (read b)
        lat2 = toRad (read c)
        lng2 = toRad (read d)
        toRad :: Double -> Double
        toRad x = x * (acos (-1)) / 180



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n), s(n + 1, 0);
  map<ll, ll> mp;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s[i + 1] = a[i] + s[i];
    mp[s[i+1]]++;
  }
  mp[s[0]]++;

  for (auto m : mp)
    ans += m.second * (m.second - 1) / 2;

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


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

int main(){
    ll N, W;  cin >> N >> W;
    vector<ll> w(N+1), v(N+1);
    for(int i=1; i<=N; i++) cin >> w[i] >> v[i];

    vector<vector<ll>> dp;
    dp = vector<vector<ll>>(N+1, vector<ll>(W+1, 0));
    dp[1][w[1]] = v[1]; // (1)

    for(int i=2; i<=N; i++){
        for(int j=0; j<=W; j++){
            if(w[i] <= j){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<=W; i++) ans = max(ans, dp[N][i]);
    cout << ans << endl;
}

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

int main()
{
    string s="abc",s2;
    int f=1;
    cin>>s2;
    for(int i=0;i<3&&f;i++)
        for(int j=0;j<3;j++)
        if(s[i]==s2[j])break;
        else if(j==2&&s[i]!=s2[j])f=0;
    if(!f)cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

struct edge{
    int l,r,c;
};

bool comp(edge e1,edge e2){
    if(e1.l != e2.l) return e1.l < e2.l;
    else if(e1.c != e2.c) return e1.c < e2.c;
    else return e1.r > e2.r;
}
const int max_n = 100005;
int dat[max_n * 4];
int N;


void update(int i , int x){
    i += N - 1;
    dat[i] = x;
    while(i > 0){
        i = (i - 1) / 2;
        dat[i] = min(dat[i* 2 + 1],dat[i * 2 + 2]);

    }
}

int query(int a, int b, int k,int l,int r){
    if( r<= a || b <= l) return INF;
    if(a <= l and r <= b) return dat[k];
    else{
        int vl = query(a,b,k * 2 + 1,l,(l+r) / 2);
        int vr = query(a,b,k * 2 + 2,(l + r) / 2,r);
        return min(vl,vr);
    }
}


signed main(){
    int n,m;
    cin >> n >> m;
    edge E[m + 1];
    REP(i,m){
        cin >> E[i].l >> E[i].r >> E[i].c;
        E[i].l --;
        E[i].r --;
    }
    E[m].l = INF;

    sort(E,E+m,comp);

    N = 1;
    while(N < n) N *= 2;
    REP(i,2 * N ) dat[i] = INF;


    update(0,0);
    REP(i,m){
        int mi = query(E[i].l,E[i].r + 1,0,0,N);
        if(dat[N - 1 + E[i].r] > E[i].c + mi){
            update(E[i].r,E[i].c + mi);
        }
    }
    if(dat[N - 1 + n-1] == INF){
        cout << - 1 << endl;
        return 0;
    }

    cout << dat[N - 1 + n-1] << endl;



}

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

int m,n;
int b[100];
int check(int w){
	int cnt=1;
	int tmp=0;
	for(int i=0;i<n;i++){
		if(b[i]>w)return 0;
		if(tmp+b[i]<=w)tmp+=b[i];
		else{
			tmp=b[i];
			cnt++;
		}
	}
	if(m>=cnt)return 1;
	return 0;
}

int main(){
	while(cin>>m>>n,m){
		for(int i=0;i<n;i++){
			cin>>b[i];
		}
		
		int safe=1500000,out=1;
		while(safe-out>1){
			if(check((out+safe)/2)){
				safe=(out+safe)/2;
			}
			else{
				out=(out+safe)/2;
			}
		}
		cout<<safe<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int ans = 0;
  rep(i, n) if (s[i] != '#') ans++;
  int res = ans;
  rep(i, n) {
    if (s[i] == '.') res--;
    else res++;
    chmin(ans, res);
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n;string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0; i+2 < n; ++i){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace abc92_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int [] array = new int [4];
            int answer;
            int train = 0;
            int bus = 0;
            for(int i = 0; i < array.Length; i++)
            {
                array [i]= int.Parse(Console.ReadLine());
            }
            if (array[0] >= array[1])
            {
                train = array[1];
            }
            else if(array[0] < array[1])
            {
                train = array[0];
            }
            if (array[2] >= array[3])
            {
                bus = array[3];
            }
            else if(array[2] < array[3])
            {
                bus = array[2];
            }
            answer = bus + train;
            Console.WriteLine(answer);

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
using namespace std;

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


void Main()
{
	string a, b;
	cin >> a >> b;
	int X = atoi((a+b).c_str());
	int sqX = static_cast<int>(sqrt(X));

	cout << (X == sqX * sqX ? "Yes" : "No") << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

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

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

  int n;
  string s;
  cin >> n >> s;
  vector<int> l(n);
  l[0] = 1 << (s[0] - 'a');
  vector<int> r(n);
  r[n-1] = 1 << (s[n-1] - 'a');
  for (int i = 1; i < n; i++) {
    l[i] = l[i-1] | (1 << (s[i] - 'a'));
    r[n-1-i] = r[n-i] | (1 << s[n-1-i] - 'a');
  }
  int res = 0;
  for (int i = 0; i < n - 1; i++) {
    int co = l[i] & r[i+1];
    int cnt = 0;
    for (int j = 0; j < 26; j++) {
      cnt += co >> j & 1;
    }
    res = max(res, cnt);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  P a[n];
  rep(i,n) {
    R a[i].F;
    a[i].S=i+1;
  }
  sort(a,a+n);
  rep(i,n) {
    if(i)cout << " ";
    cout << a[i].S;
  }
  ln;

}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 2432
#include <stdio.h>

int main(void){
    int N, a[200005], x[200005], i, j, M, S;
    scanf("%d", &N);
    for (i=1; i<=N; i++) {
        scanf("%d", &a[i]);
        x[i]=0;
    }
    M=0;
    for (i=N; i>=1; i--) {
        S=0;
        for (j=2; i*j<=N; j++) {
            S+=x[i*j];
            // printf("i=%d: x[%d]=%d\n", i, i*j, x[i*j]);
        }
        x[i]=(a[i]+S)%2;
        M+=x[i];
        // printf("%d: %d\n", i, S);
        // printf("x[%d]=%d\n", i, x[i]);
    }
    printf("%d\n", M);
    for (i=1; i<=N; i++) {
        // printf("%d\n", x[i]);
        if (x[i]==1) printf("%d ", i);
    }
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a = a*100+b*10+c;
    if(a%4==0)printf("YES");
    else printf("NO");
    return 0;
}


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

int main() {
	int N,L[2000];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	for (int i = 1; i <= N - 1; i++) {
		int v = L[i];
		int j = i - 1;
		while (j >= 0 && L[j] > v) {
			L[j + 1] = L[j];
			j--;
			L[j + 1] = v;
		}
	}
		int k = 0, ans = 0;
		for (int i = 0; i < N - 2; i++) {
			for (int j = i + 1; j < N - 1 ; j++) {
				k = j + 1;
				while (k > j && k < N) {
					if (L[k] < L[i] + L[j]) {
						ans++;
					}
					k++;
				}
			}
		}
		cout << ans << endl;

		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, k;
  cin >> a >> b >> k;
  cout << max(0ll, a-k) << ' ' << max(0ll, b - max(0ll, (k-a))) << endl;
}


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

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

  if (s == "A") cout << "T" << endl;
  if (s == "T") cout << "A" << endl;
  if (s == "C") cout << "G" << endl;
  if (s == "G") cout << "C" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint a[114514],b[114514];
int n;
lint cal(lint k){
	//cout<<k<<endl;
	lint sum=0;
	rep(i,n){
		if((a[i]&k)==a[i]) sum+=b[i];
	}
	return sum;
}
int main()
{
	lint out=0,xo=0,k;
	cin>>n>>k;
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	out=max(out,cal(k));
	rep(i,31){
		if(!((1LL<<i)&k)) continue;
		lint K=k-(1LL<<i);
		K|=((1LL<<i)-1);
		out=max(out,cal(K));
	}
	cout<<out<<endl;
}


Measured memory_bytes: 1792
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**8]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min([dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i)])
print(dp[n-1])

Measured memory_bytes: 20548
def rectangle_cutting(w, h, x, y):

    a = 0
    ans = (w*h) / 2

    if x*2 == w and y*2 == h:
        a = 1

    return ans, a
def main():
    w, h, x, y = map(int, input().split())
    print(*(rectangle_cutting(w, h, x, y)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N = int(input())
s_list = [[5, 5, 3], [25, 3], [15, 5], [75]]

a = [0 for i in range(N+1)]
for i in range(2, N+1):
    for j in range(2, N+1):
       while i%j==0:
           a[j]+=1 
           i/=j

def div_c(n):
    return len(list(filter(lambda x: x >= n-1, a))) 
    
ans=0
for s in s_list:
    i=0
    c=1
    for t in s:
        c*=(div_c(t)-i)
        i+=1
    ans+=int(c/(len(s)-len(set(s))+1))

       
print(ans)
        

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

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        set<int> s;
        bool f = false;
        cin >> a;

        int j;
        for(j=0;a>=10;j++){
            int cnt = 0;
            for(int k=10;k<=a;k*=10) cnt = max(cnt,(a/k)*(a%k));
            if(s.find(cnt) != s.end()){
                f = true;
                break;
            } else {
                a = cnt;
                s.insert(cnt);
            }
        }
        cout << (f ? -1 : j) << endl;
    }
}

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  string s; cin >> s;

  int val = 0, ans = 0;
  rep(i, n) {
    if (s[i] == 'I') ++val;
    else --val;

    chmax(ans, val);
  }

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

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

using namespace std;

typedef long long int lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
string s;
lli q;
vll k;



int main(){
  cin >> n;
  cin >> s;
  cin >> q;
  k = vll(q);
  for(lli i = 0;i < q;i++) cin >> k[i];
  for(lli w : k){
    queue<char> que;
    lli d_contain = 0;
    lli m_contain = 0;
    lli c_crossable = 0;
    lli ans = 0;
    for(lli i = 0;i < n;i++){
      if(que.size() >= w){
        char p = que.front();
        que.pop();
        if(p == 'D'){
          d_contain--;
          c_crossable -= m_contain;
        }
        if(p == 'M'){
          m_contain--;
        }

      }
      que.push(s[i]);
      if(s[i] == 'D') d_contain++;
      if(s[i] == 'M'){
        m_contain++;
        c_crossable += d_contain;
      }
      if(s[i] == 'C'){
        ans += c_crossable;
      }
    }
    cout << ans << endl;
  }
}


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

int main()
{
	bool IsOpen = false;
	int n, m;
	map<string, int> u;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		u[s] = -1;
	}

	cin >> m;
	for (int i = 0; i < m; i++)
	{
		string s;
		cin >> s;
		if (u.count(s))
		{
			if (!IsOpen)
			{
				cout << "Opened by " + s << endl;
				IsOpen = true;
			}
			else
			{
				cout << "Closed by " + s << endl;
				IsOpen = false;
			}
		}
		else
		{
			cout << "Unknown " + s << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1240
n=gets.to_i
r=[]
(0..8).each{|e|r[e]=0}
gets.split.map(&:to_i).each{|a| r[[a/400, 8].min]+=1}
x=0
for i in (0...8)
	x+=1 if r[i]>0
end
puts "#{x>0 ? x : 1} #{x+r[8]}"


Measured memory_bytes: 1788
#include<stdio.h>
int main(){
  char a[2],b[2];
  scanf("%s %s",&a,&b);
  int i = a[0],j = b[0];
  if(i > j){
    printf(">");
  }else if(i < j){
    printf("<");
  }else{
    printf("=");
  }
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	//sort(a.begin(),a.end());

	lli sum[200100];
	sum[0]=0;

	REP(i,0,n){
		sum[i+1] = sum[i]+a[i];
	}

	lli ans=INF;
	REP(i,1,n){
		lli x = sum[i];
		lli y = sum[n]-sum[i];
		ans = min(ans,abs(x-y));
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 
ll s[64];
ll us[64];
int main()
{
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
         cin>>a[i];}
         ll res=0LL;
         for(int i=0;i<=60;i++)
         {
              int zc=0,oc=0;
              for(int j=0;j<n;j++){
                   if(a[j]%2==0)zc++;
                   else oc++;
                   a[j]>>=1;
              }
              res+=((((1LL<<i)%mod)*oc)%mod*zc)%mod;
              res%=mod;
         }
         cout<<res;
    
}

Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val input = readLine() ?: ""
    val input_list = input.split(" ").map(String::toInt) 
    var ans = input_list[0] / (2*input_list[1]+1)
    when (input_list[0] % (2*input_list[1]+1)) {
        0 -> {}
        else -> ans++
    }
    println( ans )
}

Measured memory_bytes: 37984
//502

//502

#include <stdio.h>
#include <string.h>

int east(int a[])
{
   int b[6], i;


   b[1] = a[0];
   b[0] = a[3];
   b[3] = a[2];
   b[2] = a[1];
   b[4] = a[4];
   b[5] = a[5];
   for (i = 0; i < 6; i++) {
       a[i] = b[i];
   }
   return a[0];
}


int north(int a[])
{
   int b[6], i;

   b[5] = a[0];
   b[0] = a[4];
   b[2] = a[5];
   b[4] = a[2];
   b[1] = a[1];
   b[3] = a[3];
   
   for (i = 0; i < 6; i++) {
       a[i] = b[i];
   }
   return a[0];
}


int right(int a[])
{
   int b[6], i;

   b[0] = a[0];
   b[4] = a[1];
   b[1] = a[5];
   b[5] = a[3];
   b[3] = a[4];
   b[2] = a[2];
   
   for (i = 0; i < 6; i++) {
       a[i] = b[i];
   }
   return a[0];
}


int west(int a[])
{
   east(a);
   east(a);
   return east(a);
}


int south(int a[])
{
   north(a);
   north(a);
   return north(a);
}


int left(int a[])
{
   right(a);
   right(a);
   return right(a);
}


int main()
{
    int n;
    int i;
    char buf[10];
    int a[6] = {1, 3, 6, 4, 2, 5};
    int sum;

    while (1) {
        scanf("%d", &n);
        if (n == 0)
            break;
        // 初期化
        a[0] = 1;
        a[1] = 3;
        a[2] = 6;
        a[3] = 4;
        a[4] = 2;
        a[5] = 5;
        sum = a[0];

        for (i = 0; i < n; i++) {
            scanf("%s", buf);
            if (!strcmp(buf, "West")) {
                sum += west(a);
            } else if (!strcmp(buf, "East")) {
                sum += east(a);
            } else if (!strcmp(buf, "North")) {
                sum += north(a);
            } else if (!strcmp(buf, "South")) {
                sum += south(a);
            } else if (!strcmp(buf, "Left")) {
                sum += left(a);
            } else if (!strcmp(buf, "Right")) {
                sum += right(a);
            }
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys
from collections import deque

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, A: "List[int]"):

    A = deque(A)
    a = deque()

    p = 1
    for i in range(K):
        t=A.popleft()
        a.append(t)
    
    for i in range(K, N):
        t = A.popleft()
        c = a.popleft()
        if t > c: print(YES)
        else: print(NO)
        a.append(t)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 92476
N = int(input())
l = [19, 29, 39, 49, 59, 69, 79, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
bl = False
for i in l:
    if N == i:
        bl = True
        break
if bl:
    print('Yes')
else:
    print('No')


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    int p = num;
    while(!IsPrime(p)) p++;

    cout << p << endl;
    return 0;
}


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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = input()
B = input()
C = input()

cnt = 0
for i in range(N):
    if A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
        cnt += 2
    elif A[i] != B[i] or B[i] != C[i] or C[i] != A[i]:
        cnt += 1
print(cnt)


Measured memory_bytes: 5528
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int sum=0,a;
    rep(i,n/4){
      cin>>a;
      sum+=a;
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 3052
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
typedef pair<int, int> P;
vector<P> U;

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

  cin >> N;
  int a;
  rep(i, N){
    cin >> a;
    P p = make_pair(a,3);
    U.push_back(p);
  }
  rep(i, N){
    cin >> a;
    P p = make_pair(a,2);
    U.push_back(p);
  }
  rep(i, N){
    cin >> a;
    P p = make_pair(a,1);
    U.push_back(p);
  }
  sort(U.begin(), U.end(), greater<P>());

  ll ans = 0ll;
  ll b_c_cnt = 0ll;
  ll c_cnt = 0ll;
  rep(i, 3*N){
    int v = U[i].second;
    if (v ==3){
      ans+=b_c_cnt;
    }
    if (v == 2){
      b_c_cnt+=c_cnt;
    }
    if (v == 1){
      c_cnt++;
    }
  }
  
  cout << ans << "\n";
  
  return 0;
}

Measured memory_bytes: 6512
N=int(input())
DP=[0]*(N+1)
tmp=0
mod=10**9+7
if N<3:
   print(0)
   exit()
DP[3]=1
for i in range(4,N+1):
   DP[i]=(DP[i-1]+DP[i-3])%mod
print(DP[N]%mod)

Measured memory_bytes: 9212
#include "bits/stdc++.h"
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
void solve() {
	ll n;
	cin >> n;
	ll a[n], b[n], c[n];
	For(i, 0, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	ll dp1[n], dp2[n], dp3[n];
	dp1[0] = a[0];
	dp2[0] = b[0];
	dp3[0] = c[0];
	For(i, 1, n) {
		dp1[i] = a[i] + max(dp2[i - 1], dp3[i - 1]);
		dp2[i] = b[i] + max(dp1[i - 1], dp3[i - 1]);
		dp3[i] = c[i] + max(dp1[i - 1], dp2[i - 1]);
	}
	cout << max(dp3[n - 1], max(dp1[n - 1], dp2[n - 1])) << "\n";
}

int main() {
    fio;
    ll t = 1;
    //cin >> t;
    while(t--) {
    	solve();
    }
}

Measured memory_bytes: 8292
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define IMX INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
bool uu[10],p;
int n,x,k,cc;
int main()
{
    scanf("%d %d",&n,&k);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&x);
        uu[x]=true;
    }
    while(1)
    {
        p=true;
        cc=n;
        while(cc>0)
        {
            if(uu[cc%10])p=false;
            cc/=10;
        }
        if(p)
        {
            printf("%d",n);
            break;
        }
        n++;
    }
}


Measured memory_bytes: 256
w=io.read()
t={}
for i=1,#w do
    x=string.sub(w,i,i)
    t[x]=0
end
for i=1,#w do
    x=string.sub(w,i,i)
    t[x]=t[x]+1
end
even=true
for i=1,#w do
    x=string.sub(w,i,i)
    if t[x]%2~=0 then
        even = false
        break
    end
end
print(even and "Yes" or "No")

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const ll MAXN = 200001;

vl A;

vl dist;
map<ll,ll> M;

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);
    ll a,b,c,d;
    cin >> n;
    rep(c1,0,n){
        cin >> a;
        A.push_back(a);
        if(M.find(a) == M.end()){
            M[a] = 0;
            dist.push_back(a);
        }
        M[a]++;
    }

    if(sz(dist) == 1 && dist[0] == 0){
        cout << "Yes\n";
        return 0;
    }

    sort(all(dist));

    if(sz(dist) == 2 && n%3 == 0){

        if(dist[0] == 0 && M[dist[0]] == n/3 && M[dist[1]] == 2*(n/3)){
            cout << "Yes\n";
            return 0;
        }

    }

    if(n%3 != 0 || sz(dist) != 3){
        cout << "No\n";
        return 0;
    }


    if(M[dist[0]] != n/3 || M[dist[1]] != n/3 || M[dist[2]] != n/3){
        cout << "No\n";
        return 0;
    }

    a = 0;
    if((dist[0]^dist[1]) == dist[2])a++;
    if((dist[0]^dist[2]) == dist[1])a++;
    if((dist[2]^dist[1]) == dist[0])a++;
    if(a == 3){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 6376
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
    int n,m;cin>>n>>m;
    int a[n];
    int tot = 0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        tot += a[i];
    }
    int req = 4*m;
    //cout<<req<<endl;
    for(int i=0;i<n;i++)
    {
        if(req * a[i] >= tot)
        {
            m--;
            if(m==0)
            {
                break;
            }
        }
    }
    if(m==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    

}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
// #pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define reps(i, s, n) for (i64 i = s; i < (i64)(n); ++i)

void solve() {
    string s, t;
    cin >> s >> t;
    i64 ans = 1e9;
    rep(i, s.size() - t.size() + 1) {
        i64 cur = 0;
        rep(j, t.size()) {
            if (s[i + j] != t[j]) {
                cur++;
            }
        }
        ans = min(ans, cur);
    }
    cout << ans << "\n";
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3640