akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr ll mod = 1000000007;

int main() {
    ll m, c, d;
    queue<ll> q;
    cin >> m;
    ll r = 0;
    for (ll i = 0; i < m; i++) {
        cin >> d >> c;
        while (c > 0) {
            if (c % 2) {
                c--;
                q.push(d);
            }
            d *= 2;
            c /= 2;
            r += c;
            if (d >= 10) {
                ll d1 = d % 10, d2 = d / 10;
                r += c;
                d = d1 + d2;
            }
        }
    }
    while (q.size() > 1) {
        ll d1 = q.front();
        q.pop();
        ll d2 = q.front();
        q.pop();
        ll d3 = d1 + d2;
        r++;
        if (d3 >= 10) {
            d3 = (d3 % 10) + (d3 / 10);
            r++;
        }
        q.push(d3);
    }
    cout << r << endl;
    return 0;
}


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

int main(){

    int homeworkAll,lastDays,homework[10100],i;

    std::cin >>  lastDays >> homeworkAll;
    for(i = 0; i < homeworkAll; i++){
        std::cin >> homework[i];
    }

    for(i = 0; i < homeworkAll; i++){
        lastDays = lastDays - homework[i];
    }

    if(lastDays >= 0){
        cout << lastDays << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long int llint;

int N;
int a[1001];

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

  cin >> N;
  int mi = 1001, ma = -1;
  int a;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    mi = min(mi, a);
    ma = max(ma, a);
  }

  cout << ma - mi << endl;

  return 0;
}

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

int dx8[9] = { -1,-1,-1, 0, 1, 1, 1, 0 ,0};
int dy8[9] = { -1, 0, 1, 1, 1, 0,-1,-1,0 };
int main() {
	int N, M; cin >> N >> M;
	vector<pair<int, int>>ps;
	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b;
		a--; b--;
		ps.emplace_back(a, b);
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int amax = -1;
		for (int j = 0; j < M; ++j) {
			auto p(ps[j]);
			if (p.first <= i&& i<=p.second) {
				amax = max(amax, p.second);
			}
		}
		if (amax == -1) {
			ans = -1;
			break;
		}
		else {
			i = amax;
			ans++;
		}
	}
	if (ans == -1) {
		cout << "Impossible" << endl;
	}
	else {

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

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
	int m;
	cin >> n >> m;
	cout << ((n*(n-1) + m*(m-1))>> 1) << endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}

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


// 塗り絵
int main(){
    int w, h, n; cin >> w >> h >> n;
    vector<int> x(n); vector<int> y(n); vector<int> a(n);
    rep(i,n) cin >> x[i] >> y[i] >> a[i];
    vector<vector<int>> A(w, vector<int>(h));
    rep(i,n){
        if(a[i]==1){
            for(int j = x[i]-1; j >= 0; j--){
                for(int k=0; k<h; k++){
                    A[j][k] = 1;
                }
            }
        }
        else if(a[i]==2){
            for(int j = x[i]; j < w; j++){
                for(int k=0; k<h; k++){
                    A[j][k] = 1;
                }
            }
        }else if(a[i]==3){
            for(int j=y[i]-1; j>=0; j--){
                for(int k=0; k<w; k++){
                    A[k][j] = 1;
                }
            }
        }else if(a[i]==4){
            for(int j=y[i]; j<h; j++){
                for(int k=0; k<w; k++){
                    A[k][j] = 1;
                }
            }
        }
    }
    int ans=0;
    rep(i,w){
        rep(j,h){
            if(A[i][j] == 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<ll> a(n), b(m);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	for(int i = 0; i < m; ++i){ cin >> b[i]; }
	ll x = a[0], y = 1;
	for(int i = 0; i < n; ++i){ x = __gcd(x, a[i]); }
	for(int i = 0; i < m; ++i){
		const ll g = __gcd(y, b[i]);
		const ll t = b[i] / g;
		if(__int128(t) * y > x){
			y = -1;
			break;
		}
		y *= t;
	}
	if(y < 0){
		cout << 0 << endl;
	}else{
        int answer = 0;
        for(ll i = 1; i * i <= x; ++i){
            if(x % i == 0){
                if(i % y == 0){ ++answer; }
                if(i * i != x && (x / i) % y == 0){ ++answer; }
            }
        }
		cout << answer << endl;
	}
	return 0;
}


Measured memory_bytes: 1204
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin); i < (end); i++)
#define _irep3(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

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

  ll N;
  cin >> N;
  if (N == 2) {
    out(-1);
    return 0;
  }
  if (N == 3) {
    out("abb");
    out("a.a");
    out("bba");
    return 0;
  }
  if (N == 4) {
    out("abaa");
    out("abcc");
    out("ccba");
    out("aaba");
    return 0;
  }
  vector<string> ans(N, string(N, '.'));
  ans[0][0] = 'c';
  ans[0][1] = 'c';
  ans[1][0] = 'd';
  ans[2][0] = 'd';
  ans[0][N - 1] = 'c';
  ans[1][N - 1] = 'c';
  ans[0][N - 2] = 'd';
  ans[0][N - 3] = 'd';
  ans[N - 1][N - 1] = 'c';
  ans[N - 1][N - 2] = 'c';
  ans[N - 2][N - 1] = 'd';
  ans[N - 3][N - 1] = 'd';
  ans[N - 1][0] = 'c';
  ans[N - 2][0] = 'c';
  ans[N - 1][1] = 'd';
  ans[N - 1][2] = 'd';
  rep(i, N - 4) {
    char c = i % 2 == 0 ? 'a' : 'b';
    ans[i + 1][i + 2] = c;
    ans[i + 1][i + 3] = c;
    ans[i + 2][i + 1] = c;
    ans[i + 3][i + 1] = c;
  }
  rep(i, N) out(ans[i]);
}


Measured memory_bytes: 2304
#include<iostream>
using namespace std;
int main() {
	int n;
	int a[4][4];
	int b[11];
	for (int i = 0;i < 3;i++) {
		for (int j = 0;j < 3;j++) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	for (int i = 0;i < n;i++)cin >> b[i];
	for (int l = 0;l < n;l++) {
		for (int i = 0;i < 3;i++) {
			for (int j = 0;j < n;j++) {
				if (b[l] == a[i][j])a[i][j] = 0;
			}
		}
	}
	for (int i = 0;i < 3;i++) {
		int cnt = 0;
		for (int j = 0;j < 3;j++) {
			if (a[i][j] != 0)break;
			if (a[i][j] == 0)cnt++;
		}
		if (cnt == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	for (int i = 0;i < 3;i++) {
		int cnt = 0;
		for (int j = 0;j < 3;j++) {
			if (a[j][i] != 0)break;
			if (a[j][i] == 0)cnt++;
		}
		if (cnt == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
Module Module1

    Sub main()
        'Dim str1 As String = "cd"
        'Dim str2 As String = "abc"

        Dim str1 = Console.ReadLine()
        Dim str2 = Console.ReadLine()


        Dim parts1 As New List(Of Char), parts2 As New List(Of Char)
        parts1 = New List(Of Char)(str1.ToCharArray)
        parts2 = New List(Of Char)(str2.ToCharArray)

        parts1.Sort()
        parts2.Sort()
        parts2.Reverse()

        Dim result As String = "No"
        If String.Join("", parts1.ToArray) < String.Join("", parts2.ToArray) Then
            result = "Yes"

        End If
        Console.WriteLine(result)

    End Sub
end module

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

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	n = n + 1 >> 1;
	printf("%s\n", n >= k ? "YES" : "NO");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  long long int R=0;
  int G=0;
  int B=0;
  long long sum=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      R=R+1;
    }
    else if(S.at(i)=='G'){
      G=G+1;
    }
    else{
      B=B+1;
    }
  }
  sum=R*G*B;
  long long count=0;
  if(N<3){
    cout<<0<<endl;
  }
  else{
    for(int i=0;i<N-2;i++){
      for(int j=i+1;j<N-1;j++){
        int m=2*j-i;
        if(m<N){
          if((S.at(i)!=S.at(j))&&(S.at(i)!=S.at(m))&&(S.at(m)!=S.at(j))){
            count=count+1;
          }
        }
      }
    }
    cout<<sum-count<<endl;
  }
}


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


int main(void){
        int N, P;
        cin >> N >> P;
        int a[2] = {0,0};
        rep(i,N) {
                int A;
                cin >> A;
                a[A%2]++;
        }

        ll ans = 1;
        if (a[1] == 0) {
                if ( P == 0) rep(i,N) ans *= 2;
                else ans = 0;
        }
        else rep(i,N-1) ans *= 2;

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

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001

string s;
LL dfs(int a){
  LL b=0;
  if(a >= s.length()){
    string buf = "";
    for(int i=0;i<s.length();i++){
      if(s[i] == '+'){
        b+= atoll(buf.c_str());  
        buf = "";
      }else{
        buf += s[i];
      }
    }
    b += atoll(buf.c_str());
    return b;
  }
  s.insert(s.begin() + a,'+');
  b += dfs(a+2);
  s.erase(s.begin() + a);
  b += dfs(a+1);
  return b;
}
int fuct(string s){
  cout << dfs(1) << endl;
  return 0;
}
int main(){
  cin >> s;
  fuct(s);
	return 0;
}


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

int main() {
    int k, n;
    cin >> k >> n;
    int a[n + 1];
    rep(i, n) cin >> a[i];
    a[n] = k + a[0];
    int total = 0;
    int m = 0;
    for (int i = 0; i < n; i++) {
        int diff = a[i+1] - a[i];
        total += diff;
        m = max(m, diff);
    }
    cout << total - m << endl; 
    return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
N, h, w = map(int,input().split())
#N = int(input())
#l = list(map(int,input().split()))
#s = list(map(str,input().split()))
ans = 0
for i in range(N):
    a, b = map(int,input().split())
    if a >= h and b >= w:
        ans += 1

print(ans)

Measured memory_bytes: 9004
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

int n;
int a[111];

int main(){

cin>>n;

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

int cnt = 0;

for(int i=1; i<=n; i++){
    if(a[i] == a[i-1]){ a[i] = -99; cnt++; }
}

cout<<cnt;


return 0;

}















Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 100010
map<P, int> d;
map<P, vector<P>> g;
int main(){
	ll n, m;
	cin>>n>>m;
	rep(i, m){
		int u, v, c;
		cin>>u>>v>>c; u--; v--; c--;
		g[P(u, c)].push_back(P(v, c));
		g[P(v, c)].push_back(P(u, c));
		g[P(u, -1)].push_back(P(u, c));
		g[P(u, c)].push_back(P(u, -1));
		g[P(v, -1)].push_back(P(v, c));
		g[P(v, c)].push_back(P(v, -1));
	}
	deque<P> q;
	q.push_front(P(0, -1));
	d[P(0, -1)] = 0;
	while(!q.empty()){
		P p = q.front(); q.pop_front();
		for(auto x: g[p]){
			int w = p.snd!=x.snd;
			if(!d.count(x) || d[p]+w<d[x]){
				d[x] = d[p]+w;
				if(w==1) q.push_back(x);
				else q.push_front(x);
			}
		}
	}
	P t = P(n-1, -1);
	if(!d.count(t)) d[t] = -2;
	cout<<d[t]/2<<endl;
	return 0;
}


Measured memory_bytes: 99584
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a,b,ans=-1,tot;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        ans+=b;
        tot+=(a*b);
    }
    ans+=(tot-1)/9;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
if n < 105:
    print(0)
elif n == 105:
    print(1)
else:
    ans = 1
    for i in range(106,n+1):
        if i%2!=0:
            yaku = 0
            for j in range(1,i+1):
                if i%j==0:
                    yaku+=1
            if yaku == 8:
                ans+=1
    print(ans)

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    int n,k;
    cin>>n>>k;
    vector<long long>p(n);
    rep(i,n){
        cin>>p[i];
    }

    sort(p.begin(),p.end());
    long long ans=0;
    rep(i,k){
        ans+=p[i];
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  vector<long long> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];

  vector<long long> from_left(N);
  vector<long long> from_left_up(N);
  vector<long long> from_left_down(N);
  from_left[0] = a[0];
  for (int i = 1; i < N; ++i) {
    from_left[i] = a[i] + from_left[i - 1];
  }

  vector<long long> from_right(N);
  from_right[N - 1] = a[N - 1];
  for (int i = N - 2; i >= 0; --i) {
    from_right[i] = a[i] + from_right[i + 1];
  }

  long long min_diff = 1000000000000;
  int min_index = 0;
  for (int i = 0; i < N - 1; ++i) {
    long long diff = abs(from_left[i] - from_right[i + 1]);
    if (diff < min_diff) {
      min_index = i;
      min_diff = diff;
    }
  }

  cout << abs(from_left[min_index] - from_right[min_index + 1]) << endl;

  return 0;
}

Measured memory_bytes: 8064
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int T_HP, T_ATK, A_HP, A_ATK; cin >> T_HP >> T_ATK >> A_HP >> A_ATK;
  int x = ceil((double)T_HP / A_ATK);
  int y = ceil((double)A_HP / T_ATK);
  if (x < y)  cout << "No" << endl;
  else        cout << "Yes" << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

        int n = sc.nextInt();

        int array[][][] = new int[4][3][10];

        for(int i = 0; i < n; i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();

            array[b - 1][f - 1][r - 1] += v;
        }

        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 3; j++){
                for(int x = 0; x < 10; x++){
                    System.out.print(" " + array[i][j][x]);
                }
                System.out.println();
            }
            if(i != 3){
                System.out.print("####################");
                System.out.println();
            }
        }
    }
}


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

int main(){
    int a,b,x;
    cin >> a >> b >> x;
    int s;
    double the;
    double pi;
    the=0;
    pi=acos(-1);
    s=a*a*b;
    if(2*x>=s){
        the=atan(double(2*(s-x))/double(a*a*a));
        the*=(180.0/pi);
    }
    else{
        the=atan(double(a*b*b)/double(2*x));
        the*=(180.0/pi);

    }



    printf("%.10f",the);
    

    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

    int k = 2;
    while (k * (k - 1) / 2 < n) {
        k++;
    }

    if (k * (k - 1) / 2 == n) {
        cout << "Yes" << endl;
        cout << k << endl;

        cout << k - 1;
        for (int i = 0, s = 1; i < k - 1; i++, s += i + 1) {
            cout << " " << s;
        }
        cout << endl;

        for (int i = 0; i < k - 1; i++) {
            cout << k - 1;
            for (int j = 0, s = i * (i + 1) / 2 + 1; j < k - 1; j++, s += (j <= i ? 1 : j)) {
                cout << " " << s;
            }
            cout << endl;
        }
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3640
# include <bits/stdc++.h>
using namespace std;
int main () {
  int a;
  cin >> a;
  cout << "Christmas";
  if (a != 25) {
    int j = 25-a;
    for (int i=0; i<j; i++) {
      cout << " " << "Eve";
    }
  }
}

Measured memory_bytes: 3588
N,C = map(int,input().split())
STC = [list(map(int,input().split())) for _ in [0]*N]
STC.sort()

R = []
for s,t,c in STC:
    i = -1
    tm = 0
    for j,r in enumerate(R):
        tr,cr = r
        if (c==cr and tm<=tr<=s) or (c!=cr and tm<tr<=s-0.5):
            i = j
            tm = tr
    if i==-1:R.append((t,c))
    else:R[i] = (t,c)
print(len(R))

Measured memory_bytes: 29808
#『aとbとcの最大公約数』　＝　『aとbの最大公約数』と『c』　の最大公約数
K = int(input())
K = K+1
from fractions import gcd
ans =0
gcd_memo = [[[] for k in range(201)] for i in range(201)]
for i in range(201):
    for k in range(201):
        val = gcd(i,k)
        gcd_memo[i][k] = val
        gcd_memo[k][i] = val

for i in range(1,K):
    for j in range(1, K):
        for k in range(1, K):
            ans += gcd_memo[gcd_memo[i][j]][k]
print(ans)

Measured memory_bytes: 78652
#include <vector>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <fstream>
using namespace std;

const int INF = 1e7;
pair<long long, long long> calculate(long long a, long long b, long long x, long long y) {
	long long a1 = x / a;
	a1 += x % a == 0 ? 0 : 1;
	long long b1 = y / b;
	b1 += y % b == 0 ? 0 : 1;
	long long mn = max(a1, b1);
	return make_pair(a * mn, b * mn);
} 

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

	int n;
	cin >> n;
	long long x, y;
	cin >> x >> y;
	for (int i = 0; i < (n - 1); ++i) {
		long long a, b;
		cin >> a >> b;
		if (a >= x && b >= y) {
			x = a;
			y = b;
			continue;
		} else {
			pair<long long, long long> tmp = calculate(a, b, x, y);
			x = tmp.first;
			y = tmp.second;
		}
	}
	cout << x + y << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include<queue>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
using namespace std;

int main(){
	int q; cin >>q;
	int cnt=0;
	ll B=0;
	priority_queue<ll,vector<ll>,greater<ll> > q1;
	priority_queue<ll> q2;
	ll sum1=0; ll sum2=0;
	while(cnt<q){
		int x;cin >>x;
		if(x==2){
			ll x=q2.top();
			cout << x <<" ";
			cout << B+(x*(ll)q2.size()-sum2)+(sum1-(ll)q1.size()*x)<< endl;
		}
		else{
			ll a,b; cin >>a>>b;
			B+=b;
			if(q2.empty()||a<=q2.top()){
				q2.push(a);
				sum2+=a;
				if(q2.size()>q1.size()+1){
					a=q2.top();q2.pop();
					q1.push(a);
					sum2-=a;
					sum1+=a;
				}
			}
			else{
				q1.push(a);
				sum1+=a;
				if(q1.size()>q2.size()){
					a=q1.top();q1.pop();
					q2.push(a);
					sum2+=a;
					sum1-=a;
				}
			}
		}
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 3828
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  for(int i=n-2;i>0;i-=2){
    if(s.substr(0,i/2)==s.substr(i/2,i/2)) {
      cout << i << endl;
      return 0;
    }
  }
  
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C[] = new int[N];
		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt() - i - 1;
		}

		Arrays.sort(C);
		int naka = N / 2;
		int b = 0;
		b = C[naka];
		long sum = 0;
		for (int j = 0; j < N; j++) {
			sum += Math.abs((C[j] - b));

		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 86304
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var ans = Int.MAX_VALUE

    for (a in 1 until n) {
        val b = n - a
        ans = Math.min(ans, digitSum(a) + digitSum(b))
    }
    println(ans)
}

fun digitSum(x: Int): Int {
    var x = x
    var result = 0
    while (x != 0) {
        result += x % 10
        x /= 10
    }
    return result
}


Measured memory_bytes: 31144
#include<bits/stdc++.h>
#define int long long int
#define pi pair<int,int>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,b) for(int i=0;i<b;i++)
#define u_m unordered_map
#define mod 1e9+7
#define pii pair<pair<int,int> >
#define vpi vector<pair<int,int> >
#define vi vector<int>
#define vii vector<vector<int,int> >
#define endl "\n"
#define MAX 1e+5
using namespace std;


int32_t main()
{
	int n,k;
	cin>>n>>k;

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

	int dp[n+1];
	for(int i=1;i<=n;i++)
	{
		dp[i]=INT_MAX;
	}

	dp[1]=0;

	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<i+k+1;j++)
		{
          if(j<=n)
          {
			dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
          }
		}
	}


	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n;
int arr[200001];
long long ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>arr[i];
    }
    map<int,int> num;
    for (int i=1;i<=n;i++){
        if (num.find(i-arr[i])!=num.end()){
            ans+=num[i-arr[i]];
        }
        if (num.find(arr[i]+i)!=num.end()){
            num[arr[i]+i]++;
        }
        else {
            num[arr[i]+i]=1;
        }
    }
    cout<<ans;
    //i-ai=aj+j
}

Measured memory_bytes: 13728
import math

a, b, x = map(int, input().split())


if a*a*b >= x*2:
  d = 2*x/a/b
  print(math.atan(b/d)*180/math.pi)
else:
  d = 2*x/a/a - b
  print(math.atan((b-d)/a)*180/math.pi)



Measured memory_bytes: 3064
#!/usr/bin/env python3
#エクサウィザーズ2019 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,q = LI()
s = input()
l,r = -1,n
td = [list(map(str,input().split())) for _ in range(q)]
for i in range(q)[::-1]:
    t,d = td[i]
    if d == 'R':
        if r >= 0:
            if s[r-1] == t:
                r -= 1
        if l >= 0:
            if s[l] == t:
                l -= 1
    elif d == 'L':
        if l < n-1:
            if s[l+1] == t:
                l += 1
        if r < n:
            if s[r] == t:
                r += 1
print(max(0,r-l-1))


Measured memory_bytes: 92364
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 3000;
int dp[N][N], s[N][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    int x = 1;
    for (int j = 1; j < n - k; j++) x = (x + x) % mod;
    for (int j = 1; j <= n - k + 1; j++){
        dp[n - k + 1][j] = x;
        s[n - k + 1][j] = (s[n - k + 1][j - 1] + x) % mod;
    }
    for (int i = n - k + 2; i <= n; i++){
        for (int j = 1; j <= i; j++){
            dp[i][j] = dp[i - 1][max(1LL, j - 1)];
            dp[i][j] = (dp[i][j] + s[i - 1][i - 2] - s[i - 1][j - 1] + mod) % mod;
            s[i][j] = (s[i][j - 1] + dp[i][j]) % mod;
         //   for (int l = i - j; l >= 2; l--){
           //     dp[i][j] = (dp[i][j] + dp[i - 1][i - l]) % mod;
         //   }
        }
    }
    cout << dp[n][1];
}


Measured memory_bytes: 94848
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String a = sc.next();
        String b = sc.next();
        
        String result = "H";
        // if (a.equals("H") && b.equals("H")) result = "H";
        // if (a.equals("D") && b.equals("D")) result = "H";
        
        if (a.equals("H") && b.equals("D")) result = "D";
        if (a.equals("D") && b.equals("H")) result = "D";
        
        System.out.println(result);
      
    }
}


Measured memory_bytes: 21840
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  ll x;
  cin>>x;
  ll cnt = 0;
  ll t = x/11;
  int mod = x%11;
  cnt+=t*2;
  if(mod<=6&&mod!=0) cnt+=1;
  else if(mod>6) cnt+=2;
  
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int Grundy(int v, int from, const vector<vector<int>>& g) {
  int result = 0;
  for (int x : g[v]) if (x != from) result ^= 1 + Grundy(x, v, g);
  return result;
}

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (Grundy(0, -1, g) > 0) {
    cout << "Alice\n";
  } else {
    cout << "Bob\n";
  }
  return 0;
}


Measured memory_bytes: 11904
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct lazysegtree{
	using F=function<T(T,T)>;
	using G=function<T(T,T,int,int)>;
	const F calcfn,lazycalcfn;
	const G updatefn;
	int n;
	T defvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	lazysegtree(int n_=0,T defvalue_=0,
		const F calcfn_=[](T a,T b){return a+b;},
		const F lazycalcfn_=[](T a,T b){return a+b;},
		const G updatefn_=[](T a,T b,int l,int r){return a+b*(r-l);}
	):defvalue(defvalue_),
		calcfn(calcfn_),lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
		lazy.assign(2*n-1,T());
		lazyflag.assign(2*n-1,false);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
	}
	void eval(int i,int l,int r)
	{
		if(lazyflag[i])
		{
			dat[i]=updatefn(dat[i],lazy[i],l,r);
			if(r-l>1)
			{
				lazy[2*i+1]=lazyflag[2*i+1]?lazycalcfn(lazy[2*i+1],lazy[i]):lazy[i];
				lazy[2*i+2]=lazyflag[2*i+2]?lazycalcfn(lazy[2*i+2],lazy[i]):lazy[i];
				lazyflag[2*i+1]=lazyflag[2*i+2]=true;
			}
			lazyflag[i]=false;
		}
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]=lazyflag[k]?lazycalcfn(lazy[k],x):x;
			lazyflag[k]=true;
			eval(k,l,r);
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=calcfn(dat[2*k+1],dat[2*k+2]);
		}
	}
	T query(int a,int b,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return defvalue;
		else if(a<=l&&r<=b)return dat[k];
		else return calcfn(
			query(a,b,2*k+1,l,(l+r)/2),
			query(a,b,2*k+2,(l+r)/2,r)
		);
	}
};
main()
{
	int N,Q;
	cin>>N>>Q;
	lazysegtree<pair<long,pair<int,int> > >P(
		N,
		make_pair(0,make_pair(0,0)),
		[](pair<long,pair<int,int> >A,pair<long,pair<int,int> >B)
		{
			return make_pair(A.first+B.first+(long)A.second.second*B.second.first,
				make_pair(
					A.second.first+B.second.first,
					A.second.second+B.second.second
				)
			);
		},
		[](pair<long,pair<int,int> >A,pair<long,pair<int,int> >B)
		{
			A.first^=B.first;
			return A;
		},
		[](pair<long,pair<int,int> >A,pair<long,pair<int,int> >B,int l,int r)
		{
			if(B.first==0)return A;
			else
			{
				return make_pair((long)(r-l)*(r-l-1)/2-A.first-(long)A.second.first*(A.second.first-1)/2-(long)A.second.second*(A.second.second-1)/2,
					make_pair(A.second.second,A.second.first)
				);
			}
		}
	);
	vector<pair<long,pair<int,int> > >init(N);
	for(int i=0;i<N;i++)
	{
		int t;cin>>t;
		if(t==0)init[i].second.first++;
		else init[i].second.second++;
	}
	P.copy(init);
	for(int i=0;i<Q;i++)
	{
		int t,l,r;cin>>t>>l>>r;
		l--;
		if(t==1)P.update(l,r,make_pair(1,make_pair(0,0)));
		else cout<<P.query(l,r).first<<endl;
	}
}


Measured memory_bytes: 22744
#include <stdio.h>

int main () {
	int n;
	scanf("%d", &n);
	char str[n];
	scanf("%s", &str);
	
	if (n % 2 != 0) {
		printf("No");
		return 0;
	}
	
	for (int i = 0; i < n / 2;i++) {
		if (str[i] != str[n / 2 + i]) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

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

#define nax 100009
#define FOR(i,n,m) for(ll i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back

typedef long long ll;
typedef vector<ll> vi;

vi v[nax];
ll mod = 1000000007LL;
bool vis[nax][2];
ll dp[nax][2];

void dfs(int node, int color, int parent){
	vis[node][color] = 1;
	ll ans = 1LL;
	for(int u:v[node]){
		if(u==parent) continue;
		if(!vis[u][1-color]) dfs(u, 1-color,node);
		if(!vis[u][color]) dfs(u, color,node);
		if(color==1){
			ans = (ans*dp[u][1-color])%mod;
		}else{
			ans = (ans*(dp[u][1-color]+dp[u][color])%mod)%mod;
		}
	}
	dp[node][color] = ans;
}

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

	REP(i,n-1){
		int a,b; cin>>a>>b;
		a--;b--;
		v[a].pb(b);
		v[b].pb(a);
	}

	memset(vis,0,sizeof vis);
	dfs(0,0,-1); dfs(0,1,-1);
	cout<<(dp[0][0]+dp[0][1])%mod;

	return 0;
}

Measured memory_bytes: 17152
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

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

int main() {
  string S;
  cin >> S;
  ll sum=0;
  rep(i,3){
    if(S[i]=='A') sum+=1;
  }
  
  if(sum==1 || sum==2){
	cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
C.count(0)>1 and S.each {|s|
  26.times {|i| if s[i]==0 && i!=(z||=i); s[z]<s[i] ? (s[z]=0; z=i) : (s[i]=0) end }
}
L,M,N = [-1]*27,4,3
def calc(d,n)
  s = S[d]
  t = (0..25).map {s[_1] > 0 ? C[_1]*(d-L[_1])+s[_1] : 0}
  i = (0..25).max_by(M){t[_1]}.max_by {|i|
    next t[i]  if n == 0 || d+1 >= D || t[i] == 0
    l,L[i] = L[i],d
    calc(d+1,n-1)[1].tap {L[i]=l}
  }
  [i, t[i]]
end
D.times { p 1 + i=calc(_1,N)[0]; L[i]=_1 }

Measured memory_bytes: 15132
#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>

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

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
int y, m, d;

int solve(int y, int m, int d){
	int res = 0;
	res += (y - 1) / 3 * 590;
	res += (y - 1) % 3 * 195;
	if (y % 3 == 0){
		REP(i, m - 1)res += 20;
	}
	else {
		REP(i, m - 1){
			if ((i + 1) % 2 == 0)res += 19;
			else res += 20;
		}
	}
	res += d;
	return res;
}

int main(){
	cin >> n;
	REP(i, n){
		cin >> y >> m >> d;
		cout << 196471 - solve(y, m, d) << endl;
	}
}

Measured memory_bytes: 1160
n = int(input())
c = list(input())
r = n - 1
l = 0
ans = 0
while r >= l:
    if c[r] == 'R':
        while l <= r:
            if c[l] == 'W':
                break
            l += 1
        if l <= r:
            c[l], c[r] = c[r], c[l]
            ans += 1
    r -= 1
print(ans)

Measured memory_bytes: 82580
#include <cstdio>

#define ll long long

int main() {
    ll a, b, c, d;
    int n;
    ll rez;
    scanf("%d", &n);
    scanf("%lld%lld", &a, &b);
    for (int i = 2; i <= n; i++) {
        scanf("%lld%lld", &c, &d);
        ll s1 = 1, s2 = 1;
        if (c < a) {
            s1 = a / c;
            if (a % c > 0)
                s1++;
        }
        if (d < b) {
            s2 = b / d;
            if (b % d > 0)
                s2++;
        }

        if (s1 > s2) {
            c *= s1;
            d *= s1;
        }
        else {
            c *= s2;
            d *= s2;
        }
        a = c;
        b = d;
    }
    rez = a + b;
    printf("%lld", rez);
    return 0;
}


Measured memory_bytes: 128
chomp (my ($n, $k) = split / /, <STDIN>);
chomp (my @a = split / /, <STDIN>);
my %h;
$h{$_}++ for @a;
my ($c, $ans) = (0, 0);
for my $v (sort {$b <=> $a} values %h) {
  $c++;
  $ans += $v if $c > $k;
}
print "$ans\n";

Measured memory_bytes: 46668
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
#define LANCER_SHARK { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

int frq[50];
int main(){
	LANCER_SHARK;
	ll res = 0, t = 0;
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++){
		if (str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T')
			t++;
		else {
			res = max(res, t);
			t = 0;
		}
	}
	res = max(res, t);
	cout << res;
	cout << endl;
	return 0;
}


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

bool vis[200005]={false};
vector<ll> adj[200005];
ll arcc[200005]={-1};


map<ll,ll> mcc;
void dfs(ll v,ll cc){
    if(vis[v]==true){
        return ;
    }
    arcc[v]=cc;
    mcc[cc]++;
    vis[v]=true;
    for(auto u:adj[v]){
        if(vis[u]==false){
            dfs(u,cc);
        }
    }
}

int main(){
    ll n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        ll u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    ll cc=0;
    
    for(int i=1;i<=n;i++){
        if(vis[i]==true){
            continue;
        }
        else{
            dfs(i,cc);
            cc++;
        }
    }
    ll ans=0;
    for(auto u:mcc){
        ans=max(ans,u.second);
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 28744
import java.util.*;

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

    int r = sc.nextInt();
    int D = sc.nextInt();
    int x = sc.nextInt();
    for (int i = 0; i < 10; i++) {
      x = r * x - D;
      System.out.println(x);
    }
  }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
 
using namespace std;
 
int main (void) {
	int L;
    cin  >> L;
    double a = (double) L / 3.000;
  	printf("%10.10e\n",a*a*a);
    return 0;
}

Measured memory_bytes: 256
s = int(input())
check = {};c = s;count = 1
check['{}'.format(c)] = True
while True:
    count += 1
    if c % 2== 0:c = c//2 
    else:c = 3*c + 1
    try:
        if check['{}'.format(c)] == True:
            break
    except:pass
    check[str(c)] = True
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct Edge {
    ll to, cost;
};


// 特定のルートまでに閉路があるか調べたいならこう
// https://atcoder.jp/contests/abc061/submissions/12926139
vector<ll> bellman_ford(int n, int s, vector<vector<Edge> > &graph) { // nは頂点数、sは開始頂点
    vector<ll> dist(n, INF);
    dist[s] = 0; // 開始点の距離は0
    for (int i = 0; i < n; i++) {
        for (int v = 0; v < n; v++) {
            for (int k = 0; k < graph[v].size(); k++) {
                Edge e = graph[v][k];
                if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
                    dist[e.to] = dist[v] + e.cost;
                }
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int v = 0; v < n; v++) {
            for (int k = 0; k < graph[v].size(); k++) {
                Edge e = graph[v][k];
                if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
                    dist[e.to] = -INF;
                }
            }
        }
    }

    return dist;
}


int main() {

    ll n, m, p;
    cin >> n >> m >> p;

    vector<vector<Edge>> edges(n);

    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        edges[a].push_back(Edge{b, -(c - p)});
    }

    vector<ll> dist = bellman_ford(n, 0, edges);

    if (dist[n - 1] == -INF) {
        cout << -1 << endl;
    } else {
        cout << max(0ll, -dist[n - 1]) << endl;
    }


}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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







int main(){
    int n, m;
    cin >> n >> m;
    while(n || m){
        vector<vector<ll>> a(m);
        REP(i, n){
            ll d, v;
            cin >> d >> v;
            a[d - 1].push_back(v);
        }
        
        int ans = 0;
        REP(i, m){
            ans += *max_element(a[i].begin(), a[i].end());
        }
        
        cout << ans << endl;
        
        cin >> n >> m;
    }
}


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

using namespace std;

typedef long long ll;

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

	int a, b;
	cin >> a >> b;

	if(b == 1){
		cout << 0 << endl;
		return 0;
	}
	
	int t = a;
	int cnt = 1;
	while(t < b){
		t += a - 1;
		cnt++;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
		  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
		   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
			   # #  # # #                   # #      ###### #    # #    # #      #####
		  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
		   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
	*/
	 
	#include<bits/stdc++.h>
	using namespace std;
	 
	typedef long long LL;
	typedef vector<LL> VLL;
	typedef vector<string> VS;
	typedef vector<pair<LL, LL> > VP;
	 
	 
	#define For(in) for (LL i = 0; i < (n); i++)
	#define FOR(in) for(LL i=1; i <= (n); i++)
	#define pb push_back
	#define sr(v) sort(v.begin(), v.end())
	#define rev(v) reverse(v.begin(), v.end())
	#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
	#define exit(); return 0;
	#define no "NO"
	#define yes "YES"
	#define con continue;
	 
	 
	LL concate(LL a, LL b)
	{
		ostringstream os;
		os <<a <<b;
		istringstream is(os.str());
		LL c;
		is>> c;
		return c;
	}
	 
	 
	LL check(char c)
	{
		return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
	}
	LL mod = 1e9+7;
	 
	 
	int main()
	{
		LL q,t;
		//cin>>t;
		//while(t--)
		//{
		   LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
			LL aa[1000];
			LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
			LL ma=0, mi=100000000;
			LL mid=0, temp=0, stop=0, start=0;
			double pi= 3.141592653589793;
			double d1=0.0, d2, d3, d4;
			VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
			VS vs, vs1, vs2, vs3, vs4;
			VP vp, vp1,vp2;
			char ch, ch1, ch2[1001];
			string str, str1, str2, str3, str4, str5;
			pair<LL, LL> pa;
			list<LL> li, li1;
			map<LL, LL> mp, mp1;
			set<LL> st;
			map<LL ,LL> :: iterator imll;
			VLL :: iterator ivll;
			set<LL> :: iterator isll;
			VP :: iterator ivp;
	 
			
			cin>>n;
			x = 1;
			for(i=1; i<=n; i++)
			{
				x = (x*i) % mod;
			}
			cout<<x<<endl;
			
			
			
			
		 //}
	 
		exit()
	 
	 
	}


Measured memory_bytes: 3660
//  Suraj Saste

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<ll,ll>
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}

int main()
{
	fast;
	ll n;cin>>n;
	ll a[n],dp[n+1];
	for(ll i=0;i<n;i++)cin>>a[i];
    dp[0]=0;
    for(ll i=1;i<n;i++)
    {
    	dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
    	if(i-2>=0)dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

import numpy as np

def getNearestValueIndex(list_, num):
    idx = np.abs(np.asarray(list_) - num).argmin()
    return idx

input()
T, A = [int(x) for x in input().split()]
H_li = [int(x) for x in input().split()]

x = (T-A)/0.006

print(getNearestValueIndex(H_li, x)+1)


Measured memory_bytes: 12840