akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
using namespace std;

int main()
{
  int n, m, l;
  scanf("%d %d %d", &n, &m, &l);
  int a[n][m], b[m][l];
  long long c[n][l];
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < l; j++)
    {
      c[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < m; i++)
  {
    for (int j = 0; j < l; j++)
    {
      scanf("%d", &b[i][j]);
    }
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < l; j++)
    {
      for (int k = 0; k < m; k++)
      {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < l; j++)
    {
      if (j == 0)
      {
        printf("%lld", c[i][j]);
      }
      else
      {
        printf(" %lld", c[i][j]);
      }
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define me(a,b) memset(a,b,sizeof(a))
int a[200010];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	int ans=1;
	for(int i=0;i<n;i++){
		if(a[i]==ans)
		ans++;
	}
	cout<<(n-ans+1==n?-1:n-ans+1)<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;

  string ans = "";
  rep(i,N) {
    ans += S[i];
    ans += T[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/m-solutions2020
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    while(K--)
    {
        if (C >= B && B > A)
        {
            C *= 2;
        }
        else if (C >= B && B <= A)
        {
            B *= 2;
        }
        else if (C < B && B >= A)
        {
            C *= 2;
        }
        else if (C > B && B <= A)
        {
            B *= 2;
        }
        else if (A >= C && A >= B)
        {
            C *= 2;
        }
    }
    if (A < B && B < C)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

string S="";
string T="";

int main() {

	int i;

	cin >> S;

	int len = S.length();

	int now = 0;

	while (1) {

		if (now >= len) { break; }

		string s[6];

		s[0] = "";
		s[1] = "";
		s[2] = "";
		s[3] = "";
		s[4] = "";
		s[5] = "";

		int check[6] = { 0,0,0,0,0,0 };

		if (now + 10 < len) { check[0] = 1; }
		if (now + 9 < len) { check[1] = 1; }
		if (now + 6 < len) { check[2] = 1; }
		if (now + 4 < len) { check[3] = 1; }
		if (now + 5 < len) { check[4] = 1; }
		if (now + 4 < len) { check[5] = 1; }


		if (check[0] == 1) {

			for (i = now; i <= now + 10; i++) {
				s[0] += S[i];
			}
		}

		if (check[1] == 1) {

			for (i = now; i <= now + 9; i++) {
				s[1] += S[i];
			}
		}
		if (check[2] == 1) {
			for (i = now; i <= now + 6; i++) {
				s[2] += S[i];
			}
		}
		if (check[3] == 1) {
			for (i = now; i <= now + 4; i++) {
				s[3] += S[i];
			}
		}
		if (check[4] == 1) {
			for (i = now; i <= now + 5; i++) {
				s[4] += S[i];
			}
		}
		if (check[5] == 1) {
			for (i = now; i <= now + 4; i++) {
				s[5] += S[i];
			}
		}

		if (s[0] == "dreameraser"&&check[0] == 1) {
			now += 11;
			continue;
		}
		if (s[1] == "dreamerase"&&check[1] == 1) {
			now += 10;
			continue;
		}
		if (s[2] == "dreamer"&&check[2] == 1) {
			now += 7;
			continue;
		}
		if (s[3] == "dream"&&check[3] == 1) {
			now += 5;
			continue;
		}
		if (s[4] == "eraser"&&check[4] == 1) {
			now += 6;
			continue;
		}
		if (s[5] == "erase"&&check[5] == 1) {
			now += 5;
			continue;
		}
		printf("NO\n");
		return 0;
	}

	printf("YES\n");

	return 0;
}

Measured memory_bytes: 512
#D
import heapq
n = int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)

q = [-a[0]]
heapq.heapify(q)
ans = 0
for i in range(1,n):
    t = heapq.heappop(q)
    ans += -t
    heapq.heappush(q,-a[i])
    heapq.heappush(q,-a[i])
    
print(ans)

Measured memory_bytes: 31780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,mod=998244353;
int n;
char s[N];
int dp[N][N][N];
bool f[N][N][N];
int main()
{
    scanf("%s",s);
    n=strlen(s);
    f[0][0][0]=true;
    for(int i=0;i<n;i++)
        for(int n0=0;n0<=i;n0++)
        for(int n1=0;n1<=i;n1++)
    {
        if(!f[i][n0][n1]) continue;
        f[i+1][n0][n1]=true;
        if(n0)
        {
            int nn0=n0-1+(s[i]=='0');
            int nn1=n1+(s[i]=='1');
            f[i+1][nn0][nn1]=true;
        }
        if(n1)
        {
            int nn0=n0+(s[i]=='0');
            int nn1=n1-1+(s[i]=='1');
            f[i+1][nn0][nn1] = true;
        }
        if(i+1<n)
        {
            f[i+2][n0+(s[i]=='0')][n1+(s[i] == '1')] = true;
            f[i+2][n0+(s[i+1]=='0')][n1+(s[i+1] == '1')] = true;
        }
    }
    dp[n][0][0]=1;
    ll ans=0;
    for(int i=n;i>=0;i--)
        for(int n0=0;n0<=n;n0++)
        for(int n1=0;n1<=n;n1++)
    {
        if(dp[i][n0][n1]==0) continue;
        if(f[i][n0][n1])
            ans=(ans+dp[i][n0][n1])%mod;
        if(i>0)
        {
            dp[i-1][n0][n1]=(dp[i-1][n0][n1]+dp[i][n0][n1])%mod;
            if(s[i-1]=='1')
                dp[i][n0+1][n1]=(dp[i][n0+1][n1]+dp[i][n0][n1])%mod;
            else
                dp[i][n0][n1+1]=(dp[i][n0][n1+1]+dp[i][n0][n1])%mod;
        }
    }
    ans=(ans+mod-1)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 120728
#include <cmath>
#include <iostream>
#include <vector>

int main()
{
    long long int a, b, c;
    std::cin >> a >> b >> c;

    long long int d = c - a - b;
    if (d > 0 && d * d > 4 * a * b)
    {
        std::cout << "Yes\n";
    }
    else
    {
        std::cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string ss;
    cin>>ss;
    for(int i=0;i<(int)ss.length();i++)
        if(ss[i]=='?') ss[i]='D';
    cout<<ss<<'\n';
    return 0;
}


Measured memory_bytes: 3780
#include <iostream>

using namespace std;

int main()
{
  char x;
  cin>>x;
  if(x=='a' || x=='e' || x=='u' || x=='i' || x=='o')
  {
      cout<<"vowel"<<endl;
  }
  else
  {

      cout<<"consonant"<<endl;
  }


    return 0;
}

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

typedef long long ll;

main()
{
    int n, a, x, index;
    double t;
    vector<double> v;
    cin >> n;
    cin >> t >> a;
    double arr[n];
    for(int i = 0; i < n; i++){
        cin >> x;
        arr[i] = t - (x * 0.006);
        v.push_back(abs(arr[i] - a));
    }
    index = min_element(v.begin(), v.end()) - v.begin();
    cout << index + 1;
}





///promy_pompom
//hello world


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

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				1000000009
#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)
#define endl			'\n'
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int maxn = 1e5 + 5;
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

set<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	set<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.insert(i);
	}
	return primes;
}
set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		// int count = 0;
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

int power(int x, unsigned int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;
	;
	while (y > 0)
	{

		if (y & 1)
			res = (res * x) % p;

		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;

}

// Graph------------------------------------------------------------------------


int32_t main()
{
	FIO;
	// c_p_c();
	// --------------------------------------------------
	// Never GIVE UP !!!!
	int n, x, t;
	cin >> n >> x >> t;

	int final = ceil(n / (float)x);
	cout << (final * t) << endl;

}

Measured memory_bytes: 3680
#include <stdio.h>
#include <string.h>
const int N = 1300;
int main()
{
	char str[N];
	while (fgets(str, 1300, stdin))
	{
		for(int i = 0;i < strlen(str);i++)
		{
			if(str[i] >= 'A' &&str[i] <= 'Z')
			{
				printf("%c", str[i] + 32);
			}
			else if(str[i] >= 'a' &&str[i] <='z')
			{
				printf("%c", str[i] - 32);
			}
			else
			{
				printf("%c", str[i]);
			}
		}	
	}
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
int main(){
   int long long N,D;
   cin>>N>>D;
   int count=0;
   int long long a[N],b[N];
  for (int i=1; i<=N;i++){
     cin>>a[i];
     cin>>b[i];
     if(a[i]*a[i]+b[i]*b[i]<=D*D){
      count++;
     }
   }
   cout<<count<<endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> a(n+1,0),b(m+1,0);
    rep(i,n){
        ll aa; cin>>aa;
        a[i+1]=a[i]+aa;
    }
    rep(i,m){
        ll bb; cin>>bb;
        b[i+1]=b[i]+bb;
    }
    ll ans=0,j=m;
    rep(i,n+1){
        if(a[i]>k) break;
        while(a[i]+b[j]>k) j--;
        ans=max(ans,i+j);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6408
/*
It's better to sleep happy and tired rather than disappointed and frustrated
There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n , ans , sum , a , b ,arr[mx5];
string str;
char p;

int main() {
ios::sync_with_stdio(false);
//int t;cin>>t;while(t--)
{
	cin>>n>>str;
	p=str[0];
	ans=1;
	Fo(i,1,n)
	{
		if(str[i]!=p)
		{
			p=str[i];
			ans++;
		}
	}
	cout<<ans;
}
return 0;
}


Measured memory_bytes: 512
def t(n, k, q, a):
    p = [-q + k] * n
    for i in range(q):
        p[a[i-1]-1] += 1
    return ["Yes" if i > 0 else "No" for i in p]
   

if __name__ == "__main__":
    n, k, q = map(int, input().split())
    a = [int(input()) for i in range(q)]
    r = t(n, k, q, a)
    for i in r:
        print(i)


Measured memory_bytes: 10528
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
for($i=0;$i<$N;$i++) {
  list($S,$P) =  explode(" ",trim(fgets(STDIN)));
  $r = array('rank'=>$i+1,'city' => $S,'score' => $P);
  $R[]=$r;
}

foreach($R as $v) {
  $r_city[]=$v['city'];
  $r_score[]=$v['score'];
}
array_multisort($r_city,SORT_ASC,SORT_STRING,$r_score,SORT_DESC,SORT_NUMERIC,$R);

foreach($R as $v)
{
  printf("%d\n",$v['rank']);
}


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

using namespace std;


int main(void){
    long long N,K;
    map<long long ,long long> mp;
    map<long long, bool> chk;
    long long ans=1,tmp=1,tmp2=1;;
    long long loopcount=0,count=0;;
    bool loopFlg=false;

    cin>>N>>K;

    for(long long i=1;i<=N;i++){
        cin>>mp[i];
    }

    while(loopFlg == false){
        
        if(chk[tmp] == false){
            loopcount++;
            chk[tmp]=true;
            tmp=mp[tmp];
        }else{
            loopFlg=true;
        }
    }

    while(tmp2 != tmp){
        tmp2=mp[tmp2];
        count++;
    }


    // cout<<"tmp:"<<tmp<<" tmp2:"<<tmp2<<endl;

    // cout<<"loopc:"<<loopcount<<" count:"<<count<<endl;

    if(K/200 > loopcount){

    K=count + (K-count)%(loopcount-count) ;

    }

    // cout<<"K:"<<K<<endl;

    for(long long i=0;i<K;i++){
        ans=mp[ans];
    }

    cout<<ans<<endl;



    return 0;
}



Measured memory_bytes: 28308
import java.util.Scanner;

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

        int cnt10000 = -1;
        int cnt5000  = -1;
        int cnt1000  = -1;
        for(int i=0; i<=n; i++) {
            for(int j=0; j<=n-i; j++) {
                int k = n-i-j;
                if(10000*i + 5000*j + 1000*k == y) {
                    cnt10000 = i;
                    cnt5000  = j;
                    cnt1000  = k;
                    System.out.println(Integer.toString(cnt10000) + " " +
                                       Integer.toString(cnt5000)  + " " +
                                       Integer.toString(cnt1000));
                    System.exit(0);
                }
            }
        }
        System.out.println(Integer.toString(cnt10000) + " " +
                           Integer.toString(cnt5000)  + " " +
                           Integer.toString(cnt1000));
    }
}


Measured memory_bytes: 23764
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(N,K);
    vector<int> HP(N,0);
    int hpSum = 0LL,ansCount=0LL;
    rep(i,N)cin>>HP[i],hpSum+=HP[i];
    sort(All(HP),greater<int>());
    rep(i,N){
        if(K==0){
            ansCount+=HP[i];
            continue;
        }else{
            K--;
        }
    }
    cout << ansCount << nn;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=998244353;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
signed main()
{
    fastio;
    R(x);R(y);
    if(y>=2*x&&y<=4*x&&y%2==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#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()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

signed main(void)
{
  int n, m;
  cin >> n >> m;
  if(abs(n-m) <= 1) {
    // n! * m!
    ll ret = 1;
    FOR(i, 1, n+1) {
      ret = (ret*i) % MOD;
    }
    FOR(i, 1, m+1) {
      ret = (ret*i) % MOD;
    }
    if(n == m) ret = (ret*2) % MOD;
    cout << ret << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  long long x;
  std::cin >> x;

  long long money = 100;
  int ans = 0;
  while(money < x){
    money *= 1.01;
    ans += 1;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3168
#!/usr/bin/env python3


def solve(s, t, q):

    cnt_s = [0] * (len(s) + 1)
    cnt_t = [0] * (len(t) + 1)

    r = 0
    for i in range(len(s)):
        cnt_s[i] = r
        if s[i] == 'A':
            r += 1
    cnt_s[-1] = r

    r = 0
    for i in range(len(t)):
        cnt_t[i] = r
        if t[i] == 'A':
            r += 1
    cnt_t[-1] = r

    ans = []
    for _ in range(q):
        a, b, c, d = input().split()
        a = int(a) - 1
        b = int(b)
        c = int(c) - 1
        d = int(d)
        cs = cnt_s[b] - cnt_s[a]
        ms = (2 * (b - a) - cs) % 3
        ct = cnt_t[d] - cnt_t[c]
        mt = (2 * (d - c) - ct) % 3
        ans.append(ms == mt)

    for r in ans:
        print('YES' if r else 'NO')


def main():
    s = input()
    t = input()
    q = input()
    q = int(q)

    solve(s, t, q)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9704
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int main() {
    int n;cin>>n;
    ll val = 1;
    for(auto i = 1; i<=n;i++){
        val *=i;
        val %=MOD;
    }
    cout<<val<<endl;
    return 0;
}







Measured memory_bytes: 256
""" AtCoder """

import sys
input = sys.stdin.readline

N = int(input())
W = [input() for _ in range(N)]

a = []
check = 1

for i in range(N-1):
    if W[i+1] in a or W[i][-2] != W[i+1][0]:
        check = 0
        break
    a.append(W[i])

if check == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
//const long mod=(long)1e9+7;
inline void solve(void){
  int N;
  in(N);
  set<int>A;
  rep(i,N){
    int a;in(a);
    A.insert(a);
  }
  if(A.size()==N)out("YES");
  else out("NO");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, m, x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) cin >> a[i][j];
    }

    int ans = inf;
    for (int s = 0; s < (1 << n); s++) {
        int cost = 0;
        vector<int> und(m);
        for (int i = 0; i < n; i++) {
            if (s & (1 << i)) {
                cost += c[i];
                for (int j = 0; j < m; j++) {
                    und[j] += a[i][j];
                }
            }
        }
        if (*min_element(und.begin(), und.end()) >= x) {
            ans = min(ans, cost);
        }
    }
    cout << (ans < inf ? ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        System.out.println(n == 0 ? 1 : 0);
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

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


Measured memory_bytes: 32676
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  int N;
  cin >> N;
  string s, t;
  cin >> s >> t;

  string ans = s;
  REPR(i,N){
    int flag = 0;
    REP(j,i){
      if(s.at(j+N-i)!=t.at(j)){
        flag = 1;
      }
    }
    if(flag==0){
      cout << 2*N-i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.top,   self.bottom = top, bottom
        self.right, self.left   = right, left
        self.front, self.back   = front, back

    def rot(self, d):
        if   d == "N":
            self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        elif d == "S":
            self.top, self.back, self.bottom, self.front = self.back, self.bottom, self.front, self.top
        elif d == "E":
            self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        elif d == "W":
            self.top, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.top

ls = map(int, raw_input().split())
dice = Dice(ls[0], ls[1], ls[2], ls[3], ls[4], ls[5])
for d in raw_input():
    dice.rot(d)
print dice.top

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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,cnt[100005];

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	ll n,a,b;
	scanf("%lld",&n);
	scanf("%lld%lld",&a,&b);
	ll cnt=(n)/(a+b);
	printf("%lld\n",a*cnt+min(a,n%(a+b)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n;
    ll ans = 0;

    cin >> n;

    string s;

    map <string, int> mp;

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

        cin >> s;

        sort(s.begin(), s.end());

        mp[s]++;
    }

    for (auto i = mp.begin(); i != mp.end(); i++) {

        ll tmp = i->second;

        ans += (tmp*(tmp-1))/2;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 11264
n = int(input())
a = [int(i) for i in input().split()]

# a[0]の符号を正にするか負にするかの2択で
# 後は一意に決まる

_sum = 0
count = 0
out = 0
# a[0]の符号を正にする場合
for i in range(len(a)):
    if i % 2 == 1:  # a[i]までの和を負にする
        if _sum + a[i] >= 0:
            count += abs(_sum + a[i] - (-1))
            _sum = -1
        else:
            _sum += a[i]
    else:  # a[i]までの和を正にする
        if _sum + a[i] <= 0:
            count += abs(1 - (_sum + a[i]))
            _sum = 1
        else:
            _sum += a[i]
# print("count:{} sum:{}".format(count, _sum))
out = count
_sum = 0
count = 0
# a[0]の符号を負にする場合
for i in range(len(a)):
    if i % 2 == 0:  # a[i]までの和を負にする
        if _sum + a[i] >= 0:
            count += abs(_sum + a[i] - (-1))
            _sum = -1
        else:
            _sum += a[i]
    else:  # a[i]までの和を正にする
        if _sum + a[i] <= 0:
            count += abs(1 - (_sum + a[i]))
            _sum = 1
        else:
            _sum += a[i]
            # print("count:{} sum:{}".format(count, _sum))
print(min(out, count))


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

ll pnk(ll n, ll k) {
  ll result = 1, pn = n, now = 0;
  while(k>=1<<now) {
    if (k&1<<now) result = result * pn % MOD;
    pn = pn * pn % MOD;
    now++;
  }
  return result;
}

int main() {
  ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  ll dp[B+1][N+1] = {}; dp[A-1][N] = 1;

  c_fac();
  repr(i,A,B+1) rep(j,N+1) {
    dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
    ll con;
    for (ll k=C; j>=i*k&&k<=D; k++) {
      if (k==C) con = fac[j] * inv(pnk(fac[i],k)) % MOD * inv(fac[j-i*k]) % MOD * inv(fac[k]) % MOD;
      else con = con * nck(j-i*(k-1),i) % MOD * inv(k) % MOD;
      dp[i][j-i*k] = (dp[i][j-i*k] + dp[i-1][j]*con) % MOD;
    }
  }
  // rep(i,B+1) debug(dp[i],dp[i]+(N+1));

  ll result = dp[B][0];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 18616
#include <iostream>
using namespace std;
long long GCD(long long x, long long y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main() {
    int K;
    scanf("%d",&K);
    long long res = 0;
    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            for (int c = 1; c <= K; ++c) {
                res += GCD(GCD(a, b), c);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
    ll n,a,b,ma;
    cin >> a >> b >> n;
    if(n>=b) {
        ma=b-1;
    } else {
        ma=n;
    }
    ll ans=(a*ma)/b-a*(ma/b);
    cout << ans << endl;
  return 0;
}


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

int main(){
  int N, D;
  cin >> N >> D;
  int X[N][D];
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++) cin >> X[i][j];
  }
  int ans=0;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      int dist=0;
      for(int k=0; k<D; k++){
        dist+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      for(int k=1; k<401; k++){
        if(dist==k*k){
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;
#define MAX_LEN 16020
bool dpx[4010][MAX_LEN], dpy[4010][MAX_LEN];

int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    vector<int> xv, yv;
    int isX = 1;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'T') {
            if(i == 0)
                xv.pb(0);
            if(isX) {
                if(cnt)
                    xv.pb(cnt);
            } else {
                if(cnt)
                    yv.pb(cnt);
            }
            cnt = 0;
            isX = 1 - isX;
        } else {
            cnt++;
        }
    }
    if(isX) {
        if(cnt)
            xv.pb(cnt);
    } else {
        if(cnt)
            yv.pb(cnt);
    }
    int offset = 8010;
    dpx[0][offset] = true;
    dpy[0][offset] = true;
    for(int i = 0; i < xv.size(); i++) {
        for(int j = 0; j < MAX_LEN; j++) {
            if(dpx[i][j]) {
                if(j + xv[i] < MAX_LEN) {
                    dpx[i + 1][j + xv[i]] = true;
                }
                if(j - xv[i] >= 0 && i != 0) {
                    dpx[i + 1][j - xv[i]] = true;
                }
            }
        }
    }
    for(int i = 0; i < yv.size(); i++) {
        for(int j = 0; j < MAX_LEN; j++) {
            if(dpy[i][j]) {
                if(j + yv[i] < MAX_LEN) {
                    dpy[i + 1][j + yv[i]] = true;
                }
                if(j - yv[i] >= 0) {
                    dpy[i + 1][j - yv[i]] = true;
                }
            }
        }
    }

    if(dpx[xv.size()][x + offset] && dpy[yv.size()][y + offset]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 64256
import java.util.Scanner

class DP(n:Int, w:Int, items:Array[(Int,Int)]) {
  val memo = Array.fill(n+1)(Array.fill(w+1)(0))
  def solver():Int = {
    for (i <- 1 to n; j <- 1 to w) {
      val (v, w) = items(i-1)
      val v0 = memo(i-1)(j)
      val v1 = if (j < w) 0 else memo(i-1)(j-w) + v
      memo(i)(j)= if (v0 > v1) v0 else v1
    }
    // for (r <- 0 to n) println(memo(r).mkString(" "))
    memo(n)(w)
  }
}

object Main extends App { 
  val sc = new Scanner(System.in)
  val N, W = sc.nextInt()
  val items = (for (i <- 1 to N) yield (sc.nextInt, sc.nextInt)).toArray

  val dp = new DP(N, W, items)

  println(dp.solver())
}


Measured memory_bytes: 52560
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
    string s, t;
  	cin >> s >> t;
  	cout << count_if(s.begin(), s.end(), [&s, &t](char) { auto b = s.back() == t.back(); s.pop_back(); t.pop_back(); return b; }) << endl;;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, count = 0;
    scanf("%d", &n);
    
    char a[n+1], b[n+1], c[n+1];
    
    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);
    
    for(int i=0; i<n; i++){
        if(a[i] == b[i] && b[i] == c[i]){
            continue;
        }else if(a[i]==b[i] || a[i]==c[i] || b[i]==c[i]){
            count++;
        }else{
            count += 2;
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 128
#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 = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    ll ans = 0;
    rep(i, N+1){
        if(i%3 > 0 && i%5 > 0) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/g);
Array.prototype.uniq = function(){
  tmp = {};tmp_arr = [];
  for( var i=0;i<this.length;i++){tmp[this[i]] = i;}
  for( i in tmp){tmp_arr.push(i);}
  return tmp_arr;
}
var s = input[1].split(/\s/g).uniq();
console.log(s.length === 3 ? "Three" : "Four");



Measured memory_bytes: 8648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } return 0; }

ll k = 0;
vector<vector<pll>> g;
vector<ll> ans;
void dfs(ll from, ll at, ll color){
  for(auto& i : g[at]) if(i.first != from){
    color++;
    if(color >= k) color -= k;
    ans[i.second] = color;
    dfs(at, i.first, color);
  }
}
int main(){
  ll n;
  cin >> n;
  g.resize(n);
  ans.resize(n - 1);
  for(ll i = 0; i < n - 1; i++){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back({b, i});
    g[b].push_back({a, i});
  }
  for(auto& i : g) chmax<ll>(k, i.size());
  dfs(-1, 0, 0);
  cout << k << endl;
  for(auto& i : ans) cout << i + 1 << endl;
}


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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define rept(i,n) for(ll (i)=0;(i)<=(ll)(n);(i)++)
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);(i)++)
#define repst(i,s,n) for(ll (i)=(s);(i)<=(ll)(n);(i)++)
#define repr(i,n) for(ll (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\???
// .???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????
// ?????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\??????????????????

int V, E, s, t, d, dp[1<<15][15], e[15][15];

int main() {
	cin >> V >> E;
	rep(i,V) {
		fill(e[i], e[i]+V, inf);
		e[i][i] = 0;
	}
	rep(i,E) {
		cin >> s >> t >> d;
		e[s][t] = d;
	}
	// dp[i][j] i: ???????¨???????????????????????????? j:?????¨??°
	rep(i,1<<V) fill(dp[i], dp[i]+V, inf);
	dp[0][0] = 0;
	reps(i,1,1<<V) {
		rep(v,V) {
			rep(u,V) {
				if (i>>u & 1) chmin(dp[i][v], dp[i^(1<<u)][u] + e[v][u]);
			}
		}
	}
	if (dp[(1<<V)-1][0]!=inf) cout << dp[(1<<V)-1][0] << ln;
	else cout << -1 << ln;
}

Measured memory_bytes: 5048
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = sum(b)
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]

print(ans)

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

int32_t main(){
     int n;
     cin>>n;
     int a[n][2];
     for(int i=0;i<n;++i){
         cin>>a[i][0];
         cin>>a[i][1];
     }
     for(int i=2;i<n;++i){
         if( a[i][1]==a[i][0]&&a[i-1][1]==a[i-1][0]&&a[i-2][1]==a[i-2][0]){
             cout<<"Yes";
             return  0;
         }
     }

     cout<<"No";
    return 0;
}

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

ll solve() {
    ll H, W;
    cin >> H >> W;
    vector<vector<int>> S(H, vector<int>(W));
    string s;
    for ( int i = 0; i < H; i++ ) {
        cin >> s;
        for ( int j = 0; j < W; j++ ) {
            S[i][j] = s[j] == '.' ? 0 : 1;
        }
    }
    int INF = 1e8;
    vector<vector<int>> dp(H, vector<int>(W, INF));
    dp[0][0] = 0;
    for ( int i = 0; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
            if ( j > 0 ) {
                if ( S[i][j] != S[i][j-1] ) dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
                else dp[i][j] = min(dp[i][j], dp[i][j-1]);
            }
            if ( i > 0 ) {
                if ( S[i][j] != S[i-1][j] ) dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
                else dp[i][j] = min(dp[i][j], dp[i-1][j]);
            }
        }
    }
    ll ans = 0;
    if ( S[0][0] == 1 ) ans++;
    if ( S[H-1][W-1] == 1 ) ans++;
    ans += dp[H-1][W-1];
    ans = (ans + 1) / 2; 
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384