akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;

	int N = 0;
	if (B < 10) {
		 N = A * 10 + B;
	}
	else if (B >= 10 && B < 100) {
		 N = A * 100 + B;
	}
	else {
		N = A * 1000 + B;
	}
	
	double k = sqrt(N);
	bool flag = false;
	rep(i, N) {
		if (i == k) {
			flag = true;
		}
	}

	if (flag == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main(){
  long long N,K,ta;
  cin >> N >> K;
  vector<long long> C(N),P(N),ans(N);
  for(int i=0; i<N; i++){
    cin >> P[i];
    P[i]--;
  }
  for(int i=0; i<N; i++){
    cin >> C[i];
  }
  for(long long i=0; i<N; i++){
    ta = 0;
    vector<long long> T(N,0), A(N,0);
    long long m = i, h = 0, tmp = 0, tmp2, mtmp,mta=-1e10;
    while(A[m] == 0){
      h++;
      A[m] = h;
      ta += C[P[m]];
      T[m] = ta;
      m = P[m];
      mta = max(ta,mta);
      //if(i == 9)cout << i << "ta = " << ta << "-" << h << "-" << m << endl;
      if(h == K) break;
    }
    if(h == K) ans[i]=mta;
    else{
      long long sc = ta - T[m] + C[P[m]];
      long long dc = h - A[m]+1;
      tmp2 = P[m]; mtmp = 0;
      for(long long j=0; j<(K-A[m])%dc; j++){
        tmp += C[P[tmp2]];
        tmp2 = P[tmp2];
        mtmp = max(mtmp, tmp);
      }
      ans[i] = max(mtmp + T[m] + ((K-A[m])/dc)*sc, mta);
      //if(i == 9)cout << sc << "-" << dc << endl;
    }
  }
  long long mans = -1e10;
  for(long long i=0; i<N; i++){
    mans = max(mans,ans[i]);
    //if(i == 9)cout << i << "-" << ans[i] << endl;
  }
  cout << mans;
  return 0;
}

Measured memory_bytes: 3816
using System;
using System.Linq;
using System.Text;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32 (Console.ReadLine ());
            int[] Ai = Array.ConvertAll<string, int> (Console.ReadLine ().Split (), int.Parse);
            int[] answer = new int[N + 1];
            for (var i = 0; i < Ai.Length; i++) {
                answer[Ai[i]]++;
            }
            StringBuilder builder = new StringBuilder (answer.Length);
            for (var i = 1; i < answer.Length; i++) {
                builder.Append ($"{answer[i]}\n");
            }
            Console.Write (builder.ToString ());
        }
    }
}


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

using namespace std;

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

	int p_max = 0;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> p;
		sum += p;

		if (p_max < p) {
			p_max = p;
		}
	}

	sum -= p_max / 2;

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define _CRT_SECURE_NO_WARNINGS
#endif
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void print(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
template<typename First, typename ... Ints>
void scan(First &arg, Ints&... rest) { scan(arg);scan(rest...); }

using namespace std;
const int MM = 3002;

int N;
double dp[MM][2];
//number of heads, previous and cur

int main(){
    
    scanf("%d", &N);
    dp[0][1] = 1;
    double p;
    
    for(int ii = 0,i; ii < N; ii++){
        i = ii&1;
        scanf("%lf", &p);
        dp[0][i] = dp[0][i^1]*(1-p);
        for(int j = 1; j <= N; j++){
            dp[j][i] = dp[j-1][i^1]*p + dp[j][i^1]*(1-p);
        }
    }
    double sum = 0;
    for(int i = (N+1)/2; i <= N; i++){
        sum += dp[i][N&1^1];
    }
    printf("%.10lf\n", sum);
    
    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;

  int cur = 0;
  int ab_cur = 0;
  REP(i, N) {
    string ans = "No";
    if (S.at(i) == 'a') {
      if (cur < (A + B)) {
        ++cur;
        ans = "Yes";
      }
    } else if (S.at(i) == 'b') {
      if (cur < (A + B) && ab_cur < B) {
        ++cur;
        ++ab_cur;
        ans = "Yes";
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 848
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<int> pos[30];
lint cal(vector<int> a,vector<int> b){
	int n=a.size(),m=b.size(),now=0,i1=0,i2=0;lint ret=0;
	if(n%2>0) swap(n,m),swap(a,b);
	vector<int> ap;
	while(i1<n || i2<m){
		if(i2>=m || (i1<n && a[i1]<b[i2])){
			ap.pb(now);i1++;
		}
		else i2++;
		now++;
	}
	rep(i,n/2){
		int x=ap[i],y=n+m-1-ap[n-1-i];
		ret+=abs(x-y);
	}
	return ret;
}
int main()
{
	string s;
	cin>>s;
	rep(i,s.size()) pos[(s[i]-'a')].pb(i);
	int odd=0;
	rep(i,26) odd+=pos[i].size()%2;
	if(odd>1){
		cout<<-1<<endl;return 0;
	}
	lint ret=0;
	rep(i,26) REP(j,i+1,26) ret+=cal(pos[i],pos[j]);
	cout<<ret<<endl;
}


Measured memory_bytes: 3864
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	string S; cin >> S;
	bool flag = false;
	int cnt = 0;
	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'S') {
			cnt++;
		}
		else {
			if(cnt>0)ans+=2;
			cnt--;

			if (cnt < 0)cnt = 0;
		}
	}

	cout << (int)S.size() - ans << endl;

    return 0;
}



Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n, q, a, b, c;
	ll s = 0;
	cin >> n;
	map<int, int> mp;
	rep(i, 0, n) {
		cin >> a;
		mp[a]++;
		s += a;
	}
	cin >> q;
	rep(i, 0, q) {
		cin >> b >> c;
		int temp = mp[b];
		mp[b] = 0;
		mp[c] += temp;
		s += (c - b) * temp;
		printf("%lld\n", s);
	}
	return 0;
}


Measured memory_bytes: 8056
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i <= n; i++) {
		string r = s.substr(0, i) + t;
		if (r.substr(0, n) == s) {
			cout << r.size() << endl;
			break;
		}
	}
	return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  while(a>0 && c>0){
    c -= b;
    if(c<=0){
      ANS("Yes");
      return 0;
    }

    a -= d;
    if(a<=0){
      ANS("No");
      return 0;
    }
  }
  return 0;
}


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

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

    queue<ll> q;
    for (int i = 1; i < 10; i++){
        q.push(i);
    }

    ll ans = 0;
    for (int i = 1; i <= K ; i++){
        if (i == K) break;

        ll a = q.front();
        q.pop();

        if (a % 10 == 0){
            q.push(a * 10);
            q.push(a * 10 + 1);
        } else if (a % 10 == 9){
            q.push(a * 10 + 8);
            q.push(a * 10 + 9);
        } else {
            q.push(a * 10 + (a % 10) - 1);
            q.push(a * 10 + (a % 10));
            q.push(a * 10 + (a % 10) + 1);
        }

    }

    cout << q.front() << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stack>
using namespace std;
 
int div(int A, int B, int mod_p) {
  stack<int> q_stack;
  int a = B, b = mod_p, r;
  while (b) {
    q_stack.push(a / b);
    r = a % b; a = b; b = r;
  }
  long u = 1, v = 0;
  while (!q_stack.empty()) {
    int q = q_stack.top(); q_stack.pop();
    long u1 = v, v1 = u-q*v; u = u1 % mod_p; v = v1 % mod_p;
  }
  return (long)A * (u + mod_p) % mod_p;
}
 
int num_com(int n, int k, int mod_p) {
  int k2 = min(k, n - k);
  long nmr = 1, dnm = 1;
  for (int i = 1; i <= k2; i++) {
    nmr *= n + 1 - i; nmr %= mod_p;
    dnm *= i; dnm %= mod_p;
  }
  return div(nmr, dnm, mod_p);
}

int DIV = 1e+9 + 7;
long dp[2010][1000];

int main() {
  int S; cin >> S;
  if (S < 3) cout << 0 << endl;
  else {
    int k = 1;
    long sum = 0;
    while (S-2*k-1>=k-1) {
      sum = (sum + num_com(S-2*k-1, k-1, DIV)) % DIV;
      k++;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 3640
import java.util.Scanner;

//How I Wonder What You Are!
public class Main{

	double dot(double[] a, double[] b){
		return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];
	}
	double norm(double[] a){
		return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			double[][] p = new double[n][3];
			for(int i=0;i<n;i++)for(int j=0;j<3;j++)p[i][j]=sc.nextDouble();
			int m = sc.nextInt();
			boolean[] u = new boolean[n];
			while(m--!=0){
				double[] t = new double[3];
				for(int i=0;i<3;i++)t[i]=sc.nextDouble();
				double phi = sc.nextDouble();
				for(int i=0;i<n;i++){
					if(u[i])continue;
					double w = Math.acos(dot(p[i], t)/norm(p[i])/norm(t));
					if(w<phi+1e-8)u[i]=true;
				}
			}
			int res = 0;
			for(boolean f:u)if(f)res++;
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
        Scd(N);

    bool ans = true;
    int a;
    set<int> s;
    Rep(i,N){
        Scd(a);
        if( s.find(a) != s.end() ){
            ans = false;
            break;
        }
        s.insert(a);
    }

    YESNO(ans);

    return 0;
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s,t;
	cin>>s>>t;
	int a=s-'A'+10,b=t-'A'+10;
	if(a<b)cout<<"<"<<"\n";
	if(a>b)cout<<">"<<"\n";
	if(a==b)cout<<"="<<"\n";
	return 0;
}

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

using namespace std;


int main(){
    string s;
    cin>>s;

    int val;
    if(s=="SAT"){
        val=1;
    }else if(s=="FRI"){
        val=2;
    }else if(s=="THU"){
        val=3;
    }else if(s=="WED"){
        val=4;
    }else if(s=="TUE"){
        val=5;
    }else if(s=="MON"){
        val=6;
    }else if(s=="SUN"){
        val=7;
    }
    
    cout<<val<<endl;
    
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
ll w, h, wc, hc, res;
pll arr[200100];

int main() {
	int i;

	scanf("%lld%lld",&w,&h);
	for (i=0;i<w;i++) {
		scanf("%lld",&arr[i].first); arr[i].second = 0;
	}
	for (i=w;i<w+h;i++) {
		scanf("%lld",&arr[i].first); arr[i].second = 1;
	}
	sort(arr,arr+w+h);
	for (i=0;i<w+h;i++) {
		if (arr[i].second) {
			res += arr[i].first*(w+1-wc);
			hc++;
		}
		else {
			res += arr[i].first*(h+1-hc);
			wc++;
		}
	}
	printf("%lld\n",res);

    return 0;
}


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

int main(){

 int m, n;
 int a[100][100] = {}, b[100] = {}, c[100] = {};

 cin >> n >> m;

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

 for (int i = 0; i < m; i++) {
  cin >> b[i];
 }

 for (int i = 0; i < n; i++) {
  for (int j = 0; j < m; j++) {
   c[i] += a[i][j] * b[j];
  }
 }

 for (int i = 0; i <  n; i++) {
  cout << c[i] << endl;
 }
 
 return 0;
}

Measured memory_bytes: 1208
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int N, A[200001];


int main(){
  cin >> N;
  long long sum[200001] = {};
  for(int i = 0; i < N; i++){
    cin >> A[i+1];
    sum[i+1] = sum[i] + A[i+1];
  }
  long long ans = 2000000000000000;
  for(int mid_index = 3; mid_index <= N - 1; mid_index++){
    int l1 = lower_bound(sum+2, sum+mid_index, sum[mid_index-1]/2)-sum;
    int first_index;
    if(abs(sum[l1] - (sum[mid_index-1]-sum[l1])) <= abs(sum[l1-1] - (sum[mid_index-1]- sum[l1-1]))){
      first_index = l1+1;
    }else{
      first_index = l1;
    }
    int l3 = lower_bound(sum+mid_index+1, sum+N+1, (sum[N]+sum[mid_index-1])/2) - sum;
    int end_index;
    if(abs((sum[l3]-sum[mid_index-1]) - (sum[N] - sum[l3])) <= abs((sum[l3-1]-sum[mid_index-1]) - (sum[N] - sum[l3-1]))){
      end_index = l3+1;
    }else{
      end_index = l3;
    }
    long long m = min(sum[first_index-1], min(sum[mid_index-1]-sum[first_index-1], min(sum[end_index-1]-sum[mid_index-1], sum[N] - sum[end_index - 1])));
    long long M = max(sum[first_index-1], max(sum[mid_index-1]-sum[first_index-1], max(sum[end_index-1]-sum[mid_index-1], sum[N] - sum[end_index - 1])));
    long long tmp = M - m;
    ans = min(ans, tmp);
    //printf("l1 = %d, l3 = %d\n", l1, l3);
    //printf("%d, %d, %d\n", first_index, mid_index, end_index);
    //printf("tmp = %lld\n", tmp);
  }
  cout << ans << endl;
  
  return 0;
}


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

int checkPoint(double x1, double y1, double x2, double y2, double x, double y){
    if(x1 - x2 == 0) { if(x1 - x == 0) return 0; if(x - x1 > 0) { return 1; } else return -1; }
    if((y - y1) - (y2 - y1) / (x2 - x1) * (x - x1) == 0) return 0;
    if((y - y1) - (y2 - y1) / (x2 - x1) * (x - x1) > 0) { return 1; } else return -1;
}

int main(){
    double x1, y1, x2, y2, x3, y3, xp, yp;
    bool f;
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
        f = false;
        if(checkPoint(x1, y1, x2, y2, x3, y3) * checkPoint(x1, y1, x2, y2, xp, yp) == 1){
            if(checkPoint(x1, y1, x3, y3, x2, y2) * checkPoint(x1, y1, x3, y3, xp, yp) == 1){
                if(checkPoint(x2, y2, x3, y3, x1, y1) * checkPoint(x2, y2, x3, y3, xp, yp) == 1){ f = true; cout << "YES" << endl; }}}
        if(!f) cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m, a, b; cin >> n >> m >> a >> b;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << ((i < b) ^ (j < a));
		}
		cout << endl;
	}
	return 0;
}


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

int N;
int A[200]; 

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int count = 0;

    while (true) {
        bool flg = false; 
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) flg = true;
        }

        if (flg) break;
      
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>a;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		a.push_back(now);
	}
	vector<ll>b=a;
	sort(b.begin(),b.end());
	if(a==b){
		cout << "YES";
		return 0;
	}
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			vector<ll>c=a;
			swap(c[i],c[j]);
			if(c==b){
				cout <<"YES";
				return 0;
			}
		}
	}
	cout << "NO";
	// your code goes here
	return 0;
}

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


int main(){
	ll h,w,d;
	cin >> h >> w >> d;
	
	vector<P> loc(h*w);
	rep(i,h){
		rep(j,w){
			int tmp;
			cin >> tmp;
			loc[--tmp] = make_pair(i,j);
		}
	}
	
	vector<ll> s(h*w);
	rep(i,h*w){
		if(i-d >= 0) s[i] = s[i-d] + abs(loc[i-d].first - loc[i].first) + abs(loc[i-d].second - loc[i].second);
	}
	
	ll q;
	cin >> q;
	rep(i,q){
		ll l,r;
		cin >> l >> r;
		cout << s[--r]-s[--l] << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main()
{
	int n;

	cin >> n;

	std::vector<int> array(n);

	for (int i = 0; i < n; ++i)
	{
		cin >> array[i];
	}

	int ans = 0;
	for (int i = 1; i < n - 1; ++i)
	{
		if (array[i - 1] < array[i] && array[i + 1] < array[i])
		{
		}
		else if (array[i] < array[i - 1] && array[i] < array[i + 1])
		{
		}
		else
		{
			ans++;
		}


	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,C,D;cin >> A >> B >> C >> D;
  cout << min(A,B) + min(C,D) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int x,int y){return y?gcd(y,x%y):x;}

int main(void){
  int hp[100000];
  int n, g;
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> hp[i];
    g = i==0?hp[0]:gcd(g,hp[i]);
  }
  cout << g << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
 
s = str(input()).replace('\n', '')
k = int(input())
 
s = s + s[0]
 
lst = []
last = ''
cnt = 0
for i in range(len(s)):
  if s[i] == last or last == '':
    cnt += 1
  else:
    lst.append(cnt)
    cnt = 1
  last = s[i]
lst.append(cnt)
 
    
n_lst = [i // 2 for i in lst]
answer = sum(n_lst)*k

if lst[-1]%2 == 0:
  answer -=  1
  
if len(lst) == 1:
  answer = (len(s)-1)*k//2
elif s[0] == s[-2] and lst[-1]%2 == 0 and lst[0]%2 == 0:
  answer -= k-1

print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    int n;
    cin >> n;
    int d[n];
    for(int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d,d+n);
    int count = 1;
    for(int i = 1; i < n; i++) {
        if(d[i-1] < d[i]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import numpy as np

s = np.array([int(i) for i in input()])

ans_0 = np.array(
  [int(i%2==0) for i in range(len(s))])
ans_1 = np.array(
  [int(i%2==1) for i in range(len(s))])

diff_0 = (s == ans_0).sum()
diff_1 = (s == ans_1).sum()

print(min(diff_0, diff_1))

Measured memory_bytes: 15528
#include<stdio.h>
int main(void)
{
	int input[2] = { 0 };
	int s, r;
	scanf("%d %d", &input[0], &input[1]);

	s = input[0] * input[1];
	r = (input[0] * 2) + (input[1] * 2);

	printf("%d %d\n", s, r);

	return 0;

}


Measured memory_bytes: 2612
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int d, t;
	cin >> d;
	vector<int> c(26);
	rep(i, 0, 26)cin >> c[i];
	vector<vector<int>> s(d, vector<int>(26));
	vector<int> last(26, 0);
	rep(i, 0, d) {
		rep(i2, 0, 26)cin >> s[i][i2];
	}
	rep(i, 1, d + 1) {
		ll score = 0, M = 0;
		int p = 0;
		rep(j, 0, 26) {
			score = s[i - 1][j];
			rep(k, 0, 26)if(k != j)score -= c[k] * (i - last[k]);
			if (M < score)M = score, p = j;
		}
		last[p] = i;
		printf("%d\n", p + 1);
	}
	//ll ans = 0;
	/*rep(i, 1, d + 1) {
		cin >> t;
		t--;
		last[t] = i;
		ans += s[i - 1][t];
		rep(i2, 0, 26)ans -= c[i2] * (i - last[i2]);
		printf("%lld\n", ans);
	}*/
	return 0;
}

Measured memory_bytes: 3760
using System;

namespace _139d
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long M_total = 0;
            // float[] N_array = new float[N];
            for(int i = 0; i < N;i++){
                // N_array[i] = i+1;
                if(i != N-1){
                    M_total += i+1;
                }
            }
            // for(int i = 0; i < N ; i++){
            //     if(i != N-1){
            //         M_total += N_array[i]%N_array[i+1];
            //     }
            // }
            Console.WriteLine(M_total);
        }
    }
}

Measured memory_bytes: 13140
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll i,N,ans=0;
  cin>>N;
  vec a(N),b(N),c(N),sum(N,0);
  rep(i,N)cin>>a[i];vsort(a);
  rep(i,N)cin>>b[i];vsort(b);
  rep(i,N)cin>>c[i];vsort(c);
  rep(i,N){
    auto itr=upper_bound(all(c),b[i]);
    sum[i]=c.end()-itr;
  }
  brep(i,N-1){
    sum[i]+=sum[i+1];
  }
  rep(i,N){
    auto itr=upper_bound(all(b),a[i]);
    ans+=sum[itr-b.begin()];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3328
n,k=map(int,input().split())
p=list(map(int,input().split()))
for i in range(n):
  p[i]=(p[i]+1)/2
tmp=0
for i in range(k):
  tmp+=p[i]
t=[tmp]
for j in range(1,n-k+1):
  tj=t[j-1]-p[j-1]+p[j+k-1]
  t.append(tj)
t.sort()
print(t[n-k])

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for(int i = 0; i < N; ++i)
    cin >> A[i] >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if(N%2){
    cout << B[N/2]-A[N/2]+1 << endl;
    return 0;
  }else{
    cout << (B[N/2]+B[N/2-1])-(A[N/2]+A[N/2-1])+1 << endl;
    return 0;
  }
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s; cin >>s;
  map<char, int> mp;
  for (auto &&a: s){
    if(mp.count(a))mp[a]++;
    else mp[a] = 1;
  }
  if(mp.size() == 2 && mp[s.at(0)] == 2)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int K;
double R, L, P, E, T;

double f(double r, double l, double p, int k) {
	if (!k) {
		return (abs((r+l)/2.0 - T) <= E) ? p : 0;
	}
	if (l < T-E || T+E < r) return 0;
	if (T-E <= r && l <= T+E) return p;

	double h = (r+l) / 2.0;
	if (h < T) return f(r, h, p*P, k-1) + f(h, l, p*(1.0-P), k-1);
	return f(r, h, p*(1.0-P), k-1) + f(h, l, p*P, k-1);
}

int main() {
	cin >> K >> R >> L >> P >> E >> T;
	printf("%.6f\n", f(R, L, 1.0, K));
	return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <queue>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()

int main() {
    int a,p;
    cin >> a >> p;

    int sum = a*3+p;
    cout << sum / 2;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)

{
  int a , b;

  scanf("%d %d",&a,&b);
  
  if(a+b > a-b && a+b > a*b){
  	
  printf("%d\n",a+b);
  
  } else if(a*b > a+b && a*b > a-b){
  	
  printf("%d\n",a*b);
  
  } else {
  
  printf("%d\n",a-b);
  
  }
  
  return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n)); 
	for (int i = 0; i < n; i++) {
		cin >> a.at(0).at(i) >> a.at(1).at(i);
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a.at(1).at(i) - a.at(0).at(i) + 1;
	}
	cout << sum;
}

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

#define endl '\n'

using namespace std;


void solve() {
	int n;
	cin >> n;
	if (n == 0) {
		cout << "1" << endl;
	} else {
		int arr[n], mod = 1000000007;
		arr[0] = 0; arr[1] = 0; arr[2] = 1;
		for (int i = 3; i < n; i++) {
			arr[i] = (arr[i - 1] + arr[i - 3]) % mod;
		}
		cout << arr[n - 1] << endl;
	}
}

int main() {
	int T = 1;
	//cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  for(ll i = 1; i <= 3500; i++){
    for(ll j = 1; j <= 3500; j++){
      if(4 * i * j - n * i - n * j != 0){
        if((n * i * j) % (4 * i * j - n * i - n * j) == 0){
          ll k = (n * i * j) / (4 * i * j - n * i - n * j);
          if(k > 0){
            cout << i << " " << j << " " << k << '\n';
            return 0;
          }
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    set<int> st;
    rep(i, 0, n){
        int a;
        cin >> a;
        if(!st.count(a)) st.insert(a);
        else st.erase(a);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	int a;
	vi b;
	cin >> a; b.push_back(a);
	cin >> a; b.push_back(a);
	cin >> a; b.push_back(a);
	sort(all(b), greater<int>());
	cout << b[0] * 10 +b[1] +b[2] << endl;


}


Measured memory_bytes: 764
x,y=map(int,input().split())
ans=0
if x==0 and y==0:
  print(ans)
  exit(0)
elif y==0:
  if x>0:ans+=1
  ans+=abs(x)
  print(ans)
  exit(0)
elif x==0:
  if y<0:ans+=1
  ans+=abs(y)
  print(ans)
  exit(0)

if x>0 and y>0:
  if x<=y:
    ans+=abs(y-x)
  else:
    ans+=abs(y-x)+2
elif (x>0 and y<0) or (x<0 and y>0):
  ans+=abs(abs(x)-abs(y))+1
elif x<0 and y<0:
  if x<=y:
    ans+=abs(y-x)
  else:
    ans+=abs(y-x)+2
print(ans)

Measured memory_bytes: 9036
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int K = s.nextInt();
        int A = s.nextInt();
        int B = s.nextInt();

        double A_div = A / K;
        double B_div = B / K;

        if (B_div - A_div >= 1 || A % K == 0 || B % K == 0) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }
        s.close();
    }
}

Measured memory_bytes: 35812
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 

 
const long double pi = 3.14159265358979323846;
const ll mod = 998244353;

namespace modop {
	ll madd(ll a, ll b) {
	  return (a + b) % mod;
	}
	ll msub(ll a, ll b) {
	  return (((a - b) % mod) + mod) % mod;
	}
	ll mmul(ll a, ll b) {
	  return ((a % mod) * (b % mod)) % mod;
	}
	ll mpow(ll base, ll exp) {
	  ll res = 1;
	  while (exp) {
		if (exp % 2 == 1){
			res = (res * base) % mod;
		}
		exp >>= 1;
		base = (base * base) % mod;
	  }
	  return res;
	}
	ll minv(ll base) {
	  return mpow(base, mod - 2);
	}
	ll mdiv(ll a, ll b) {
	  return mmul(a, minv(b));
	}
}

using namespace modop;


 
ll fact[300005], ifact[300005];

ll nck(ll n, ll k) {
  ll dem = (ifact[n - k] * ifact[k]) % mod;
  return (fact[n] * dem) % mod;
}

void solve() {
  ll n, m, k; cin >> n >> m >> k;
  
  fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
  f1r(i, 2, 250005) {
    fact[i] = (i * fact[i - 1]) % mod;
    ifact[i] = minv(fact[i]);
  }

  ll v0 = mpow(m, n);
  ll vk = 0;
  f1r(i, k + 1, n) {
    ll vp = ((nck(n - 1, i) * mpow(m - 1, n - i - 1))) % mod;
    vp = (vp * m) % mod;
    v0 = msub(v0, vp);
  }
  v0 = msub(v0, vk);
  cout << v0 << '\n';
}
 
int main() {
  fio();
  
  int T;
  T = 1;
  // cin >> T;
  while (T--) solve();
} 

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

int v[105], num, N, d;

int main()
{
    cin >> N;
    while(N--)
    {
        cin >> d;
        if(v[d]==0)
        {
            num++;
            v[d]=1;
        }
    }

    cout << num;
    return 0;
}

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

int dp[5005][5005];

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

  for (int i = n - 1; i >= 0; --i) {
    for (int j = n - 1; j >= 0; --j) {
      if (s[i] != s[j])
        dp[i][j] = 0;
      else
        dp[i][j] = dp[i + 1][j + 1] + 1;
    }
  }

  int ans = 0;
  rep(i, n) rep(j, n) {
    if (i >= j) continue;  // i < j;
    int now = min(dp[i][j], j - i);
    ans = max(ans, now);
  }

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


Measured memory_bytes: 101376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    ll H, W, N; cin >> H >> W >> N;
    int a, b;
    map<pair<ll,ll>,ll> cnt;
    REP(i,N){
        cin >> a >> b; a--; b--;
        FOR(dx,-1,2) FOR(dy,-1,2){
            int nx = a + dx, ny = b + dy;
            if (1<=nx && nx<=H-2 && 1<=ny && ny<=W-2) {cnt[make_pair(nx,ny)]++;}
        }
    }
    vector<long long> ans(10);
    ans[0] = (H-2)*(W-2);
    for (auto p:cnt){
        ans[p.second]++;
        ans[0] --;
    }
    REP(i,10){
        cout << ans[i] << endl;
    }
    return 0;
}
      

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

const int maxn=20000+10;
int n;
vector<int> vec;

void dfs(int pos,int remain){
	if(pos>30000)
		return;
	if(vec.size()>=n){
		if(remain==0){
			for(int i=0;i<n;++i)
				printf("%d ",vec[i]);
			exit(0);
		}
		return;
	}
	while(pos%2&&pos%3&&pos%5)
		++pos;
	vec.push_back(pos);
	dfs(pos+1,(remain+pos)%30);
	vec.pop_back();
	dfs(pos+1,remain);
}

int main(){
	cin>>n;
	dfs(1,0);
	return 0;
}

Measured memory_bytes: 1536
A = int(input()) # 500
B = int(input()) # 100
C = int(input()) # 50
X = int(input()) # 合計
ans = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                ans += 1
print(ans)

Measured memory_bytes: 3060
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int n = sc.nextInt();
        String s = sc.next();

        int count = 1;
        for (int i = 1; i < n; i++) {
            if (s.charAt(i-1) != s.charAt(i)) count++;
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 24148
#include <iostream>
using namespace std;
int main() {
    int a, b;
    string str;
    while (true) {
        cin >> str;
        if (str == "-")
            break;
        cin >> a;
        for (int i = 0; i < a; i++) {
            cin >> b;
            str=str.substr(b,str.length()-b)+str.substr(0,b);
        }
        cout<<str<<endl;
    }
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,A,B,C,D,E;
    cin >> N >> A >> B >> C >> D >> E;
    ll min_trans = min(A,min(B,min(C,min(D,E))));
    if (N % min_trans == 0){
        cout << N / min_trans - 1 + 5 << endl;
    }
    else{
        cout << N / min_trans + 5 << endl;
    }
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using Grid = std::vector<std::vector<char>>;
using ValueGrid = std::vector<std::vector<int>>;

void update_vg_and_result(int first, int last, std::vector<int>& vg_row, int& result)
{
  const int value = last - first;
  std::fill(
      vg_row.begin() + first,
      vg_row.begin() + last,
      value);
  result = std::max(result, value);
}

int solve(const Grid& rows, const Grid& cols)
{
  const int h = static_cast<int>(rows.size());
  const int w = static_cast<int>(cols.size());
  int result = 0;
  ValueGrid vg(h, std::vector<int>(w));

  for (int row_index = 0; row_index < h; ++row_index) {
    const auto& row = rows[row_index];
    int prev_index = 0;
    for (int col_index = 0; col_index < w; ++col_index) {
      if (row[col_index] == '#') {
        update_vg_and_result(prev_index, col_index, vg[row_index], result);
        prev_index = col_index + 1;
      }
    }

    update_vg_and_result(prev_index, w, vg[row_index], result);
  }

  for (int col_index = 0; col_index < w; ++col_index) {
    const auto& col = cols[col_index];
    int prev_index = 0;
    for (int row_index = 0; row_index < h; ++row_index) {
      if (col[row_index] == '#') {
        const int value = row_index - prev_index;
        for (int i = prev_index; i < row_index; ++i) {
          result = std::max(result, vg[i][col_index] + value - 1);
        }
        prev_index = row_index + 1;
      }
    }

    for (int i = prev_index; i < h; ++i) {
      const int value = h - prev_index;
      result = std::max(result, vg[i][col_index] + value - 1);
    }
  }

  return result;
}

int main()
{
  int h, w;
  std::cin >> h >> w;

  Grid rows(h);
  Grid cols(w, std::vector<char>(h));
  std::string s;
  for (int i = 0; i < h; ++i) {
    std::cin >> s;
    rows[i] = std::vector<char>(s.begin(), s.end());
    for (int j = 0; j < w; ++j) {
      cols[j][i] = s[j];
    }
  }

  std::cout << solve(rows, cols) << std::endl;
}


Measured memory_bytes: 23936
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc077/submissions/1745942 を参考に実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt();

			// 計算結果を保存する配列
			long[] result = new long[k];
			Arrays.fill(result, Long.MAX_VALUE >> 1);

			Deque<Data> deque = new ArrayDeque<>();
			deque.add(new Data(1, 1L));

			while (deque.size() > 0) {
				Data data = deque.poll();
				if (result[data.m] > data.c) {
					result[data.m] = data.c;
					deque.addLast(new Data((data.m + 1) % k, data.c + 1));
					deque.addFirst(new Data((data.m * 10) % k, data.c));
				}
			}
			System.out.println(result[0]);
		}
	}

	/**
	 * データを格納するクラス
	 */
	private static class Data implements Comparable<Data> {
		/** 入力数字 */
		int m;
		/** 計算結果 */
		long c;

		/**
		 * コンストラクタ
		 * 
		 * @param m 入力数字
		 * @param c 計算結果
		 */
		Data(int m, long c) {
			super();
			this.m = m;
			this.c = c;
		}

		/**
		 * dataと比較した結果を返す
		 * 
		 * @param data 比較対象データ
		 * @return dataと比較した結果
		 */
		@Override
		public int compareTo(Data data) {
			return Long.compare(c, data.c);
		}
	}
}


Measured memory_bytes: 30548
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans = n;
    rep(i, n - 1){
        if(s[i] == s[i + 1]){
            --ans;
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int read(){
	int sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
int n;
int map1[201][201];
int gcd(int a,int b){
	if (a>b){
		int c=a;
		a=b,b=c;
	}
	if (map1[a][b])return map1[a][b];
	int x=a,y=b;
	while (a%b){
		int c=a%b;
		a=b;
		b=c;
	}
	map1[x][y]=b;
	return b;
}
int main(){
	n=read();
	long long sum=0;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			for (int k=1;k<=n;k++){
				sum+=gcd(gcd(i,j),k);
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}



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

int main(){
  long long int n,A=0;
  cin>>n;
  if(n==1){
    A=0;
  }
  else{
    for(int i=1;i<n;i++){
      A+=i;
    }
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
import math
import itertools

# sqrt = math.sqrt((4 - 1) ** 2 + (4 - 1) ** 2)
# print(sqrt)

N = int(input())

P = []
for i in range(N):
    x, y = map(int, input().split())
    P.append((x, y))

paths = []
for one_case in itertools.permutations(P):
    sum_path = 0
    for i in range(len(P)):
        if i == len(P) - 1:
            break
        sum_path = sum_path + math.sqrt(
            (one_case[i][0] - one_case[i + 1][0]) ** 2 + (one_case[i][1] - one_case[i + 1][1]) ** 2)
    paths.append(sum_path)

print(sum(paths) / len(paths))


Measured memory_bytes: 4404
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[3];
    a[0]=n/100; n=n-100*a[0];
    a[1]=n/10;  n=n-10*a[1];
    a[2]=n;
    
    for(int i=0;i<3;++i){
        if(a[i]==7){cout<<"Yes"; return 0;}
        
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3568
// ????????±?????¨??????
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <set>
#include <string>
#define MAX 1050
using namespace std;
int q,length_x,length_y;
int dp[MAX][MAX];
string X,Y;
int init_func () {
  for (int i=0; i<MAX ; i++)
    for (int j=0; j<MAX ; j++)
      dp[i][j] = 0;
}

int solve () {
  // dp = {0}
  // dp?????¨?????????X????¨????Y??¨??????
  for (int tate=1; tate<=length_x ; tate++)
    for (int yoko=1; yoko<=length_y ; yoko++)
      if (X[tate-1] == Y[yoko-1]) dp[tate][yoko] = 1 + dp[tate-1][yoko-1];
      else dp[tate][yoko] = max(dp[tate-1][yoko],dp[tate][yoko-1]);
  
  return dp[length_x][length_y];
}

int main(){
  cin >> q;
  for (int i=0; i<q; i++) {
    cin >> X >> Y;
    length_x = X.length();
    length_y = Y.length();
    init_func();
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 5508