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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    string s; cin >> s;
    if(s == "RRR"){
        out(3); return 0;
    }
    if(s == "RRS" || s == "SRR"){
        out(2); return 0;
    }
    if(s == "SSS"){
        out(0); return 0;
    }
    out(1);
}

Measured memory_bytes: 3624
#include<stdio.h>
#define min(x,y) ((x<y)?(x):(y))
int main(){
	int n,k,x,y,i,f;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++){
		scanf("%d%d",&x,&y);
		f=min(x-1,y-1);
		f=min(f,n-x);
		f=min(f,n-y);
		printf("%d\n",f%3+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
inline void chmax (int& a, int b) {
  if (a < b) a = b;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, W;
  cin >> n >> W;
  vector<pair<int, int>> gds(n);
  for (int i = 0; i < n; i++) {
    int v, w;
    cin >> v >> w;
    gds[i] = {v, w};
  }
  vector<int> dp(W + 1, 0);
  for (const auto& p : gds) {
    int v = p.first;
    int w = p.second;
    for (int j = 0; j + w <= W; j++) {
      chmax(dp[j + w], dp[j] + v);
      chmax(dp[j + w], dp[j + w - 1]);
    }
  }
  cout << dp[W] << '\n';
  return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>

typedef long long LL;
using namespace std;


LL LCM(LL a, LL b)
{
    return (a*b)/__gcd(a, b);
}

int main()
{
    LL left, right, a, b;
    cin >> left >> right >> a >> b;

    LL a_multiples = right/a - (left - 1)/a;
    LL b_multiples = right/b - (left - 1)/b;
    LL both_multiples = right/LCM(a, b) - (left - 1)/LCM(a, b);

    LL multiples = a_multiples + b_multiples - both_multiples;
    LL non_multiples = right - (left - 1) - multiples;

    cout << non_multiples;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[51];
int n; 

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i];
	}
	ll ans=0;
	while(1)
	{
		sort(a,a+n);
		if(a[n-1]<n) break;
		ans+=a[n-1]/n;
		for(int i=0;i<n-1;i++) a[i]+=a[n-1]/n;
		a[n-1]%=n;
	}
	cout<<ans<<'\n';
}


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

int main(){
    int N,M,kazu = 0;

    cin >> N >> M;

    int ga = -1,ha = -1;

    vector<long long> h(N+10);

    vector<bool> takai(N+1); 

    for(int i = 1;i <= N;i++)
        cin >> h.at(i);

    for(int i = 1;i <= N;i++)
        takai.at(i) = true;

    for(int i = 0;i < M;i++){
        cin >> ga >> ha;
        if(h.at(ga)-h.at(ha) > 0){
            takai.at(ha) = false;
        }
        else if(h.at(ha) - h.at(ga) > 0){
            takai.at(ga) = false;
        }
        else{
            takai.at(ga) = false;
            takai.at(ha) = false;
        }

    }

    for(int i = 1; i <= N;i++){
        if(takai.at(i))
            kazu++;
    }
    
    cout << kazu << endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

// < val の要素数
int CountLower(const vll &vec, ll val)
{
    return distance(vec.begin(), lower_bound(ALL(vec), val));
}

int main()
{
    ll A, B, Q;
    cin >> A >> B >> Q;
    vll s(A + 2), t(B + 2), x(Q);
    s[0] = -20000000000;
    s[A + 1] = 30000000000;
    t[0] = -20000000000;
    t[B + 1] = 30000000000;
    repb(i, 1, A+1) cin >> s[i];
    repb(i, 1, B+1) cin >> t[i];
    rep(i, Q) cin >> x[i];

    sort(ALL(s));
    sort(ALL(t));
    rep(i, Q)
    {
        int sr = CountLower(s, x[i]);
        int sl = sr - 1;
        int tr = CountLower(t, x[i]);
        int tl = tr - 1;
        int srtr = CountLower(t, s[sr]);
        int srtl = srtr - 1;
        int sltr = CountLower(t, s[sl]);
        int sltl = sltr - 1;
        int trsr = CountLower(s, t[tr]);
        int trsl = trsr - 1;
        int tlsr = CountLower(s, t[tl]);
        int tlsl = tlsr - 1;
        ll ans = abs(x[i] - s[sr]) + abs(s[sr] - t[srtr]);
        ans = min(ans, abs(x[i] - s[sr]) + abs(s[sr] - t[srtl]));
        ans = min(ans, abs(x[i] - s[sl]) + abs(s[sl] - t[sltr]));
        ans = min(ans, abs(x[i] - s[sl]) + abs(s[sl] - t[sltl]));
        ans = min(ans, abs(x[i] - t[tr]) + abs(t[tr] - s[trsr]));
        ans = min(ans, abs(x[i] - t[tr]) + abs(t[tr] - s[trsl]));
        ans = min(ans, abs(x[i] - t[tl]) + abs(t[tl] - s[tlsr]));
        ans = min(ans, abs(x[i] - t[tl]) + abs(t[tl] - s[tlsl]));
        cout << ans << endl;
    }
}

Measured memory_bytes: 3712
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    String A = scan.next();
    int ans = 1;
    for (int i = 0 ; i < N - 1 ; i++) {
      if (!A.substring(i, i+1).equals(A.substring(i+1, i+2))){
        ans += 1;
      }
    }
    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 36176
// Don't Lose Hope, Nor Be Sad -- Quran

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,x,coordinates=0,ans=1;
    cin >> n >> x;
    int L[n];
    for(int i=0; i<n; i++){
        cin >> L[i];
        coordinates += L[i];
        if(coordinates <= x) ans++;
    } 
    cout << ans << endl;
    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N), y(N);
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            int a, b;
            cin >> a >> b;
            x[i].pb(a);
            y[i].pb(b);
        }
    }
    int ans = 0;
    rep(i, 1 << N) {
        vector<int> p, r;
        rep(j, N) {
            if ((i >> j) & 1) {
                rep(k, A[j]) {
                    if (y[j][k] == 0) {
                        p.pb(x[j][k]);
                    } else {
                        r.pb(x[j][k]);
                    }
                }
            }
        }
        int f = 0;
        int tmp = 0;
        rep(j, N) {
            if ((i >> j) & 1) {
                tmp++;
                for (int q : p) {
                    if ((j + 1) == q) {
                        f = 1;
                        break;
                    }
                }
            } else {
                for (int q : r) {
                    if ((j + 1) == q) {
                        f = 1;
                        break;
                    }
                }
            }
            if (f) {
                break;
            }
        }
        if (f == 0) {
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S;
int main()
{
	cin >> S;
	if(S[0]==S[(int)S.length()-1]){
		if((int)S.length()%2==1){
			printf("Second\n");
		}
		else{
			printf("First\n");
		}
	}
	else{
		if((int)S.length()%2==0){
			printf("Second\n");
		}
		else{
			printf("First\n");
		}
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int bitcount(int val)
{
  int ret = 0;
  while (val > 0) {
    ret += (1 & val);
    val >>= 1;
  }
  return ret;
}

int main()
{
  int N; scanf("%d", &N);
  vector<int> F(N);
  for (int i = 0; i < N; ++i) {
    int val = 0, d = 0;
    for (int j = 0; j < 10; ++j) {
      scanf("%d", &d);
      val |= (d << j);
    }
    F[i] = val;
  }
  vector<vector<int>> P(N, vector<int>(11, 0));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      scanf("%d", &P[i][j]);
    }
  }

  int ans = -INF;
  for (int pat = 1; pat < (1 << 10); ++pat) {
    int sum = 0;
    for (int i = 0; i < N; ++i) {
      int cnt = bitcount(pat & F[i]);
      sum += P[i][cnt];
    }
    ans = max(ans, sum);
  }
  printf("%d\n", ans);
  return 0;
}


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

long long mod=1e9+7;

long long n,m;
long long maxn,k;

int main()
{
    scanf("%lld%lld",&n,&m);
    if(abs(n-m)>1)
    {
        printf("0\n");
        return 0;
    }
    maxn=max(n,m);
    k=min(n,m);
    if(n==m)
    {
        long long ans=1;
        for(long long i=1;i<=maxn;i++)
        {
            ans=(ans*i)%mod;
        }
        ans=(ans*ans)%mod;
        printf("%lld",(ans*2)%mod);
    }
    else
    {
        long long ans=1;
        for(int i=1;i<=k;i++)
        {
            ans=(ans*i)%mod;
        }
        ans=(ans*ans)%mod;
        ans=(ans*maxn)%mod;
        printf("%lld",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;

ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%m;
        a = a * a%m;
        b >>= 1;
    }
    return res;
}

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

int main() {
	int t;
	//cin>>t;
	t = 1;
	while(t--) {
		int x; cin>>x;
		if(x>=30) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

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


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

ll f(ll x, int c, int d) {
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c,d);
    return res;
}

int main() {

    ll a, b;
    int c, d;
    cin >> a >> b >> c >> d;
    ll ans = f(b,c,d) - f(a-1,c,d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstring>
#include <string>
#include <sstream>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

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

int main(void){
    for(int n, sum = 0, ma, mi; cin >> n, n; cout << sum / (n - 2) << endl, sum = 0){
        rep(i, n){
            int s; cin >> s;
            if(!i) mi = s;
            else if(i == 1) ma = max(mi, s), mi = min(mi, s); 
            else if(s < mi) sum += mi, mi = s;
            else if(s > ma) sum += ma, ma = s;
            else sum += s;
        }
    }

    return 0;
}

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

using namespace std;

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

int n;
int INF = 1001001001;

const int max_n = 1010;
vector<int> to[max_n];

vector<int> bfs(int sv){
	// cout << "--- " << sv << " ---" << endl;
	vector<int> dist(n, INF), pre(n, -1);
	queue<int> q;
	dist[sv] = 0;
	q.push(sv);
	while(!q.empty()){
		int v = q.front();
		q.pop();
		for(int u : to[v]){
			if(dist[u] != INF) continue;
			// cout << "bfs:" << v << "," << u << endl;
			pre[u] = v;
			dist[u] = dist[v] + 1;
			q.push(u);
		}
	}

	pii best(INF, -1);
	rep(v, n){
		if(v == sv) continue;
		for(int u : to[v]){
			if(u == sv){
				best = min(best, pii{dist[v], v});
			}
		}
	}

	// cout << best.first << "," << best.second << endl;
	if(best.first == INF) return vector<int>(n+1);

	int v = best.second;
	vector<int> res;
	while(v != -1){
		res.push_back(v);
		v = pre[v];
	}
	return res;
}

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

	int m;
	cin >> n >> m;

	rep(i, m){
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
	}

	vector<int> ans(n + 1);
	rep(s, n){
		auto now = bfs(s);
		if(now.size() < ans.size()) ans = now;
	}

	if(ans.size() == n + 1){
		cout << -1 << endl;
		return 0;
	}

	cout << ans.size() << endl;
	for(int v : ans) cout << (v+1) << endl;

}


Measured memory_bytes: 384
import math

def gcd(a, b, c):
    tmp = math.gcd(a, b)
    tmp = math.gcd(tmp, c)
    return tmp

K = int(input())
K += 1
ans = 0
for i in range(1, K):
    for j in range(i, K):
        for k in range(j, K):
            if i == j == k:
                ans += gcd(i, j, k) 
            elif i == j or j == k or k == i:
                ans += gcd(i, j, k) * 3
            else:  # i != j != k
                ans += gcd(i, j, k) * 6
print(ans)

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

using namespace std;

void solve(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto&& i : p){
        cin >> i;
    }
    int ans = 0;
    for(int i = 1; i < n - 1; i++){
        if(p[i - 1] <= p[i] && p[i] <= p[i + 1]) ans++;
        else if(p[i + 1] <= p[i] && p[i] <= p[i - 1]) ans++;
    }
    cout << ans << "\n";
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.nextLine();
            String t = sc.nextLine();
            int lcsLen = getLcsLen(s.length(), s.toCharArray(), t.length(), t.toCharArray());
            System.out.println(lcsLen);
        }
    }


    static int getLcsLen(int m, char[] s, int n, char[] t) {
        int[][] dp = new int[m][n];
        int maxLen = 0;

        for (int i=0; i<m; i++) {
            for (int j=0; j<n; j++) {
                if (s[i] == t[j]) {
                    if (i ==0 || j==0) {
                        dp[i][j] = 1;
                    } else {
                        dp[i][j] = dp[i - 1][j - 1] + 1;
                    }
                    maxLen = Math.max(maxLen, dp[i][j]);
                } else {
                    dp[i][j] = 0;
                }
            }
        }
        return maxLen;
    }
}



Measured memory_bytes: 299008
#include <iostream>
#include <vector>
using namespace std;
int N, taka, ao;
vector<int> G[100005];
int dis[100005];
void dfs(int v, int k) {
  dis[v] = k;
  for (auto i : G[v]) {
    if (dis[i] == -1) {
      dfs(i, k + 1);
    }
  }
}

int flag[100005];
void dfs_2(int v, int k) {
  flag[v] = 1;
  for (auto i : G[v]) {
    if (flag[i] == -1) {
      if (i != ao && k < dis[i]) {
        dfs_2(i, k + 1);
      }
    }
  }
}

int main() {
  cin >> N >> taka >> ao;
  taka--;
  ao--;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 0; i < 100005; i++)
    dis[i] = -1, flag[i] = -1;
  dfs(ao, 0);
  dfs_2(taka, 0);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (flag[i] == 1) {
      ans = max(ans, dis[i]);
    }
  }
  cout << max(0, ans - 1) << endl;
}


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

int main() {
  int N, M, A = 1;
  cin >> N >> M;
  
  for (int i = 0; i < N; i++){
  	if (A+M <= A*2){
    	A+=M;
    }
    else {
    	A*=2;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define MAX 64
typedef unsigned long long int ull;

using namespace std;

int main(int argc, char *argv[])
{
    ull arr[MAX] = {0};
    ull brr[MAX] = {0};
    ull res = 0;
    int num, flag, index;
    int jj = 0;
    int count = 0;

    scanf("%d", &num);
    for (int i = 0; i < num; i++)
    {
        scanf("%d", &flag);
        switch(flag)
        {
        case 0:
            scanf("%d", &index);
            cout <<arr[index] << endl;
            break;
        case 1:
            scanf("%d", &index);
            arr[index] = 1;
            break;
        case 2:
            scanf("%d", &index);
            arr[index] = 0;
            break;
        case 3:
            scanf("%d", &index);
            if (0 == arr[index])
            {
                arr[index] = 1;
            }
            else
            {
                arr[index] = 0;
            }
            break;
        case 4:
            //scanf("%d", &index);
            for (jj = 0; jj < MAX; jj++)
            {
                if (arr[jj] == 0)
                {
                    break;
                }
            }
            if (jj == 64)
            {
                printf("%d\n", 1);
            }
            else
            {
                printf("%d\n", 0);
            }
            break;
        case 5:
            for (jj = 0; jj < MAX; jj++)
            {
                if (1 == arr[jj])
                {
                    printf("%d\n", 1);
                    break;
                }
            }
            if (jj == 64)
                printf("%d\n", 0);
            break;

        case 6:
            for (jj = 0; jj < MAX; jj++)
            {
                if (arr[jj] == 1)
                    break;
            }
            if (jj == 64)
                printf("%d\n", 1);
            else
                printf("%d\n", 0);
            break;

        case 7:
            count = 0;
            for (jj = 0; jj < MAX; jj++)
            {
                if (arr[jj] == 1)
                    count++;
            }
            printf("%d\n", count);
            break;

        case 8:
            res = 0;
            for (jj = 0; jj < MAX; jj++)
            {
                brr[jj] = arr[jj];
            }

            for (int i = 1; i < MAX; i++)
            {
                for (int j = i; j < MAX; j++)
                {
                    brr[j] = 2 * brr[j];
                }
            }

            for (jj = 0; jj < MAX; jj++)
            {
                res += brr[jj];
            }
            cout << res << endl;


            break;
        default:
            break;
        }
    }


    return 0;
}



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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;

    return 0;
}

Measured memory_bytes: 256
//From "http://cpp.sh/"
#include <bits/stdc++.h>
using namespace std;

int main(){
    int x[100],n;
    for(n=0;1;n++){
        cin>>x[n];
        if(x[n]==0)break;
    }
    n-=1;//n=(num)-1
    int map[9][9];//map[x][y]
    for(int k=0;k<=n;k++){
        //calculation
        int y=1;
        for(int i=0;i<x[k];i++){//x+y
            for(int j=0;j<=i;j++){//x
                if(i%2)map[j][i-j]=y;
                else map[i-j][j]=y;
                y++;
            }
        }
        for(int i=x[k];i<x[k]*2-1;i++){//x+y
            for(int j=i-x[k]+1;j<x[k];j++){//x
                if(i%2)map[j][i-j]=y;
                else map[i-j][j]=y;
                y++;
            }
        }
        //writing
        cout<<"Case "<<k+1<<":"<<endl;
        //(x[k],x[k])
        for(int i=0;i<x[k];i++){
            for(int j=0;j<x[k];j++){
                if(map[i][j]>9)cout<<" "<<map[i][j];
                else cout<<"  "<<map[i][j];
            }
            cout<<endl;
        }
    }
}

Measured memory_bytes: 3080
def dfs(i, f):
    if i == n-1:
        return sum(list(map(int, f.split("+"))))

    return dfs(i+1, f + "+" + s[i+1]) + dfs(i+1, f + s[i+1])


s = input()
n = len(s)

print(dfs(0, s[0]))

Measured memory_bytes: 9172
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	positions, distances := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&positions[i])
		if i > 0 {
			distances[i] = abs(positions[i] - positions[i - 1]) + distances[i - 1]
		}
	}
	min := math.MaxInt32
	for i := 0; i < n - k + 1; i++ {
		tmp := distances[i + k - 1] - distances[i] + min1(abs(positions[i]), abs(positions[i + k - 1]))
		if tmp < min {
			min = tmp
		}
	}
	fmt.Println(min)
}

func abs(x int) int {
	if x < 0 {
		return -1 * x
	} else {
		return x
	}
}

func min1(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    int x , c = 0 ;
    cin >> x ;
    string y ;
    cin >> y ;
    for(int i=0 ; i <= x-3 ; i++){
        string a = y.substr(i,3) ;
        if(a == "ABC")
        c = c + 1 ;
    }
    cout << c ;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  int TT = 1;
  // cin >> TT;
  while (TT--) {
    ll l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; ++i) {
      if (i%d==0) ++ans;
    }
    cout << ans << endl;
    
  }
}


Measured memory_bytes: 3652
import copy
n,m = map(int,input().split())
graph = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
memo = [0]*n
now = [[0,0]]
nxt = []
done = [False]*n
done[0] = True


while now:
    for l in now:
        for j in graph[l[1]]:
            if not done[j]:                
                done[j] = True
                nxt.append([l[1],j])
                memo[j] = l[1]+1
    now = copy.copy(nxt)
    nxt = []
for l in now:
    done[l[1]] = True
if False in done:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(memo[i])

Measured memory_bytes: 107544
#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;

ll dp[100005][2];
vi w(100005),val(100005);
ll n,cnt=0;



int main()
{
    fastio;
        memset(dp,0,sizeof dp);
        ll W;
        cin>>n>>W;


        fr(i,0,n)cin>>w[i]>>val[i];



       fr(i,0,n)
       {
           fr(j,0,W+1)
           {
               if(i%2==0)
               {
                   if(j-w[i]>=0)  dp[j][1]=max(dp[j][0],val[i]+dp[j-w[i]][0]);
                   else dp[j][1]=dp[j][0];
               }
               else
               {
                   if(j-w[i]>=0) dp[j][0]=max(dp[j][1],val[i]+dp[j-w[i]][1]);
                   else dp[j][0]=dp[j][1];
               }
           }
       }


       ll ans=max(dp[W][0],dp[W][1]);

       cout<<ans<<endl;








}




























Measured memory_bytes: 6256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<iomanip>
using namespace std;
int main() {
	long int n, k,ans=0;
	cin >> n >> k;
	if(k == 2) {
		cout << 2 << endl;
		return 0;
	}
	if(n == 1) {
		cout << k << endl;
		return 0;
	}
	ans = pow(k - 1, n - 1);
	ans *= k;
	cout <<fixed<<setprecision(10)<< ans << endl;
}

Measured memory_bytes: 384
def C(n, r):
    global MOD
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD
    

K = int(input())
S = input()
N = len(S)

MOD = 10 ** 9 + 7
ans = 0

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, K + N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

for i in range(0, K + 1):
    ans += C(i + N - 1, N - 1) * pow(25, i, MOD) * pow(26, K - i, MOD)
    ans %= MOD
print(ans)




Measured memory_bytes: 227072
// AOJ 2618: Trip to Kyoto
// 2018.1.25 bal4u@uu

#include <stdio.h>

#define MIN(a,b)  ((a)<=(b)?(a):(b))

int x1[10002], y1[10002], x2[10002], y2[10002];
char *msg[2] = { "%d\n", "%d.5\n" };

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(int x1, int y1, int x2, int y2)
{
	int dx, dy;

	x1 += 200000000, x2 += 200000000;
	y1 += 200000000, y2 += 200000000;
	dx = x1-x2; if (dx < 0) dx = -dx;
	dy = y1-y2; if (dy < 0) dy = -dy;
	if (!(x1%20 | x2%20)) {
		if (x1 == x2) return dy;
		else if (y1/20 == y2/20) return dx + MIN(y1%20+y2%20, 40-y1%20-y2%20);
	} else if (!(y1%20 | y2%20)) {
		if (y1 == y2) return dx;
		else if (x1/20 == x2/20) return dy + MIN(x1%20+x2%20, 40-x1%20-x2%20);
	}
	return dx+dy;
}

int main()
{
	int n, x, y, i, j, k, s, t, ans;
	int xmin, xmax, ymin, ymax;
	int x0, y0;

	n = in();
	x = in() << 1, y = in() << 1;
	x1[0] = x, y1[0] = y, xmin = xmax = x2[0] = x+y, ymin = ymax = y2[0] = x-y;
	for (i = 1; i < n; i++) {
		x = in() << 1, y = in() << 1;
		x1[i] = x,   y1[i] = y;
		x2[i] = x+y, y2[i] = x-y;
		if      (x2[i] < xmin) xmin = x2[i];
		else if (x2[i] > xmax) xmax = x2[i];
		if      (y2[i] < ymin) ymin = y2[i];
		else if (y2[i] > ymax) ymax = y2[i];
	}
 
	x = (xmin + xmax) >> 1, y = (ymin + ymax) >> 1;
	x0 = (x + y) >> 1, y0 = (x - y) >> 1;

#define OFF 10
	ans = 0x7fffffff;
	for (i = x0-OFF; i <= x0+OFF; i++)for (j = y0-OFF; j <= y0+OFF; j++) {
		if (i%20 && j%20) continue;
		t = 0; for (k = 0; k < n; k++) if (t < (s = calc(i, j, x1[k], y1[k]))) t = s;
		if (ans > t) ans = t;
	}
	printf(msg[ans & 1], ans >> 1);
	return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int cnt[1000000];

int main()
{
	ll N, P, ans = 1;

	cin >> N >> P;

	if (N == 1) {
		cout << P << endl;
		return 0;
	}

	for (ll d = 2; d * d <= P; d++) {
		while (P % d == 0) {
			cnt[d]++;
			P /= d;
		}
	}
	
	rep(i, 1000000) {
		rep(j, cnt[i] / N) {
			ans *= i;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main()
{
   int D, T, S;
   cin >> D >> T >> S;
   if (S * T >= D)
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    int min = INT_MAX;
    int a;
    int ans = 0; 
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        if ( min > a ) { min = a; ans++; }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<double> vec(n);
    cin>>vec;
    sort(all(vec));
    double ans=vec[0];
    FOR(i,1,n){
        ans=(ans+vec[i])/2;
    }
    printf("%.10f\n",ans);
    return 0;
}

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

char a [100][101] , b [102][102];
int main () {
  int H , W ; 
  cin >> H >> W ;
  for ( int i = 0; i < H ; i ++){
    scanf ("%s " , a [ i ]);
  }
    for ( int i = 0; i < H + 2; i ++){
      for ( int j = 0; j < W + 2; j ++){
  		b [ i ][ j ] = '#';
      }}
  for ( int i = 0; i < H ; i ++){
    for ( int j = 0; j < W ; j ++){
      b [ i + 1][ j + 1] = a [ i ][ j ];
    }}
  for ( int i = 0; i < H + 2; i ++) {
    for ( int j = 0; j < W + 2; j ++){
    cout << b [ i ][ j ];
    }
    cout << endl ;
    }
  }


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char S[4], T[4];
    int i;
    int ctr = 0;
    
    
    scanf("%s", &S);
    scanf("%s", &T);
    
    
    for(i=0; i<3; i++)
    {
        if(S[i] == T[i])
            ctr++;
    }
    
    
    printf("%d\n", ctr);
    
    
    //system("pause");
    
    return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

mint f(int n)
{
  if (n == 0)
    return 1;
  mint x = f(n / 2);
  x *= x;
  if (n % 2 == 1)
    x *= 2;
  return x;
}

mint choose(int n, int a)
{
  mint x = 1, y = 1;
  rep(i, a)
  {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n, a);
  ans -= choose(n, b);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	s := next()
	counter := 0
	max := 0
	for i := 0; i < 3; i++ {
		if s[i] == 'R' {
			counter++
			max = counter
		} else if s[i] == 'S' {
			counter = 0
		}
	}
	fmt.Fprintf(out, "%d\n", max)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func quickSort(val []int) []int {
	if len(val) < 2 {
		return val
	}

	pivot := val[0]

	left := []int{}
	right := []int{}

	for _, v := range val[1:] {
		if pivot > v {
			left = append(left, v)
		} else {
			right = append(right, v)
		}
	}

	left = quickSort(left)
	right = quickSort(right)

	ret := append(left, pivot)
	ret = append(ret, right...)

	return ret
}


Measured memory_bytes: 1808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int q;
  cin>>q;
  rep(i,0,q){
    ll a,b;
    cin>>a>>b;
    /*ll c=(ll)sqrt(a*b-1);
    ll ans;
    if(c*(c+1)>a*b-1){
      ans=2*c-2;
    }
    else{
      ans=2*c-1;
    }
    if(a==b) ans++;
    cout<<ans<<endl;*/
    if(a==b) cout<<2*a-2<<endl;
    else{
      ll c=sqrt(a*b);
      if(c*(c+1)<a*b){
        cout<<2*c-1<<endl;
      }
      else if(c*c==a*b){
        cout<<2*c-3<<endl;
      }
      else{
        cout<<2*c-2<<endl;
      }
    }
  }
}

Measured memory_bytes: 3656
while True:
    n = input();
    if n == '-':
        break;
    m = int(input());
    N = list(n);
    
    for i in range(0,m):
        h = int(input());
        for j in range(0,h):
            x = [];
            x.append(N[0]);
            N.pop(0);
            N.append(x[0]);
    print(''.join(N));


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

int main() {
  int H,W;
  cin>>H>>W;
  for(int i=0;i<H;i++){
    vector<char> p(W);
    for(int k=0;k<W;k++){
      cin>>p.at(k);
      cout<<p.at(k);
    }
    cout<<endl;
    for(int k=0;k<W;k++){
      cout<<p.at(k);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
double myabs(double a) {
    if (a < 0) return -1 * a;
    return (double)a;
}

int main()
{
    int n, t, a;
    cin >> n >> t >> a;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    double diff = 0xffff;
    int p = -1;

    for (int i = 0; i < n; i++) {
        double temp = t - h[i] * 0.006;
        if (diff > myabs(a - temp)) {
            diff = myabs(a - temp);
            p = i + 1;
        }
    }
    cout << p << endl;
}

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

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

template<typename T>
map<T, long long> factorize(T x) {
  map<T, long long> res;
  for (long long i = 2; i * i <= x; ++i) {
    while (x % i == 0) {
      x /= i;
      res[i] += 1;
    }
  }
  if (x != 1) res[x]++;
  return res;
}


int main() {
  int n; cin >> n;
  vector<ll> fac(111,0);
  for (int i = 1; i <= n; ++i) {
    for (auto pa : factorize(i)) {
      fac[pa.first] += pa.second;
    }
  }

  ll ans = 0;

  if (fac[2] >= 74) ans++;
  for (int i = 2; i < 111; ++i) {
    for (int j = 2; j < 111; ++j) {
      if (i != j and fac[i] >= 2 and fac[j] >= 24) ans++;
    }
  }

  for (int i = 2; i < 111; ++i) {
    for (int j = 2; j < 111; ++j) {
      if (i != j and fac[i] >= 4 and fac[j] >= 14) ans++;
    }
  }

  for (int i = 2; i < 111; ++i) {
    for (int j = 2; j < 111; ++j) {
      for (int k = 2; k < j; ++k) {
        // here
        if (i != j and i != k and fac[i] >= 2 and fac[j] >= 4 and fac[k] >= 4) ans++;
      }
    }
  }

  cout << ans << endl;
}

/*
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


template<typename T>
map<T, Int> factorize(T x){
  map<T, Int> res;
  for(Int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;

  vector<Int> cnt(111,0);
  for(Int i=1;i<=n;i++){
    for(auto p:factorize(i))
      cnt[p.first]+=p.second;
  }

  Int ans=0;
  // 75 = 74 + 1
  if(cnt[2]>=74) ans++;

  // 75 = (2 + 1) * (24 + 1)
  for(Int i=2;i<111;i++)
    for(Int j=2;j<111;j++)
      if(i!=j&&cnt[i]>=2&&cnt[j]>=24) ans++;


  // 75 = (4 + 1) * (14 + 1)
  for(Int i=2;i<111;i++)
    for(Int j=2;j<111;j++)
      if(i!=j&&cnt[i]>=4&&cnt[j]>=14) ans++;

  // 75 = (2 + 1) * (4 + 1) * (4 + 1)
  for(Int i=2;i<111;i++)
    for(Int j=2;j<111;j++)
      for(Int k=2;k<j;k++)
        if(i!=j&&i!=k&&cnt[i]>=2&&cnt[j]>=4&&cnt[k]>=4) ans++;

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


Measured memory_bytes: 256
from collections import deque

def main():
    H, W = map(int, input().split())
    maze = [list(input()) for _ in range(H)]
    directions = [[0, 1], [0, -1], [1, 0], [-1, 0]]

    ans = 0
    for h in range(H):
        for w in range(W):
            if maze[h][w] == '#':
                continue

            goal_dists = [[-1] * W for _ in range(H)]
            goal_dists[h][w] = 0
            d = deque([[h, w]])

            while d:
                ht, wt = d.popleft()
                for dh, dw in directions:
                    if not (0 <= ht+dh < H and 0 <= wt+dw < W):
                        continue
                    if maze[ht+dh][wt+dw] == '#':
                        continue
                    if goal_dists[ht+dh][wt+dw] == -1:
                        goal_dists[ht+dh][wt+dw] = goal_dists[ht][wt] + 1
                        d.append([ht+dh, wt+dw])
            
            ans = max(ans, max([max(l) for l in goal_dists]))

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(n) (n).begin(), (n).end()

int main()
{
    ll n;

    cin >> n;

    for (ll bit = 0; bit < (1 << n); bit++)
    {
        vector<ll> sum;
        for (ll i = 0; i< n;i++) {
            if (bit & (1 <<i))
                sum.push_back(i);
        }

        cout << bit << ":";
        for (ll i = 0; i< (ll)(sum.size()); i++)
        {
            cout << " " << sum[i];
        }
        cout << endl;
    }


}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,m=-1,r,ans=0;
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++){
		scanf("%lld",&r);
		m=max(r,m);
		ans=ans+m-r;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3760
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> n;
  for(int i = 1; i <= sqrt(n); i++) {
    if(n % i == 0)
      mn = min(mn, i + n / i - 2);
  }
  cout << mn;
}

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


//SHORTCUTS

#define ll long long
#define endl '\n'
#define i1(a) cin>>a
#define i2(a,b) cin>>a>>b
#define i3(a,b,c) cin>>a>>b>>c
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define f(i,a,b) for(int i = a;i<b;i++)
#define fe(i,a,b) for(int i = a;i<=b;i++)
#define fi(i,a,b) for(i=a;i<b;i++)
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair


// DEBUG CODE & FAST OUTPUT

#define printv(a) for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
#define printvl(a) for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
#define printa(a, n) for (int i = 0; i< n; i++) cout << a[i] << ' ';
#define printal(a, n) for (int i = 0; i < n; i++) cout << a[i] << endl;


//DATA STRUCTURES

#define pq priority_queue
#define ms multiset
// #define y0 _y0_
// #define y1 _y1_
// #define div divi

typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;


//IMP CONSTANT
const int mod = 1e9 + 7, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
bool google_contest = false;

//MODULAR OPERATIONS
ll myadd(ll a,ll b){
    ll ans = a+b;
    ans-= ans>=mod ? mod : 0;
    return ans; 
}
ll mysub(ll a, ll b){
    return (a-b+mod)%mod;
}
ll mymul(ll a,ll b){
    return (a*b)%mod;
}
ll mypow(ll a, ll b){
    ll ans = 1;
    while(b>0)
        if(b&1) ans = mymul(ans,a),b--;
        else a = mymul(a,a),b >>= 1;
    return ans;
}
ll nCr(ll n,ll r){
    if(r==0)return 1;
    if(r==1)return n;
    if(n==0)return 0;
    return mymul(n,mymul(nCr(n-1,r-1),mypow(r,mod-2)));
}




const int dx[4] = {1, -1, 0,  0};
const int dy[4] = {0, 0,  1, -1};
//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    | 



int main(){

ios_base::sync_with_stdio(0);
cin.tie(0); 
cout.tie(0);

int t,tt;
t=1;
// i1(t);
if(google_contest)tt=1;

while(t--){

int a[5];
f(i,0,5)i1(a[i]);

f(i,0,5){
    if(a[i]==0)o1(i+1);
}



if(google_contest){
    cout<<"Case "<<tt++<<": ";
}
}

return 0;   
}


//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    |   OVER!!!!


Measured memory_bytes: 3656
n=int(input())
S=[]
T=[]
data=set()
for i in range(n):
  s=input()
  S.append(s)
  data.add(s)
m=int(input())
for i in range(m):
  t=input()
  T.append(t)
  data.add(t)
ans=0
for i in data:
  ans=max(ans,S.count(i)-T.count(i))
print(ans)

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

#define pb push_back
const int maxn = 10000;
const int INF = 0x3f3f3f3f;
int A, B;

int main()
{
	cin >> A >> B;
	int a = A+B;
	int b = A-B;
	int c = A*B;
	printf("%d\n", max(a, max(b, c)));
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(true){
            String key = scan.next();
            if(key.equals("-")) break;
            int n = scan.nextInt();
            for(int i = 0;i < n;i++){
                int h = scan.nextInt();
                String tmpStr = key.substring(0, h);
                key = key.substring(h, key.length()) + tmpStr;
            }
            System.out.println(key);
        }
    }
}

Measured memory_bytes: 26308