akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> w(n);
    REP(i, n) cin >> w[i];

    int ans = INF;

    FOR(i, 1, n)
    {
        int a = 0, b = 0;
        REP(j, i) a+=w[j];
        FOR(j, i, n) b+=w[j];
        //cout << a << " " << b << endl;
        ans = min(ans, abs(a-b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int main() {
	ll A, B;
	cin >> A >> B;
	ll ans = 0;
	for (int i = 0; i < 40; i++) {
		ll x = 1LL << i;
		ll cnt = x * ((B + 1) / (2 * x));
		if ((B + 1) % (2 * x) >= x + 1) cnt += ((B + 1) % (2 * x) - x);
		cnt -= (x * (A / (2 * x)));
		if (A % (2 * x) >= x + 1) cnt += (A % (2 * x) - x);
		if (cnt % 2) ans |= x;
	}
	cout << ans << endl;
 }

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

int main(){
	string S;
	cin >> S;
	bool jdg = true;
	if(S.at(0) == S.at(1)) jdg = false;
	if(S.at(1) == S.at(2)) jdg = false;
	if(S.at(2) == S.at(3)) jdg = false;
	if(jdg) cout << "Good" << endl;
	else cout << "Bad" << endl;
}

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

/*
int sort(const void *b, const void *a){
    return *(int*)b-*(int*)a ;
}
qsort (data,sizeof(data),sizeof(int),sort);
*/

int main(void){
    long long n,m;
    scanf("%lld%lld",&n,&m);
    if (n==1 && m==1){
        printf ("1\n");
    } else if (n==1){
        printf ("%lld\n",m-2);
    } else if (m==1){
        printf ("%lld",n-2);
    } else if (n==2 || m==2){
        printf ("0\n");
    } else {
        printf ("%lld\n",(n-2)*(m-2));
    }
    return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  map<char,ll> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s[0]] ++;
  }
  vector<char> cl = {'-','M','A','R','C','H'};
  ll ans = 0;
  rep1(i,3){
    for(ll j=i+1;j<=4;j++){
      for(ll k=j+1;k<=5;k++){
        ans += mp[cl[i]]*mp[cl[j]]*mp[cl[k]];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (n, d) = {
        let line = get_input();
        let mut split = line.split_whitespace();
        let n:u64 = split.next().unwrap().parse().unwrap();
        let d:u64 = split.next().unwrap().parse().unwrap();
        (n, d)
    };

    let ans = (n + d * 2) / (d * 2 + 1);
    println!("{}", ans);
}



Measured memory_bytes: 4352
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a;
        int b;
        int c;
        int keta;

        while(sc.hasNext()){
            a = sc.nextInt();
            b = sc.nextInt();
            c = a + b;
            keta = 1;
            while(c >= 10){
                c /= 10;
                keta++;
            }

            System.out.println(keta);
        }

    }
}

Measured memory_bytes: 20428
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N;
    cin >> N;
    vec<ll> a(N);
    REP(i, N){
        cin >> a[i];
        a[i]--;
    }
    ll cnt = 0;
    REP(i, N){
        if(i == a[a[i]]){
            cnt++;
        }
    }
    cout << cnt/2 << el;
}



Measured memory_bytes: 3952
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>
#include <bitset>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};

const int mx = 300001;

int main() {
  int h,w,m; cin>>h>>w>>m;
  set<pair<int,int>> se;
  int p[mx]={}, q[mx]={};

  for(int i=0;i<m;i++) {
    int a,b; cin>>a>>b; a--; b--;
    p[a]++; q[b]++;
    se.insert({a,b});
  }

  int f=0, g=0;
  for(int i=0;i<mx;i++) {
    chmax(f,p[i]);
    chmax(g,q[i]);
  }
  vector<int> s1, s2;
  for(int i=0;i<mx;i++) {
    if (p[i] == f) s1.push_back(i);
    if (q[i] == g) s2.push_back(i);
  } 
  for(int x : s1) {
    for(int y : s2) {
      if (se.find({x,y}) == se.end()) {
        cout<<f+g<<endl;
        return 0;
      }
    }
  }
  cout<<f+g-1<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 22828
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

//Hit and Blow
public class Main{

	int get(int x, int k){
		return k==0?x/1000:k==1?x/100%10:k==2?x/10%10:x%10;
	}
	
	int[] f(int A, int B){
		int[] a = new int[4], b = new int[4];
		for(int i=0;i<4;i++){
			a[i] = get(A, i);
			b[i] = get(B, i);
		}
		int hit = 0, blow = 0;
		for(int i=0;i<4;i++)for(int j=0;j<4;j++)if(a[i]==b[j]){
			if(i==j)hit++;
			else blow++;
		}
		return new int[]{hit, blow};
	}
	
	void run(){
		boolean[] v = new boolean[10000];
		for(int i=123;i<=9876;i++){
			Set<Integer> s = new HashSet<Integer>();
			for(int j=0;j<4;j++)s.add(get(i, j));
			v[i] = s.size()==4;
		}
		Scanner sc = new Scanner(System.in);
		boolean[] cand = new boolean[10000];
		int[][] p = new int[5][5];
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			for(int i=0;i<10000;i++)cand[i] = v[i];
			int[] x = new int[n], h = new int[n], b = new int[n];
			for(int i=0;i<n;i++){
				x[i] = sc.nextInt(); h[i] = sc.nextInt(); b[i] = sc.nextInt();
				for(int j=123;j<=9876;j++)if(cand[j]){
					int[] r = f(j, x[i]);
					cand[j]&=r[0]==h[i]&&r[1]==b[i];
				}
			}
			List<Integer> l = new ArrayList<Integer>();
			for(int i=123;i<=9876;i++)if(cand[i])l.add(i);
			if(l.size()==1){
				System.out.printf("%04d\n", l.get(0)); continue;
			}
			int res = -1;
			for(int i=123;i<=9876;i++)if(v[i]){
				for(int[]a:p)Arrays.fill(a, 0);
				for(int s:l){
					int[] r = f(s, i);
					p[r[0]][r[1]]++;
					if(1 < p[r[0]][r[1]])break;
				}
				boolean ok = true;
				for(int j=0;j<5;j++)for(int k=0;k<5;k++)if(1 < p[j][k])ok = false;
				if(ok){
					res = i; break;
				}
			}
			if(res==-1)System.out.println("????");
			else System.out.printf("%04d\n", res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
import java.util.*;

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

    int n = scan.nextInt();
    int x = scan.nextInt();
    scan.nextLine();
    ArrayList<Integer> l = new ArrayList<Integer>();
    ArrayList<Integer> list = new ArrayList<Integer>();
    Arrays.stream(scan.nextLine().split(" ", -1)).forEach(a -> l.add(Integer.parseInt(a)));
    int ans = 1;
    int pos = 0;
    for(int i = 0; i < n; i++) {
      pos += l.get(i);
      if(pos <= x) {
        ans++;
      } else {
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 32204
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ");

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 120003;
int n, m, k, l;
string s;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

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

    cin >> s;
    
    int cnt = 0;
    REP(i, (int) s.length()) {
        cnt += ctoi(s[i]);
    }

    if (cnt % 3 == 0) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3768
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    double r;
    cin >> r;
 
    cout << fixed;  
    cout << setprecision(10) << M_PI*r*r << " " << 2*M_PI*r << endl;
    return 0;
}



Measured memory_bytes: 3300
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = list()
y = list()
c = list()
for i in range(M):
	_x, _y, _c = map(int, input().split())
	x.append(_x-1)
	y.append(_y-1)
	c.append(_c)


# no discount
price_no_discount = min(a) + min(b)

# with discount
price_with_discount = list()
for i in range(M):
	price_with_discount.append(a[x[i]] + b[y[i]] - c[i])

price_with_discount = min(price_with_discount)

if price_no_discount < price_with_discount:
	print(price_no_discount)
else:
	print(price_with_discount)


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

double Distance(double x1, double y1, double x2, double y2){
    return pow(pow(x1 - x2, 2.0) + pow(y1 - y2, 2.0), 0.5);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(10);
    // cout << pow(x1 - x2, 2.0) << endl;
    // cout << pow(y1 - y2, 2.0) << endl;
    // cout << pow(x1 - x2, 2.0) + pow(y1 - y2, 2.0) << endl;
    cout << Distance(x1, y1, x2, y2) << endl;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define N 2000500
using namespace std;
typedef long long LL;
int a[N], n;
LL ans;
inline int rd() {int r;scanf("%d",&r);return r;}
int main() {
	n = rd();
	for (int i=1;i<=n;i++) a[i] = rd();
	for (int i=1;i<=n;i++) {
		ans += a[i] / 2;
		a[i] -= a[i] / 2 * 2;
		int t = min(a[i], a[i+1]);
		ans += t;
		a[i] -= t;
		a[i+1] -= t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import heapq
n,m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for _ in range(m):
  tmp_min = heapq.heappop(a)
  heapq.heappush(a, (-1)*(-tmp_min//2))
print(-sum(a))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    char c;
    cin >> c;
    if (c == 'A') cout << 'T' << endl;
    else if (c == 'T') cout << 'A' << endl;
    else if (c == 'G') cout << 'C' << endl;
    else cout << 'G' << endl;
}


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

int foreach_permutation(int n, string p, string q) {
  int permutation[n];
	int counter = 0, p_index = 0, q_index = 0;
	// 初期化
  for (int i = 0; i < n; i++) {
		permutation[i] = i + 1;
	}

  do {
		ostringstream oss;
		counter++;
		for (int temp = 0; temp < n; temp++) {
	    oss << permutation[temp];
		}
		if (p == oss.str()) p_index = counter;
		if (q == oss.str()) q_index = counter;

		if (p_index != 0 && q_index != 0) break;
  } while (next_permutation(permutation, permutation + n));

	return abs(p_index - q_index);
}

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

	// N個分の領域確保
	int _i;
	ostringstream p_oss, q_oss;

	// 1回目の入力
	for (int i = 0; i < N; i++) {
    cin >> _i;
		p_oss << _i;
	}

	// 2回目の入力
	for (int i = 0; i < N; i++) {
    cin >> _i;
		q_oss << _i;
	}

  const int result = foreach_permutation(
		N,
		p_oss.str(),
		q_oss.str()
	);
	cout << result << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1e6+5;
int a[N];
char ans[N];
int main()
{
	ll n;
	scanf("%lld",&n);
	ll sum=0;
	int len=1;
	ll i=1;
	for(;;i*=26){
		if(sum+i*26>=n){
			break;
		}
		sum+=i*26;
		len++;
	}
	n-=sum;
	n--;
	for(int i=1;i<=len;i++){
		ans[i]='a';
		ans[i]+=n%26;
		n/=26;
	}
	for(int i=len;i>=1;i--){
		printf("%c",ans[i]);
	}
}


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

using namespace std;

typedef long double ld;
typedef long long ll;

const int M = 50;


void read() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      string s;
      cin >> s;
      if (s == "snuke") {
        cout << (char(j + 'A')) << i + 1 << endl;
      }
    }

}

int main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();


}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x%N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x)%N;
		y = y >> 1;
		x = (x * x)%N;
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	string s = "", ans = "";
	cin >> s;
	string q = "q";
	q[0] = s[0];
	ans += q;
	f(i, 1, s.length())
	{
		if (s[i] != s[i - 1])
		{
			q[0] = s[i];
			ans += q;
		}
	}
	cout << ans.length();
	return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;

    cin >> s;

    int ans = 0;

    for (int i = 1; i < s.size(); ++i) {
        if (s[i] - s[i-1]) {
            ans++;
        }
    }

    cout << ans << endl;
}


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

using namespace std;

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

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int i,j;
    vi a(4);
    rep(i,4)cin >> a[i];
    sort(all(a));
    if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

ll n;
vector<ll> color;
vector<ll> adj[N];
vector<ll> nodeslist[N];
ll siz[N];
vector<ll> ans;

vector<ll> tsenter,tsexit;
ll tim;

void dfs(ll v,ll p)
{
    ++tim;
    tsenter[v]=tim;
    siz[v]=1;
    ll c=color[v];
    for(auto u:adj[v])
    {
        if(u==p){continue;}
        dfs(u,v);
        siz[v]+=siz[u];
        ll w=siz[u];
        while( nodeslist[c].size()>0 && tsenter[nodeslist[c].back()]>tsenter[v] )
        {
            ll node=nodeslist[c].back();
            w-=siz[node];
            nodeslist[c].pop_back();
        }
        ans[c]+=(w*(w+1))/2;
    }
    nodeslist[color[v]].pb(v);
}

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

    cin>>n;
    color.resize(n+1);
    ans.resize(n+1,0);
    tsenter.resize(n+1,-1);
    tsexit.resize(n+1,-1);
    tim=-1;
    for(ll i=1;i<=n;++i){cin>>color[i];}
    for(ll i=0;i<n-1;++i){
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    dfs(1,1);

    for(ll i=1;i<=n;++i){
        ll w=n;
        while( nodeslist[i].size()>0 ){
            ll node=nodeslist[i].back();
            w-=siz[node];
            nodeslist[i].pop_back();
        }
        ans[i]+=(w*(w+1))/2;
    }

    for(ll i=1;i<=n;++i){
        ll x=(n*(n+1))/2;
        x-=ans[i];
        cout<<x<<endl;
    }

    return (0);
}


Measured memory_bytes: 60124
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

// index が条件を満たすかどうか

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	long long int ans = 0;
	for (int i = 1; i <= n; i++) {
		int sum = 0;
		int number = i;
		while (number != 0) {
			sum = sum + number % 10;
			number = number / 10;
		}
		if (sum >= a && sum <= b) {
			ans = ans + i;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct team{
	char n[9];
	int p[5];
}TEAM;
TEAM a[15];
int comp(const void *_p,const void *_q){
	TEAM *x=(TEAM *)_p,*y=(TEAM *)_q;
	if(x->p[0] != y->p[0]){
		return y->p[0] - x->p[0];
	}else{
		return x->p[1] - y->p[1];
	}
}
int main(){
	int n,i,j,d;
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%s",a[i].n);
			a[i].p[0]=a[i].p[1]=a[i].p[2]=0;
			for(j=0;j<n-1;j++){
				scanf("%d",&d);
				a[i].p[d]++;
			}
		}
		qsort(a,n,sizeof(TEAM),comp);
		for(i=0;i<n;i++)printf("%s\n",a[i].n);
	}
	return 0;
}

Measured memory_bytes: 0
INF = 10 ** 20

n, c = map(int, input().split())
d_mp = [list(map(int, input().split())) for _ in range(c)]
c_mp = [list(map(int, input().split())) for _ in range(n)]
dic_lst = [dict() for _ in range(3)]

for x in range(n):
  for y in range(n):
    s = (x + 1 + y + 1) % 3
    v = c_mp[y][x]
    if v in dic_lst[s]:
      dic_lst[s][v] += 1
    else:
      dic_lst[s][v] =  1

ans = INF
for x in range(c):
  for y in range(c):
    for z in range(c):
      if x != y and x != z and y != z:
        score = 0
        dic1 = dic_lst[0]
        for k, v in dic1.items():
          score += d_mp[k - 1][x] * v
        dic2 = dic_lst[1]
        for k, v in dic2.items():
          score += d_mp[k - 1][y] * v
        dic3 = dic_lst[2]
        for k, v in dic3.items():
          score += d_mp[k - 1][z] * v
        ans = min(score, ans)

print(ans)

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >>B;
  REP(i,20){
      if(1 + i * (A-1) >= B){
          cout << i << endl;
          return 0;
      }
  }
}

Measured memory_bytes: 256
s = input()
n=len(s)
R=[0]*(n+1)
L=[0]*(n+1)
for i in range(n):
    if s[i]=='<':
        R[i+1]=R[i]+1
for i in range(n-1,-1,-1):
    if s[i]=='>':
        L[i]=L[i+1]+1
res = [x if x>y else y for x,y in zip(R,L)]
print(sum(res))


Measured memory_bytes: 31908
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    bool ans = false;
    int N;
    cin >> N;
    rep(i, N/4+1){
        if((N-4*i)%7 == 0) ans = true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}
string s[33];


int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    int n; cin >> n;
    for (int i = 0; i < 3; i++) cin >>s[i];
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (s[0][i] == s[1][i] && s[1][i] == s[2][i]) res += 0;
        else if (s[0][i] == s[1][i] || s[0][i] == s[2][i] || s[1][i] == s[2][i]) res += 1;
        else res += 2;
    }
    cout << res << endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    long a[202020]; for(int i=0; i < n; ++i) cin >> a[i], a[i] -= (i+1);

    sort(a, a + n);
    long b = a[n/2], ans = 0;
    for(int i=0; i < n; ++i) ans += abs(b -a[i]);

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

Measured memory_bytes: 1792
import math

input_line = list(map(int, input().split(' ')))
theta = 30*input_line[2] - 5.5*input_line[3]
c = input_line[0]**2 + input_line[1]**2 - 2*input_line[0]*input_line[1]*math.cos(math.radians(theta))
print(math.sqrt(c))

Measured memory_bytes: 9564
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

signed main(){
	int A,B,C;
	cin>>A>>B>>C;
	set<int>st;
	st.insert(A);st.insert(B);st.insert(C);
	if(st.size()==2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
/*
[abc122] C - GeT AC
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;
const int MAX_Q = 1e5;

int N, Q;
string S;
int l[MAX_Q], r[MAX_Q];
int c[MAX_N];

void solve() {
    for (int i = 1; i < N; i++) {
        c[i] = c[i - 1];
        if (S[i - 1] == 'A' && S[i] == 'C') {
            c[i]++;
        }
    }

    for (int i = 0; i < Q; i++) {
        cout << c[r[i]] - c[l[i]] << endl;
    }
}

int main() {
    cin >> N >> Q;
    cin >> S;
    for (int i = 0; i < Q; i++) {
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }

    solve();

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int H,W; cin >>H >>W;
  vector<string> field(H); rep(i, H) cin >>field[i];
  vector<vector<int>> ver,hor;
  ver = hor = vector<vector<int>>(H, vector<int>(W, 0));
  // ver[i][j] := マス(i,j)について、縦に何個照らされるか
  // hor[i][j] := マス(i,j)について、横に何個照らされるか
  int j1 = 0, j2 = 0;
  int sum = 0;
  rep(i, H){
    j1 = 0, j2 = 0;
    while (j2 < W){
      // i行目の[j1, j2)の範囲について、連続して何個'.'があるか調べる
      while (j2 < W && field[i][j2] == '.'){
        sum++; j2++;
      }
      // ここに来たということはj2=W || field[i][j2] = '#' ということ
      // いずれにせよ今までのsumを清算する必要がある
      for (int j=j1; j<j2; j++) hor[i][j] = sum;
      sum = 0;
      j2++; j1 = j2;
    }
  }
  sum = 0;
  int i1 = 0, i2 = 0;
  rep(j, W){
    i1 = 0, i2 = 0;
    while (i2 < H){
      while (i2 < H && field[i2][j] == '.'){
        sum++; i2++;
      }
      for (int i=i1; i<i2; i++) ver[i][j] = sum;
      sum = 0;
      i2++; i1 = i2;
    }
  }
  int res = 0;
  rep(i, H) rep(j, W) chmax(res, ver[i][j] + hor[i][j] - 1);
  cout <<res <<endl;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll a, b, c, d, e, f, g; cin >> a >> b >> c >> d >> e >> f >> g;
	ll ade = a % 2 + d % 2 + e % 2;
	ll x = 0;
	if (ade == 3) {
		x = 3;
	} else if (ade == 2 && (a%2==0 && a>0 || d%2==0 && d>0 || e%2==0 && e>0)) {
		x = 1;
	}

	cout << a / 2 * 2 + b + d / 2 * 2 + e / 2 * 2 + x << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a; i < b; i++)

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

	int m = 1000;
	while (n > m) {
		m += 1000;
	}

	cout << m - n << endl;

	return 0;
}

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

using namespace std;

const int NMAX = (int) 1e5+11;
int par[NMAX], rnk[NMAX], grp[NMAX];

void init()
{
    for (int i = 0; i < NMAX; ++i) {
        par[i] = i;
        grp[i] = 1;
    }
}

int find(int x) {
    if (par[x] != x)
        par[x] = find(par[x]);
    return par[x];
}

int merge(int x, int y) {
    x = find(x), y = find(y);
    if (x != y) {
        if (rnk[x] < rnk[y]) swap(x, y);
        par[y] = x;
        grp[x] += grp[y];
        if (rnk[x] == rnk[y]) ++rnk[x];
        return 1;
    }
    return 0;
}

int group(int x) {
    return grp[find(x)];
}

void solve(long long N, long long M, vector<long long> A, vector<long long> B)
{
    init();
    long long cnt = 1ll * N * (N-1) / 2;
    vector<long long> ans(M);
    for (int i = M-1; i >= 0; --i) {
        ans[i] = cnt;
        long long cc = 1ll * group(A[i]) * group(B[i]);
        if (merge(A[i], B[i])) {
            cnt -= cc;
        }
    }
    for (auto &x: ans) {
        cout << x << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long N;
    cin >> N;
    long long M;
    cin >> M;
    vector<long long> A(M);
    vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        cin >> A[i];
        cin >> B[i];
    }
    solve(N, M, move(A), move(B));
    return 0;
}


Measured memory_bytes: 4864
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    std::string S; std::cin >> S;
    int N(S.size());
    long long ans(0);
    //m[i] = i文字目から最後まで
    std::vector<int> m(N+1, 0);
    int keta(1);
    //m[i]: U_i % 2019 = i
    std::vector<int> cnt(2019, 0);
    cnt[0] = 1;
    for(int i(N-1); i >= 0; --i){
        m[i] = (keta*(S[i]-'0') + m[i+1]) % 2019;
        if(m[i] < 0) m[i] += 2019;
        ans += cnt[m[i]];
        ++cnt[m[i]];
        keta = 10 * keta % 2019;
        if(keta < 0) keta += 2019;
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 4372
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=10005;
char Str1[MAXN],Str2[MAXN];
int Len1,Len2;

int main(){
	scanf("%s",Str1);
	Len1=strlen(Str1);
	Str2[0]='C';
	Str2[1]='F';
	Len2=2;
	int j=0;
	for(int i=0;i<Len1;i++)
	if(Str1[i]==Str2[j]){
		j++;
		if(j==2){
			printf("Yes");
			return 0;
		}
	}
	
	printf("No");
	return 0;
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B;
    cin >>A>>B;
    if((B-A)%2==0){
        cout <<(A+B)/2<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

char a[22][22], b[22][22];
int c[22][22];
int main()
{
	int n, m;
	cin >> n >> m;
	for(int i= 1; i <= n; i ++)
	{
		for(int j = 1; j <= m; j ++)
		{
			char x;
			cin >> x;
			a[i][j] = x;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= m; j ++)
		{
			if(a[i][j] == '#')
				continue;
			for(int e = 1; e <= n; e ++)
			for(int r = 1; r <= m; r ++)
				b[e][r] = a[e][r], c[e][r] = 0;
			queue<pii> q;
			q.push(M(i, j));
			b[i][j] = '#';
			int mx = 0;
			while(q.size())
			{
				int x = q.front().F, y = q.front().S;
				q.pop();
				for(int dx = -1; dx <= 1; dx ++)
				for(int dy = -1; dy <= 1; dy ++)
					if(abs(dx - dy) == 1)
					{
						if(b[x + dx][y + dy] == '.')	
						{
							q.push(M(x + dx, y + dy));
							b[x + dx][y + dy] = '#';
							c[x + dx][y + dy] = c[x][y] + 1;
							umax(mx, c[x + dx][y + dy]);
						}
					}
			}
			umax(ans, mx);
		}
	}
	cout << ans;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
using System;

namespace ITP1_4_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            Console.WriteLine("{0} {1} {2:#.00000}", a / b, a % b, (double)a / b);
        }
    }
}

Measured memory_bytes: 9324
#include <bits/stdc++.h>
#define MAXN 18
#define MOD 666019

int v[1 + MAXN], w[1 + MAXN];
std::map <std::pair <int, int>, long long> M;
int main(){
    FILE*fi,*fo;
    //fi = fopen("a.in","r");
    //fo = fopen("a.out","w");
    fi = stdin;
    fo = stdout;

    int n;
    fscanf(fi,"%d", &n);
    fgetc(fi);
    for(int i = 1; i <= n; i++) v[i] = fgetc(fi) - 'a' + 1;
    for(int i = 1; i <= n; i++) w[n - i + 1] = fgetc(fi) - 'a' + 1;

    for(int i = 0; i < (1 << n); i++){
        int hash1 = 0, hash2 = 0;
        for(int j = 1; j <= n; j++)
            if(i & (1 << (j - 1)))
                hash1 = (hash1 * 27 + v[j]) % MOD;
            else
                hash2 = (hash2 * 27 + v[j]) % MOD;
        M[{hash1, hash2}]++;
    }
    long long ans = 0;
    for(int i = 0; i < (1 << n); i++){
        int hash1 = 0, hash2 = 0;
        for(int j = 1; j <= n; j++)
            if(i & (1 << (j - 1)))
                hash1 = (hash1 * 27 + w[j]) % MOD;
            else
                hash2 = (hash2 * 27 + w[j]) % MOD;
        ans += M[{hash1, hash2}];
    }
    fprintf(fo,"%lld", ans);

    return 0;
}


Measured memory_bytes: 33024
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=924844033;
int main()
{
	int n, k;
  cin>>n>>k;
  vector<ll> ct[4001];
  ll dp[3][2001][2001]={};
  for(int i=0; i<2*k; i++){
    if(i>=n) break;
    dp[0][0][0]=1;
    if(i<k) dp[1][0][1]=0;
    else dp[1][0][1]=1;
    if(i+k>=n) dp[2][0][1]=0;
    else dp[2][0][1]=1;
    for(int j=1; j*2*k+i<n; j++){
      for(int x=0; (x-1)*2*k+i<n; x++){
        dp[0][j][x]=(dp[0][j-1][x]+dp[1][j-1][x]+dp[2][j-1][x])%MOD;
        dp[1][j][x]=0;
        dp[2][j][x]=0;
        if(x==0) continue;
        dp[1][j][x]=(dp[0][j-1][x-1]+dp[1][j-1][x-1])%MOD;
        dp[2][j][x]=(dp[0][j-1][x-1]+dp[1][j-1][x-1]+dp[2][j-1][x-1])%MOD;
      }
    }
    int y;
    if((n-i)%(2*k)==0) y=(n-i)/2/k-1;
    else y=(n-i)/2/k;
    if(i+2*k*y+k>=n){
      for(int j=0; j<=y+1; j++){
        ll ct0=(dp[0][y][j]+dp[1][y][j])%MOD;
        ct[i].push_back(ct0);
      }
    }else{
      for(int j=0; j<=y+1; j++){
        ll ct0=(dp[0][y][j]+dp[1][y][j]+dp[2][y][j])%MOD;
        ct[i].push_back(ct0);
      }
    }
  }
  ll dp0[4001][2001]={};
  dp0[0][0]=1;
  for(int i=1; i<=2*k; i++){
    for(int j=0; j<=n; j++){
      if(i-1>=n){
        dp0[i][j]=dp0[i-1][j];
        continue;
      }
      for(int l=0; l<ct[i-1].size(); l++){
        if(j>=l){
          dp0[i][j]+=(dp0[i-1][j-l]*ct[i-1][l]%MOD);
          dp0[i][j]%=MOD;
        }
      }
    }
  }
  ll f[2001]; f[0]=1;
  for(ll i=1; i<=n; i++){
    f[i]=f[i-1]*i%MOD;
  }
  ll ans=f[n];
  for(int i=1; i<=n; i++){
    if(i%2){
      ans-=(dp0[2*k][i]*f[n-i]%MOD);
      ans+=MOD;
    }else{
      ans+=(dp0[2*k][i]*f[n-i]%MOD);
    }
    ans%=MOD;
  }
  cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,ac,wa,tle,re;
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        if(s=="AC")
            ac++;
        if(s=="WA")
            wa++;
        if(s=="TLE")
            tle++;
        if(s=="RE")
            re++;
    }
    cout<<"AC x "<<ac<<'\n';
    cout<<"WA x "<<wa<<'\n';
    cout<<"TLE x "<<tle<<'\n';
    cout<<"RE x "<<re<<'\n';
    return 0;
}


Measured memory_bytes: 3676
import math
a , b , k = map(int , input().split())
ans = set()
for i in range(min(k , math.ceil((b - a + 1) / 2))):
  ans.add(a + i)
  ans.add(b - i)
ans = sorted(list(ans))
print('\n'.join([str(n) for n in ans]))

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>

int main()
{
  int n;
  long long K;
  scanf("%d%lld",&n,&K);
  std::vector<int> a(n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  const long long mod=1000000007ll;
  long long c=0,d=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i]>a[j]){
	if(i<j){
	  c++;
	}
	d++;
      }
    }
  }
  printf("%lld\n",(K*c%mod+K*(K-1)/2%mod*d%mod)%mod);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		while(true){
			int a = scan.nextInt();
			String mark = scan.next();
			int b = scan.nextInt();

			if(mark.equals("?")){
				break;
			}

			if(mark.equals("+")){
				System.out.println(a+b);
			}else if(mark.equals("-")){
				System.out.println(a-b);
			}else if(mark.equals("*")){
				System.out.println(a*b);
			}else if(mark.equals("/")){
				System.out.println(a/b);
			}
		}
	}
}

Measured memory_bytes: 18156
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq_int;
typedef priority_queue<ll, vector<ll>, less<ll> > lpq_int;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll D, G;
ll p[20], c[20];

int main(void){
  cin >> D >> G;
  rep(i, D){
    cin >> p[i] >> c[i];
  }
  ll ans=100000000;
  for(int i=0;i<pow(2,D);i++){
    ll iscore=0, isolved=0;
    vector<int> solevednum(20,0); 
    rep(j, D){
      if(i&(1<<j)){
        isolved += p[j];
        iscore += c[j] + p[j] * (j+1) * 100;
        //cout <<"j="<<j << " completed: "<<iscore << endl;
        solevednum[j]=1;
      }
    }
    
    if(iscore >= G) {
      if(isolved < ans){
        ans = isolved ;
        //cout <<"pattern:1 current ans = " << ans << endl;
      }
      continue;
    }else{
      rep(jj, D){
        int j = D - 1 -jj;
        if(solevednum[j]==1)continue;
        if((p[j]-1)*(j+1)*100>=G - iscore){
          int count=0;
          while(iscore < G){
            isolved ++;
            iscore += (j+1)*100;
          }
          break;
        }else{
          isolved += p[j]-1;
          iscore += (p[j]-1)*(j+1) * 100 ;
        }
      }      
      if(ans >isolved  && iscore >=G) {
        ans = isolved;
      }
      //cout <<"pattern:2 current ans = " << ans << endl;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    int a,b;
    cin >> a >> b;
    int cc=0;
    for (int i = a; i <= b; i++)
    {
        string s=to_string(i);
        string t = s;
        reverse(t.begin(), t.end());
        if(s==t){
            cc++;
        }
    }
    cout<<cc<<endl;
    return 0;
}

Measured memory_bytes: 256