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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

ll dist[110][110];

// ワーシャルフロイド
void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    Fill(dist, INF);

    vector<ll> A(M);
    vector<ll> B(M);
    vector<ll> C(M);

    REP(i, M){
        ll a, b, c;
        cin >> a >> b >> c;
        dist[a-1][b-1] = c;
        dist[b-1][a-1] = c;

        A[i] = a-1;
        B[i] = b-1;
        C[i] = c;
    }

    warshall_floyd(N);

    ll ans = 0;
    REP(i, M){
        if(dist[A[i]][B[i]] < C[i]) ans++;
    }

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

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int k,n,a[100004],mn=lmax,q;
int main(){std::ios::sync_with_stdio(false);
cin>>n>>k;q=n;k--;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	mn=min(a[i],mn);
}
for(int i=0;i<n;i++)
{
	if(a[i]==mn)
	{
		q--;		
	}
}
cout<<q/k+(0!=q%k)<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 640
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test(t) int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{	
	int n,m;
	cin>>n>>m;
	int ac=0,wa=0;
	vector<vector<int>> V(n+1);
	for(int i=0;i<m;i++)
	{
		int p;
		string s;
		cin>>p>>s;
		if(s=="AC")
		{
			V[p].push_back(1);
		}
		else V[p].push_back(0);
	}
	for(int i=1;i<=n;i++)
	{
		int w=0;
		for(auto x:V[i])
		{
			if(x==1)
			{
				wa+=w;
				ac+=1;
				break;
			}
			else w++;
		}
	}
	cout<<ac<<" "<<wa<<endl;
}

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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
   vector<int> B(N);
   for (int i = 0; i < N-1; i++) {
    B.at(i)=A.at(i+1)-A.at(i);
  }
   for (int i = N-1; i < N; i++){
     B.at(i)=K-A.at(N-1)+A.at(0);
   }
int max = *std::max_element(B.begin(), B.end());
  cout<<K-max<<endl;
}

 

 


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

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    for (int i=0; i<N; i++){
        cin >> h.at(i);
    }

    int num = 0;
    int num_max = 0;
    for (int i=0; i<N-1; i++){
        if (h[i] >= h[i+1]){
            num = num + 1;
        }
        else{
            num = 0;
        }
        if (num>num_max){
            num_max = num;
        }
    }

    cout << num_max << endl;
}

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

int main(){

    int n,m,c;
    cin >> n >> m >>c;

    vector<vector<int> > a(n,vector<int>(m));
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }

    int ans=0;
    rep(i,n){
        ll t=0;
        rep(j,m){
            t+=a[i][j]*b[j];
        }
        t+=c;
        if(t>0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s,t;
	cin>>s>>t;
	ll i,j;
	ll sol[3001][3001]={0};
	for(i=1;i<=s.length();i++)
	{
		for(j=1;j<=t.length();j++)
		{
			if(s[i-1]==t[j-1])
			sol[i][j]=sol[i-1][j-1]+1;
			else
			sol[i][j]=max(sol[i-1][j],sol[i][j-1]);
		}
	}
	//cout<<sol[s.length()][t.length()]<<endl;
	ll len=sol[s.length()][t.length()];
	string str="";
	i=s.length();
	j=t.length();
	while(str.length()!=len)
	{
		if(s[i-1]==t[j-1])
		{
			str=s[i-1]+str;
			i--;
			j--;
		}
		else if(s[i-1]!=t[j-1])
		{
			if(sol[i-1][j]>=sol[i][j-1])
			i=i-1;
			else
			j=j-1;
		}
	}
	cout<<str<<endl;
}

Measured memory_bytes: 70656
using System;
class Program
{
  static void Main(string[] args)
  {
    int n = 0;
    string yohou = Console.ReadLine();
    string tenki = Console.ReadLine();
    for (int i = 0; i < 3; i++) {
      if (yohou[i] == tenki[i]) n++;
    }
    Console.WriteLine(n);
  }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();

		String line2 = sc.nextLine();
		String[] a = line2.split(" ");

		int n = Integer.parseInt(line1);

		for (int i = n - 1; i >= 0; i--) {
			if (i == 0) {
				System.out.print(a[i]);

			} else {
				System.out.print(a[i] + " ");

			}

		}
		System.out.println();
	}

}

Measured memory_bytes: 26072
#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (auto&& e : p) cin >> e, --e;
  vector<int64_t> c(n);
  for (auto&& e : c) cin >> e;
  auto res = numeric_limits<int64_t>::min();
  for (int s = 0; s < n; ++s) {
    vector<int64_t> v;
    for (int i = s;; i = p[i]) {
      v.push_back(c[i]);
      if (p[i] == s) break;
    }
    int m = size(v);
    auto sum = accumulate(begin(v), end(v), 0LL);
    int64_t cur = 0;
    for (int r = 1; r <= m; ++r) {
      if (r > k) break;
      cur += v[r - 1];
      res = max(res, cur + (k - r) / m * max<int64_t>(sum, 0));
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 3772
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define It iterator
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=100003;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



ll n,t,a[100000],m=10000000000,cnt=0;

int main(){
    cin>>n>>t;
    rep(i,0,n) {
        int cur; cin>>cur;
        if(cur<m) m=cur;
        a[i]=cur-m;
    }
    m=0;
    rep(i,0,n) if(a[i]>m) m=a[i];
    rep(i,0,n) if(a[i]==m) cnt++;
    cout<<cnt;

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }



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

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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;cin >> a >> b;
	if(a < b) swap(a,b);
	cout << lcm(a,b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void solve()
{
    int n;
    cin>>n;
    if(n==1)
    {
        cout<<1<<endl;
        return;
    }
    if(n==2 || n==3)
    {
        cout<<2<<endl;
        return;
    }
    vi vis(n+1,0);
    vi prime(n+1,-1);
    for(int i=2;i*i<=n;i++)
    {
        if(!vis[i])
        {
            prime[i]=i;
            vis[i]=1;
        }
        for(int j=i*i;j<=n;j+=i)
        {
            if(!vis[j])
            {
                vis[j]=1;
                prime[j]=i;
            }
        }
    }
    repu(i,1,n)
    {
        if(prime[i]==-1)
            prime[i]=i;
    }
    ll ans=1;
    // repu(i,2,4)
    // {
    //     cout<<prime[i]<<endl;
    // }
    repu(i,2,n)
    {
        int n1=i;
        ll cnt=1;
        while(n1!=1)
        {
            ll x=0;
            int y=prime[n1];
            while(n1%y==0)
            {
                n1/=y;
                x++;
            }
            cnt*=(x+1);
        }
        ll i1=i;
        ans+=cnt*i1;
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 81312
#include<bits/stdc++.h>
using namespace std;
const int N=4e2+7;

int n,h,in[N],out[N];

int f[2*N],hav[2*N];
inline int getf(int x){return f[x]?f[x]=getf(f[x]):x;}

int main(){
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;++i){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int lv=c?c+h:a,rv=d?d:b+h;
		++out[lv]; ++in[rv];
		if(getf(lv)!=getf(rv)) f[getf(lv)]=rv;
	}
	for(int i=1;i<=h;++i) if(out[i]<in[i]) return puts("NO"),0;
	for(int i=h+1;i<=h+h;++i) if(out[i]>in[i]) return puts("NO"),0;
	for(int i=1;i<=h+h;++i) if(out[i]!=in[i]) hav[getf(i)]=1;
	for(int i=1;i<=h+h;++i) if(in[i]+out[i]&&getf(i)==i&&!hav[i]) return puts("NO"),0;
	return puts("YES"),0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl; 
#define De(...)
#define pii pair<int,int>
#define mp make_pair<int,int>
using namespace std; 

int _; 

int x,y;

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d%d",&x,&y);
	if(y%2 || y>x*4 || y<x*2)
		return puts("No"),0;
	puts("Yes");	
	return 0;
}

Measured memory_bytes: 3760
using System;

namespace g
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] lee = Console.ReadLine().Split();
                if (int.Parse(lee[0]) == 0 && int.Parse(lee[1]) == 0) break;
                Console.WriteLine(Combinaciones(int.Parse(lee[0]), int.Parse(lee[1])));
            }
        }
        public static int cant;
        static int Combinaciones(int n, int x)
        {
            cant = 0;
            Solucion(n, x, 3, 0, 1);
            return cant;
        }
        static void Solucion(int n, int x, int numeros, int suma, int pos)
        {
            if (numeros == 0 && suma == x) { cant++; return; }
            else if (numeros == 0 && suma != x) return;
            for (int i = pos; i <= n; i++)
            {
                if (i + suma <= x)
                {
                    Solucion(n, x, numeros - 1, i + suma, i + 1);
                }
            }
        }
    }
}



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

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

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }

  else if ((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }

  else {
    cout << "Right" << endl;
  }
}

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

using namespace std;

#define MAXN 60
#define INF 0x3f3f3f3f
typedef long long LL;

int n, a[MAXN];
vector< pair<int, int> > ans;

int main()
{
    int i, j, k, mx = 0, mi = 0;
    scanf("%d", &n);
    for(i = 1; i <= n; ++i){
        scanf("%d", a + i);
        mx = max(mx, a[i]);
        mi = min(mi, a[i]);
        if(a[i] == mx) k = i;
        if(a[i] == mi) j = i;
    }
    if(abs(mi) < abs(mx)){
        ans.push_back({k, 1});
        ans.push_back({k, 1});
        for(i = 2; i <= n; ++i){
            ans.push_back({i - 1, i});
            ans.push_back({i - 1, i});
        }
    }
    else{
        ans.push_back({j, n});
        ans.push_back({j, n});
        for(i = n - 1; i; --i){
            ans.push_back({i + 1, i});
            ans.push_back({i + 1, i});
        }
    }
    printf("%d\n", (int)ans.size());
    for(auto &it: ans){
        printf("%d %d\n", it.first, it.second);
    }
	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;

	if (N % 2 == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	
	int ans = 0;
	rep(i, 1, 27)
	{
		ans += N / ((int)pow(5LL, i) * 2);
	}

	cout << ans << endl;

	/*int ans = 1;

	for (int i = 44; i <= 50; i += 2)
	{
		ans *= i;
	}

	cout << ans << endl;*/

	

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,time,head,tail;
int *queue;
int *dist;
int *color;
int **matrix;

void enqueue(int);
int dequeue(void);
void bfs(void);

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  queue = malloc(n * sizeof(int));
  color = malloc(n * sizeof(int));
  dist = malloc(n * sizeof(int));

  matrix = malloc(n * sizeof(int *));
  for(i = 0 ; i < n ; i++){
    matrix[i] = malloc(n * sizeof(int));
 }
 for(i = 0 ; i < n ; i++){
   dist[i] = -1;
 }
 for(i = 0 ; i < n ; i++){
   for(j = 0 ; j < n ; j++){
     matrix[i][j] = 0;
   }
 }

 for(i = 0 ; i < n ; i++){
    scanf("%d",&u); u--;
    scanf("%d",&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v); v--;
      matrix[u][v] = 1;
    }
  }

  bfs();
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i+1,dist[i]);
  }

  for(i = 0 ; i < n ; i++){
    free(matrix[i]);
  }
  free(matrix);
  free(queue);
  free(dist);
  free(color);
  return 0;
}

void bfs(){
  int u,i;
  for(i = 0 ; i < n ; i++){
    color[i] = WHITE;
  }
  head = tail = 0;
  color[0] = GRAY;
  dist[0] = 0;
  enqueue(0);

  while(head != tail){
    u = dequeue();
    for(i = 0 ; i < n ; i++){
      if(matrix[u][i] == 1 && color[i] == WHITE){
        color[i] = GRAY;
        dist[i] = dist[u] + 1;
        enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

void enqueue(int q){
  queue[tail] = q;
  if(++tail == n) tail = 0;
}

int dequeue(){
  int v = queue[head];
  if(++head == n) head = 0;
  return v;
}

Measured memory_bytes: 636
import math


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


x = int(input())
while (1):
    if is_prime(x):
        print(x)
        exit()
    else:
        if x % 2 == 0:
            x += 1
        else:
            x += 2


Measured memory_bytes: 3060
#include "bits/stdc++.h"
    using namespace std;
    const int N=2e3+20,MOD=1e9+7;
    int c[N][N],n,k,red,blue,ans;
    int main()
    {
        c[0][0]=1;
        for(int n=1;n<N;n++)
        {
            for(int r=0;r<=n;r++)
            {
                if(r==0 or r==n) c[n][r]=1;
                else c[n][r]=c[n-1][r-1]+c[n-1][r];
                c[n][r]%=MOD;
            }
        }
     
        cin>>n>>k;
     
        blue=k,red=n-k;
        for(int k=1;k<=blue;k++)
        {
            ans=(1ll*c[red+1][k]*c[blue-1][k-1])%MOD;
            printf("%d\n",ans);
        }
    }

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

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		String S = input.next();
		String T = input.next();
		int a=0;
		
		for(int i=0;i<3;i++) {
			char x =S.charAt(i);
			char y =T.charAt(i);
			if (x==y) {
				a+=1;
			}
		}
		System.out.print(a);

	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>
int main(void){
  int n,x,y;
  scanf("%d%d%d",&n,&x,&y);
  if(n>=x+y) printf("%d %d",(int)fmin(x,y),0);
  else printf("%d %d",(int)fmin(x,y),x+y-n);
  return 0;
}

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

ll read()
{
	ll s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(ll x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(ll x,char c='\n')
{
	write(x);
	putchar(c);
}

int main()
{
	ll n=read(),now=1,ans=0;
	while (n)
	{
		ans+=now;
		now*=2;
		n/=2;
	}
	print(ans);

	return 0;
}

Measured memory_bytes: 256
from collections import deque 
A=deque(list(input()))
B=deque(input())
C=deque(list(input()))
now='a'
while len(A)>=0 and len(B)>=0 and len(C)>=0:
  if now=='a':
    if A:
      now=A.popleft()
    else:
      print('A')
      exit()
  elif now=='b':
    if B:
      now=B.popleft()
    else:
      print('B')
      exit()
  else:
    if C:
      now=C.popleft()
    else:
      print('C')
      exit()

Measured memory_bytes: 9336
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
using namespace std;
inline int read()
{
	int ans=0,f=1;
	char c=getchar();
	while (!isdigit(c))
	{
		if (c=='-')
			f=-1;
		c=getchar();
	}
	while (isdigit(c))
	{
		ans=(ans<<3)+(ans<<1)+(c^48);
		c=getchar();
	}
	return ans*f;
}
void write(int x)
{
	if (x>=10)
	{
		write(x/10);
		x%=10;
	}
	putchar(x+'0');
}
int main()
{
	int a,b,c;
	a=read(),b=read(),c=read();
	int ans=0x7fffffff;
	ans=min(ans,min(abs(b-a)+abs(c-b),abs(c-a)+abs(b-c)));
	ans=min(ans,min(abs(b-a)+abs(c-a),abs(c-b)+abs(a-c)));
	ans=min(ans,min(abs(a-c)+abs(b-a),abs(b-c)+abs(a-b)));
	write(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    string S;
    cin >> S;
    int a[4];
    for (int i = 0; i < 4; i++) {
        a[i] = S[i] - '0';
    }

    for (int i = 0; i < 8; i++) {
        int n = i;
        string ans = to_string(a[0]);
        int num = a[0];
        for (int j = 1; j <= 3; j++) {
            if (n % 2 == 0) {
                num += a[j];
                ans += "+";
            } else {
                num -= a[j];
                ans += "-";
            }
            ans += to_string(a[j]);
            n /= 2;
        }
        ans += "=7";
        if (num == 7) {
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static void Main(){
		string[] s = Console.ReadLine().Split();
		int a = int.Parse(s[0]);
		int b = int.Parse(s[1]);
		int ans = 0;
		if (a > b){
			ans += a;
			a--;
		}else{
			ans += b;
			b--;
		}
		if (a > b){
			ans += a;
			a--;
		}else{
			ans += b;
			b--;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>
 
int main()
{
	int N,counter;
	scanf("%d",&N);
	int * A = (int*)malloc(sizeof(int) * N);
	for(int i = 0;i < N;i++)
	{
		scanf("%d",&A[i]);
	}
	while(1)
	{
		for(int i = 0;i < N;i++)
		{
			if (A[i] % 2) goto end;
			else A[i] /= 2;
		}
		counter++;
	}
end:
	free(A);
	printf("%d",counter);
	return 0;
}

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

int main(){
  int n;
  double s[1001];
  double avg, sum, sigma;

  while(1){
	avg = sum = sigma = 0.0;
	scanf("%d", &n);
	if(n == 0){break;}
	for(int i = 0; i < n; i++){
	  scanf("%lf", &s[i]);
	  sum += s[i];
	}
	avg = sum / n;
	for(int i = 0; i < n; i++){
	  sigma += (s[i] - avg) * (s[i] -avg);
	}
	printf("%.8lf\n", sqrt(sigma / n));
  }
  return 0;
}


Measured memory_bytes: 2044
import sys
from fractions import gcd
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())
for i,a in enumerate(A):
    if i==0:
        a_gcd=a
    else:
        a_gcd=gcd(a_gcd,a)

a_lcm=a_gcd
for a in A:
    a_lcm*=a/a_gcd

bunbo=0
for a in A:
    bunbo+=a_lcm/a

print float(a_lcm)/bunbo

Measured memory_bytes: 34536
#include <bits/stdc++.h>
using namespace std;
int n;
int f[5][105];
int main()
{
	cin >> n;
	for (int i = 1;i <= 2;i++)
	{
		for (int j = 1;j <= n;j++)
		{
			cin >> f[i][j];
		}
	}
	for (int i = 1;i <= 2;i++)
	{
		for (int j = 1;j <= n;j++)
		{ 
			f[i][j] = f[i][j] + max(f[i-1][j],f[i][j-1]);
		}
	}
	cout << f[2][n] << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int sum =1;
  int m =0;
  vector<int> h(n);
  for(int i=0;i<n;i++)
    cin >> h[i];
  
  for(int i=1;i<n;i++){
    m = max(m,h[i-1]);
    if(h[i]-m>=0)
      sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c - max(a, max(b, c)) << endl;
}


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

int main(){
  int n;cin >> n;
  map<string,int> m;
  string s[n];rep(i,n){cin >> s[i];m[s[i]] = 0;}
  rep(i,n-1){
    m[s[i]] += 1;
    if(s[i][s[i].length()-1] != s[i+1][0]){
      cout << "No" << endl;
      return 0;
    }
  }
  m[s[n-1]] += 1;
  rep(i,n){
    if(m[s[i]] != 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(void) {
	int N;
	cin >> N;
	vector<int>FB;
	long long int Ans = 0;
	for (int i = 1; i <= N; i++) {
		FB.push_back(i);
	}
	for (int i = 0; i < N; i++) {
		if (FB[i] % 3 == 0) {
			if (FB[i] % 5 == 0) {
				FB[i] = 0;//FizzBuzz
			}
			else {
				FB[i] = 0; //Fizz
			}
		}
		else if (FB[i] % 5 == 0) {
			FB[i] = 0; //Buzz
		}
		else {
			Ans += FB[i];
		}
	}
	cout << Ans << endl;
}

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

#define ll long long
#define s second
#define f first

int main()
{
	ll n;
	cin >> n;
	
	string s;
	cin >> s;
	
	for(int j=0;j<s.size();j++)
	{
		for(int i=1;i<=n;i++)
		{
			if(s[j]=='Z')
				s[j]='A';
			else s[j]++;
		}
	}
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(a) (int)((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

int divide(int x) {
  if (x == 0) return 0;
  int s = 1;
  while (x % 2 == 0) {
    x >>= 1;
    s++;
  }
  return 1 << s;
}

class Trie {
  private:
    struct Node {
      Node* child[2];
      Node() {
        child[0] = NULL;
        child[1] = NULL;
      }
    };
    Node* root;
    int L;

  public:
    Trie(int l) {
      root = new Node();
      L = l;
    }
    void insert(string s) {
      Node* now = root;
      rep(i, 0, SIZE(s)) {
        int x = s[i] - '0';
        if (!now->child[x]) {
          // when child --related to string-- not exists
          now->child[x] = new Node();
        }
        now = now->child[x];
      }
    }
    int dfs(Node* now, int depth) {
      // debug(depth)
      if (!now) {
        return divide(L+1 - depth);
      } else {
        return dfs(now->child[0], depth+1) ^ dfs(now->child[1], depth+1);
      }
    }
    int dfs() {
      return dfs(root, 0);
    }
    // void show(Node* now) {
    //   if (!!now->child[0]) {
    //     cout << 0 << " ";
    //     show(now->child[0]);
    //   }
    //   if (!!now->child[1]) {
    //     cout << 1 << " ";
    //     show(now->child[1]);
    //   }
    //   cout << endl;
    // }
    // void show() {
    //   show(root);
    // }


};



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

// template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
//   int len = v.size();
//   for (int i = 0; i < len; ++i) {
//     s << v[i]; if (i < len - 1) s << " ";
//   }
//   return s;
// }


signed main()
{
  int N, L; cin >> N >> L;
  vector<string> s(N);
  rep(i, 0, N) {
    cin >> s[i];
  }

  Trie trie(L);
  rep(i, 0, N) {
    trie.insert(s[i]);
    // dump(i)
    // trie.show();
    // cout << endl;
  }

  if (trie.dfs() == 0) {
    cout << "Bob" << endl;
  } else {
    cout << "Alice" << endl;
  }

  return 0;
}


Measured memory_bytes: 6400
def resolve():
	n, m, x, y = map(int, input().split())
	xp = list(map(int, input().split()))
	yp = list(map(int, input().split()))
	for i in range(-99, y+1):
		ok = True
		if i <= x or i > y:
			continue
		for cx in xp:
			if cx >= i:
				ok = False
				break
		for cy in yp:
			if cy < i:
				ok = False
				break
		if ok:
			print('No War')
			return
	print('War')
resolve()

Measured memory_bytes: 38640
s = gets.chomp.split('')
t = gets.chomp.split('')
clear = 0
i = 0
j = s.count
while i < j
  if s == t then
    clear = 1
    break
  else
    w = s[-1]
    s.insert(0,w)
    s.pop
    i += 1
  end
end
if clear == 1
  puts 'Yes'
elsif clear == 0
  puts 'No'
end

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>

using namespace std;

int main(int argc, char *argv[])
{
  int H,W;
  while(scanf("%d %d",&H,&W)!= EOF){
    if(H ==0&&W == 0)
      break;
  for(int i= 0;i < H;i++){
    for(int j = 0;j < W;j++){
      if(i == 0 ||i == H-1|| j==0||j == W-1){
	cout <<"#";
      }
      else if(j != 0 &&j != W-1){
	cout <<".";
      }
    }
    cout <<endl;
  }
  cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;
vector<vector<ll>>x(100005);
vector<vector<ll>>y(100005);
vector<vector<ll>> used(2, vector<ll> (100005,0));
ll cx,cy;

void dfs(int t, int n){
  if (used[n][t]==1)return;
  used[n][t]=1;
  if (n==0){
    cx++;
    n++;
    n%=2;
  //  cout<<"t"<<t<<"cx"<<cx<<endl;
    for (ll to:x[t]){
      
      dfs(to,n);
    //  return;

    }
  }
  else if(n==1){
    cy++;
  //  cout<<"t"<<t<<"cy"<<cy<<endl;
  n++;
  n%=2;
    for (ll to:y[t]){
      
      dfs(to,n);
    //  return;

    }
  }
}


int main() {
  ll n;
  cin >> n;
  vector<P> v(n);


  rep(i,n){
    ll a1,b1;
    cin>>a1>>b1;
    v[i]=make_pair(a1,b1);
    x[a1].push_back(b1);
    y[b1].push_back(a1);
  }
ll ans=0;
  rep(i,n){
    cx=0;
    cy=0;
    dfs(v[i].first,0);
  //  cout<<"i"<<i<<cx<<" "<<cy<<endl;
    ans+=cx*cy;
  }

  ans-=n;
  cout<<ans;

}


Measured memory_bytes: 17144
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	int w,n,t[30];
	scanf("%d%d",&w,&n);
	rep(i,w) t[i]=i;
	rep(i,n){
		string s;
		cin >> s;
		int a=0,b=0,cnt=0;
		for(;s[cnt]!=',';cnt++){
			a*=10;
			a+=(s[cnt]-'0');
		}
		for(cnt++;cnt<s.size();cnt++){
			b*=10;
			b+=(s[cnt]-'0');
		}
		swap(t[a-1],t[b-1]);
	}
	rep(i,w) printf("%d\n",t[i]+1);
	return 0;
}

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

typedef struct {double x, y;} Point;

void koch(int n, Point a, Point b){
	if(n == 0) {return;}
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;
	
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
	
	koch(n-1,a,s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n-1,s,u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n-1,u,t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n-1,t,b);
}

int main(){
	Point a,b;
	int n;
	
	scanf("%d", &n);
	
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	
	printf("%.8f %.8f\n", a.x, a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n", b.x, b.y);
	
	return 0;
}



Measured memory_bytes: 2084
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N, M = list(map(int, input().split()))
a = list(map(int, input().split()))

# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

c = 1
for e in a:
    c = lcm(c, e // 2)
hoge = [ (c // (e // 2)) % 2 == 1 for e in a ]

if all(hoge):
    ans = 0
    if c <= M:
        ans += 1
        M -= c
    ans += M // (c * 2)
    print(ans)
else:
    print(0)


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

int main()
{
    long int D, N;
    cin >> D >> N;

    if (D == 0)
    {
        if (N == 100)
        {
            cout << (N + 1);
            return 0;
        }
        cout << N;
    }
    else if (D == 1)
    {
        if (N == 100)
        {
            cout << 100 * (N + 1);
            return 0;
        }
        cout << 100 * N;
    }
    else
    {
        if (N == 100)
        {
            cout << 10000 * (N + 1);
            return 0;
        }
        cout << 10000 * N;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

const int mod = 1000003;
const int NIL = -1;
const string order = "ACGT";
int T[mod];

ll h1(ll key) {
    return key % mod;
}

ll h2(ll key) {
    return 1 + (key % (mod - 1));
}

ll h(ll key, int i) {
    return (h1(key) + i * h2(key)) % mod;
}

void insert(ll key) {
    int i = 0;
    while (1) {
        ll j = h(key, i);

        if (T[j] == NIL) {
            T[j] = key;
            return ;
        } else {
            i++;
        }
    }
}

void search(ll key) {
    int i = 0;
    while (1) {
        ll j = h(key, i);

        if (T[j] == key) {
            puts("yes");
            return ;
        } else if (T[j] == NIL || i >= mod) {
            puts("no");
            return ;
        } else {
            i++;
        }
    }
}

ll changeToKey(char str[]) {
    ll res = 0, p = 1;
    for (int i = 0; i < strlen(str); i++) {
        res += p * (order.find(str[i]) + 1);
        p *= 5;
    }
    return res;
}

int main() {
    for (int i = 0; i < mod; i++) {
        T[i] = NIL;
    }

    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        char cmd[10], str[15];
        scanf("%s %s", cmd, str);

        ll key = changeToKey(str);
        if (cmd[0] == 'i') {
            insert(key);
        } else {
            search(key);
        }
    }
    return 0;
}


Measured memory_bytes: 7176
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#define int long 
using namespace std;

signed main() {
	double N,K;
	cin >> N >> K;
	double answer = 0;
	for(int i = 1;i <= N;i++) {
		double count = 0;
		for(int j = 0;j < 10000000;j++) {
			if(i * pow(2.0,j * 1.0) >= K) {
				count = N * pow(2.0,j * 1.0);
				break;
			}
		}
		answer += 1 / count;
	}
	cout << fixed;
	cout << setprecision(12) << answer << endl;
}

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

int main(void) {
    int n = 0, err;
    unsigned long long h, ans;

    err = scanf("%lld", &h);

    while (h > 1) {
        h /= 2;
        n++;
    }

    ans = pow(2, n + 1) - 1;

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+23;

int a[maxn],vis[maxn];

int main(){
	int n;cin>>n;
	for(int i=0;i<n;i++) scanf("%d",&a[i]),vis[a[i]]++;
	int g=0;
	for(int i=0;i<n;i++){
		g=__gcd(a[i],g);
	}
	if(g>1) return 0*puts("not coprime");
	int flag=0;
	for(int i=2;i<maxn;i++){
		int cnt=0;
		for(int j=i;j<maxn;j+=i) cnt+=vis[j];
		if(cnt>1) flag=1;
	}
	puts(flag?"setwise coprime":"pairwise coprime");
}

Measured memory_bytes: 11460
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int move(int n, int m, int h, int d, char line[30][10])
{
	for(int i=0;i<d;i++)
	{
		if(m-2>=0&&line[i][m-2]=='1')m-=1;
		else if(m-1<n-1&&line[i][m-1]=='1')m+=1;
	}
	return m;
}

int main(void)
{
	while(1)
	{

		int n,m,h,d;
		cin>>n;
		if(n==0)break;
		cin>>m>>h>>d;
		char line[30][10];
		for(int i=0;i<d;i++)
		{
			for(int j=0;j<n-1;j++)
			{
				cin>>line[i][j];
			}
		}
		if(move(n,m,h,d,line)==h)
		{
			cout<<0<<endl;
			goto end;
		}
		for(int i=0;i<d;i++)
		{
			for(int j=0;j<n-1;j++)
			{
				bool flag=true;
				if(line[i][j]=='1')flag=false;
				if(j-1>=0&&line[i][j-1]=='1')flag=false;
				if(j+1<=n-1&&line[i][j+1]=='1')flag=false;
				if(flag==true)
				{
					line[i][j]='1';
					int v=move(n,m,h,d,line);
					line[i][j]='0';
					if(v==h)
					{
						cout<<i+1<<' '<<j+1<<endl;
						goto end;
					}
				}
			}
		}
		cout<<1<<endl;
end:
		;
	}
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[] dp = new int[n];
		ArrayList<Integer> hArrayList = new ArrayList<>();
		for (int i=0; i<n; i++) {
			hArrayList.add(sc.nextInt());
		}

		dp[0] = 0;
		dp[1] = Math.abs(hArrayList.get(0)-hArrayList.get(1));

		for (int i=2; i<n; i++){
			dp[i] = Math.min(dp[i-1]+Math.abs(hArrayList.get(i)-hArrayList.get(i-1)), dp[i-2]+Math.abs(hArrayList.get(i)-hArrayList.get(i-2)));
		}

		System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 63520
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int A=sc.nextInt();
    	int B=sc.nextInt();


    	int counter=0;
    	for(int i=A;i<=B;i++) {

    		if(Judge(i)) {
    			counter++;
    		}

    	}

    	System.out.println(counter);


    }

    public static boolean Judge(int X) {

    	String str=String.valueOf(X);
    	String[] S=str.split("");

    	for(int i=0;i<S.length/2;i++) {

    		if(!S[i].equals(S[S.length-1-i])) {
    			return false;
    		}

    	}

    	return true;
    }



}



Measured memory_bytes: 64896
#include <iostream>
#include <algorithm>
#include <cstring>

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

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

using namespace std;

int dp[1003][1003];
int main() {
    int q; cin>>q;
    rep(_,q) {
        memset(dp,0,sizeof(dp));
        string s,t;
        cin>>s>>t;
        s=" "+s;
        t=" "+t;
        rep(i,s.size()){
            rep(j,t.size()) {
                if(i&&j) {
                    if(s[i]==t[j]) dp[i][j]=dp[i-1][j-1]+1;
                    else {
                        chmax(dp[i][j],dp[i-1][j]);
                        chmax(dp[i][j],dp[i][j-1]);
                    }
                }
            }
            //rep(j,t.size()) cout<<dp[i][j]<<" ";
            //cout<<endl;
        }
        int ans=0;

        rep(i,s.size()) chmax(ans,*max_element(dp[i],dp[i]+t.size()));
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 5156
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(20) << sqrt((x1 - x2) * (x1 - x2) + (y1- y2) * (y1 - y2));

    return 0;
}


Measured memory_bytes: 3264
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define MOD 1000000007;
using namespace std;

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

    int a {}, b {}, c {};
    cin >> a >> b >> c;

    cout<<(c/a)*b<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

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


int main(){
	double eps = 10e-9;
	
	int num;

	while(~scanf("%d",&num)){
		if(num==0) break;

		int sum=0;
		while(num > 0){
			sum += num / 5;
			num = num / 5;
		}

		cout << sum << endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  ll A[N],T=0;
  REP(i,N){
    cin>>A[i];
    T^=A[i];
  }
  
  REP(i,N){
    ll P=A[i]^T;
    cout<<P<<" ";
  }
  cout<<endl;
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

ll imos[100001];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,t,l,r;
  cin >> n >> t;
  rep(i,n){
    cin >> l >> r;
    imos[l]++;
    imos[r]--;
  }
  ll ans = 0;
  rep(i,t){
    /* cout << imos[i] << ' ' ; */
    imos[i+1] += imos[i];
    ans = max(ans,imos[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3932