akhauriyash/Code-Regression huggingface dataset:
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, m; readV(n, m);

  auto g = Graph!int(n);
  foreach (_; 0..m) {
    int x, y; readV(x, y); --x; --y;
    g.addEdge(x, y);
  }

  auto t = g.topologicalSort;
  auto dp = new int[](n);
  foreach (u; t)
    foreach (v; g[u])
      dp[v] = max(dp[v], dp[u]+1);

  writeln(dp.reduce!max);
}

struct Graph(N = int)
{
  alias Node = N;
  Node n;
  Node[][] g;
  alias g this;
  this(Node n) { this.n = n; g = new Node[][](n); }
  void addEdge(Node u, Node v) { g[u] ~= v; }
  void addEdgeB(Node u, Node v) { g[u] ~= v; g[v] ~= u; }
}

auto topologicalSort(Graph)(ref Graph g)
{
  import std.container;
  alias Node = g.Node;
  auto n = cast(Node)(g.length), h = new int[](n);

  foreach (u; 0..n)
    foreach (v; g[u])
      ++h[v];

  auto st = SList!Node();
  foreach (i; 0..n)
    if (h[i] == 0) st.insertFront(i);

  Node[] ans;
  while (!st.empty()) {
    auto u = st.front; st.removeFront();
    ans ~= u;
    foreach (v; g[u]) {
      --h[v];
      if (h[v] == 0) st.insertFront(v);
    }
  }

  return ans;
}


Measured memory_bytes: 8828
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val c = sc.nextInt()
  val x = sc.nextInt()
  
  var count = 0

  (0 to a).map { ai =>
    (0 to b).map { bi =>
      (0 to c).map { ci =>
        if (x == (ai * 500 + bi * 100 + ci * 50)) count += 1
      }
    }
  }

  println(count)

}


Measured memory_bytes: 28152
def gcd(x, y)
  a, b = [x, y].max, [x, y].min
  until b == 0
    a, b = b, a % b
  end
  return a
end

while line = gets
  x, y = line.chomp.split(" ").map(&:to_i)
  gcd = gcd(x, y)
  lcm = x * y / gcd
  puts "#{gcd} #{lcm}"
end

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;
int main(){
  int ab,bc,ca;
  cin >> ab >> bc >> ca;
  cout << ab * bc / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Data=pair<long,long>;
int mmax(int a,int b,int c){
  if(a<b){
    return max(b,c);
  }else{
    return max(a,c);
  }
}

int main(){
  long long i,N,a,b,now=0;
  char ss[10000];
  cin>>N;
  vector<Data> v(N);
  for(i=0;i<N;i++){
    scanf("%lld",&a);
    scanf("%lld",&b);
    v[i]=Data(b,a);
  }
  sort(v.begin(),v.end());
  for(i=0;i<N;i++){
    now+=v[i].second;
    if(v[i].first<now){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(){
	int A,B;
	scanf("%d %d",&A,&B);
	char str1[255];
	scanf("%s",str1);
	int ctr=0;
	
	for(int i=0; str1[i] != '\0'; i++){
		if(str1[A] != '-'){
			printf("No");
			return 0;
		}
		if(str1[i] >= '0'&&str1[i] <= '9'){
			ctr++;
		}
	}
	if(ctr==A+B){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1728
main(){
	double d;
	int n,i;
	for(;scanf("%lf",&d),d>=0;){
		n=d*16;
		d-=n/16.;
		if(d)
			puts("NA");
		else{
			for(i=0;i<12;i++){
				putchar('0'+(n>>(11-i))%2);
				if(i==7)
					putchar('.');
			}
			putchar('\n');
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>

using namespace std;

void solve()
{
	int N, M;
	while(cin >> N >> M, N || M)
	{
		vector<int> Vech(N);
		vector<int> Vecw(M);
		map<int, int> Map;
		for(int i = 0; i < N; ++i)
		{
			cin >> Vech[i];
		}
		for(int i = 0; i < M; ++i)
		{
			cin >> Vecw[i];
		}
		for(int i = 0; i < M; ++i)
		{
			int w = Vecw[i];
			Map[w]++;
			for(int j = i + 1; j < M; ++j)
			{
				w += Vecw[j];
				Map[w]++;
			}
		}

		int count = 0;
		for(int i = 0; i < N; ++i)
		{
			int h = Vech[i];
			count += Map[h];
			for(int j = i + 1; j < N; ++j)
			{
				h += Vech[j];
				count += Map[h];
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 12000
input();a,b,c,d,r=list(map(int,input().split())),0,0,0,'NYoe s'
for i in a:
  if i%2!=0: b+=1
  elif i%4==0: c+=1
  else: d+=1
print([r[b<=c::2],r[b<=c+1::2]][not d])

Measured memory_bytes: 20156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    cin >> S >> T;
    sort(S.begin(),S.end());
    sort(T.rbegin(),T.rend());
    cout << (S<T? "Yes\n":"No\n");
}

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

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;

int main() {

    int n ;
    cin >> n ;
    vector<int> a(26) ;
    rep(i,n){
        string s ;
        cin >> s ;
        vector<int> tmp(26) ;
        rep(i,s.size()){
            int idx = (int)s[i] ;
            tmp[idx-97]++ ;
        }
        if(i==0){
        rep(i,a.size()){
            a[i] = tmp[i] ;
        }
        }else{
        rep(i,a.size()){
            a[i] = min(tmp[i],a[i]) ;
        }
        }
    }

    string ans = "" ;
    for(char c='a'; c<='z';c++){
            int idx = (int)c ;
            
        if(a[c-97]>0){
            rep(i,a[c-97]){
                ans+=c ;
            }
        }
    }

    cout << ans << endl ;

    return 0 ;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b;
    cin >> a >> b;

    if (a >= b) {
        cout << 10 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;


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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve(){
	ll d,t,s;
	cin>>d>>t>>s;
	if(d<=t*s)cout<<"Yes";
	else cout<<"No";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main() {
	int K;
	cin >> K;
	if (K % 2 == 1) {
		cout << K / 2 * (K /2 + 1)  << endl;
	}
	if (K % 2 == 0) {
		cout << K / 2 * K/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (X == 500 * i + 100 * j + 50 * k) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0;
	for(int i = 1; i < n - 1; ++i) {
		string tmp = s.substr(0, i);
		string tmp2 = s.substr(i, n - i);
		
		int cnt = 0;
		for(char c = 'a'; c <= 'z'; ++c) {
			if( tmp.find(c) != string::npos && tmp2.find(c) != string::npos ) {
				cnt++;
			}
		}
		
		ans = max(ans, cnt);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;

int main() {

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

    int x,n;
    cin >> x >> n;

    set<int> have; 
    for (int i = -1; i <= 101; i++) {
        have.insert(i);
    }

    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        have.erase(a);
    }

    for (int i = 0; i <= 100; i++) {
        int lo = x-i;
        if (have.count(lo)) out(lo);
        int hi = x+i;
        if (have.count(hi)) out(hi);
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3664
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        System.out.print((x2+y1-y2) + " ");
        System.out.print((y2+x2-x1) + " ");
        System.out.print((x1+y1-y2) + " ");
        System.out.println(y1+x2-x1);
    }
}

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

int main(){
  int n;
  string s;
cin >> n >> s;
if( n < s.length() ) {
  for(int i = 0 ; i < n ; ++i ) cout << s[i];
  cout << "...";
}
  else cout << s;
  return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int p(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
signed main()
{
    fastio();
   int n,c=0,a;
   cin>>n;
   int x=sqrt(n);
    if(p(n)==1)
   cout<<n-1;
   else
   {
   for(int i=x;i>=1;i--)
   {
       if(n%i==0)
       {
           a=i;
           break;
       }
   }
   int zz=n/a;
   cout<<(a+zz)-2;
   }
}

// 🍪 🍪 🍪


Measured memory_bytes: 3660
#include <stdio.h>

int main() {
  int a[101][101] = {0};
  int b[101] = {0};
  int d[101] = {0};
  int i,j,r,c;
  int x;
  int e = 0;

  scanf("%d %d" , &r,&c);

  for(j=0; j<r; j++) {
    for(i=0; i<c; i++) {
      scanf("%d",&x);
      a[j][i] = x;
    }
  }

  for(j=0; j<r; j++){
    for(i=0; i<c; i++) {
      b[i] += a[j][i];
    }
  }

  for(j=0; j<r; j++){
    for(i=0; i<c; i++){
      d[j] += a[j][i];
    }
  }

  for(j=0; j<r; j++) {
    for(i=0; i<c; i++) {
      printf("%d ",a[j][i]);
    }
    printf("%d\n", d[j]);
  }
  for(i =0; i<c; i++) {
    printf("%d " ,b[i]);
    e += b[i];
  }
  printf("%d\n", e);

  return 0;
}



Measured memory_bytes: 1964
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long

using namespace std;

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

  string s; cin >> s;
  int num = 0;

  for (int i = 0; i < s.length(); ++i) {
    for (int j = 0; j < s.length() - i + 1; ++j) {
      string t = s.substr(i, j); 
      // cout << t << endl;
      bool flag = true;
      for (auto it = t.begin(); it != t.end(); ++it) {
        if (*it != 'A' && *it != 'C' && *it != 'G' && *it != 'T') { flag = false; break;}
      }
      if (flag) num = max(num, (int)t.length());
    }
  }
  cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x; cin>>x;
	if (x<=400||x<=599) cout<<"8"<<endl;
	else if (x<=600||x<=799) cout<<"7"<<endl;
	else if (x<=800||x<=999) cout<<"6"<<endl;
	else if (x<=1000||x<=1199) cout<<"5"<<endl;
	else if (x<=1200||x<=1399) cout<<"4"<<endl;
	else if (x<=1400||x<=1599) cout<<"3"<<endl;
	else if (x<=1600||x<=1799) cout<<"2"<<endl;
	else if (x<=1800||x<=1999) cout<<"1"<<endl;
	else cout<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int A, B;
int ans = -1;

int main(){
  cin >> A >> B;
  for(int i=1;i<1010;++i){
      if((int)(i * 0.08) == A and (int)(i * 0.1) == B){
        ans = i; 
        break;
      }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> b(n - 1);
    for (int i = 0; i < b.size(); i++) {
        cin >> b[i];
    }

    ll ans = 0;
    ans += *(b.begin());
    for (int i = 1; i < b.size(); i++) {
        ans += min(b[i - 1], b[i]);
    }
    ans += *(b.end() - 1);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
#define LL long long



int main() {
	int a, b, c, d;
	cin >> a >> b;
	cout << (b >= a ? a : a - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    const int inf = 1e9 + 7;
    vector<vector<int>> d(4, vector<int>(4, inf));
    rep(i, 4) d[i][i] = 0;
    int md = 0;
    
    rep(i, 3) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        d[a][b] = 1;
        d[b][a] = 1;
    }
    
    rep(i, 4) {
        rep(ii, 4) {
            rep(iii, 4) {
                d[ii][iii] = min(d[ii][iii], d[ii][i] + d[i][iii]);
            }
        }
    }
    
    rep(i, 4) {
        rep(ii, 4) {
            md = max(md, d[i][ii]);
        }
    }
    
    cout << ((md == 3) ? "YES" : "NO") << endl;
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(2));
    for (int i = 0; i < n; i++) cin >> v[i][0];
    for (int i = 0; i < n; i++) cin >> v[i][1];

    vector<int> l;
    vector<int> r;
    for (int i = 0; i < n; i++) (v[i][0] > 0 ? l : r).push_back(v[i][1]);

    if (l.size() == 0 || r.size() == 0)cout << 0 << endl;
    else {
        sort(l.begin(), l.end());
        sort(r.begin(), r.end());
        cout << l[0] + r[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
using namespace std;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int jc[N], ny[N],n;
int C(int n,int m)
{
	if(n < m) return 0;
	return (ll)jc[n] * ny[m] % mod * ny[n - m] % mod;
}
int ans=0;
int main()
{
	n = read();
	jc[0] = 1;
	rep(i, 1, n) jc[i] = (ll)jc[i - 1] * i % mod;
	ny[1] = 1;
	rep(i, 2, n) ny[i] = (ll)(mod - mod / i) * ny[mod % i] % mod;
	ny[0] = 1;
	for(int i = 1; i <= n && i < mod; i ++) ny[i] = (ll)ny[i] * ny[i - 1] % mod;
	rep(i, 1, n - 1)
	{
		int now = C(i - 1, n - i - 1);
		ans = (ans + (ll)now * jc[i] % mod * jc[n - i - 1] % mod) % mod;
	}
	printf("%d",(jc[n] + mod - ans) % mod);
}




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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  int count=1;
  int a;
  int prea;
  int ans=0;
  cin >> prea;
  for(int i=1;i<n;i++){
    cin >> a;
    if(a==prea){
      count++;
    }else{
      ans+=count/2;
      count=1;
      prea=a;
    }
  }
    ans+=count/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
set_abc = {"a", "b", "c"}
abc_array = [{key: int(value) for key, value in zip(set_abc, input().split())} for y in range(n)]

# a or b or cを選んだときの報酬の最高値
dp = [{key: 0 for key in set_abc} for x in range(n)]
res = 0
for index in range(n):
    if index == 0:
        dp[index] = abc_array[index]
        continue
    for key, value in abc_array[index].items():
        candidate_key = set_abc - set(key)
        dp[index][key] = max(dp[index - 1][candidate_key.pop()] + value, dp[index - 1][candidate_key.pop()] + value)

print(max(dp[-1].values()))


Measured memory_bytes: 119128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define f first
#define s second

ll dp[100100];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
        //freopen("output.out", "w", stdout);
	int n, w;
	cin >> n >> w;	
	int a[n], b[n];
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = w - a[i]; j >= 0; j--){
			dp[j + a[i]] = max(dp[j] + b[i], dp[j + a[i]]);
		}
	}
	ll ans = 0;
	for(int i = 0; i <= w; i++){
		ans = max(ans, dp[i]);
	}	
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main(){
    char A;
    cin >> A;
    if(isupper(A)){
        cout << 'A' << endl;
    }else{
        cout << 'a' << endl;
    }
    return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  sort(a,a+n);
  int b=a[n-1];
  int u=a[0];
  rep(i,n-2){
    if(b%2==0){
      if(abs(u-b/2)>abs(a[i+1]-b/2))u=a[i+1];
    }
    else{
      if((min(abs(a[i+1]-b/2),abs(a[i+1]-b/2-1)))<(min(abs(u-b/2),abs(u-1-b/2)))){
        u=a[i+1];
      }
      //else cout << 99 << endl;
    }
    //cout << min(abs(a[i+1]-b/2),abs(a[i+1]-b/2+1)) << " " << min(abs(u-b/2),abs(u-1-b/2)) << endl;
  }
  cout << b << " " << u << endl;
}


Measured memory_bytes: 764
N = int(input())
s = list(input())
g = 0
mg = -1
cs = set()
for i in range(N-1):
    if s[i] in s[i+1:]:
        if not s[i] in cs:
            g += 1
            cs.add(s[i])
    else:
        if s[i] in cs:    
            g -= 1
            cs.remove(s[i])
    mg = max(mg,g)
print(mg)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            int money = reader.readInt();
            int cakePrice = reader.readInt();
            int donutPrice = reader.readInt();

            money -= cakePrice;
            money %= donutPrice;

            writer.println(money);
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readLine().split(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readLine().split(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}

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

int main()
{
    long n;
    scanf("%ld", &n);
    if(n%2==1)
    {
        printf("%ld", n / 2+1);
    }
    else
    {
        printf("%ld", n / 2);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define MAX_N 200005
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll n;
    cin >> n;
    vector<ll> z(n), d(n);
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        z[i] = x + y;
        d[i] = x - y;
    }
    sort(all(z));
    sort(all(d));
    ll ans = max(z[n-1]-z[0], d[n-1]-d[0]);
    cout << ans << endl;


    return 0;

}


Measured memory_bytes: 6404
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;

bool CMP(pll x, pll y){
	return (x.F - x.S < y.F - y.S);
	
	
}
ll n;
pll a[N];

int main(){
	IOS;
	cin >> n;
	ll Totala = 0, Totalb = 0;
	for (int i = 0 ; i < n; i++) cin >> a[i].F, Totala += a[i].F;
	for (int i = 0; i< n; i++) cin >> a[i].S, Totalb += a[i].S;
	//cout << Totala << ' ' << Totalb << '\n';
	if (Totalb > Totala) kill(-1);
	sort(a, a + n, CMP);
	ll Sum = 0, Sum1 = 0;
	ll Cnt = 0;
	for (int i = 0; i < n; i++){
		if (a[i].F < a[i].S) Sum += (a[i].S - a[i].F), Cnt ++;
	}
	//ll Cnt = 0;
	ll pnt = n - 1;
	//cout << Cnt << ' ' << Sum << '\n';
	while (Sum1 < Sum){
		Cnt ++;
		Sum1 += a[pnt].F - a[pnt].S;
		pnt --;
	}
	cout << Cnt;
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

sum_A = abs(A[0])
for i in range(1, N):
     sum_A= sum_A + abs(A[i - 1] -  A[i])
sum_A += abs(A[N - 1])

for i in range(N):
    if i == 0:
        print(sum_A - abs(A[0]) - abs(A[1] - A[0]) + abs(A[1]))
    elif i == N - 1:
        print(sum_A - abs(A[N - 1] - A[N - 2]) - abs(A[N - 1]) + abs(A[N - 2]))
    else:
        print(sum_A - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]))

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

using namespace std;
using ll = long long;

int main(void) {
  int n, y;
  cin >> n >> y;
  for (int i = 0; i <= y / 10000 && i <= n; i++) {
    for (int j = 0; j <= y / 5000 && j <= n; j++) {
      int k = n - i - j;
      if (10000 * i + 5000 * j + 1000 * k == y && i + j + k <= n && k >= 0) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    } 
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll a[n];
    ll sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum += a[i];
    }
    if(n == 2){
        cout << abs(a[0] - a[1]) << endl;
        return 0;
    }

    ll d = 0;
    ll b = 0;
    ll c = 0;
    ll flag = 0;
    rep(i, 0, n){
        if(b + a[i] < (double(sum) / 2.0) && flag == 0){
            b += a[i];
        }else if(flag == 0){
            c = a[i];
            flag = 1;
        }else{
            d += a[i];
        }
    }

    if(b == 0){
        cout << abs(c - d) << endl;
        return 0;
    }else if(d == 0){
        cout << abs(b - c) << endl;
        return 0;
    }

    ll cost = 0;
    if(b + c == d || b == c + d){
        cout << cost << endl;
    }else{
        cout << min(b + c - d, d + c - b) << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define mid ((l + r) >> 1)
#define lson (x << 1)
#define rson ((x << 1) | 1)
using namespace std;
typedef long long LL;

LL val[800005] = {0};

void pushup(LL x){
	val[x] = max(val[lson],val[rson]);
}

void modify(LL x,LL l,LL r,LL L,LL R,LL v){
	if(L > R) return;
	if(L <= l && r <= R){
		val[x] = max(val[x],v);
		return;
	}
	if(L <= mid) modify(lson,l,mid,L,R,v);
	if(R > mid) modify(rson,mid + 1,r,L,R,v);
	pushup(x);
}

LL query(LL x,LL l,LL r,LL L,LL R){
	if(L > R) return 0;
	if(L <= l && r <= R) return val[x];
	LL ret = 0;
	if(L <= mid) ret = max(ret,query(lson,l,mid,L,R));
	if(R > mid) ret = max(ret,query(rson,mid + 1,r,L,R));
	pushup(x); return ret;
}

LL n;
LL h[200005];
LL a[200005];
LL dp[200005] = {0};

int main(){
	scanf("%lld",&n);
	for(LL i = 1;i <= n;i ++) scanf("%lld",&h[i]);
	for(LL i = 1;i <= n;i ++) scanf("%lld",&a[i]);
	LL ans = 0;
	for(LL i = 1;i <= n;i ++){
		dp[i] = query(1,1,n,1,h[i]) + a[i];
		modify(1,1,n,h[i],h[i],dp[i]);
		ans = max(ans,dp[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    int n,x,t;
    cin >> n >> x >> t;
    int c = (n+x-1)/x;
    cout << c*t;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

typedef struct Station {
    int distance;
    int opening;
    int cycle;
    int takeTime;
};

Station stations[512];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int c, s, f;
        cin >> c >> s >> f;

        Station station = {c, s, f, 0};
        stations[i] = station;
    }

    Station station = {0, 0, 0, 0};
    stations[n - 1] = station;

    for (int i = 0; i < n - 1; ++i) {
        for (int j = i; j < n; ++j) {
            // 開通式
            if (stations[i].takeTime < stations[j].opening) stations[i].takeTime = stations[j].opening;

            // 乗車間隔考慮
            if (stations[j].cycle > 0) {
                int diff = (stations[i].takeTime - stations[j].opening) % stations[j].cycle;
                if (diff != 0) stations[i].takeTime += stations[j].cycle - diff;
            }

            // 移動時間
            stations[i].takeTime += stations[j].distance;
        }
    }

    for (int i = 0; i < n; ++i) cout << stations[i].takeTime << endl;

    return 0;
}

Measured memory_bytes: 256
# test

import sys
readline = sys.stdin.buffer.readline


class SegmentTree:
    def __init__(self, N, func, I):
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(range(1, self.sz)):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = map(int, readline().split())
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()


Measured memory_bytes: 60528
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

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

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

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
  }

  int ans = 0;
  rep(i, N) {
    ans += (i % 2 == 0) && (a[i] % 2 == 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3660
s = input()
K = int(input())


sub_string = []
for i in range(len(s)):
    for j in range(0, len(s) + 1 - i):
        if j > K:
            break
        sub_string.append(s[i:i+j])

#重複の排除
sub_string = set(sub_string)
#辞書順にソートする
sub_string = sorted(sub_string)
#空白を削除
sub_string.remove('')
print(sub_string[K - 1])

Measured memory_bytes: 5044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

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

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

ll a, b, c, d;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>

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

  uint32_t N;
  std::cin >> N;

  std::vector<double> c;
  c.resize(N);

  for (uint32_t i = 0; i < N; i++) {
    std::cin >> c[i];
  }

  double dp[3000][3000];

  dp[0][0] = 1.0;

  for (uint32_t i = 0; i < N; i++) {
    for (uint32_t j = 0; j <= i; j++) {
      dp[i + 1][j + 1] = dp[i][j] * c[i];
      dp[i + 1][j] += dp[i][j] * (1 - c[i]);
    }
  }

  double ret = 0.0;
  for (auto i = (N + 1) >> 1; i <= N; i++) {
    ret += dp[N][i];
  }

  std::cout << std::fixed << std::setprecision(10) << ret << std::endl;

  return 0;
}


Measured memory_bytes: 70528
#include <iostream>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W));
  rep(i, H) rep(j, W) cin >> A[i][j];
  vector<vector<int>> B(H, vector<int>(W));
  rep(i, H) rep(j, W) cin >> B[i][j];

  // 80+80x80=160x80=12800
  vector<vector<vector<bool>>> DP(
      H + 1, vector<vector<bool>>(W + 1, vector<bool>(12802, false)));
  DP[0][0][abs(A[0][0] - B[0][0])] = true;
  rep(i, H) {
    rep(j, W) {
      rep(k, 12800) {
        if (!DP[i][j][k]) continue;
        if (i + 1 < H) {
          int diff_i = abs(A[i + 1][j] - B[i + 1][j]);
          int nk0_i = (k + diff_i);
          if (nk0_i < 12801) DP[i + 1][j][nk0_i] = true;
          int nk1_i = abs(k - diff_i);
          if (nk1_i < 12801) DP[i + 1][j][nk1_i] = true;
        }

        if (j + 1 < W) {
          int diff_j = abs(A[i][j + 1] - B[i][j + 1]);
          int nk0_j = (k + diff_j);
          if (nk0_j < 12801) DP[i][j + 1][nk0_j] = true;
          int nk1_j = abs(k - diff_j);
          if (nk1_j < 12801) DP[i][j + 1][nk1_j] = true;
        }
      }
    }
  }

  rep(k, 12801) {
    if (DP[H - 1][W - 1][k]) {
      cout << k << endl;
      break;
    }
  }
  return 0;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int arr[51];

int main(){

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    for(int i = 0; i < n; ++i)
        cin >> arr[i];

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){

            int sw = arr[i];
            arr[i] = arr[j];
            arr[j] = sw;

            bool f = false;
            for(int k = 1; k < n; ++k){
                //cout << arr[k - 1] << " " << arr[k] << endl;
                if(arr[k] < arr[k - 1]){
                    f = true;
                }
            }
            if(!f){
                //cout << i << " " << j << endl;
                cout << "YES\n";
                return 0;
            }
            sw = arr[i];
            arr[i] = arr[j];
            arr[j] = sw;
        }
    }

    cout << "NO\n";


    return 0;

}


Measured memory_bytes: 256
def tax(rate, base)
  base * (100 + rate) / 100
end

while true
  a = gets.split(" ").map(&:to_i)
  break if a == [0,0,0]
  max = 0
  for i in 1..(a[2]-1)
    for j in i..(a[2]-1)
      if (tax(a[0],i)+tax(a[0],j)) == a[2]
        max = [max, tax(a[1],i)+tax(a[1],j)].max
      end
    end
  end
  puts max
end

Measured memory_bytes: 8696
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) {
    const T INF = numeric_limits<T>::max();
    using P = pair<T, int>;
    int n = G.size();
    vector<T> d(n, INF);
    vector<int> b(n, -1);
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.emplace(d[s], s);
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (auto &e : G[v]) {
            int u = e.first;
            T c = e.second;
            if (d[u] > d[v] + c) {
                d[u] = d[v] + c;
                b[u] = v;
                q.emplace(d[u], u);
            }
        }
    }
    return d;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<pii>> edges(n);
    vvi edgesUsed;
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
        edgesUsed.push_back({0, a, b, c});
    }
    for (int i = 0; i < n; ++i) {
        auto dist = dijkstra(i, edges);
        for (auto &e : edgesUsed) {
            int from = e[1];
            int to = e[2];
            int cost = e[3];
            if (abs(dist[to] - dist[from]) == cost)
                e[0] = 1;
        }
    }
    int ret = m;
    for (auto &e : edgesUsed) {
        ret -= e[0];
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        while(true){
            int m=sc.nextInt();
            int f=sc.nextInt();
            int r=sc.nextInt();
            if(m==-1 && f==-1 && r==-1)break;
            if(m==-1 || f==-1)System.out.println("F");
            else if(m+f>=80)System.out.println("A");
            else if(m+f>=65) System.out.println("B");
            else if(m+f>=50) System.out.println("C");
            else if(r>=50)System.out.println("C");
            else if(m+f>=30)System.out.println("D");
            else System.out.println("F");
        }

    }
}



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

int main() {
  long long n, m, L, g;
  int j = 1;
  string s, t;
  cin >> n >> m;
  cin >> s >> t;
  g = __gcd(n, m);
  L = (n * m) / g;
  for(int i = 0; i < g; i++) {
    if (s[i * (n / g)] != t[i * (m / g)]) {
      j = 0;
      break;
    }
  }
  if(j != 0){
  cout << L << endl;
  }else{
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 512
N, M = map(int, input().split())
Ai = [list(map(int, input().split())) for _ in range(M)]

groups = [-1 for i in range(N + 1)] #0番目は使わない
sizes = [1 for _ in range(N + 1)]
Ai.reverse()

value = N * (N - 1) // 2
answers = []
answers.append(value)

def parent(n):
    if groups[n] < 0:
        return n
    return parent(groups[n])

for a in Ai:
    if value <= 0:
        answers.append(0)
        continue
    p1 = parent(a[0])
    p2 = parent(a[1])
    if p1 == p2:
        answers.append(value)
        continue

    value -= sizes[p1] * sizes[p2]
    if p1 > p2:
        sizes[p2] += sizes[p1]
        groups[p1] = p2
    else:
        sizes[p1] += sizes[p2]
        groups[p2] = p1
    answers.append(value)

answers.reverse()
answers = answers[1:]
for a in answers:
    print(a)

Measured memory_bytes: 34216
import sys
sys.setrecursionlimit(10**5)

# input
n, u, v = map(int, list(input().split()))

tree = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, list(input().split()))
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

# process
def getdis(idx, num, dis):
    dis[idx] = num
    for i in tree[idx] :
        if dis[i] < 0:
            dis = getdis(i, num+1, dis)
    return dis

dis_u = [-1]*n
dis_u = getdis(u-1, 0, dis_u)
dis_v = [-1]*n
dis_v = getdis(v-1, 0, dis_v)

ans = 0
for i in range(n):
    if dis_u[i] <= dis_v[i]:
        ans = max(ans, dis_v[i]-1)

# output
print(ans)


Measured memory_bytes: 101548
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

signed main()
{
    ll N;
    cin >> N;
    if(N%1000 == 0){
        cout << 0;
    }else{
    cout << -1 *( N - (N / 1000 + 1)*1000);
}}


Measured memory_bytes: 3596