akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
    char S[4], T[4];
    scanf("%s", S);
    scanf("%s", T);

    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) {
            cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int s, w;
  cin>>s>>w;
  if(s <= w){
    cout<< "unsafe" <<endl;
  }else{
    cout<< "safe" <<endl;
  }
  return 0;
}


Measured memory_bytes: 3628
N,M = [int(x) for x in input().split()]
scs = [[int(x) for x in input().split()] for _ in range(M)]

i_range = range(10**(N-1),10**N) if N!=1 else range(0,10)
def search(scs):
    for i in i_range:
        cnt = 0
        for s,c in scs:
            if str(i)[s-1]==str(c):
                cnt +=1
        if cnt == len(scs):
            return i
    return -1

print(search(scs))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

long long a[100];
int main()
{
	int N,i;
	scanf("%d",&N);
	a[0] = 2;
	a[1] = 1;
	for(i = 2; i <= N; i++)
	{
		a[i] = a[i-1] + a[i-2];
	}
	printf("%lld",a[N]);
	return 0;
}


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

int main() {
  int DIV = 1e+9 + 7;
  int N, M; cin >> N >> M;
  int S[N]; for (int i = 0; i < N; i++) cin >> S[i];
  int T[M]; for (int j = 0; j < M; j++) cin >> T[j];
  int D[N+1][M+1];
  for (int i = 0; i <= N; i++) D[i][0] = 1;
  for (int j = 0; j <= M; j++) D[0][j] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      D[i+1][j+1] = (D[i+1][j] + D[i][j+1]) % DIV;
      if (S[i] != T[j])
        D[i+1][j+1] = (D[i+1][j+1] - D[i][j] + DIV) % DIV;
    }
  }
  cout << D[N][M] << endl;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	int n,m; cin >> n >> m;
	vector<pair<int, int> > b(m);
	for(int i = 0; i < m; i++)cin >> b[i].first >> b[i].second;
	sort(ALL(b));
	
	vector<int> a(n+1,0);
	for(auto e : b){
		a[e.first] += 1;
		a[e.second] += -1;
	}
	for(int i = 1; i < n+1; i++){
		a[i] += a[i-1];
	}
//	for(auto e : a)cerr << e << " ";
//	cerr << endl;
	
	bool flag = false;
	int cnt = 0;
	int ans = n+1;
	for(auto e : a){
		if(flag && !e){
			flag = false;
			ans += 2*cnt;
			cnt = 0;
//			cerr << cnt << endl;
		}
		else if(e){
			cnt++;
			if(!flag)flag = true;
		}
	}
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3120
n = int(input())
list_ = [0]*1000000
for i in range(1,100):
   for j in range(1,100):
       for k in range(1,100):
           list_[i**2 + j**2 + k**2+i*j+j*k+k*i - 1] += 1
for i in range(n):
    print(list_[i])


Measured memory_bytes: 16804
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

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

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<int> res;
vector<int> ord;

int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
   ll n, m, i, j, k, t, q, c;

   cin>>n>>k>>c;

   string s;

   cin>>s;

   ll a[sz(s)], b[sz(s)];
  // cout<<sz(s)<<"\n";

  

   for(i = 0;i < sz(s);i++){
       if(s[i] == 'o'){
         //  cout<<"here "<<i<<"\n";
           if(i == 0){
               a[i] = 1;
           }
           else{
               a[i] = a[i-1]+1;
           }

           for(j = i+1;j <= min(i+c, ll(sz(s)-1));j++){
               a[j] = a[i];
           }
            i = j-1;
       }
       else{
           if(i == 0){
               a[i] = 0;
           }
           else
           a[i] = a[i-1]; 
       }
   }

    for(i = sz(s)-1;i >= 0;i--){
       if(s[i] == 'o'){
           if(i == sz(s)-1){
               b[i] = 1;
           }
           else{
               b[i] = b[i+1]+1;
           }

           for(j = i-1;j >= max(i-c, ll(0));j--){
               b[j] = b[i];
           }
            i = j+1;
       }
       else{
           if(i == sz(s)-1){
               b[i] = 0;
           }
           else
           b[i] = b[i+1]; 
       }
   }

   vector<ll> res;

  for(i = 0;i < sz(s);i++){
      if(i == 0){
          if(b[i+1] >= k){
              continue;
          }
          else{
            res.push_back(i+1);
          }
      }
      else if(i == sz(s)-1){
          if(a[i-1] >= k){
              continue;
          }
          else{
              res.push_back(i+1);
          }
      }
      else{
          if(a[i-1] + b[i+1] < k){
              res.push_back(i+1);
          }
      }
  }

  for(i = 0;i < sz(res);i++){
      cout<<res[i]<<"\n";
  }

}




Measured memory_bytes: 6536
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int N;
string S;
bool F[100000];
bool C(){
  FOR(i,1,N-1){
    if(S[i]=='o'){
      if(F[i]){
        F[i+1]=F[i-1];
      }else{
        F[i+1]=(F[i-1]?false:true);
      }
    }else{
      if(F[i]){
        F[i+1]=(F[i-1]?false:true);
      }else{
        F[i+1]=F[i-1];
      }
    }
  }
  bool update=false;
  if(F[N-1]){
    if(S[N-1]=='o'&&F[N-2]==F[0]){
      update=true;
    }else if(S[N-1]=='x'&&F[N-2]!=F[0]){
      update=true;
    }
  }else{
    if(S[N-1]=='o'&&F[N-2]!=F[0]){
      update=true;
    }else if(S[N-1]=='x'&&F[N-2]==F[0]){
      update=true;
    }
  }
  if(update&&F[0]){
    if(S[0]=='o'&&F[N-1]==F[1]){
      return true;
    }else if(S[0]=='x'&&F[N-1]!=F[1]){
      return true;
    }
  }else if(update&&!F[0]){
    if(S[0]=='o'&&F[N-1]!=F[1]){
      return true;
    }else if(S[0]=='x'&&F[N-1]==F[1]){
      return true;
    }
  }
  return false;
}
void end(){
  FOR(i,0,N){
    cout<<(F[i]?'S':'W');
  }
  cout<<endl;
}
int main(){
  cin>>N>>S;
  F[0]=F[1]=true;
  if(C()){
    end();
    return 0;
  }
  F[0]=false;
  if(C()){
    end();
    return 0;
  }
  F[1]=false;
  if(C()){
    end();
    return 0;
  }
  F[0]=true;
  if(C()){
    end();
    return 0;
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 640
/**
 * @author torith
 * @date 2018-10-24
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<int,int> A;
    for (int i = 0; i < N; ++i) {
        int t;
        cin >> t;
        A[t] = (A[t] + 1)%2;
    }

    int ans = 0;
    for (auto& a: A){
        if (a.second == 1) ans ++;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 4992
N = int(input())
A = [int(input()) for _ in range(N)]

max1 = max(A)
n_max1 = A.count(max1)

# 最大値と等しい値がが2つ以上ある場合
if n_max1 > 1:
    for _ in range(N):
        print(max1)
    exit()

# 最大値と等しい値が1つだけの場合
else:
    max2 = sorted(list(set(A)))[-2]
    for i in range(N):
        if A[i] != max1:
            print(max1)
        else:
            print(max2)


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename T> class RPQ : public PQ<T, vector<T>, greater<T>> { };

LL n, a[300000];
LL ma[300000];
LL mi[300001];

int main() {
	cin >> n;
	inc(i, 3 * n) { cin >> a[i]; }
	
	RPQ<LL> p;
	inc(i, n) {
		p.push(a[i]);
		ma[i] = (i == 0 ? 0 : ma[i - 1]) + a[i];
	}
	incID(i, n, 2 * n) {
		p.push(a[i]);
		LL maa = p.top(); p.pop();
		ma[i] = ma[i - 1] + a[i] - maa;
	}
	
	PQ<LL> p2;
	decID(i, n * 2, n * 3) {
		p2.push(a[i]);
		mi[i] = mi[i + 1] + a[i];
	}
	decID(i, n, n * 2) {
		p2.push(a[i]);
		LL mii = p2.top(); p2.pop();
		mi[i] = mi[i + 1] + a[i] - mii;
	}
	
	LL ans = -1e15;
	incII(i, n, n * 2) {
		setmax(ans, ma[i - 1] - mi[i]);
	}
	
	// inc(i, 3 * n) { cout << ma[i] << " "; } cout << endl;
	// inc(i, 3 * n) { cout << mi[i] << " "; } cout << endl;
	
	cout << ans << endl;
	
	return 0;
}


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

int main(int argc, char* argv[])
{
	long long M,N;
	cin>>N>>M;
	long long m1=M/2;
	long long m2=M-2*m1;
	if (N>=m1){
		cout<<m1<<endl;
		return 0;
	}
	//N<m1;

	long long aw=N;
	long long m3=(m1-N)*2+m2;
	aw += m3/4;
	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
c_list = []
count = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        c_list.append(count)
        count = 0
c_list.append(count)
print(max(c_list))


Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int h, w; scanf("%d%d", &h, &w);
	std::vector<std::string> s(h);
	for(int i = 0; i < h; i++) cin >> s[i];
	
	using P = std::pair<int, int>;
	
	std::queue<P> qu;
	auto used = make_v<int>(h, w);
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			used[i][j] = -1;
			if(s[i][j] != '#') continue;
			qu.push({i, j});
			used[i][j] = 0;
		}
	}
	
	std::vector<int> dx = {0, -1, 0, 1};
	std::vector<int> dy = {1, 0, -1, 0};
	while(!qu.empty()) {
		auto p = qu.front(); qu.pop();
		
		for(int k = 0; k < 4; k++) {
			int nx = p.first + dx[k], ny = p.second + dy[k];
			if(nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
			if(used[nx][ny] != -1) continue;
			used[nx][ny] = used[p.first][p.second] + 1;
			qu.push({nx, ny});
		}
	}
	
	int ans = 0;
	for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) ans = std::max(ans, used[i][j]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
const double PI = 3.141592653589793;

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

double a,b,x;

double f(double angle){
	if(angle < atan(b / a)) return a * a * b - a * a * a * tan(angle) / 2;
	else return b * b * a / tan(angle) / 2;
}

signed main(){
	cin >> a >> b >> x;
	double ok = 0,ng = PI / 2.0;
	for(int i = 0;i < 100;i++){
		double mid = (ok + ng) / 2;
		if(f(mid) > x) ok = mid;
		else ng = mid;
	}
	printf("%.12lf\n",ok / PI * 180);
}

Measured memory_bytes: 512
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val h, w, d = sc.nextInt()
  val n = h * w;
  val pos = Array.fill(n)((0, 0))
  for {
    i <- 0 until h
    j <- 0 until w
  } {
    val a = sc.nextInt() - 1
    pos(a) = (i, j)
  }
  val c = Array.fill(d, n / d)(0)
  for {
    i <- 0 until d
    j <- 0 until n / d
  } {
    if (i + (j + 1) * d < n) {
      val (x1, y1) = pos(i + j * d)
      val (x2, y2) = pos(i + (j + 1) * d)
      c(i)(j) = (x1 - x2).abs + (y1 - y2).abs
    }
  }

  val ca = c.map(_.scanLeft(0)(_ + _))

  val q = sc.nextInt()
  val lr = List.fill(q)((sc.nextInt()-1, sc.nextInt()-1))
  val pw = new java.io.PrintWriter(Console.out)
  for ((l, r) <- lr) {
    val x = l % d
    pw.println(ca(x)(r / d) - ca(x)(l / d))
  }
  pw.flush()
}


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

int main(){
	
	int n,i;
	long long ans=0;
	cin>>n;
	long long a[n+1],h[n+1];
	memset(h,0,sizeof(h));
	
	for(i=1;i<=n;++i){
		cin>>a[i];
		++h[a[i]];
	}
	
	for(i=1;i<=n;++i){
		ans+=h[i]*(h[i]-1)>>1;
	}
	
	for(i=1;i<=n;++i){
		cout<<ans-h[a[i]]+1<<endl;
	}
	
	return 0;
} 

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

long long N=0,K=0,M=0,A=0,B=0,ans=0,p=0;
long long n=0,x=0,s=0,t=0;
string S,T,ANS;

int main(){
    cin >> N >> S >> T;
    rep(i,N){
        ANS += S[i];
        ANS += T[i];
    }

    cout << ANS << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello{
    public static void Main(){
        // Here your code !
        string line1 = Console.ReadLine();
        string []ab1 = line1.Split(' ');
        int n = Convert.ToInt32(ab1[0]);
        string line2 = Console.ReadLine();
        string []ab2 = line2.Split(' ');
        long []ans = new long[n];
        for(int i = 0; i < n; i++){
            ans[i]= Convert.ToInt32(ab2[i]);
        }
        for(int i = 0; i < n - 1; i++){
            Console.Write("{0} ",ans[n-i-1]);
        }
        Console.WriteLine(ans[0]);

    }
}

Measured memory_bytes: 9260
/*
𝓐𝓾𝓽𝓱𝓸𝓻:-

╭━━━┳━━━┳╮╱╭┳━━━┳━━━┳━━╮╭╮╱╭╮
┃╭━╮┃╭━╮┃┃╱┃┃╭━╮┃╭━╮┃╭╮┃┃┃╱┃┃  
┃╰━━┫┃╱┃┃┃╱┃┃╰━╯┃┃╱┃┃╰╯╰┫╰━╯┃
╰━━╮┃╰━╯┃┃╱┃┃╭╮╭┫╰━╯┃╭━╮┃╭━╮┃
┃╰━╯┃╭━╮┃╰━╯┃┃┃╰┫╭━╮┃╰━╯┃┃╱┃┃
╰━━━┻╯╱╰┻━━━┻╯╰━┻╯╱╰┻━━━┻╯╱╰╯  

*/

#include <bits/stdc++.h> 
using namespace std; 
#define int long long int
#define REDBULL ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define MAX 131079

void change(string s) 
{ 
  
    // Finding the length of the string  
    int n = s.length();  
  
    // To store the number of replacement operations  
    int cc = 0; 
  
    for(int i=0;i<n/2;i++) 
    { 
  
        // If the characters at location  
        // i and n-i-1 are same then  
        // no change is required  
        if(s[i]== s[n-i-1])  
            continue; 
  
        // Counting one change operation  
        cc+= 1; 
  
        // Changing the character with higher  
        // ascii value with lower ascii value  
        if(s[i]<s[n-i-1])  
            s[n-i-1]= s[i] ; 
        else
            s[i]= s[n-i-1] ; 
    } 
    // printf("Minimum characters to be replaced = %d\n", (cc)) ; 
    cout<<cc<<endl;
    // cout<<s<<endl;  
} 
int32_t main() 
{ 
	REDBULL
	string s;
	cin>>s;
	change(s);
	return 0; 
} 


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

int a[2][19], dp[1 << 18][18], newmask, n;

inline int GetBit(const int &a, const int &b)
{
    return (a >> b & 1);
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
    cin >> n;
    for(int j = 0; j < 2; j++)
        for(int i = 0; i < n; i++)
            cin >> a[j][i];
    fill_n(&dp[0][0], (1 << 18) * 18, 1e9);
    for(int i = 0; i < n; i++)
    {
        dp[1 << i][i] = 0;
    }
    for(int mask = 0; mask < (1 << n); mask++)
    {
        if(__builtin_popcount(mask) < 2) continue;
        int cnt = __builtin_popcount(mask);
        for(int i = 0; i < n; i++)
        {
            if(!GetBit(mask, i)) continue;
            newmask = mask ^ (1 << i);
            for(int j = 0; j < n; j++)
            {
                if(!GetBit(newmask, j)) continue;
                if(a[(j ^ (cnt - 2)) & 1][j] <= a[(i ^ (cnt - 1)) & 1][i])
                {
                    int bonus = 0;
                    for(int k = i + 1; k < n; k++)
                    {
                        if(GetBit(newmask, k)) bonus++;
                    }
                    dp[mask][i] = min(dp[mask][i], dp[newmask][j] + bonus);
                }
            }
        }
    }
    int ans = 1e9;
    for(int i = 0; i < n; i++)
    {
        ans = min(ans, dp[(1 << n) - 1][i]);
    }
    cout << (ans >= 1e9 ? -1 : ans);
}


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

using namespace std;
using ll = long long int;
#define long ll

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

    while(1) {
        string s;
        cin >> s;
        if(s == "#") break;
        ll y, m, d;
        cin >> y >> m >> d;
        if((y == 31 && m >= 5) || y > 31)
            s = "?", y -= 30;
        cout << s << ' ' << y << ' ' << m << ' ' << d << endl;
    }
}



Measured memory_bytes: 3224
#include <stdio.h>

typedef struct {
	long long key, x, l;
} data;

void merge_sort(data x[], int n)
{
	static data y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long X[100001], L[100001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%lld %lld", &(X[i]), &(L[i]));
	
	data arm[100001];
	for (i = 0; i < N; i++) {
		arm[i].key = X[i] + L[i];
		arm[i].x = X[i];
		arm[i].l = L[i];
	}
	merge_sort(arm, N);
	
	int ans[100001] = {0, 1}, lb, ub, j;
	for (i = 1; i < N; i++) {
		for (lb = -1, ub = i - 1; lb < ub; ) {
			j = (lb + ub + 1) / 2;
			if (arm[j].x + arm[j].l <= arm[i].x - arm[i].l) lb = j;
			else ub = j - 1;
		}
		if (ans[lb+1] + 1 > ans[i]) ans[i+1] = ans[lb+1] + 1;
		else ans[i+1] = ans[i];
	}
	
	printf("%d\n", ans[N]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6784
l, r = map(int, input().split())

if r-l>2019:
    print(0)
    exit(0)
else:
    a = list(range(l, r+1))

num = 0
ans = 2019

for i in range(len(a)):
    for j in range(len(a)):
        if a[i]<a[j]:
            num = (a[i]*a[j])%2019
            ans = min(ans, num)
            if ans == 0:
                print(0)
                exit(0)

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

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

        int n = sc.nextInt();

        int w[] = new int[n];

        int max[] = new int[n];

        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }


        int min = 0;

        for (int i = 1; i < n; i++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                left += w[j];
            }
            for (int k = 0; k < (n - i); k++) {
                right += w[i+k];
            }

            if((Math.abs(left-right) <= min) || min == 0){
                min = Math.abs(left-right);
            }
        }
        System.out.println(min);

        sc.close();
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<18,INF=1<<30;
int ans[MAX];
int N;
string win;

void DFS(vector<int> &S,int bit,int turn){
    if(turn==N){
        ans[bit]=S[0];
        return;
    }
    
    vector<int> T;
    for(int i=0;i<S.size();i+=2){
        int a=S[i],b=S[i+1];
        if(a>b) swap(a,b);
        if(win[b-a-1]=='1'){
            T.push_back(b);
        }else{
            T.push_back(a);
        }
    }
    
    DFS(T,bit,turn+1);
    
    T.clear();
    
    for(int i=1;i<S.size();i+=2){
        int a=S[i],b=S[(i+1)%int(S.size())];
        if(a>b) swap(a,b);
        if(win[b-a-1]=='1'){
            T.push_back(b);
        }else{
            T.push_back(a);
        }
    }
    
    DFS(T,(bit|(1<<turn)),turn+1);
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    cin>>win;
    
    vector<int> S((1<<N));
    for(int i=0;i<(1<<N);i++){
        cin>>S[i];
        S[i]--;
    }
    
    DFS(S,0,0);
    
    for(int i=0;i<(1<<N);i++){
        cout<<ans[i]+1<<endl;
    }
}


Measured memory_bytes: 6300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;

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

inline void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n, a[1001], ans;

int main(void) {
  init();

  cin >> n;
  rep(i,n) cin >> a[i];

  sort(a, a + n);

  rep(i,n-1) ans += a[i+1] - a[i];

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n;
	cin>>n;
	if(n%10==9||n-n%10==90)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	
	return 0;
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int h, n;
    cin >> h >> n;
    int sum = 0, x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        sum += x;
    }
    if (sum >= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
OK = 1
a = list(map(int,input().split()))
for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            OK = 1
        else:
            OK = 0
            break
if OK == 1:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

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

    while (A > 0)
    {
        C -= B;

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

        A -= D;
    }

    cout << "No" << endl;
}


Measured memory_bytes: 3592
a,b=map(int,input().split())
l=[2,3,4,5,6,7,8,9,10,11,12,13,1]
if l.index(a) < l.index(b):
    print('Bob')
elif l.index(a) > l.index(b):
    print('Alice')
else:
    print('Draw')

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

namespace ITP1_2_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int W = int.Parse(input[0]);
            int H = int.Parse(input[1]);
            int x = int.Parse(input[2]);
            int y = int.Parse(input[3]);
            int r = int.Parse(input[4]);

            if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}



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

#define CEK(x) cerr << "The value of " << #x << " is " << x << endl
#define endl '\n'
using graphInt = vector<vector< int> >;
using graphStr = map<string, vector<string> > ;

int a,b;

int main(){
	scanf("%d %d", &a,&b);
	printf("%d",max(a+b,max(a-b,a*b)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  string s;cin>>s;
  int n=s.length();
  rep(i,n)cout<<'x';
  cout<<endl;
  return 0;
}


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

line = input().split(" ")
n = int(line[0])
m = int(line[1])
edge = [[] for _ in range(n+1)]

for _ in range(m):
    line = input().split(" ")
    a = int(line[0])
    b = int(line[1])

    edge[a].append(b)
    edge[b].append(a)


visited = [False for _ in range(n+1)]
visited[0] = True#dummy
visited[1] = True

def solve(x):
    allVisited = True
    for e in visited:
        allVisited = allVisited and e
    if allVisited:
        return 1

    ret = 0
    for e in edge[x]:
        if not visited[e]:
            visited[e] = True
            ret += solve(e)
            visited[e] = False
    return ret


print(solve(1))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll prod=1;
    sort(a,a+n);
    ll p=pow((ll)10,18);
    for(i=0;i<n;i++)
    {
        if(a[i]!=0 && p/a[i]<prod)
        {
            cout<<"-1";
            return;
        }
        prod=prod*a[i];
    }
    cout<<prod;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B) {
    vector<set<int> > ab(N);
    rep (i, M) {
        A[i]--;
        B[i]--;

        ab[A[i]].insert(B[i]);
        ab[B[i]].insert(A[i]);
    }

    int ans = 0;
    vector<bool> visited(N);

    rep (i, N) {
        if (visited[i]) continue;
        visited[i] = true;

        stack<int> Q;
        Q.push(i);
        int a = 1;
        while (!Q.empty()) {
            int p = Q.top();
            Q.pop();
            for (int t : ab[p]) {
                if (visited[t]) continue;
                visited[t] = true;
                a++;
                Q.push(t);
            }
        }
        ans = max(ans, a);
    }

    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &A[i]);
        scanf("%lld", &B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 34684
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        Set<Integer> si = new HashSet<>();
        si.add(s);
        int x=2;
        while(true) {
            if(0==s%2) {
                s/=2;
            } else {
                s = s * 3 + 1;
            }
            if(si.contains(s)) break;
            si.add(s);
            x++;
        }
        System.out.println(String.format("%d", x));
    }
}


Measured memory_bytes: 22736
#include<iostream>
#include <cmath>
#include <set>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

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

int N,M,X,Y;
int x[101],y[101];
string s;

int main(){
  cin >> N >> M >> X >> Y ;
  FOR(i,0,N){
    cin >> x[i];
  }
  FOR(i,0,M){
    cin >> y[i];
  }

  int max = *max_element(x,x+N);
  int min = *min_element(y,y+M);
  string war = "War";

  FOR(Z,X+1,Y){
    if(max<Z&&Z<=min){
      war="No War";
      break;
    }
  }

  cout << war << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, M;
int A[310][310];
int used[310];
int cnt[310];

int f() {
  fill(cnt, cnt+310, 0);
  REP(i, N) REP(j, M) if (!used[A[i][j]]) {
    cnt[A[i][j]]++;
    break;
  }
  int id = -1;
  REP(i, M) {
    if (id < 0 || cnt[i] > cnt[id]) {
      id = i;
    }
  }
  return id;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  if (M == 1) {
    cout << N << endl;
    return 0;
  }
  REP(i, N) REP(j, M) {
    cin >> A[i][j];
    A[i][j]--;
  }
  int ans = INF;
  REP(i, M-1) {
    int id = f();
    used[id] = 1;
    chmin(ans, cnt[id]);
  }
  cout << ans << endl;

  return 0;
}

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

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

    int N; cin >> N;
    int K; cin >> K;
    string S; cin >> S;
    vector< pair<int,bool> > vec(N);
    int i=0,j=0;
    int answer = 0;

    while(j < N){
        while(j<N&&S[j]=='1') j++;
        answer = max(answer,j-i);
        while(j<N&&S[j]=='0') j++;
        K--;
        if(K<0){
            while(i<N&&S[i]=='1') i++;
            while(i<N&&S[i]=='0') i++;
        }
        answer = max(answer,j-i);
    }

    cout << answer;

    return 0;
}


Measured memory_bytes: 1232
from collections import defaultdict

Blue, Red = defaultdict(int), defaultdict(int)

N = int(input())
for _ in range(N):
  Blue[input()] += 1

M = int(input())
for _ in range(M):
  Red[input()] += 1

ans = 0
for word, cnt in Blue.items():
  temp = cnt - Red[word]
  ans = max(ans, temp)

print(ans)
  

Measured memory_bytes: 9456
class UnionFind:
    def __init__(self, data):
        """
        与えられたdataまでの長さの配列を作成
        配列は1から開始する
        それがunionfindの親となり初めは自分自身
        またrankも定義し初期値は0
        """
        self.parent = {}
        self.rank = {}
        for i in range(1, data+1):
            self.parent[i] = i
            self.rank[i] = 0


    def find(self, x):
        """
        与えられた値に対してその親ノードを返却
        """
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x]) # self.parentに入れ直しているのは次findするとき高速になるよう再起により親を直接結んでいる
            return self.parent[x]


    def same(self, x, y):
        """
        与えられた2つの値が同一グループ(親)かチェック
        """
        return self.find(x) == self.find(y)


    def unite(self, x, y):
        """
        与えられた2つの値を同一のグループ(親)にする
        """
        x = self.find(x)
        y = self.find(y)
        if x == y: # すでに同じグループなら何もしない
            return
        if self.rank[x] > self.rank[y]: # ランクが異なる場合小さい方の親を大きい方にする
            self.parent[y] = x
            return
        else: # ランクが同じ場合どちらかの親にする その際親にした方の値のランクをあげる
            self.parent[x] = y
            if self.rank[x] == self.rank[y]: self.rank[y] += 1
            return


N,M = map(int, input().split())
union_find = UnionFind(N)
for i in range(M):
    X,Y,Z = map(int, input().split())
    union_find.unite(X,Y)

ans = 0
for i in range(1,N+1):
    if union_find.find(i) == i:
        ans += 1

print(ans)

Measured memory_bytes: 97500
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,n,m=0,t,p,s=0;
    cin>>p>>s;
    cin>>n;
    m=max(p,s);
    i=n/m;
    if(n%m!=0){
        i++;
    }
    cout<<i<<endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug cout<<"debug "<<++debug_num<<" :"
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
int debug_num=0;

string s;
int n;

const int maxn=1e5+10;

int a[maxn];

bool check(int x)
{
    for(int i=1;i<=x;++i){
        if(a[i]!=a[n-i]) return false;
    }
    if(a[1]!=1 || a[n]!=0) return false;
    return true;
}

int main()
{
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    n=s.size();
    //cout<<s<<endl;
    for(int i=0;i<n;++i){
        a[i+1]=s[i]-'0';
        //cout<<a[i+1]<<endl;
    }
    if(!check(n/2)){
        cout<<-1<<endl;
    }
    else{
        int tp1=1;
        int tp2;
        for(int i=2;i<=n;++i){
            if(a[i]==1){
                tp2=i;
                cout<<tp2<<" "<<tp1<<endl;
                for(int i=tp1+1;i<tp2;++i){
                    cout<<tp2<<" "<<i<<endl;
                }
                tp1=tp2;
            }
        }
        cout<<n<<" "<<n-1<<endl;
    }
    return 0;
}


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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, tim;
    cin>>n>>tim;
    int c[n], t[n];
    int ans = 100000;
    REP(i, n){
        cin>>c[i]>>t[i];
    }

    REP(i, n){
        if(t[i]<=tim){
            if(ans>c[i]){
                ans = c[i];
            }
        }
    }
    if(ans==100000){
        cout<<"TLE"<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
C = [list(map(int, input().split())) for _ in range(3)]
for i in range(2):
  for j in range(2):
    if C[i][j] + C[i+1][j+1] != C[i][j+1] + C[i+1][j]:
      print('No')
      exit()
print('Yes')

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
//#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const int INF = 1e9;
int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

int H, W;
int dp[303][303];
vector<int>v[2][303];
int calc(const string &S,const string &T) {
	REP(i, 2)REP(j, H)v[i][j].clear();
	REP(i, H) {
		FOR(j, i, H) {
			if (S[i] == T[j]) {
				v[0][j - i].push_back(H - i - 1);
			}
		}
	}
	REP(j, H) {
		FOR(i, j, H) {
			if (T[j] == S[i]) {
				v[1][i - j].push_back(H - j - 1);
			}
		}
	}
	REP(i, H) {
		//VSORT(v[0][i]);
		//VSORT(v[1][i]);
		VREVERSE(v[0][i]);
		VREVERSE(v[1][i]);
	}
	REP(i, H + 1) {
		REP(j, H + 1)dp[i][j] = INF;
	}
	dp[0][0] = 0;
	REP(i, H + 1)REP(j, H + 1) {
		if (i >= j) {
			int cnt = 0;
			int M = v[0][i - j].size();
			cnt = v[0][i - j].end() - lb(v[0][i - j], i);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cnt);
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cnt);
		}
		else {
			int cnt = 0;
			cnt = v[1][j - i].end() - lb(v[1][j - i], j);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cnt);
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cnt);
		}
	}
	return dp[H][H];
}
char C[303][303];
string S[303];
void solve() {
	cin >> H >> W;
	REP(i, H)REP(j, W) {
		cin >> C[i][j];
		S[j] += C[i][j];
	}
	int ans = 0;
	REP(j, W - 1) {
		//print(calc(S[j], S[j + 1]));
		ans += calc(S[j], S[j + 1]);
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 1408
<?php

//文字列の入力
fscanf(STDIN,"%d",$n);

$lim = $n -1;

//2から始まる数字で$nを割り切れる数字がない場合、(1,n-1)となる
for ($i = 1; $i < $n; $i++){
    if ($n % $i == 0){
        $count = $i + $n/$i -2;
        if ($count > $lim){
            echo $lim;
            exit;
        }
        $lim = $count;
    }
    if ($i > 10000000){
        echo $lim;
        exit;
    }
}

//2以降でnをあまり0で割り切れる数字がある場合
echo $count;


Measured memory_bytes: 3576
import heapq

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
A = list(map(lambda x: x * (-1), A))
heapq.heapify(A)

for x in range(M):
    maxA = heapq.heappop(A)
    heapq.heappush(A, -1 * ((-1 * maxA) // 2))
A = list(map(lambda x: x * (-1), A))

print(sum(A))


Measured memory_bytes: 73240
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll =int long long;
map <int ,int> mpa,mpb;

int main (void){
  ll N,A,B;
  cin >> N >> A >> B;
  ll ans=0;
  ans=max(ans,(N-2)*(B-A)+1);
  cout << ans;
}

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

using namespace std;

typedef long long ll;

const int N = 105;

const int mod = 1e9+7;

int n;
int m;
int dist[N][N];
vector < pair < pair < int , int > , int > > ed;

int main() {
    memset(dist , '?' , sizeof dist);
    scanf("%d%d" , &n , &m);
    for(int i = 1; i <= n; i++)
        dist[i][i] = 0;
    for(int i = 1; i <= m; i++){
        int a, b , c;
        scanf("%d%d%d" , &a , &b , &c);
        ed.push_back({{a , b} , c});
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                dist[i][j] = min(dist[i][j] , dist[i][k] + dist[k][j]);
            }
        }
    }
    int cnt = 0;
    for(auto e : ed){
        int a = e.first.first;
        int b = e.first.second;
        int c = e.second;
        bool yes = 1;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(dist[i][j] == dist[i][a] + c + dist[b][j]){
                    //printf("%d %d %d\n" , i , j , dist[i][j]);
                    yes = 0;
                }
            }
        }
        if(!yes){
            cnt++;
        }
    }
    printf("%d\n" , m - cnt);
    return 0;
}


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

#define mx 100007
using namespace std;

int main()
{
    ll t,n,item,temp,a,b,c,x,y,z,sum,flag,k;
    string s,s1,s2;
    vector<ll>v;
    vector<string>vs;
    map<ll,ll>mp;
    map<ll,ll>check;

    ll arr[mx];
   vector<pair<ll,ll> >vp;
   cin>>n>>k;
   item=k*k;
   ll ans=0;
   while(n--)
   {
       cin>>a>>b;
       sum=a*a+b*b;
       if(sum<=item)
        ans++;


   }

   cout<<ans<<endl;

    return 0;
}


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

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

  int w, a, b;
  cin >> w >> a >> b;

  if (a > b) swap(a, b);

  int ans = b - (a + w);

  cout << (ans <= 0 ? 0 : ans) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,a[100],cnt=0,j,flag=1,tmp;

  scanf("%d",&n);

  for(j=0;j<n;j++) scanf("%d",&a[j]);

  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	flag=1;
	cnt++;
      }
    }
  }
  
  for(j=0;j<n-1;j++) printf("%d ",a[j]);

  printf("%d\n%d\n",a[n-1],cnt);

  return 0;
}


Measured memory_bytes: 2140
n, a, b = map(int, input().split())
mod = 10**9+7
N = 2*10**5

factorial = [1]
for i in range(1, N+1):
    factorial.append((factorial[i-1]*i)%mod)

p_list = [n%mod]
for i in range (1,N+1):
    p_list.append((p_list[i-1]*(n-i))%mod)
    
x = pow(2,n,mod)-1
ya = pow(factorial[a],10**9+5,mod)
yb = pow(factorial[b],10**9+5,mod) 

print ((x-p_list[a-1]*ya-p_list[b-1]*yb)%mod)

Measured memory_bytes: 18964
listH=[]
listW=[]
while True:
   H,W=(int(x) for x in input().split())
   if H!=0 or W!=0:
      listH.append(H)
      listW.append(W)
   else:
      break

for i in range(len(listH)):
   for _ in range(listH[i]):
      for j in range(listW[i]):
         print("#",end="")
      print()
   print()


Measured memory_bytes: 7008
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=15;
const int mod=1e9+7;
int n,m,f[1<<N],cnt[N+5][1<<N],g[N+5][1<<N],ans=1;
bool st[N+5][1<<N],ok[1<<N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		st[u][1<<(v-1)]=true;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<(1<<n);j++){
            int k=j&-j;
			cnt[i][j]=cnt[i][j^k]+st[i][k];
			g[i][j]=(1<<cnt[i][j])-1;
		}
	for(int i=0;i<(1<<n);i++)
        ok[i]=((i&1)>0)==((i&2)>0);
	f[0]=1;
	for(int i=1;i<(1<<n);i++)
		if(ok[i]){
			f[i]=1;
			for(int j=(i-1)&i;j;j=(j-1)&i)
				if(ok[j]){
					int k=i^j,s=f[k];
					for(int x=0;x<n;x++)
						if((1<<x)&k)
                            s=1ll*s*g[x+1][j]%mod;
						else if((1<<x)&j)
                            s=1ll*s*(1<<cnt[x+1][k])%mod;
					f[i]=(f[i]+s)%mod;
				}
		}
	for(int i=1;i<=m;i++)
        ans=ans*2%mod;
	ans=(ans-f[(1<<n)-1]+mod)%mod;
	printf("%d\n",ans);
}


Measured memory_bytes: 4992
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())	
	L = []
	Slist1 = []
	Slist2 = []
	R = []
	l = 0; r = 0
	for i in range(N):
		M = 0; end = None
		var = 0
		S = input()
		for j in S:
			if j == "(":
				var += 1
				l += 1
			else:
				var -= 1
				r += 1
			M = min(var, M)

		end = var
		if M == 0:
			L.append([M, end])
		elif M == end:
			R.append([M, end])
		elif M < 0 and end > 0:
			Slist1.append([-M, end])
		else:
			Slist2.append([M - end, M, end])
	
	Slist1 = sorted(Slist1)
	Slist2 = sorted(Slist2)
	if l != r:
		print("No")
		return

	cnt = 0
	X = len(L)
	for i in range(X):
		cnt += L[i][1]

	judge = "Yes"
	X = len(Slist1)
	for i in range(X):
		M = Slist1[i][0]
		cnt -= M
		if cnt < 0:
			judge = "No"
			break
		else:
			cnt += M + Slist1[i][1]

	X = len(Slist2)
	for i in range(X):
		cnt += Slist2[i][1]
		if cnt < 0:
			judge = "No"
			break
		else:
			cnt -= Slist2[i][0]

	print(judge)


if __name__ == '__main__':
	main()

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
	ll N;
	cin >> N;
	ll v[N];
	rep(i,0,N) cin >> v[i];

	sort(v, v+N);
	double ans = v[0];
	rep(i,1,N) {
		ans = (ans + v[i]) / 2;
	}
	cout << setprecision(20) << ans << endl;
	return 0;
}


Measured memory_bytes: 256