akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;
struct mint {
   ll x;
   mint(ll x = 0) { (this->x = (x + MOD)) %= MOD; }
   mint& operator+=(const mint a) {
      if ((this->x += a.x) >= MOD) x -= MOD;
      return *this;
   }
   mint& operator-=(const mint a) {
      if ((this->x += MOD - a.x) >= MOD) this->x -= MOD;
      return *this;
   }
   mint& operator*=(const mint a) {
      (this->x *= a.x) %= MOD;
      return *this;
   }
   mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
   }
   mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
   }
   mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
   }
   mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
   }
   mint inv() const { return pow(MOD - 2); }
   mint& operator/=(const mint a) { return *this *= a.inv(); }
   mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
   }
};
ll f(ll l, ll r) {
   return (l + r) * (r - l + 1) / 2;
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n, k;
   cin >> n >> k;
   mint ans;
   rep(i, k, n + 2) {
      ll l = f(0, i - 1), r = f(n - i + 1, n);
      ans += r - l + 1;
   }
   cout << ans.x << endl;
   return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    int ans = INF;
    rep(i, s.size() - 2)
    {
        int num = 100 * (s[i] - '0') + 10 * (s[i + 1] - '0') + (s[i + 2] - '0');
        ans = min(ans, abs(num - 753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
X,N = list(map(int,input().split()))
p = list(map(int,input().split()))

if N == 0:
  print(X)
  import sys
  sys.exit()
  
i = 0
while 1:
  if (X-i) not in p:
    print(X-i)
    break
  elif (X+i) not in p:
    print(X+i)
    break
  else:
    i += 1

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

int main() {
  char c;
  cin >> c;
  if (c=='a' ||c=='e' ||c=='i' ||c=='o' ||c=='u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string S, T;
  cin >> S >> T;
  string ans = "No";
  for (int i = 0; i < S.length(); i++)
  {
    string tmp = S;
    S = tmp.substr(tmp.length() - 1, 1) + tmp.substr(0, tmp.length() - 1);
    if (S == T)
      ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    int n, count = 0;
    string a,b,c;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b >> c;
    rep(i,n) {
        if(a[i] == b[i] && a[i] != c[i]) {
            count++;
        } else if(a[i] == c[i] && a[i] != b[i]) {
            count++;
        } else if(b[i] == c[i] && a[i] != b[i]) {
            count++;
        } else if(a[i] != b[i] && a[i] != c[i]) {
            count += 2;
        }
    }
    cout << count << endl;
}


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



int main() {
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N,vector<int>(M));
    for(int i=0; i<M ; i++){
        cin >> B.at(i);
    }
    for(int i=0; i< N;i++){
        for(int j=0; j<M; j++){
            cin >> A.at(i).at(j);
        }
    }
    int ans = 0;
    for(int i=0; i<N;i++){
        int x = 0;
        for(int j=0; j<M; j++){
            x += A.at(i).at(j) * B.at(j);
        }
        if(x + C > 0){
            ans += 1;
        }
    }
    cout << ans << endl;
    
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int MAX=1e5+5;
LL arr[MAX];
LL bst[MAX];

int main()
{
  int n,k;
  scanf("%d %d",&n,&k); 
  LL ans=0;
  for(int i=1;i<=n;i++)
  {
	scanf("%lld",&arr[i]);	
	bst[i]=max(0ll,arr[i]);
	arr[i]+=arr[i-1];
	bst[i]+=bst[i-1];
//	printf("%lld %lld\n",arr[i],bst[i]);
  }
  for(int i=k;i<=n;i++)
  {
	ans=max(max(0ll,arr[i]-arr[i-k])+bst[n]-bst[i]+bst[i-k],ans);	
  } 
  printf("%lld",ans);
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;


typedef vector<vector<ll> > Matrix;

const ll INF = 100000000;
Matrix d; // グラフの距離を格納した2次元配列（隣接行列）
          // d[u][v]は辺e=(u,v)のコスト（辺が存在しない場合はINF、ただしd[i][i]=0）

void warshall_floyd(int n) { // nは頂点数
    for (int i = 0; i < n; i++)      // 経由する頂点
        for (int j = 0; j < n; j++)    // 開始頂点
            for (int k = 0; k < n; k++)  // 終端
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {

    int H, W;
    cin >> H >> W;


    int n = 10;

    //コストマップを初期化
    d = Matrix(n, vector<ll>(n, INF));
    for (int i = 0; i < n; i++){
        d[i][i] = 0;
    } 
    
    //コストマップに代入
    for (int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++){
            ll cost;
            cin >> cost;
            d[i][j] = cost;
        }
    }
    
    //引数：頂点数
    warshall_floyd(n);
    
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
           // cout << i << j << ":" <<d[i][j] << endl;
        }
    }

    ll ans = 0;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            int a;
            cin >> a;
            if(a != -1) ans += d[a][1];
        }
    }
    cout << ans << endl;

    return 0;
}

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

double W=0, H=0, x=0, y=0, ans=0;

int main(){
  cin >> W >> H >> x >> y;
  ans = W * H / 2;
  cout << fixed << setprecision(10);
  cout << ans << " ";
  if (W/2==x and H/2==y) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3764
#include<stdio.h>

int main(){
    int a,b,c,d;
    int sum = 0;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    if(a<b){
        sum+=a;
    }else{
        sum+=b;
    }
    if(c<d){
        sum+=c;
    }else{
        sum+=d;
    }
    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools


def main():
  X = int(input())
  values = [0]

  for i in range(1, 200):
    values.append(i ** 5)

    if values[-1] - values[-2] > 1e9:
      break;

  for i, j in itertools.product(range(len(values)), repeat=2):
    if values[j] - values[i] == X:
      print('{} {}'.format(j, i))
      break
    elif values[j] + values[i] == X:
      print('{} {}'.format(j, -i))
      break
    elif -values[j] + values[i] == X:
      print('{} {}'.format(-j, -i))
      break


if __name__ == '__main__':
  main()


Measured memory_bytes: 63956
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
using namespace std;

typedef complex<double> P;

struct C {
    P p; double r;
    C(const P &p, double r) : p(p), r(r) { }
};

const double EPS = 1e-8;

namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

int intersection(C &c1, C &c2){
    if(c1.r > c2.r) swap(c1, c2);

    P p1 = c1.p;
    P p2 = c2.p;
    double r1 = c1.r;
    double r2 = c2.r;

    double centDist = sqrt(norm(p1 - p2));
    if(r1 + r2 < centDist - EPS) return 4;
    if(abs(r1 + r2 - centDist) <= EPS) return 3;
    if(r1 + r2 > centDist + EPS){
        if( r2 - r1 < centDist - EPS ) return 2;
        if( abs(r2 - r1 - centDist) <= EPS ) return 1;
        if( r2 - r1 > centDist + EPS ) return 0;
    }

}

int main(){
    double c1x, c1y, c1r, c2x, c2y, c2r;
    cin >> c1x >> c1y >> c1r >> c2x >> c2y >> c2r;
    P p1(c1x, c1y);
    P p2(c2x, c2y);
    C c1(p1, c1r);
    C c2(p2, c2r);
    cout << intersection(c1, c2) << endl;
    return 0;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  double t, a;
  cin >> n >> t >> a;
  ll res = 0;
  double tmp = (double)INF;
  rep(i, n) {
    double h;
    cin >> h;
    if (tmp > abs(t-h*0.006-a)) {
      tmp = abs(t-h*0.006-a);
      res = i+1;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
data = list(map(int, input().split()))

d = list(map(lambda x: -x, data))
heapq.heapify(d)

for i in range(m):
    tmp = int(heapq.heappop(d) / 2)
    heapq.heappush(d, tmp)

d = list(map(lambda x: -x, d))

print( sum(d) )


Measured memory_bytes: 79468
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class KEYENCE2020A
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var H = NN;
            var W = NN;
            var N = NN;
            var max = Max(H, W);
            var cnt = (N - 1) / max + 1;
            Console.WriteLine(cnt);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


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

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

#define BYTE 8

int main(void) {
    int n, ans = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, BYTE) {
        if (n >= (1 << (BYTE - 1 - i))) {
            ans = 1 << (BYTE - 1 - i);
            break;
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  ll x;
  cin >> x;

  ll s = 100;
  int ans = 0;
  while (true){
    s = s * 1.01;
    ans++;
    if (s >= x) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
package main

import (
    "fmt"
)

func main() {
    var n int 
    fmt.Scan(&n)
    ls := make([]int, n+1)
    ls[0] = 2 
    ls[1] = 1 
    for i := 2; i <= n; i++ {
        ls[i] = ls[i-1] + ls[i-2]
    }   
    fmt.Println(ls[n])
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
using namespace std; 
int main()
{
	int L,R,d;
	cin >> L >> R >> d;
	int count=0;
	for(L;L<=R;L++)
	{
		if(L%d==0)	count++;
	}
	cout << count;
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string ALP = "abcdefghijklmnopqrstuvwxyz";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << ((c>=a&&c<=b)?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int n, d, i, j, k;
    int s = 0;
    int count = 0;
    int A[20][20];
    scanf("%d %d", &n, &d);
    for(i = 0; i < n; i++){
        for(j = 0; j < d; j++){
            scanf("%d", &A[i][j]);
        }
    }
    for(i = 0; i < n-1; i++){
        for(j = i+1; j < n; j++){
            s = 0;
            for(k = 0; k < d; k++){
                s += (A[i][k] - A[j][k]) * (A[i][k] - A[j][k]);
                //printf("%d\n", A[i][k] - A[j][k]);
            } 
            //printf("s= %d\n", s);
            if(ceil(sqrt(s)) == floor(sqrt(s)))count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/24  Problem: ABC 123 D / Link: http://abc123.contest.atcoder.jp/tasks/abc123_d  ----- */


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

	int A, B, C; cin >> A >> B >> C;
	int K; cin >> K;
	vector<LL> a(A);
	for (int i = 0; i < A; ++i) {
		cin >> a[i];
	}
	vector<LL> b(B);
	for (int i = 0; i < B; ++i) {
		cin >> b[i];
	}
	vector<LL> c(C);
	for (int i = 0; i < C; ++i) {
		cin >> c[i];
	}
	RSORT(a);
	RSORT(b);
	RSORT(c);
	using tp = tuple<LL, int, int, int>;
	priority_queue<tp>pq;
	pq.push(tp(a.front() + b.front() + c.front(), 0, 0, 0));
	set<tp>se;
	while(K){
		LL val;
		int ai, bi, ci;
		tie(val, ai, bi, ci) = pq.top(); pq.pop();
		if (se.count(tp(val, ai, bi, ci))) {
			continue;
		}
		se.insert(tp(val, ai, bi, ci));
		K--;
		DD(de(ai,bi,ci))
		cout << val << endl;
		if (ai + 1 < A) {
			pq.push(tp(a[ai + 1] + b[bi] + c[ci], ai + 1, bi, ci));
		}
		if (bi + 1 < B) {
			pq.push(tp(a[ai] + b[bi + 1] + c[ci], ai, bi + 1, ci));
		}
		if (ci + 1 < C) {
			pq.push(tp(a[ai] + b[bi] + c[ci + 1], ai, bi, ci + 1));
		}
	}

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac;
    Comb(){fac.resize(FAC_MAX,1);ifac.resize(FAC_MAX,1);rep(i,1,FAC_MAX)fac[i]=fac[i-1]*i;
        ifac[FAC_MAX-1]=T(1)/fac[FAC_MAX-1];rrep(i,FAC_MAX-2,1)ifac[i]=ifac[i+1]*T(i+1);}
    T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; }
    T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; }
    T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0;
        return aCb(n + k - 1, k); }}; // nHk = (n+k-1)Ck : n is separator
typedef ModInt<1000000007> mint;
//------------------------------------------------------------------------------
void _main()
{
    int K, X;
    cin >> K >> X;
    for (int i = max(X - (K - 1), -1000000); i <= min(X + (K - 1), 1000000); ++i)
    {
        cout << i << " ";
    }
    cout << endl;
}


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

#define fi first
#define se second
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))
#define debug(x) cout<<#x": "<<x<<'\n';
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=5000010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

template<class T> inline void gmax(T &A,T B)
{
    (A<B)&&(A=B);
}
template<class T> inline void gmin(T &A,T B)
{
    (A>B)&&(A=B);
}

template<class T> inline bool re(T &ret)
{
    char c;
    int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}

int n;
int a[3333];
ll dp[3333][3333];

int main()
{
#ifdef local
    //freopen("in.txt", "r", stdin);
#endif
    IOS;
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i],dp[i][i]=a[i];
    for(int k=2; k<=n; k++)
        for(int i=1; i+k-1<=n; i++)
        dp[i][i+k-1]=max(a[i]-dp[i+1][i+k-1],a[i+k-1]-dp[i][i+k-2]);
    cout<<dp[1][n];
    return 0;
}


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

int main(){
  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  int five = 0; int seven = 0;
  for (int i = 0; i < 3; i++){
    if (a.at(i) == 5){
      five++;
    }
    else if (a.at(i) == 7){
      seven++;
    }
    else{
      continue;
    }
  }
  if (five == 2 || seven == 1){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  LL N, M, ans=0;
  cin >> N >> M;
  if (N*2 <= M) {
    ans += N;
    M -= N*2;
    ans += M/4;
  }
  else {
    ans += M/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<62)-10e15;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
LL H,W;
LL c[10][10];
LL A[200][200];
 
LL ans = 0;
 
void solve(){
	//各数字について、それらを1にするような最小のコストを求める
	//ワーシャルフロイド
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
			}
		}
	}
	for(int h=0;h<H;h++){
		for(int w=0;w<W;w++){
			if(A[h][w]==-1) continue;
			ans += c[A[h][w]][1];
		}
	}
}
 
int main(){
    cin >> H >> W;
    for(int i=0;i<10;i++){
    	for(int j=0;j<10;j++) cin >> c[i][j];
    }
	for(int h=0;h<H;h++){
		for(int w=0;w<W;w++) cin >> A[h][w];
	}
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> A(N);
  pair<int, int> MIN(INF, 0), MAX(-INF, 0);
  REP(i, N){
    cin >> A[i];
    if(MIN.first > A[i]) MIN = {A[i], i};
    if(MAX.first < A[i]) MAX = {A[i], i};
  }

  cout << 2*N-2 << endl;
  if(abs(MIN.first) <= abs(MAX.first)){
    REP(i, N){
      if(i == MAX.second) continue;
      cout << MAX.second+1 << " " << i+1 << endl;
    }
    REP(i, N-1){
      cout << i+1 << " " << i+2 << endl;
    }
  }else{
    REP(i, N){
      if(i == MIN.second) continue;
      cout << MIN.second+1 << " " << i+1 << endl;
    }
    RREP(i, N-1){
      cout << i+2 << " " << i+1 << endl;
    }
  }


  return 0;
}

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

int main()
{
	int a, b, c, d, e;
	cin >> a >> b;
	
	c = a + b;
	d = a - b;
	e = a * b;
	
	cout << max(max(c, d), e) << endl;

	return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
// #define FOR(i, m, n) for (ll i = m; i < (n); i++)
// #define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
// #define REP(i, n) FOR(i, 0, n)
// #define RREP(i, n) RFOR(i, n, 0)
// #define ALL(v) v.begin(), v.end()
// #define RALL(v) v.rbegin(), v.rend()
// #define print(ele) cout << (ele) << "\n"
// #define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

// using namespace std;
// typedef long long ll;
// typedef vector<int> ivec;
// typedef vector<string> svec;
// typedef vector<ll> lvec;

// const int mod = 1e9 + 7;
// const ll INF = 1000000000000000000LL;
// lvec a = {10, 11, 12};
// lvec f(ll x) {
//   REP(i, x) {
//     string a0 = to_string(a[0]);
//     string a1 = to_string(a[1]);
//     if (a0.size() != a1.size()) {
//       REP(i, 3) a[i] += 11;
//       x--;
//     } else {
//       a[0] += 11;
//       a[1] += 11;
//       a[2] += 11;
//     }
//   }
//   return a;
// }

// int main() {
//   int k;
//   cin >> k;
//   ll ans;
//   if (k <= 9) {
//     ans = k;
//   } else {
//     k -= 10;
//     ll num = k / 3;
//     lvec a = f(num);
//     int b = k % 3;
//     print(a[b]);
//   }
//   return 0;
// }

#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int k;
  cin >> k;
  lvec a;
  FOR(i, 1, 10) a.push_back(i);

  while (1) {
    if (k <= a.size()) {
      print(a[k - 1]);
      return 0;
    }
    k -= a.size();
    lvec old;
    swap(a, old);
    for (ll x : old) {
      for (int i = -1; i <= 1; i++) {
        int d = x % 10 + i;
        if (d < 0 || d > 9) continue;
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,3) if(s[i] == 'o') cnt++;
    cout << (7+cnt) * 100 << endl;
    return 0;
}


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

int main(){
  std::string S,T;
  std::cin >> S >> T;
  rep(i,S.size()) {
    if(S == T) {
      std::cout << "Yes" << '\n';
      return 0;
    }
    else {
      S.insert(S.begin(), S[S.size()-1]);
      S.pop_back();
    }
  }

  std::cout << "No" << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<int> retval;
		retval.reserve(num);

		for (int i = 0; i < num; ++i)
		{
			std::getline(stream, buf, delim);
			retval.push_back(std::stoi(buf));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename T>
	void PrintLine(const std::vector<T>& sequence)
	{
		std::cout << sequence[0];

		for (size_t i = 1; i < sequence.size(); ++i)
		{
			std::cout << ' ' << sequence[i];
		}

		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	char input;
	std::stack<int> s1;
	std::stack<std::pair<int, int>> s2;
	int total_area = 0;

	for (int i = 0; stream >> input; ++i)
	{
		switch (input)
		{
		case '/':
			if (!s1.empty())
			{
				int p = s1.top();
				s1.pop();
				total_area += i - p;

				int area = i - p;
				while (!s2.empty() && p < s2.top().first)
				{
					area += s2.top().second;
					s2.pop();
				}
				s2.push({ p, area });
			}
			break;
		case '\\':
			s1.push(i);
			break;
		case '_':
		default:
			break;
		}
	}

	std::cout << total_area << '\n';
	std::vector<int> areas;
	while (!s2.empty())
	{
		areas.push_back(s2.top().second);
		s2.pop();
	}
	std::reverse(areas.begin(), areas.end());
	std::cout << areas.size();
	for (const auto& e : areas)
	{
		std::cout << ' ';
		std::cout << e;
	}
	std::cout << std::endl;
}



Measured memory_bytes: 3220
def main():
    S = input()
    N = len(S)
    K = int(input())

    S1 = {}
    for i, s in enumerate(S):
        if not s in S1.keys():
            S1[s] = [i]
        else:
            S1[s].append(i)
    alp = sorted(list(S1.keys()))

    c = 0
    for a in alp:
        aset = set()
        inds = S1[a]
        for d in inds:
            up = min(N-d+1, K+1)
            for i in range(up):
                aset.add(S[d:d+i])
        L = len(aset)-1
        if L >= K-c:
            break
        c += L

    for _ in range(10):
        M = '何だこれはもうやめてくれよ'
        for a in aset:
            if a < M:
                M = a
        aset.discard(M)
        if M == '':
            continue
        c += 1
        if c >= K:
            ans = M
            break

    print(ans)



if __name__=='__main__':
    main()

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	string s;
	cin >> s;
	int max_c = 0;
	int moment_c = 0;
	REP(i, 0, (int)s.size()){
		if(s[i] == 'A'  || s[i] == 'C'  ||  s[i] == 'G'  ||  s[i] == 'T')
			++moment_c;
		else{
			max_c = max(moment_c, max_c);
			moment_c = 0;
		}
	}
	max_c = max(moment_c, max_c);
	cout << max_c;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdint.h>
using namespace std;
  
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, ll> mll;
  
const int N = 1e5 + 2;
const int M = 1e5 + 2;
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18 + 100;

  
void data() {
    #ifdef PC
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif	
}

template <typename T>
void scerr(T nums) {
    for (auto it : nums)
        cerr << it << " | ";
    cerr << "\n";
}

int n, a[N], dp[N];

int main() {
	data();
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for (int i = 3; i <= n; ++i) {
		dp[i] = inf;
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	printf("%d", dp[n]);
}
  
/*
    Timus: 288481RF
    CodeForces: fractal
*/


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

A_={}
for _ in range(-1,10**5+10):
    A_[_]=0

for a in A:
    a_b = a-1
    a_a = a+1
    A_[a] +=1
    A_[a_b] +=1
    A_[a_a] +=1    

ans = 0
ans_idx = 0
for k in A_.keys():
    a = A_[k]
    if ans < a:
        ans = a
        ans_idx = k
        
# print(ans_idx,ans)
print(ans)

Measured memory_bytes: 24340
N = int(input())
H = list(map(int, input().split()))
tmp_h = H[-1]
answer = "Yes"

for i in range(N-1):
    if H[-2-i] -1 > tmp_h:
        answer = "No"
        break
    elif H[-2-i] -1 == tmp_h:
        tmp_h = H[-2-i] -1
    else:
        tmp_h = H[-2-i]

print(answer)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define TOSTRING(x) #x
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a):i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef struct Edge{
  int from,to,cost;
public:
  Edge(){}
  Edge(int _from, int _to, int _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }
} Edge;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

class UnionFindTree{
public:
  int treeCnt; //ツリーの数
  vi rank; // 根の高さ
  vi p; //親
  vi num;//グループの要素数
  UnionFindTree(){}
  UnionFindTree(int size){
    rank.resize(size,0);
    p.resize(size,0);
    treeCnt = 0;
    REP(i,size){
      makeset(i);
    }
  }

  void makeset(int x){
    p[x] = x;
    rank[x] = 0;
    treeCnt++;
  }

  //同じ木に属しているか判定
  bool same(int x, int y){
    return findSet(x) == findSet(y);
  }

  //xとyが属している木をつなぐ
  void unite(int x, int y){
    link(findSet(x),findSet(y));
  }
  
  ///木と木を繋ぐ処理をする。(ついでに木の高さを調整)
  void link(int x, int y){
    if(!same(x,y)){
      if(rank[x] > rank[y]){
	p[y] = x;
      }else{
	p[x] = y;
	if(rank[x] == rank[y]){
	  rank[y]++;
	}
      }
      treeCnt--;
    }
  }

  //xが属している木の根を探る(ついでに木を操作)
  int findSet(int x){
    if(p[x] == x) return x;
    else return p[x] = findSet(p[x]);
  }

  int countTree(){
    return treeCnt;
  }
};

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

  while(cin >> n >> m){
    vi a(m),b(m);
    REP(i,m){
      int ia,ib;
      cin >> ia >> ib;
      a[i] = ia;
      b[i] = ib;
    }
    DUMP(a);
    DUMP(b);
    int ans = 0;
    //除く辺
    REP(i,m){
      UnionFindTree utf(n);
      REP(j,m){
	if(i != j){
	  utf.unite(a[j]-1,b[j]-1);
	}
      }
      if(utf.countTree() == 2)
	ans++;
    }
    
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int a[200010];
int main(void){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	deque<int> res;
	for (int i=1;i<=n;i++){
		if (i&1){
			res.push_back(a[i]);
		}
		else{
			res.push_front(a[i]);
		}
	}
	deque<int>::iterator it;
	if (n&1){
		it=res.end();
		it--;
		for (;it!=res.begin();it--){
			printf("%d ",*it);
		}
		printf("%d",*it);
	}
	else{
		it=res.begin();
		for (;it!=res.end();it++){
			printf("%d ",*it);
		}
	}
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int mod = 1e9 + 7;
const int inf = 2e9 + 5;
const int N = 1e4 + 5;



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

    string s, t;
    cin >> s >> t;

    t.pop_back();
    if (s == t) {
        cout << "Yes\n";
    }
    else cout << "No\n";
    return 0;
}

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

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int a, b;

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

  cin >> a >> b;
  if ((a * b) % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }

  return 0;
}


Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[100000]={0};
	for(int i=1;i<101;i++){
		for(int j=1;j<101;j++){
			for(int k=1;k<101;k++){
				int z=i*i+j*j+k*k+i*j+i*k+j*k;
				if(z<10001)
					a[z]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	cout<<a[i]<<endl;
}



Measured memory_bytes: 4012
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String sa = scanner.next();
        String sb = scanner.next();
        String sc = scanner.next();
        int ia = 0;
        int ib = 0;
        int ic = 0;
        char next = 'a';
        for(int i = 0; i<(sa.length()+sb.length()+sc.length()); i++) {
            if(next=='a') {
                if(ia == sa.length()) {
                    System.out.println("A");
                    return;
                }
                next = sa.charAt(ia);
                ia++;
            }else if(next=='b') {
                if(ib == sb.length()) {
                    System.out.println("B");
                    return;
                }
                next = sb.charAt(ib);
                ib++;
            }else {
                if(ic == sc.length()) {
                    System.out.println("C");
                    return;
                }
                next = sc.charAt(ic);
                ic++;
            }
        }
    }
}

Measured memory_bytes: 22868
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  int H, A;
  cin >> H >>  A;

  int ret=0;
  while(H>0) {
    ret++;
    H-=A;
  }
  cout << ret << endl;

  return 0;
}


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

#include <stack>
using namespace std;

int main(){
    int n;
    int x=0;
    stack<int> st;
    string s;
    cin>>n;

    if(n==1){
        cin>>s;
        cout<<"NO"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        cin>>s;



        if(s=="A"){
            st.push(1);
        }else{
            if(!st.empty()){
                st.pop();
            }else{
                cout<<"NO"<<endl;
                return 0;
            }
            
        }
    }

    if(st.empty()){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3164
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;

int n, k, c;
void solve()
{
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> vec;
    set<int> rvec;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'o')
        {
            vec.push_back(i);
            i += c;
        }
        if (vec.size() == k+1)
            return ;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == 'o')
        {
            rvec.insert(i);
            i -= c;
            cnt++;
        }
        if (rvec.size() == k+1)
            return ;
    }
    for (int i:vec)
    {
        int j = i;
        if(rvec.count(j))
        {
            cout << i + 1 << "\n";
        }
    }
}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while (T-- > 0)
        solve();
}

Measured memory_bytes: 11916