akhauriyash/Code-Regression huggingface dataset:
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
const int MAX_N = 100005;
int n;
map<int,int> odd;
map<int,int> even;

int main( int argc, char *argv[] ) {
    RI(n);
    int max_odd[2]={}, max_even[2]={};
    int ov, ev;
    REP(i, n) {
        int a; RI(a);
        if(i%2) {
            odd[a]++;
        } else {
            even[a]++;
        }
    }
    FOR(i, odd) {
        int a = i->first;
        if(odd[a] > max_odd[0]) {
            max_odd[1] = max_odd[0];
            max_odd[0] = odd[a];
            ov = a;
        } else if(odd[a] > max_odd[1]) {
            max_odd[1] = odd[a];
        }
    }
    FOR(i, even) {
        int a = i->first;
        if(even[a] > max_even[0]) {
            max_even[1] = max_even[0];
            max_even[0] = even[a];
            ev = a;
        } else if(even[a] > max_even[1]) {
            max_even[1] = even[a];
        }
    }
    if(ev == ov) {
        if(max_even[0] == max_odd[0]) {
            printf("%d\n", n - max_even[0] - max(max_even[1], max_odd[1]));
        } else if(max_even[0] > max_odd[0]) {
            printf("%d\n", n - max_even[0] - max_odd[1]);
        } else {
            printf("%d\n", n - max_even[1] - max_odd[0]);
        }
    } else {
        printf("%d\n", n - max_even[0] - max_odd[0]);
    }
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  
  int i;
  for(i=0; i<N; i++)
    cout << S[i] << T[i] ;
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int q;

multiset<ll> a;
ll b;
map<ll, ll> A;

int main()
{
    cin >> q;

    bool even = false;

    int num;
    ll tmp;
    cin >> num >> tmp >> b;

    a.insert(tmp);
    A[tmp]++;
    auto itr = a.begin();

    tmp = 0;

    for (int i = 0; i < q - 1; i++)
    {
        cin >> num;

        if (num == 1)
        {
            ll aa, bb;
            cin >> aa >> bb;
            b += bb;

            if (even)
            {
                if (aa < *itr)
                {
                    a.insert(aa);
                    tmp += abs(aa - *itr);
                    A[aa]++;
                }
                else
                {
                    ll tt = *itr;
                    a.insert(aa);
                    ++itr;
                    tmp += abs(aa - tt) - (*itr - tt);
                    A[aa]++;
                }
                even = false;
            }
            else
            {
                if (aa < *itr)
                {
                    ll tt = A[*itr];
                    tmp += abs(*itr - aa);
                    a.insert(aa);
                    --itr;
                    A[aa]++;
                }
                else
                {
                    a.insert(aa);
                    tmp += abs(aa - *itr);
                    A[aa]++;
                }
                even = true;
            }
        }
        else
        {
            cout << *itr << ' ' << tmp + b << endl;
        }
    }
}


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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define Y first
#define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

struct Corner{
	Corner(char c_) : c(c_) {
		s = MP(INF, INF);
		e = MP(-1, -1);
	}

	void update(PII p) {
		s.X = min(s.X, p.X);
		s.Y = min(s.Y, p.Y);
		e.X = max(e.X, p.X);
		e.Y = max(e.Y, p.Y);
	}

	PII s; // ??????
	PII e; // ??????
	char c;
};

const char DONE = '*';

int H, W;
VS ts;
vector<Corner> corners;
string types;

// ???????????¶????????????????????¶???
// ???????????¶???????????£??????????????????
void corner_fill(Corner &corner) {
	PII s = corner.s;
	PII e = corner.e;
	char c = corner.c;

	for (int y = s.Y; y <= e.Y; y++) {
		for (int x = s.X; x <= e.X; x++) {
			if (ts[y][x] != c && ts[y][x] != DONE) {
				return;
			}
		}
	}

	// fill
	for (int y = s.Y; y <= e.Y; y++) {
		for (int x = s.X; x <= e.X; x++) {
			ts[y][x] = DONE;
		}
	}
}

// ??????????????????
bool is_ok() {
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			if (ts[y][x] != DONE &&
				ts[y][x] != '.') {
				return false;
			}
		}
	}
	return true;
}

void dump() {
	cout << "---------------" << endl;
	for (auto &line : ts) {
		cout << line << endl;
	}
	cout << "---------------" << endl << endl;
}

int main(void) {
	int N;
	cin >> N;
	while (N--) {
		// input
		cin >> H >> W;
		ts = VS(H);
		corners = vector<Corner>();
		types = "";

		for (int y = 0; y < H; y++) {
			string line;
			cin >> line;
			for (int x = 0; x < W; x++) {
				char t = line[x];
				ts[y] += t;

				if (t != '.') {
					auto num = types.find(t);
					if (num == string::npos) {
						types += t;
						num = types.size() - 1;
						corners.PB(Corner(t));
					}

					corners[num].update(MP(y,x));
				}
			}
		}

		// /input

		for (int i = 0; i < 7; i++) {
			for (auto corner : corners) {
				corner_fill(corner);
			}
		}

//		dump();

		cout << (is_ok() ? "SAFE" : "SUSPICIOUS") << endl;
	}

	return 0;
}

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

int main(){
    int n;
    int cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i+=2) {
        int num = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) num++;
        }
        if (num == 8)cnt++;
    }
cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	int N;
	cin >> N;
	int M = N - 2;

	vector<int>vec1(N);
	rep(i, N) {
		cin >> vec1[i];
	}
	vector<int>vec2(N);
	for (int i = 0; i < N; i++) {
		vec2[i] = i + 1;
	}


	int ans = 0;
	for (int i = 0; i < N; i++) {
			if (vec1[i] == vec2[i]) {
				ans++;
		}
	}

	if (ans == M || ans == N) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

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

typedef long long ll;

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	cout << (t / a) * b << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, X, Y;
	int ans[2003] = {};

	cin >> N >> X >> Y;
	X--;
	Y--;

	rep(i,N) reps(j,i+1,N) {
		int mn = j - i;
		chmin(mn, abs(X-i) + abs(Y-j) + 1);
		ans[mn]++;
	}

	reps(i,1,N) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 256
//In the Name of God
//Let Our Voices Echo
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define X real()
#define Y imag()
typedef long long ll;
typedef double ld; 
typedef complex<ld> point;
const ld eps=1e-9;
const int MAX=5e5+9,MOD=1e9+7;
ll n,D,a[MAX],b[MAX],be[MAX],q;
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>D;
	for (int i=1;i<=n;i++) 
	{
		cin>>a[i];
		b[i]=b[i-1];
		if (b[i]<D)
		{
			if (abs(b[i]+a[i]-D)<abs(b[i]-D))
				b[i]+=a[i];
		}
		else
			if (abs(b[i]-a[i]-D)<abs(b[i]-D))
				b[i]-=a[i];
	}
	ll x=1;
	for (int i=n;i>=1;i--)
	{
		if (abs(b[i-1]-D)>=x)
			be[i]=1;
		if (x<a[i])
		{
			if (a[i]-x<x)
				x=a[i]+x;
		}
		else
			x=x+a[i];		
	}
	cin>>q;
	for (int i=0;i<q;i++)
	{
		int x;
		cin>>x;
		if (be[x]) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}


Measured memory_bytes: 13696
a, b, c, d = gets.chomp.split(' ').map(&:to_i)
lcm = c.lcm(d)


a_lcm_num = (a / lcm)
b_lcm_num = (b / lcm)

b_lcm = (b / lcm) * lcm


lcm_num = (b_lcm - a) / lcm

puts (b - a + 1) - ((b / c) - ((a-1) / c) + (b / d) - ((a-1) / d)) + (lcm_num + 1)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define pi pair<int,int>
#define mk make_pair
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,a,n) for(int i=a;i<n;i++)
#define fr(i,a,n) for(int i=a;i>=n;i--)
#define ll long long
#define N 1000000007
using namespace std;

double pro[3005];
vector<vector<double>> dp(3005,vector<double> (1510,-1));
int n;

double total(int ind,int tail)
{
    if(ind>n)
        return 1;
    if(dp[ind][tail]==-1)
    {
        if(tail>0)
        {
            double left=total(ind+1,tail-1)*(1-pro[ind]);
            double right=total(ind+1,tail)*pro[ind];
            dp[ind][tail]=left+right;
        }
        else
            dp[ind][tail]=total(ind+1,tail)*pro[ind];
    }
    return dp[ind][tail];
}

int main()
{
   // int n;
    cin>>n;
    fo(i,1,n+1)
        cin>>pro[i];
    int tail =n/2;
    double ans=total(1,tail);
    printf("%.10f",ans);

}


Measured memory_bytes: 39200
#include<bits/stdc++.h>
using namespace std;
int ans;
int a[21];
int x[21][21],y[21][21];
int count(int x){int ans=0;while(x)ans+=x&1,x>>=1;return ans;}
signed main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		for(int j=1;j<=a[i];j++)
			scanf("%d%d",&x[i][j],&y[i][j]);
	}
	int ans=0;
	for(int s=0;s<(1<<n);s++)
	{
		int flag=1;
		for(int i=1;i<=n;i++)
			if(s&(1<<(i-1)))
			{
				for(int j=1;j<=a[i];j++)
					if((s&(1<<(x[i][j]-1))&&y[i][j]==0)||
						((s&(1<<(x[i][j]-1)))==0&&y[i][j]==1))
						flag=0;
			}
		if(flag) 
			ans=max(ans,count(s));
	}
	printf("%d",ans);
	return 0;
}


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

int main() {
	int a, b, c, k, max, maxx;
	cin >> a >> b >> c;
	cin >> k;
	if (a <= b) {
	    max = b;
	} else max = a;
	if (max <= c) {
	    max = c;
	}
	maxx = max;
	for (int i = 0;i < k;i++) {
	    max = max * 2;
	}
	cout << a + b + c + max - maxx;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int w = scanner.nextInt(), a = scanner.nextInt(), b = scanner.nextInt();
			System.out.println(Math.max(0, Math.abs(a - b) - w));
		}
	}
}


Measured memory_bytes: 35668
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[] answers = new long[n];
    int left = 0;
    int right = 0;

    if(n % 2 == 1)
    {
      answers[n/2] = nums[0];
      right = n/2 + 1;
      left = n/2 - 1;
      for(int i = 1; i < n; i++)
      {
        if(i % 2 == 1)
        {
          answers[right] = nums[i];
          right++;
        }else
        {
          answers[left] = nums[i];
          left--;
        }
      }
    }else
    {
      right = n/2;
      left = n/2 - 1;
      for(int i = 0; i < n; i++)
      {
        if(i % 2 == 0)
        {
          answers[right] = nums[i];
          right++;
        }else
        {
          answers[left] = nums[i];
          left--;
        }
      }
    }

    Console.WriteLine(string.Join(" ", answers));
	}
}

Measured memory_bytes: 48056
#include<stdio.h>
int main(void)
{
    int n,m=0,a,b;
	scanf("%d",&n);
	a=n;
	m=a%10*100;
	b=a%10;
	m=m+a%100-b;
	b=a%100;
	m=m+a/100;
	if(n==m) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
import itertools
S = input()
npm = len(S) - 1
sum = eval(S)
pcomb = []
for i in range(npm):
    pcomb.append(list(itertools.combinations(range(1, npm + 1), i + 1)))
for j in pcomb:
    k = 0
    for l in range(len(j)):
        pcomb2 = j[k]
        npmc = 0
        F = S
        for m in pcomb2:
            F = F[:m + npmc] + "+" + F[m + npmc:]
            npmc += 1
        sum += eval(F)
        k += 1
print(sum)


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int n; cin>>n;
    vector<int> h(n);
    rep(i,n) cin>>h[i];

    vector<int> dp(n,INF);
    dp[0]=0;

    for (int i = 0; i < n-1; i++)
    {
        chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        if(i<n-2) chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }
    cout<<dp[n-1]<<endl;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    vector<int> ans;
    int i = N;
    while (i >= 1) {
        int m = M;
        while (i - m <= -1) {
            m--;
        }
        while (S[i - m] == '1') {
            m--;
            if (m == 0) {
                cout << -1 << endl;
                return 0;
            }
        }
        ans.push_back(m);
        i = i - m;
    }
    reverse(ans.begin(), ans.end());
    for (auto a : ans) {
        cout << a << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1144
#include<stdio.h>
void arraypPrint(int[], int);
void insertionSort(int[], int);
int main(){
  int N, i;
  int A[100];
  scanf("%d",&N);
  for( i = 0 ; i < N ; i++ ){
    scanf("%d",&A[i]);
  }

  arraypPrint(A, N);
  insertionSort(A, N);

  return 0;
}

void insertionSort(int A[], int N){
  int i, j, v;
  for( i = 1 ; i < N ; i++ ){
    v = A[i];
    j = i - 1;
    while( j >= 0 && A[j] > v ){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    arraypPrint(A, N);
  }
}

void arraypPrint(int A[], int N){
  int i;
  for( i = 0 ; i < N ; i++ ){
    if( i > 0 ) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}



Measured memory_bytes: 2140
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
int n,k;
ll s[N];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>n>>k;
	for (int i=1;i<=n;++i)
	{
		cin>>s[i];
		s[i]+=s[i-1];
	}
	ll ma=0;
	for (int i=k;i<=n;++i) ma=max(ma,s[i]-s[i-k]);
	cout<<fixed<<setprecision(1)<<(ma+k)/2.;
}





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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll a, b, c;
    cin >> a >> b>> c;

    if(min(a,b) <= c && c <= max(a,b)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, M;
vector<vector<P>> edge1(100001);
vector<vector<P>> edge2(100001);
bitset<100001> bit;
vector<ll> memo(100001, 0);

void rec(int corrent, int p = 0){
    
    if(bit[corrent]){
        if(memo[corrent] != p) { printf("No\n"); exit(0); }
        return;
    }
    bit[corrent] = true;
    memo[corrent] = p;

    for(auto e : edge1[corrent]) rec(e.first, p + e.second);
    for(auto e : edge2[corrent]) rec(e.first, p - e.second);
    
    return;
}

int main(void){
    
    scanf("%d %d", &N, &M);
    for(int i = 0; i < M; ++i){
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        edge1[a].push_back(make_pair(b, c)), edge2[b].push_back(make_pair(a, c));
    }
    
    for(int i = 1; i <= N; ++i) if(!bit[i]) rec(i, 0);
    
    printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    int x=0,y=0,f=0;
    int l=s.length();
    for(int i=0; i<l; i++)
    {
        int cur=s[i]-'0';
        if(cur!=f)
            x++;
        f^=1;
    }
    f=1;
    for(int i=0; i<l; i++)
    {
        int cur=s[i]-'0';
        if(cur!=f)
            y++;
        f^=1;
    }
    cout<<min(x,y)<<endl;


    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <map>
#include <string>

using namespace std;

class Dice {
public:
    explicit Dice(int a[]) {
        for (int i = 0; i < 6; ++i) {
            face[i] = a[i];
            f2i[a[i]] = i;
        }
    }

    void rotate(char dir);
    void loop_swap(int a[]);

    static int rotate_itr[6][4];
    static map<char, int> c2i;
    map<char, int> f2i;
    int face[6];
};

/* ----- member funcs of Dice class ----- */

void Dice::rotate(char dir) {
    loop_swap(rotate_itr[c2i[dir]]);
}

int Dice::rotate_itr[6][4] = {
    {0, 1, 5, 4},  // N
    {0, 3, 5, 2},  // E
    {0, 2, 5, 3},  // W
    {0, 4, 5, 1},  // S
    {1, 2, 4, 3},  // L
    {1, 3, 4, 2},  // R
};

map<char, int> Dice::c2i = {{'N', 0}, {'E', 1}, {'W', 2}, {'S', 3}, {'L', 4}, {'R', 5}};

void Dice::loop_swap(int a[]) {
    int tmp = face[a[0]];
    for (int i = 0; i < 3; ++i) {
        face[a[i]] = face[a[i + 1]];
    }
    face[a[3]] = tmp;
}

/* ----- main func ----- */

const string ope = "NRRRRNRRRRNRRRRNRRRRWRRRRWRRRRWRRRRWRRRRW";

int main() {
    int a[6], b[6];
    for (int i = 0; i < 6; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < 6; ++i) {
        cin >> b[i];
    }

    Dice dice_a(a), dice_b(b);

    for (char c : ope) {
        dice_b.rotate(c);

        bool judge = true;
        for (int i = 0; i < 6; ++i) {
            if (dice_a.face[i] != dice_b.face[i]) judge = false;
        }

        if (judge) {
            cout << "Yes" << endl;
            return 0;
        }
    }

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



Measured memory_bytes: 3228
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        int sum = Arrays.stream(a).mapToInt(i -> i).sum();
        int ave = (int) Math.round((double) sum / n);

        int result = 0;
        for (int num : a) {
            int cost = (num - ave) * (num - ave);
            result += cost;
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 28628
#include <iostream>
#include <array>

int main()
{
    int a;
    int b;
    int sum;
    int digit;
    while (std::cin >> a >> b) {
        sum = a + b;
        digit = 0;
        while (sum != 0) {
            sum = sum / 10;
            digit++;
        }
        std::cout << digit << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2928
#include<bits/stdc++.h>
#include<string.h>
long int max = 200000;
int main()
{
    char s[max];
    std::cin>>s;
    int ans = 0;
    int l = std::string(s).length();
    for(int i =0;s[i]!='\0';i++)
    {
        if (s[i] == 'A')
        {    ans = i;
            break;  
        }
    }
    for(int i =l;i>0;i--)
    {
        if (s[i] == 'Z')
        {    ans = i-ans;
            break;  
        }
    }
    
    std::cout<<ans+1;
   
   // std::cout<<count;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll A, B;
  cin >> A >> B;

  if (A == B) {
    COUT(A);
    return 0;
  }

  if (A % 2 == 0 && B % 2 == 1) {
    ll a = A / 2;
    ll b = B / 2 + 1;
    ll kosu = b - a;
    if (kosu % 2 == 0) {
      COUT(0);
    } else {
      COUT(1);
    }
    return 0;
  }

  if (A % 2 == 0 && B % 2 == 0) {
    ll a = A / 2;
    ll b = B / 2;
    ll kosu = b - a;
    if (kosu % 2 == 0) {
      COUT(B ^ 0);
    } else {
      COUT(B ^ 1);
    }
    return 0;
  }

  if (A % 2 == 1 && B % 2 == 1) {
    ll a = A / 2;
    ll b = B / 2 + 1;
    ll kosu = b - a;
    if (kosu % 2 - 1 == 0) {
      COUT(A ^ 0);
    } else {
      COUT(A ^ 1);
    }
    return 0;
  }

  if (A % 2 == 1 && B % 2 == 0) {
    ll a = A / 2;
    ll b = B / 2;
    ll kosu = b - a;
    if (kosu % 2 - 1 == 0) {
      COUT(A ^ B ^ 0);
    } else {
      COUT(A ^ B ^ 1);
    }
    return 0;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
from bisect import bisect_right
 
N,T = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N)]

b0 = []
ab1 = []

#aが0とそれ以外で分ける
for a,b in ab:
    if a == 0:
        #+1は店間の移動を先に考慮
        b0.append(b+1)
    else:
        ab1.append([(b+1)/a, a, b])

N0 = len(b0)
N1 = len(ab1)

b0.sort()

#bは累積和で時間計算可能（最後にどこまで足せるかを調べる）
if N0>0:
    b_ruiseki = [0]*N0
    b_ruiseki[0] = b0[0]
    for i in range(1,N0):
        b_ruiseki[i] = b_ruiseki[i-1] + b0[i]
else:
    b_ruiseki = []
#探索範囲が28店まででいいからソートする
ab1.sort()

INF = T + 100
 
dp = [[INF]*31 for i in range(N1+1)]
dp[0][0] = 0
ans = 0
for i in range(N1):
    # dp[i+1][j] : 0~i番目までの店を見て，j個選ぶときの最小時間
    for j in range(31):
        if j > i+1:
            break
        if j == 0:
            dp[i+1][j] = 0
        else:
            dp[i+1][j] = min(dp[i][j], dp[i][j-1]+1 + ab1[i][1]*(dp[i][j-1]+1) + ab1[i][2])

for j in range(31):
    if dp[N1][j] > T:
        break    
    # a>0をj店舗めぐった後にa=0を何店舗めぐれるか
    num0 = bisect_right(b_ruiseki, T - dp[N1][j])
    ans = max(ans, j + num0)
        
    
print(ans)

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

int main() {
   int n;
   cin >> n;
   int r[n+1],c[n+1];
   for (int i=1; i<n+1; i++) {
       cin >> r[i] >> c[i];
   }
   int dp[n+1][n+1];
   memset(dp,0,sizeof(dp));
   for (int i=1; i<=n; i++) {
       for (int j=1; j<=i; j++) {
           if (j==1) {
               continue;
           }
           if (j==2) {
               dp[i][j]=r[i-1]*r[i]*c[i];continue;
           }
           int m;
           for (int k=1; k<j; k++) {
               if (k==1) {
                   m=dp[i][j-1]+r[i-j+1]*c[i-j+1]*c[i];
               }
               else m=min(m,dp[i-j+k][k]+dp[i][j-k]+r[i-j+1]*c[i-j+k]*c[i]);
           }
           dp[i][j]=m;
       }
   }
   cout << dp[n][n] << endl;
}


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

const int MAXN=15;

int N;
int A[MAXN],B[MAXN];
int Fact[MAXN];

int Coktour(){
	
	Fact[0]=1;
	for(int i=1;i<=N;i++){
		Fact[i]=Fact[i-1]*i;
	}
	
	int Ans1=0,Ans2=0;
	
	for(int i=1;i<=N;i++){
		int Cnt1=0;
		int Cnt2=0;
		for(int j=i+1;j<=N;j++){
			if(A[j]<A[i]){
				Cnt1++;
			}
			if(B[j]<B[i]){
				Cnt2++;
			}
		}
		Ans1=Ans1+Cnt1*Fact[N-i];
		Ans2=Ans2+Cnt2*Fact[N-i];
	}
	
	return abs(Ans1-Ans2);
	
}

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d",&A[i]);
	}
	for(int j=1;j<=N;j++){
		scanf("%d",&B[j]);
	}
	
	printf("%d\n",Coktour());
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 62;
vector<int> A;
long long dp[100010];
long long rec(int num) {
    if (dp[num] != INF) return dp[num];
    if (num == 0) return dp[num] = 1;
    if(binary_search(A.begin(), A.end(), num)) return dp[num] = 0;


    if (num > 1) {
        dp[num] = (rec(num-1) + rec(num-2)) % 1000000007;
    } else if(num == 1) {
        dp[num] = 1;
    }

    return dp[num];
}
int main() {
    int N, M; cin >> N >> M;
    int prev = 0;
    bool flag = false;
    rep(i, M) {
        int n; cin >> n;
        if(i != 0 && abs(n-prev) == 1) {
            flag = true;
        }
        A.push_back(n);
        prev = n;
    }
    rep(i, N+1) dp[i] = INF;

    if (!flag) {
        cout << rec(N) << endl;


    } else {
        cout << 0 << endl;
    }



    return 0;
}



Measured memory_bytes: 4096
s=input()
t=input()
lens=len(s)
lent=len(t)

mxcnt=0
for i in range(lens-lent+1):
  cnt=0
  for j in range(lent):
    if  s[i+j]==t[j]:
      cnt+=1
      mxcnt=max(mxcnt,cnt)
print(lent-mxcnt)


Measured memory_bytes: 72728
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int [][] a = new int[3][3];
		
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				a[i][j] = stdIn.nextInt();
			}
		}
		
		boolean [][] flag = new boolean[3][3];
		
		int n = stdIn.nextInt();
		
		for(int i = 0; i < n; i++) {
			int b = stdIn.nextInt();
			
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 3; k++) {
					if(b == a[j][k]) {
						flag[j][k] = true;
					}
				}
			}
			
		}
		
		
		if(flag[0][0] && flag[1][0] && flag[2][0] || flag[0][1] && flag[1][1] && flag[2][1] || flag[0][2] && flag[1][2] && flag[2][2] || flag[0][0] && flag[0][1] && flag [0][2] || flag[1][0] && flag[1][1] && flag[1][2] || flag[2][0] && flag[2][1] && flag[2][2] || flag[0][0] && flag[1][1] && flag[2][2] || flag[0][2] && flag[1][1] && flag[2][0]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		
		
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<cstring>
using namespace std;
int lastin[1111];
int blessed[1111];
bool manin[1111];
bool valkyria_in;
int valkyria_time;
int n;
string s;
int ans;
int hr,mi;
char mmmmm;
int inde;
void solve(){
	int t=hr*60+mi;
	if(mmmmm=='I'){
		if(inde==0){
			valkyria_in=true;
			valkyria_time=t;
		}
		else{
			manin[inde]=true;
			lastin[inde]=t;
		}
	}
	else{
		if(inde==0){
			valkyria_in=false;
			for(int i=1;i<1111;i++){
				if(manin[i])blessed[i]+=t-max(lastin[i],valkyria_time);
			}
		}
		else{
			manin[inde]=false;
			if(valkyria_in)blessed[inde]+=t-max(lastin[inde],valkyria_time);
		}
	}
}
int main(){
	while(cin>>n&&n>0){
		ans=0;
		memset(manin,0,sizeof(manin));
		memset(blessed,0,sizeof(blessed));
		valkyria_in=false;
		while(n--){
			cin>>s>>hr>>mmmmm>>mi>>mmmmm>>inde;
			solve();
		}
		for(int i=1;i<1111;i++)ans=max(ans,blessed[i]);
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 1208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC0603
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = Convert.ToInt32(Console.ReadLine());

			var param = new List<int>();

			for (var i = 0; i < n; i++)
			{
				param.Add(Convert.ToInt32(Console.ReadLine()));
			}

			param = param.OrderBy(i => i).ToList();

			var sum = param.Sum();

			if (sum % 10 != 0)
			{
				Console.WriteLine(sum);
			}
			else
			{
				foreach (var i in param)
				{
					if ((sum - i) % 10 != 0)
					{
						Console.WriteLine(sum - i);
						return;
					}
				}
				Console.WriteLine(0);
			}
		}
	}
}


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

int main()
{
	char	grid[50][50];
	int		H, W;
	cin >> H >> W;
	char	obj;
	int		num_black = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> obj;
			grid[i][j] = obj;
			if (obj == '#')
				++num_black;
		}
	}
	int	cost[50][50];
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j)
			cost[i][j] = -1;
	}
	int	di[4] = {1, 0, -1, 0};
	int	dj[4] = {0, 1, 0, -1};
	queue<pair<int, int>>	que;
	cost[0][0] = 1;
	que.push(make_pair(0, 0));
	while (!que.empty()) {
		int	i = que.front().first;
		int	j = que.front().second;
		que.pop();
		for (int k = 0; k < 4; ++k) {
			int	ni = i + di[k];
			int	nj = j + dj[k];
			if (ni < 0 || H <= ni || nj < 0 || W <= nj) continue;
			if (grid[ni][nj] == '#') continue;
			if (cost[ni][nj] != -1) continue;
			cost[ni][nj] = cost[i][j] + 1;
			que.push(make_pair(ni, nj));
		}
	}
	if (cost[H - 1][W - 1] == -1)
		cout << -1 << endl;
	else
		cout << H * W - cost[H - 1][W - 1] - num_black << endl;
}


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

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int pickCount = sc.nextInt();
        int[] numbers = new int[total];
        int result = 0;
        for(int i = 0 ; i < total ; i++){
            numbers[i] = sc.nextInt();
        }
        Arrays.sort(numbers);
        for(int i = 0; i < pickCount ; i++){
            result += numbers[i];
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 38768
from operator import itemgetter
N,M=map(int, input().split())
PY = []
for i in range(M):
    P,Y=map(int, input().split())
    PY.append([P,Y,i])
PY.sort(key=lambda x:x[1])
PY.sort(key=lambda x:x[0])
ANS = []
beforeP = PY[0][0]
x = 1
for i in range(M):
    if beforeP != PY[i][0]:
        x = 1
    ANS.append([PY[i][2],'{:0=6}'.format(PY[i][0]) + '{:0=6}'.format(x)])
    beforeP = PY[i][0]
    x += 1

ANS.sort(key=lambda x:x[0])
for i in range(M):
    print(ANS[i][1])

Measured memory_bytes: 41420
n = int(input())
h = list(map(int,input().split()))

seed = h[0]
checker = True

for i in range(1,n):
    if h[i] == h[i-1]:
        continue
    d = h[i] - h[i-1] + 1
    if d > 0:
        checker = True
        pass
    elif d == 0:
        if checker:
            checker = False
        else:
            print('No')
            quit()
    else:
        print('No')
        quit()


print('Yes')

Measured memory_bytes: 14396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc139
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int count = 0;

            for(int i = 0; i <= 2; i++)
            {
                if(S[i] == T[i])
                {
                    count += 1;
                }
            }
            Console.WriteLine(count);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
object Main {

    def main(args: Array[String]): Unit = {
        val sc = new java.util.Scanner(System.in)

        val n, m = sc.nextInt
        val a = Array.fill(n, m)(sc.nextInt)
        val b = Array.fill(m)(sc.nextInt)
        val c = Array.fill(n)(0)

        for( i <- 0 until n ) {
            for( j <- 0 until m ) {
                c(i) += a(i)(j)*b(j) 
            }
        }

        c.foreach(println)
    }
}



Measured memory_bytes: 58144
N = int(input())
A = list(map(int, input().split( )))


A = [0] + A + [0]
d = 0
for i in range(N+1):
	d += abs(A[i+1]- A[i])

for i in range(N):
	ans = d - abs(A[i+2]- A[i+1]) - abs(A[i+1]- A[i]) + abs(A[i+2]-A[i])
	print(ans)


Measured memory_bytes: 14040
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (k:a:b:_) <- fmap (map read . words) getLine :: IO [Integer]
  print $ solve k a b

solve k a b
  | k <= a = k + 1
  | a + 2 > b = k + 1
  | (k - a) `mod` 2 == 1 = let i = (k + 1 - a) `div` 2 in i * b - (i-1) * a
  | otherwise = 1 + solve (k-1) a b


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

string s, t;
long long dp[30030][3004];

int main () {
    cin >> s >> t;
    for ( int i = 0; i < s.size(); i++) {
        for ( int j = 0; j < t.size(); j++) {
            if ( s[i] == t[j] ) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            else {
                dp[i + 1][j + 1] = max(dp[i][j], max(dp[i][j + 1], dp[i + 1][j]));
            }
        }
    }
    string ans;
    int i = s.size(), j = t.size();
    while ( i > 0 && j > 0 ) {
        if ( dp[i][j] == dp[i - 1][j] ) i--;
        else if ( dp[i][j] == dp[i][j - 1] ) j--;
        else {
            ans = s[i - 1] + ans;
            i--; j--;
        }
    }
    cout << ans;
}


Measured memory_bytes: 71936
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int check = 0;
	for (int four = 0; four < 100; four += 4){
		for(int seven = 0; seven < 100; seven += 7){
			int temp = four + seven;
			if(temp != 0 && n % temp == 0) check++;
		}
	}
	if(check != 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a1 = list(map(str, a[::2]))
a2 = list(map(str, a[1::2]))

if n % 2 == 1:
  print(" ".join(a1[::-1] + a2))
else:
  print(" ".join(a2[::-1] + a1))

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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}

const int N = 5e5+100;
const int inf = 1e9;

int tr[4*N];

void update(int cn, int b, int e, int idx, int x) {
    if(b == e) {
        tr[cn] = x;
        return;
    }
    int mid = (b+e)/2, lc = 2*cn, rc = 2*cn+1;
    if(idx <= mid) update(lc, b, mid, idx, x);
    else update(rc, mid+1, e, idx, x);
    tr[cn] = min(tr[lc], tr[rc]);
}

int query(int cn, int b, int e, int i, int j) {
    if(b > j or e < i or b > e) return inf;
    if(b >= i && e <= j) return tr[cn];
    int mid = (b+e)/2, lc = 2*cn, rc = 2*cn+1;
    return min(query(lc, b, mid, i, j), query(rc, mid+1, e, i, j));
}

int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, K;
    cin >> n >> K;
    vector<int> v(n), pos(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        v[i]--;
        pos[v[i]] = i;
    }
    for(int i = 0; i < n; i++) {
        update(1, 0, n-1, i, inf);
    }
    vector<int> right_bad(n);
    priority_queue<int> candidate;
    vector<vector<int>> edges(n);
    for(int i = n-1; i >= 0; i--) {
        int l = pos[i], r = min(n-1, pos[i]+K-1);
        int min_idx = query(1, 0, n-1, l, r);
        if(min_idx != inf) {
            right_bad[i]++;
            edges[min_idx].push_back(i);
        }
        l = max(0, pos[i]-(K-1)), r = pos[i];
        min_idx = query(1, 0, n-1, l, r);
        if(min_idx != inf) {
            right_bad[i]++;
            edges[min_idx].push_back(i);
        }
        if(right_bad[i] == 0) {
            candidate.push(pos[i]);
        }
        update(1, 0, n-1, pos[i], i);
    }
//    debug(), dbg(edges), dbg(right_bad);
    vector<int> res_pos;
    while(candidate.size() > 0) {
        int y = candidate.top();
        int x = v[candidate.top()];
//        debug(), dbg(x), dbg(y);
        candidate.pop();
        res_pos.push_back(pos[x]);
        for(auto i : edges[x]) {
            right_bad[i]--;
            if(right_bad[i] == 0) candidate.push(pos[i]);
        }
    }
    reverse(res_pos.begin(), res_pos.end());
    vector<int> res(n);
    for(int i = 0; i < n; i++) {
        res[res_pos[i]] = i;
    }
    for(int x : res) cout << x+1 << " ";
    cout << endl;
}





Measured memory_bytes: 45860
#include<stdio.h>
int main(void){
int n,s,f,all,kai,i,j;
for(;;){
    all=0;
    scanf("%d",&n);
    if(n==0)break;
    scanf("%d",&kai);
    for(i=0;i<kai;i++){
        scanf("%d %d",&s,&f);
        all=all+f-s;
    }
    if(all>=n){
        printf("OK\n");
    }
    else printf("%d\n",n-all);
}
return 0;
}

Measured memory_bytes: 612
n,p=map(int,input().split())
s=input()
b=1
d=0
l=[0]*p
l[0]=1
ans=0
for i,c in enumerate(s[::-1]):
  if p==2 or p==5:
    if int(c)%p==0:
      ans+=n-i
  else:
    d+=int(c)*b
    d%=p
    l[d]+=1
    b*=10
    b%=p
if p!=2 and p!=5:
  for i in l:
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 3500
import sys
input = sys.stdin.readline

N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]

T.sort()
ans = 1
head = T[0]
num = 1

for i in range(1,N):
    if num+1 > C or head+K < T[i]:
        ans += 1
        head = T[i]
        num = 1
    else:
        num += 1
        
print(ans)

Measured memory_bytes: 7492
package main

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

var sc = NewScanner(os.Stdin, 1000000)

type Store struct {
	Price int
	Count int
}

type StoreCollection []Store

func (sc StoreCollection) Len() int {
	return len(sc)
}
func (sc StoreCollection) Swap(i, j int) {
	sc[i], sc[j] = sc[j], sc[i]
}
func (sc StoreCollection) Less(i, j int) bool {
	return sc[i].Price < sc[j].Price
}

func main() {
	N := sc.readInt()
	M := sc.readInt()
	stores := []Store{}
	for i := 0; i < N; i++ {
		p := sc.readInt()
		c := sc.readInt()
		store := Store{p, c}
		stores = append(stores, store)
	}
	storeCollection := StoreCollection(stores)
	sort.Sort(storeCollection)

	n := 0
	totalPrice := 0
	for M > 0 {
		if M-storeCollection[n].Count >= 0 {
			totalPrice += storeCollection[n].Price * storeCollection[n].Count
			M -= storeCollection[n].Count
		} else {
			totalPrice += storeCollection[n].Price * M
			M = 0
		}
		n++
	}
	fmt.Println(totalPrice)
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}


Measured memory_bytes: 8704