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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    ll n,k;
    cin >> n >> k;

    ll ans=k*pow(k-1, n-1);
    cout << ans << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
from collections import deque


N = int(input())
V = [ list(map(int, input().split())) for _ in range(N-1)]

X = [[] for _ in range(N)]
for v in V:
    X[v[0]-1].append((v[0],v[1],v[2]))
    X[v[1]-1].append((v[1],v[0],v[2]))
# print(X)
color = [-1] * N
color[0] = 0

que = deque()
que.append(1)

while len(que) > 0:
    v = que.popleft()
    for x in X[v-1]:
#         print(x)
        b = x[1]
        dist = x[2]
        color_a = color[v-1]
        if  color[b-1] != -1:
            continue
        que.append(b)
        if dist % 2 == 0:
            color[b-1] = 0 if color_a == 0 else 1
        else:
            color[b-1] = 0 if color_a == 1 else 1

for c in color:
    print(c)

Measured memory_bytes: 54164
#include <bits/stdc++.h>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
  long double A, B, H, M;
  long double PI = 3.14159265358979323846;

  cin >> A >> B >> H >> M;

  long double rad = (60.000000000 * H - 11.000000000 * M) / 360.000000000 * PI;
  
  if (rad < 0)
    rad = rad * -1.000000000;
  if (rad > PI)
    rad = 2.000000000 * PI - rad;
  
  long double ans = sqrtl(A * A + B * B - 2.000000000 * A * B * cosl(rad));
  
  cout << fixed << setprecision(15) << ans << endl;

}

Measured memory_bytes: 4164
n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())    
    if abs( (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3) ) < 1e-10:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    vector<queue<int>> data(n);
    rep(i,n) {
        rep(j,m) {
            int x; cin >> x;
            data[i].push(x);
        }
    }
    set<int> use;
    REP(i,m+1) use.insert(i);
    int ans = inf;
    while (use.size() != 0) {
        map<int,int> ct;
        rep(i,n) {
            while (true) {
                int x = data[i].front();
                if (!use.count(x)) data[i].pop();
                else {
                    ct[x]++;
                    break;
                }
            }
        }
        int mx = 0;
        int omit;
        for (P p : ct) {
            if (chmax(mx,p.second)) omit = p.first;
        }
        ans = min(ans,mx);
        use.erase(omit);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4092
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int N;
long long h[110000];

long long dp[110000];

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

    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string s;
  cin>>s;
  int n = s.size();
  
  string ans = "";
  ans += s[0];
  ans += to_string(n-2);
  ans += s[n-1];
  
  cout<<ans<<endl;
  return 0;
}


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

ll power(ll x,ll n){
  if(n==0) return 1;
  ll res=power(x*x%mod,n/2);
  if(n&1) res=res*x%mod;
  return res;
}

int main(){
  int n;
  cin>>n;
  int a[n+1];
  rep(i,0,n+1){
    cin>>a[i];
    a[i]--;
  }
  int b[n];
  rep(i,0,n) b[i]=-1;
  int c,d;
  rep(i,0,n+1){
    if(b[a[i]]==-1) b[a[i]]=i;
    else{
      c=b[a[i]];
      d=i;
    }
  }
  
  ll shi[n+2];
  shi[0]=1;
  rep(i,1,n+2) shi[i]=shi[i-1]*i%mod;
  ll bo[n+2];
  bo[0]=1;
  rep(i,1,n+2) bo[i]=power(shi[i],1e9+5);
  
  rep(i,1,n+2){
    ll ans=shi[n+1]*bo[i]%mod*bo[n+1-i]%mod;
    if(i-1<=c+n-d){
      ans-=shi[c+n-d]*bo[i-1]%mod*bo[c+n-d-i+1]%mod;
      if(ans<0) ans+=mod;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3584
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		A(sc);
	}
	
	public static void A(Scanner sc) {
		int n = sc.nextInt();
		int k = sc.nextInt()-1;
		String s = sc.next();
		System.out.println(s.substring(0,k)+Character.toLowerCase(s.charAt(k))+s.substring(k+1,n));
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector> 
#include <algorithm>
#include <functional>

using namespace std;

int main(){
	vector<int> a;
	int b;
	int N;
	cin >> N ;
	for(int i=0;i<N;i++){
		cin >> b;
		a.push_back(b);
	}
	sort(a.begin(),a.end());
	int count=0;
	for(int i=0;i<a.size()-1;i++){
		if(a[i]==a[i+1]){
			count++;
		}
	}
	
	int d;
	d=count%2;
	if(d==1){
		count+=1;
	}
	cout<<N-count<<endl;
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<cmath>
#include<vector>
#include<limits.h>


using namespace std;

int main(){

  int n=0,m=0,l=0,term=0;
long int matrix_a[120][120]={};
long int matrix_b[120][120]={};
long  int matrix_c[120][120]={0};

//cout << INT_MAX << endl;

    cin >> n >> m >> l;
/*    if(n >= 100 || m >= 100 || l >=100 ){
      //cout  << "Too Large" << endl;
      return 0;
}*/

//cout << INT_MAX << endl;

  for(int i=0 ; i<n ; i++){
    for(int j=0 ; j<m ; j++){
      cin >> matrix_a[i][j];                   //??????????´?
    }
  }

  for(int i=0 ; i<m ; i++){
    for(int j=0 ; j<l ; j++){
      cin >> matrix_b[i][j];                   //??????????´?
    }
  }


  for (int i = 0 ; i < n ; i++) {
         for (int j = 0 ; j < l ; j++) {
             // Multiply the row of A by the column of B to get the row, column of product.
             for (int k = 0 ; k < m ; k++) {
                 matrix_c[i][j] += matrix_a[i][k] * matrix_b[k][j];
             }

         }
     }



  /* ??????????????????????????? */
/*    for(int i=0; i<n; ++i){
      for(int j=0; j<l ; ++j){
        matrix_c[i][j] = matrix_a[i][j] * matrix_b[i][j];

        // ????????????????¨????
        for(int i=0;i<n;i++){
          for(int j=0 ; j<l ; j++){
             term = 0;
            for(int k=0 ; k<m ; k++)
              term = term + matrix_a[i][k] * matrix_b[k][j];
            matrix_c[i][j] = term;
          }
        }

      }
    }
*/
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
        if(j==0){
            cout << matrix_c[i][j];                        //?????????????????????????????¨???
          }
          else{
            cout << ' ' << matrix_c[i][j];                //????????\??????????????¨???
          }
        }
        cout << endl;
    }
    return 0;



}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
    ll a,b,ans;
    cin>>a>>b;
    if(a>=13)
        ans=b;
    else if(a<=5)
        ans=0;
    else
        ans=b/2;
    
    cout<<ans<<endl;
    return 0;
}



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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int a,b,c;
  cin>>a>>b>>c;
  cout<<(a<=c&&c<=b?"Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
using namespace std;
int main(){
	char str;
	refrain:
	scanf("%c",&str);
	if(str=='\n'){
		printf("\n");
		return 0;
	}
	if(islower(str)) str=toupper(str);
	else if(isupper(str)) str=tolower(str);
	printf("%c",str);
	goto refrain;
}

Measured memory_bytes: 940
q,h,s,d = map(int,input().split())
n = int(input())
ans =0
two_litter = [8*q,4*h,2*s,d]
ans += (n // 2) * min(two_litter) 
n = n - (n // 2) * 2

one_litter = [4*q,2*h,s]
ans += n * min(one_litter)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,-1,1,1,-1};
int dy[]={0,1,0,-1,-1,-1,1,1};




int main(){
    int n;cin >> n;
    vector<LL> a(n);
    map<LL,LL> ma;
    LL sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ma[a[i]]++;
        sum += a[i];
    }
    int q;cin >> q;
    while(q--){
        LL b,c;cin >> b >> c;
        if(ma[b]){
            sum -= ma[b] * b;
            sum += ma[b] * c;
            ma[c] += ma[b];
            ma[b] = 0;
        }
        cout << sum << endl;
    }
    return 0;
}

    


Measured memory_bytes: 9864
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut map = HashMap::new();
    let mut count = 0;

    for _i in 0..n {
        let count = map.entry(read::<u32>()).or_insert(0);
        *count += 1;
    }

    for (key, value) in map.iter() {
        if key < value {
            count += value - key;
        } else if key > value {
            count += *value;
        }
    }

    println!("{}", count);

}


Measured memory_bytes: 8444
#include<iostream>
#include<string.h>
using namespace std;
char s[100001] = { '\0' };
int main(void)
{
	int sum = 0;
	int sumg=0, sump=0;
	cin >> s;
	for (int i = 0; i <strlen(s); i++)
	{
		if (s[i] == 'g')
		{
			if (sump <sumg)
			{
				sump++;
				sum++;
			}
			else if (sump >= sumg)
			{
				sumg++;
			}
		}
		else if (s[i] == 'p')
		{
			if (sump < sumg)
			{
				sump++;
			}
			else if (sump >= sumg)
			{
				sumg++;
				sum--;
			}
		}
	}
	cout << sum;
}

Measured memory_bytes: 384
program abc166d
      implicit none
      integer(8)::x
      integer(8)::i,j,n

         read *, x

         n=1
         do while ( (n**5-(n-1)**5) < x)
            n=n+1
         end do

         do i=-n,n
            do j=-n,n
               if ((i**5-j**5)==x) then
                  print *, i,j
                  stop
               end if
            end do
         end do

   end program abc166d

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  vector<ll> a(3);
  REP(i, 3) { cin >> a[i]; };

  sort(all(a));
  a.erase(unique(a.begin(), a.end()), a.end());

  cout << (a.size() == 2 ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define INF 1000000009
#define MAX_V 100000

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];
int previous[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    fill(previous,previous+V,-1);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
                previous[e.to]=v;
            }
        }
    }
}

vector<int> get_path(int t){
    vector<int> path;
    for(;t!=-1;t=previous[t])path.push_back(t);
    reverse(path.begin(),path.end());
    return path;
}

int main(){
    cin>>V;
    rep(i,V-1){
        int a,b;
        cin>>a>>b;
        --a;--b;
        G[a].push_back({b,1});
        G[b].push_back({a,1});
    }
    dijkstra(0);
    auto gp=get_path(V-1);
    int reached[V];
    memset(reached,0,sizeof(reached));
    reached[gp[((int)gp.size()+1)/2]]=1;
    stack<int> st;
    st.push(0);
    reached[0]=1;
    int ctr=1;
    while(!st.empty()){
        int sttop=st.top();
        st.pop();
        for(auto au:G[sttop]){
            if(reached[au.to]==1)continue;
            reached[au.to]=1;
            ctr++;
            st.push(au.to);
        }
    }
    cout<<(ctr>V-ctr?"Fennec":"Snuke")<<endl;
}

Measured memory_bytes: 7536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	ll sumb = 0, suma = 0;
	rep(i, n) suma += a[i];
	rep(i, n) sumb += b[i];
	ll sum = sumb - suma;
	if (sum < 0) {
		dunk("No");
		return 0;
	}
	ll ca = 0, cb = 0;
	rep(i, n) {
		ll d = a[i] - b[i];
		if (d < 0) {
			d = -d;
			ca += (d + 1) / 2;
			cb += d % 2;
		}
		else {
			cb += d;
		}
	}
	if (sum < ca || sum < cb) {
		dunk("No");
		return 0;
	}
	dunk("Yes");
	return 0;
}


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

const int N = 2e3 + 10;
const int mod = 1e9 + 7;
const int INV2 = 5e8 + 4;

int n, k, a[N], pref[N], suf[N];

void self_add(int &x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
}

int mult(int x, int y) {
  return (1LL * x * y) % mod;
}

int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++)
    scanf("%d", a + i);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++)
      pref[i] += (a[i] < a[j]);
  for (int i = n - 1; i >= 0; i--)
    for (int j = n - 1; j > i; j--)
      suf[i] += (a[i] < a[j]);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    self_add(ans, mult(mult(pref[i], mult(k, k + 1)), INV2));
    self_add(ans, mult(mult(suf[i], mult(k, k - 1)), INV2));
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

	const int MAX = 100001;
	vector<int> cnt(MAX + 2, 0);

	int n;
	cin >> n;

	for(int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		++cnt[a];
		--cnt[b + 1];
	}

	for(int i = 0; i < MAX; ++i)
		cnt[i + 1] += cnt[i];

	for(int i = n + 1; i > 0; --i) {
		if(cnt[i] + 1 >= i) {
			cout << i - 1 << endl;
			break;
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N, M;
  cin>>N>>M;
  vector<ll> a(M),b(M),c(M);

  //vector<vector<int>> tonari(N,vector<int>(N,-1));
  vector<pair<int,int>> tonari[100];

  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i]>>c[i];
    tonari[a[i]-1].push_back({b[i]-1,c[i]});
    tonari[b[i]-1].push_back({a[i]-1,c[i]});
  }
  int ans=0;
  for(int i=0;i<M;i++){
    int start=a[i]-1,goal=b[i]-1;
    vector<bool> det(N,false); //確定しているか
    vector<int> sdis(N,1e9);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
    sdis[start]=0;
    pq.push({sdis[start],start});
    while(!pq.empty()){
      int pos=pq.top().second;
      pq.pop();
      if(det[pos]) continue;
      det[pos]=true;
      for(int j=0;j<tonari[pos].size();j++){
        int next=tonari[pos][j].first, dis=tonari[pos][j].second;
        if(det[next]) continue;
        sdis[next]=min(sdis[next],sdis[pos]+dis);
        pq.push({sdis[next],next});
      }
    }
    if(sdis[goal]<c[i]) ans++;
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func divs(n int) []int {
	r := make([]int, 0)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			r = append(r, i)
			if i*i != n {
				r = append(r, n/i)
			}
		}
	}
	return r
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	d := divs(M)
	// sort.Ints(d)
	// fmt.Println("N", N, "M", M, "divs(M)", d)
	ans := 1
	for i := 0; i < len(d); i++ {
		v := M / d[i]
		if v >= N {
			ans = max(ans, d[i])
		}
	}
	fmt.Println(ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007

int main()
{
	FASTIO
	int n, m, x;
	cin >> n >> m;
	vector<bool> blocked(n+1, false);
	for(int i=0; i<m; i++)
	{
		cin >> x;
		blocked[x] = true;
	}
	int f1 = 1, f2 = (blocked[1]) ? 0 : 1;
	//for(auto x : blocked) cout << x << " ";
	//cout << "\n";
	for(int i=2; i<=n; i++)
	{
		swap(f1,f2);
		if(!blocked[i]) f2 = (f1+f2)%mod;
		else f2 = 0; 
	}
	cout << f2 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int i,n,k,a[100001],sum,ans;
  
  while(scanf("%d %d",&n,&k),n,k){
    ans=sum=0;
    for(i=0;i<n;i++)scanf("%d",&a[i]);

    for(i=0;i<k;i++)sum+=a[i];

    for(i=0;k<n;i++,k++){
      sum+=a[k]-a[i];
      ans=(ans>sum)?ans:sum;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())
p = list(map(int, input().split()))
px = [(1 + p[i])/2 for i in range(n)]

ans = sum(px[0: 0 + k])
bef = sum(px[0: 0 + k])
for i in range(1, n - k + 1):
    bef = bef-px[i-1]+px[i+k-1]
    ans = max(ans, bef)
print(ans)


Measured memory_bytes: 25060
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int key) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = new Node;
    z->key = key;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

// void find(Node *u, int key) {
//     if (key == u->key) {
//         printf("yes\n");
//         return;
//     } else if (key < u->key && u->left != NIL) {
//         find(u->left, key);
//     } else if (key > u->key && u->right != NIL) {
//         find(u->right, key);
//     } else {
//         printf("no\n");
//         return;
//     }
// }

Node *find(Node *u, int key) {
    while (u != NIL && key != u->key) {
        if (key < u->key) { u = u->left; }
        else { u = u->right; }
    }
    return u;
}

void inorder(Node *u) {
    if (u == NIL) { return; }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) { return; }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        string command;
        cin >> command;
        int key;
        if (command == "insert") {
            scanf("%d", &key);
            insert(key);
        } else if (command == "find") {
            scanf("%d", &key);
            // find(root, key);
            if (find(root, key) != NIL) { printf("yes\n"); }
            else { printf("no\n"); }
        } else if (command == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 22032
import scala.io.StdIn.{readInt, readLine}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val arr = readLine.split(" ").map(a => (a, a.substring(1).toInt))
        val retBubble = bubbleSort(arr, len).map(_._1).mkString(" ")
        val retSelection = selectionSort(arr, len).map(_._1).mkString(" ")
        println(retBubble)
        println("Stable")
        println(retSelection)
        println(if (retBubble == retSelection) "Stable" else "Not stable")
    }
    
    def swap(arr: Array[(String, Int)], a: Int, b: Int): Unit = {
        val tmp = arr(a)
        arr(a) = arr(b)
        arr(b) = tmp
    }
    
    def bubbleSort(arr: Array[(String, Int)], len: Int): Array[(String, Int)] = {
        val copy = new Array[(String, Int)](len)
        arr.copyToArray(copy)
        (1 until len).foreach { i =>
            (i until len).reverse.foreach { j =>
                if (copy(j)._2 < copy(j - 1)._2) swap(copy, j, j - 1)
            }
        }
        copy
    }
    
    def selectionSort(arr: Array[(String, Int)], len: Int): Array[(String, Int)] = {
        val copy = new Array[(String, Int)](len)
        arr.copyToArray(copy)
        def min(arr: Array[(String, Int)], ptr: Int): Int = {
            if ((arr.length - 1 == ptr)) ptr
            else min(arr, ptr + 1) match {
                case m if arr(m)._2 < arr(ptr)._2 => m
                case _ => ptr
            }
        }
        (0 until len).foreach { i => 
            val m = min(copy, i)
            if (i != m) swap(copy, i, m)
        }
        copy
    }
}


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

using namespace std;
#define ull unsigned long long
#define ll long long

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

/*-----------------------------------------------------MATH------------------------------------------------*/

const int inf = 1e6;
const int MAXN = 2e5 + 10;
ll mod = 998244353;
vector<ull> arr(26);
vector<ull> arr2(60);
ull fact5(ull n){
    ull ans=0;
    vector<ull> prefarr(26);
    for(int i=25;i>=1;i--){
        ull now=n/arr[i];
        for(int j=i+1;j<26;j++){
            now-=prefarr[j];
        }
        prefarr[i]=now;
        ans+=now*i;
    }
    return ans;
}
ull fact2(ull n){
    ull ans=0;
    vector<ull> prefarr(60);
    for(int i=59;i>=1;i--){
        ull now=n/arr2[i];
        for(int j=i+1;j<60;j++){
            now-=prefarr[j];
        }
        prefarr[i]=now;
        ans+=now*i;
    }
    return ans;
}
void solve() {
    ull k;
    cin>>k;
    arr[0]=1;
    arr2[0]=1;
    for(int i=1;i<26;i++) arr[i]=arr[i-1]*5;
    for(int i=1;i<60;i++) arr2[i]=arr2[i-1]*2;
    ull ans5;
    ull ans2;
    if(k%2==0){
        ans5= fact5(k/2);
        ans2=k/2+fact2(k/2);
    }
    else{
        ans5=fact5(k)-fact5((k-1)/2);
        ans2=fact2(k)-fact2((k-1)/2)-(k-1)/2;
        //cout<<fact2(k)<<endl;
    }
    cout<<min(ans2, ans5);

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n = 1;
    for (int i = 0; i < n; i++) solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;

int main () {
  int a, b;
  cin >> a >> b;
  if (a == b) {
    for (int i = 0; i < a; i++) cout << a;
  }else if (a < b) {
    for (int i = 0; i < b; i++) cout << a;
  }else {
    for (int i = 0; i < a; i++) cout << b;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdfix.h>

using namespace std;

int main() {
    int N,D;
    cin >> N >> D;
    float X[N][D];
    for(int ni = 0; ni < N; ni++){
        for(int di = 0; di < D; di++){
            cin >> X[ni][di];
        }
    }
    int count = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            float distance = 0;
            for(int di = 0; di < D; di++){
                distance += (X[i][di] - X[j][di]) * (X[i][di] - X[j][di]);
            }
            distance = sqrt(distance);
            if(distance == floor(distance)){
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 384
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
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;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    int n, k;
    cin >> n >> k;

    map<int,int> mp;

    rep(i, k){
        int d;
        cin >> d;
        rep(j, d){
            int a;
            cin >> a;
            a--;
            mp[a]++;
        }
    }
    int ans = 0;
    rep(i, n){
        if(mp[i] == 0){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <cstdio>

#define LB -1000000
#define UB  1000000
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) > (y) ? (y) : (x))

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int K, X;
int max;



int main () {

	// 文字列数の読込み
	scanf("%d %d", &K, &X);

	for(int i = max(X - K + 1, LB); i <= min(X + K - 1, UB); i++)
		printf("%d%c", i, i < max(X + K - 1, UB) ? ' ' : '\n');	
	
	return 0;
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

i64 n, s;
i64 next_b(i64 b) {
  i64 ok = b, ng = 1e18;
  while (ng - ok > 1) {
    i64 md = (ok + ng) / 2;
    if (n / b == n / md) ok = md;
    else ng = md;
  }
  return ok + 1;
}

i64 f(i64 b, i64 n) {
  if (n < b) return n;
  return f(b, n / b) + n % b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cin >> n >> s;
  if (n < s) {
    cout << -1 << endl;
    return 0;
  } else if (n == s) {
    cout << n + 1 << endl;
    return 0;
  } else {
    if (s > (n + 1) / 2) {
      cout << -1 << endl;
      return 0;
    }
  }
  i64 b = 2;
  while (true) {
    i64 nb = next_b(b);
    if (s >= f(nb - 1, n) && s <= f(b, n) && (s - f(nb - 1, n)) % (n / b) == 0) {
      cout << b + (f(b, n) - s) / (n / b) << endl;
      return 0;
    }
    b = nb;
  }
  return 0;
}


Measured memory_bytes: 256
#Z-algorithm
n=int(input())
s=input()
def Zalgo(s):
    ans=0
    L=len(s)
    Z=[0]*L
    Z[0]=L
    i=1;j=0
    while i<L:
        while i+j < L and s[j]==s[i+j]:j+=1
        Z[i]=j
        if Z[i] > ans and Z[i]<=i:
            ans=Z[i]
        if j == 0:
            i+=1
            continue
        k=1
        while k<j and k+Z[k]<j:
            Z[i+k]=Z[k]
            k+=1
        i+=k
        j-=k
    return ans
ans=0
for i in range(n):
    p=Zalgo(s[i:])
    if p > ans:
        ans=p
print(ans)

Measured memory_bytes: 48792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
int main() {
  int N; cin >> N;
  vector<int> P(N);
  rep(i,N) cin >> P[i];
  int ans = 1, tmp = P[0];
  for(int i=1; i<N; ++i) {
    if(P[i] < tmp) {
      tmp = P[i];
      ++ans;
    }
  }
  cout << ans << endl;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<'\n'

int main(){
    int n;
    cin >> n;
    ll a[n],b[n];
    ll count = 0;
    REP(i,n)cin >> a[i] >> b[i];
    for(int i=n-1;i>=0;i--){
        a[i] += count;
        ll num = b[i]-(a[i]%b[i]);
        if(num==b[i])num=0;
        count += num;
    }
    COUT(count);
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  
  while (N>=1) {
    N = N / K;
    ans += 1;
  }
  
  dunk(ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    	long long n,fib[100];
	cin >>n;
	fib[0]=2;
	fib[1]=1;
	for(int i=2;i<=n;i++){
		fib[i]=fib[i-1]+fib[i-2];
	}
	cout <<fib[n]<<endl;
   

}

Measured memory_bytes: 256
// AOJ 0184: Tsuruga Castle
// 2017.10.28 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int n;
	char buf[10];
	int cnt[10];
	
	while (fgets(buf, 10, stdin) && *buf != '0') {
		memset(cnt, 0, sizeof(cnt));
		n = atoi(buf);
		while (n--) {
			fgets(buf, 10, stdin);
			if (*(buf+1) < '0') cnt[0]++;
			else if (*(buf+2) >= '0') cnt[6]++;
			else cnt[*buf & 0xf]++;
		}
		for (n = 7; n < 10; n++) cnt[6] += cnt[n];
		for (n = 0; n < 7; n++) printf("%d\n", cnt[n]);
	}
	return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>

int main(){
	int N,a[100],i,j,k,temp;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++) scanf("%d",&a[i]);
	for(i=0;i<N-1;i++) printf("%d ",a[i]);
	printf("%d\n",a[N-1]);
	
	for(i=1;i<N;i++){
		temp = a[i];
		j = i-1;
		while(j >= 0 && a[j] > temp){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = temp;
		for(k=0;k<N-1;k++) printf("%d ",a[k]);
		printf("%d\n",a[N-1]);
	}
	return 0;
}

Measured memory_bytes: 2684
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.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<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//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 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())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;


int main(){
	LL d;
	while(cin>>d){
		LL res=0;
		for(LL i=d;i<600;i+=d)res+=i*i*d;
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String firstHalf = S.substring(0, N / 2);
		String secondHalf = S.replaceFirst(firstHalf, "");
		
		if(2 <= N && firstHalf.equals(secondHalf)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 21972
import itertools

N = int(input())
S = [input() for _ in range(N)]

CNT = [0] * 5
iniset = ["M","A","R","C","H"]
s_to_i = {"M":0,"A":1,"R":2,"C":3,"H":4}


for s in S:
  i = s[0]
  if not i in iniset:
    continue
    
  CNT[s_to_i[i]] += 1
  
ans = 0
for x,y,z in itertools.combinations(CNT,3):
  ans += x * y * z

print(ans)
  
  


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

#define ll long long

ll GCD(ll m,ll n){
    ll big,small;
    ll p=-1;
    big=max(m,n);
    small=min(m,n);

    while(1){
        p=big%small;
        if(p==0)break;
        big=small;
        small=p;
    }
    
    return small;
}

int main(){
    ll ans=1,sum=0;
    ll t;
    int n,m;
    cin >>n;
    ll data[n];
    
    for (int i = 0; i < n; i++){
        cin >>data[i];
    }
    
    sort(data,data+n);
    ans=data[0];

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

        if(data[j+1]%ans == 0){

            ans = data[j+1];
            
        }else{

            ll temp = ans;
            ans = temp/GCD(data[j+1],ans);
            ans *= data[j+1];

        }

    }
    


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	while(cin>>a)
    {
    	if(a==1)cout<<"Hello World\n";
    	else 
    	{
    		scanf("%d%d",&b,&c);
    		cout<<b+c<<endl;
		}
	}
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
bool is(char c){
	return (c=='A')||(c=='C')||(c=='G')||(c=='T');
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	string s;
	cin>>s;
	int mx=0;
	int cnt=0;
	for(int i=0; i<s.length(); i++) {
		while(is(s[i])) {
			cnt++;
			mx=max(cnt,mx);
			i++;
		}
		cnt=0;
	}
	cout<<mx<<endl;

	return 0;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N; cin >> N;
  ll ans = 0;
  if(N%2!=0){
    ans = 0;
  } else { 

    N /= 2;

    ll num = 0;
    while(N>0){
      num += N / 5;
      N /= 5;
    }

    ans = num;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3576
/*
Author : N_o_o_B
Created : January 18 2020 17:34:03 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    vll a(n);
    fori(i,n){
        ll x,l;
        cin >> x >> l;
        a[i].fi = x - l + 1;
        a[i].se = x + l - 1;
    }
    sort(all(a));
    vl dp(n+1);
    ford(i,n){
        int ind = (lower_bound(all(a),make_pair(a[i].se+1,INF)) - a.begin());
        dp[i] = max(dp[i+1],dp[ind]+1);
    }
    cout << dp[0] << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int N; bool flag;
vector<int> k;
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> N;
    for (int i = 0, a; i < N; i++){
        cin >> a;
        if (a % 2 == 0){
            if (a % 3 && a % 5) flag = 1;
        }
    }
    cout << (flag ? "DENIED\n" : "APPROVED\n"); 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll keta(ll n) {
	if (n < 10) { return n; }
	return keta(n - 9) * 10 + 9;

}

int main() {

	ll N;
	cin >> N;

	ll ans = 0;

	while (keta(ans) <= N) {
		ans++;
	}

	cout << ans - 1;

	
	system("PAUSE");

}





Measured memory_bytes: 504
def solve(x,y)
  i = 0
  i += 1 if y > 0
  i += 2 if x >= 0
  i += 4 if y > x
  i += 8 if y > -x
  
  case i
  when 4,15
    y - x
  when 2,5
    1 - y - x
  when 10,13
    1 + x + y
  when 0,11
    x - y + 2
  end
end

x,y = gets.split.map &:to_i
puts solve(x,y)

__END__
cases = {
  [10,3] => 9,
  [3,10] => 7,
  [0,10] => 10,
  [-3,10] => 8,
  [-10,3] => 8,
  [-10,0] => 10,
  [-10,-3] => 7,
  [-3,-10] => 9,
  [0,-10] => 11,
  [3,-10] => 8,
  [10,-10] => 1,
  [10,-3] => 8,
  [10,0] => 11
}

cases.each do |k,v|
  ans = solve(*k)
  next if ans == v

  puts "bad #{k}. want:#{v}, got:#{ans}"
end


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

int main(){
  int N; cin >> N;
  int P; cin >> P;
  string S; cin >> S;
  
  if(P==2||P==5){
    long long count=0;
    for(int i=0; i<N; i++){
      if((S[i]-'0')%P==0) count+=(i+1);
    }
    cout << count << endl;
    return 0;
  }
  
  multiset<int> modp;
  long long t=1;
  int current=0;
  for(int i=N-1; i>=0; i--){
    current=(current+((S[i]-'0')*t))%P;
    modp.insert(current);
    t=(t*10)%P;
  }
  
  t=modp.count(0);
  long long count=(t+t*(t-1)/2);
  modp.erase(0);
  while(!modp.empty()){
    int tmp=*(modp.begin());
    long long c=modp.count(tmp);
    count+=c*(c-1)/2;
    modp.erase(tmp);
  }
  cout << count << endl;
}

Measured memory_bytes: 9860
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 201000
using namespace std;
int A[N_], B[N_];
int n1, n2, m, r1 = 1e9, r2 = 1e9;
int main() {
	int i;
	scanf("%d%d%d", &n1, &n2, &m);
	for (i = 1; i <= n1; i++) {
		scanf("%d", &A[i]);
		r1 = min(r1, A[i]);
	}
	for (i = 1; i <= n2; i++) {
		scanf("%d", &B[i]);
		r2 = min(r2, B[i]);
	}
	int res = r1 + r2;
	for (i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		res = min(res, A[a] + B[b] - c);
	}
	printf("%d\n", res);
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1000000007;

int main() {
	ll x;
	cin >> x;
	for (ll a = -1000; a <= 1000; a++) {
		for (ll b = -1000; b <= 1000; b++) {
			if ((a * a * a * a * a) - (b * b * b * b * b) == x) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		String ary[]=s.split("");
		int cnt=0;
		
		for(int i=0; i<ary.length; i++) {
			if(ary[i].equals("1")) {
				cnt++;
			}
		}
		
		System.out.println(cnt);
	}

}


Measured memory_bytes: 22996