akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll  long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define all(a) a.begin(),a.end()
#define int ll
#define vvi vector<vector<int>>
using namespace std;
using namespace __gnu_pbds;
typedef tree <pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll const mod=1e9+7;
int powi(int i,int b){
    int res=1;
    while(b){
        if(b&1)res*=i,res%=mod;
        b>>=1;
        i*=i;
        i%=mod;
    }
    return res;
}
// map<int,int> m;
// ll fact(int n){
// 	//if(n==0)return 0;
// 	if(n<=1)return 1;
// 	if(m[n]!=0)return m[n];
// 	return (n*fact(n-1))%mod;
// }
// int ncr(int n,int r){
//     int h=fact(n);
//     int v=fact(r);
//     int j=fact(n-r);
//     v*=j;
//     v%=mod;
//     v=powi(v,mod-2);
//     return (h*v)%mod;
// }
// vi ar(2000000);
// vi sz(2000000);
// int root(int a){
//     if(ar[a]==a)return a;
//     return ar[a]=root(ar[a]);
// }
// int merge(int a,int b){
//     int h=root(a),j=root(b);
//     int ans=sz[h]*sz[j];
//     sz[j]+=sz[h];
//     if(h!=j){
//         ar[h]=j;
//     }
//     return ans;
// } 
void solve(){
    int n,m,k;
    cin>>n>>m>>k;
    vi a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vi b(m);
    for(int i=0;i<m;i++){
        cin>>b[i];
        if(i!=0)b[i]+=b[i-1];
    }
    int mins=0,ans=0;
    auto h=lower_bound(all(b),k);
    if(h==b.end()){
        ans=m;
    }else{
        int l=h-b.begin();
        if(b[l]>k)l--;
        ans=l+1;
    }
    for(int i=0;i<n;i++){
        mins+=a[i];
        if(mins>k)break;
        int cn=k-mins;
        auto h=lower_bound(all(b),cn);
        if(h==b.end()){
            ans=max(ans,m+i+1);
        }else{
            int l=h-b.begin();
            if(b[l]>cn)l--;
            ans=max(ans,i+1+l+1);
        }
    }
    cout<<ans;
}
signed main(){
    boost;
    int t=1;
    //freopen("input.txt", "r", stdin);
    //cin>>t;
    for(int _=1;_<=t;_++){
        //cout<<"Case #"<<_<<": ";
        solve();
        cout<<"\n";
    }
    
    return 0;
}

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

class Prime {
    public:
        vector<char> prime;
        Prime(size_t n) : prime(n+1) {
            fill(prime.begin(), prime.end(), 1);
            prime[0] = prime[1] = 0;
            for(size_t i=2; i<=n; i++) {
                if(!prime[i]) continue;
                for(size_t j=2; i*j<=n; j++)
                    prime[i*j] = 0;
            }
        };
        bool is(size_t i) {
            return prime[i] == 1;
        };
};


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

    Prime pr(55555);

    int j=0;
    for(int i=1; j<n; i+=5) {
        if(pr.is(i)) cout << i << ' ', j++;
    }
    cout << endl;
}


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

using namespace std;

int main()
{
   int n,i,j,k;
   cin>>n>>k;
   int h[n],dp[n];
   //memset(dp,INT_MAX,sizeof(dp));
   for(i=0;i<n;i++)
   {
     cin>>h[i];
     dp[i] = INT_MAX;
   }

   dp[0] = 0;
  for(i=0;i<n;i++)
  {
      for(j=i+1;j < min(n,i+k+1);j++)
      {
          dp[j] = min(dp[j],dp[i]+(int)fabs(h[j]-h[i]));
          //cout<<j<<" "<<dp[j]<<" "<<dp[i]+(int)fabs(h[j]-h[i])<<"\n";
      }
  }
  //cout<<dp[1]<<" ";
  cout<<dp[n-1];

  return 0;
}


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

int a[50];

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

    int n,m;
    cin>>n>>m;

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

    int ans=0;

    for(int i=0;i<m;i++)
    {
        if(a[i+1]==n)ans++;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
ab?d
c??f
def?h
*/

int ans=1e9,ans2[2]={};
string a,b,c;
bool ab[20010],ac[20010],bc[20010];

bool match(char a, char b){
	return (a==b || a=='?' || b=='?');
}

int main(void){
	cin>>a>>b>>c;
	int am=a.size(),bm=b.size(),cm=c.size();  // b.size()みたいなのは符号なし整数型で、intとの演算で負になったらオーバーフローするからWAになる。
	reg(i,-4000,4000){  // bの位置
		rep(j,am){
			if(j-i >= bm)break;
			if(-i+j < 0)continue;
			if(!match(a[j],b[-i+j]))ab[i+10000]=true;
		}
	}
	reg(i,-4000,4000){  // cの位置
		rep(j,am){
			if(-i+j >= cm)break;
			if(-i+j < 0)continue;
			if(!match(a[j],c[-i+j]))ac[i+10000]=true;
		}
	}
	reg(i,-8001,8001){  // cの位置
		rep(j,bm){
			if(-i+j >= cm)break;
			if(-i+j < 0)continue;
			if(!match(b[j],c[-i+j]))bc[i+10000]=true;
		}
	}
	reg(i,-4000,4000){  // b
		reg(j,-4000,4000){  // c
			bool ok=true;
			if(ab[i+10000])ok=false;
			if(ac[j+10000])ok=false;
			if(bc[j-i+10000])ok=false;
			if(ok){
				int t = max({am, bm+i, cm+j})-min({0,i,j});
				if(ans>t){
					ans = t;
					ans2[0]=i;
					ans2[1]=j;
				}
			}
		}
	}
	cerr<<ans2[0]<<", "<<ans2[1]<<endl;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic

signed main()
{
    Int(n);
    vi l(n), r(n);
    rep(i, n) {
        cin >> l[i];
    }
    rep(i, n) {
        cin >> r[i];
    }

    vb rcheck(n, false), lcheck(n, false);
    rcheck[n-1] = true; lcheck[0] = true;
    Rep(i, n) {
        if (l[i] != l[i-1]) {
            lcheck[i] = true;
        }
    }

    for (int i = n-1; i > 0; i--) {
        if (r[i] != r[i-1]) {
            rcheck[i-1] = true;
        }
    }

    rep(i, n) {
        if (rcheck[i] && lcheck[i] && 
                r[i] != l[i]) {
            std::cout << 0 << std::endl;
            return 0;
        }
        if (rcheck[i] && !lcheck[i] && 
                r[i] > l[i]) {
            std::cout << 0 << std::endl;
            return 0;
        }
        if (!rcheck[i] && lcheck[i] && 
                r[i] < l[i]) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    /*
    rep(i, n) {
        cout << lcheck[i] << " ";
    }
    cout << endl;
    rep(i, n) {
        cout << rcheck[i] << " ";
    }
    cout << endl;
    */


    int ans = 1;
    rep(i, n) {
        if (!rcheck[i] && !lcheck[i]) {
            ans *= min(r[i], l[i]);
            ans %= MOD;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}





Measured memory_bytes: 1792
def run(h, w, a):
    move = []
    for i in range(h):
        if i % 2 == 0:
            for j in range(w):
                if a[i][j] % 2 == 1:
                    if j < w-1:
                        move.append([i+1, j+1, i+1, j+2])
                        a[i][j] -= 1
                        a[i][j+1] += 1
                    elif i < h-1:
                        move.append([i+1, j+1, i+2, j+1])
                        a[i][j] -= 1
                        a[i+1][j] += 1
        else:
            for j in range(w-1, -1, -1):
                if a[i][j] % 2 == 1:
                    if j > 0:
                        move.append([i+1, j+1, i+1, j])
                        a[i][j] -= 1
                        a[i][j-1] += 1
                    elif i < h-1:
                        move.append([i+1, j+1, i+2, j+1])
                        a[i][j] -= 1
                        a[i+1][j] += 1
    return move


def main():
    h, w = map(int, input().split())
    a = []
    for i in range(h):
        a.append(list(map(int, input().split())))
    move = run(h, w, a)
    print(len(move))
    for mv in move:
        mv = map(str, mv)
        print(' '.join(mv))


if __name__ == '__main__':
    main()


Measured memory_bytes: 29848
n,m=io.read("*n","*n","*l")
a={}
for i=1,n do
    a[i]={}
    a[i][1],a[i][2]=io.read("*n","*n")
end
table.sort(a,function(x,y)
    if x[1]~=y[1] then
        return x[1]<y[1]
    else
        return x[2]>y[2]
    end
end)

drink=0
yen=0
for i=1,n do
    if m-drink<a[i][2] then
        yen=yen+a[i][1]*(m-drink)
        print(yen)
        return
    else
        drink=drink+a[i][2]
        yen=yen+a[i][1]*a[i][2]
    end
end
print(yen)

Measured memory_bytes: 13304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,l,r) for(int i=l;i<r;i++)
const int inf=2e9+10;
const int INF=9e18+10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const ll MOD=1e9+7;

int main(){
    int n;cin>>n;
    int a[n],b[n];
    int x,y;
    rep(i,n){
        scanf("%d %d",&x,&y);
        x--;y--;
        a[x]=y;
        b[i]=x;
    }
    stack<pair<int,int> > s;//<最も小さいyの値,要素数> 
    rep(i,n){
        int miny=a[i];
        int sum=1;
        while(!s.empty()&&s.top().first<a[i]){
            miny=min(miny,s.top().first);
            sum+=s.top().second;
            s.pop();
        }
        s.push(make_pair(miny,sum));
    }
    int ans[n];
    int i=n-1;//iで次埋めるべきx座標の場所を保持
    while(!s.empty()){
        pair<int,int> p=s.top();
        for(int j=i;j>i-s.top().second;j--){
            ans[j]=s.top().second;
        }
        i-=s.top().second;
        s.pop();
    }    
    rep(i,n){
        cout<<ans[b[i]]<<endl;
    }

    return 0;
}

Measured memory_bytes: 6244
#include <bits/stdc++.h>
using namespace std;
int k = 55555;
int a[55555]={};
int main(){
    int n;
    cin >> n;
    for(int i=2;i<=k;i++){
        for(int j=i;j<=k;j+=i) a[j]++;
    }
    for(int i=2;i<=k;i++){
        if(a[i]==1){
            if(i%5==2&&n>0){
                cout << i << ' ';
                n--;
            }
        } 
    }
    cout << endl;
}

Measured memory_bytes: 3776
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;


int main() {

    ll N, D ,X;
    cin >> N >> D >> X;

    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ll t = 0; cin >> t;
        ans += D / t;
        if(D % t > 0){
            ans++;
        }
    }

    cout << ans + X << endl;

}

Measured memory_bytes: 256
w=gets.chomp
cnt=Array.new(26,0)
w.length.times do |i|
  cnt[w[i].ord-'a'.ord]+=1
end
res=0
26.times do |s|
  if cnt[s]%2!=0
    puts "No"
    break
  end
  res+=1
end
if res==26
  puts "Yes"
end
#puts cnt


Measured memory_bytes: 1788
def create_fact_mod(num_max)
    $fmod = Array.new(num_max + 1)
    $fmod[0] = 1
    $fmod[1] = 1
    (2..num_max).each do |i|
        $fmod[i] = ($fmod[i - 1] * i) % MOD
    end
end

def create_seq_inv_mod(num_max)
    $simod = Array.new(num_max + 1)
    $simod[0] = 1
    $simod[1] = 1
    (2..num_max).each do |i|
        $simod[i] = (MOD - MOD / i) * $simod[MOD % i] % MOD
    end
end

def create_fact_inv_mod(num_max)
    $fimod = Array.new(num_max + 1)
    $fimod[0] = 1
    $fimod[1] = 1
    (2..num_max).each do |i|
        $fimod[i] = ($fimod[i - 1] * $simod[i]) % MOD
    end
end

def create_mod_tables(n)
    create_fact_mod(n)
    create_seq_inv_mod(n)
    create_fact_inv_mod(n)
end

def comb_mod(n, k)
    return $fmod[n] * $fimod[n - k] * $fimod[k] % MOD
end


require 'prime'
N, M = gets.split.map(&:to_i)
pn = Prime.prime_division(M).map{|a| a[1]}
MOD = 10**9+7

create_mod_tables(N+100)

ans = 1
pn.each do |num|
    ans *= comb_mod(N-1+num, num)
    ans %= MOD
end
puts ans

Measured memory_bytes: 4348
# ARC097D

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))

n, m = map(int, input().split())
p = list(map(lambda x: int(x)-1, input().split()))
from collections import defaultdict
es = defaultdict(set)
for i in range(m):
    u,v = map(int, input().split())
    es[u-1].add(v-1)
    es[v-1].add(u-1)
    
count = 0
seen = [False] * n
for u in range(n):
    index = set()
    values = set()
    if seen[u]:
        continue
    index.add(u)
    values.add(p[u])
    q = [u]
    seen[u] = True
    while q:
        u = q.pop()
        for v in es[u]:
            if not seen[v]:
                q.append(v)
                seen[v] = True
                index.add(v)
                values.add(p[v])
    count += len(index & values)
print(count)

Measured memory_bytes: 104172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B {
    class questionB {
        static void Main(string[] args) {
            int A = int.Parse(Console.ReadLine()); //標準入力
            int B = int.Parse(Console.ReadLine()); //標準入力
            int C = int.Parse(Console.ReadLine()); //標準入力
            int X = int.Parse(Console.ReadLine()); //標準入力
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            int count = 0;
            for (int i = 0; i <= A; i++) {
                if (i * 500 <= X) {
                    int money = X - i * 500;
                    for (int j = 0; j <= B; j++) {
                        if(100 * j <= money && (money - j * 100) / 50 <= C) {
                            count++;
                        }
                    }
                }
            }
            Console.WriteLine(count.ToString());
        }
    }
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)


const ll mod = 1000000007;

int main(void)
{
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string s;
	cin >> s;

	auto minab = min(a, b);
	auto maxcd = max(c, d);
	const char path = '.';
	const char wall = '#';
	auto prev = path;
	repi(i, minab, maxcd) {
		if (s[i] == wall) {
			if (prev == wall) {
				cout << "No" << endl;
				return 0;
			}
		}
		prev = s[i];
	}
	if (c < d) {
		cout << "Yes" << endl;
		return 0;
	}
	int ok = 0;
	repi(i, b-1, min(d+2,n)) {
		if (s[i] == path) {
			ok++;
		}
		else {
			ok = 0;
		}
		if (ok >= 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    int b[100];
    std::cin >> n;
    for (int i = 0; i < n-1; i++) {
        std::cin >> b[i];
    }
    long long int sum=0;
    int a[100];
    a[0]=b[0];
    a[1]=b[0];
    for (int i = 1; i <n-1;i++) {
        if(b[i]<b[i-1]){
            a[i]=b[i];
        }
        a[i+1]=b[i];
    }
    for (int i = 0; i < n; i++) {
        sum+=a[i];
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;

#define EPS (1e-10)
#define equals( A, B ) (fabs((A) - (B)) < EPS)

class Point {
public:
    double x, y;
    Point( double x = 0, double y = 0 ): x(x), y(y) {}
    
    Point operator + ( Point p ) { return Point( x + p.x, y + p.y ); }
    Point operator - ( Point p ) { return Point( x - p.x, y - p.y ); }
    Point operator * ( double a ) { return Point( a * x, a * y ); }
    Point operator / ( double a ) { return Point( x / a, y / a ); }

    double abs() { return sqrt( norm() ); }
    double norm() { return x * x + y * y; }

    bool operator < ( const Point &p ) const {
	return ( x != p.x ) ? x < p.x : y < p.y;
    }

    bool operator == ( const Point &p ) const {
	return equals( x, p.x ) && equals( y, p.y ); 
    }

    double dot( Point a ) { return x * a.x + y * a.y; }
    double cross( Point a ) { return x * a.y - y * a.x; }
};

typedef Point Vector;

class Line {
public:
    Point p1, p2;
    Line( Point p1 = Point(), Point p2 = Point() ): p1(p1), p2(p2) {}
    // ?????´????????????( cos = 0 )
    bool isOrthogonal( Line a ) {
	return equals( 0.0, (p1 - p2).dot( a.p1 - a.p2 ) );
    }
    // ??????????????????( sin = 0 )
    bool isParallel( Line a ) {
	return equals( 0.0, (p1 - p2).cross( a.p1 - a.p2 ) );
    }
};

typedef Line Segment;



int q;

int main()
{
    Line l01, l23;
    Point p0, p1, p2, p3;

    scanf("%d", &q);

    for ( int i = 0; i < q; i++ ) {
	scanf("%lf %lf", &p0.x, &p0.y);
	scanf("%lf %lf", &p1.x, &p1.y);
	scanf("%lf %lf", &p2.x, &p2.y);
	scanf("%lf %lf", &p3.x, &p3.y);
	l01 = Line( p0, p1 );
	l23 = Line( p2, p3 );

	if ( l01.isParallel( l23 ) ) printf("2\n");
	else if ( l01.isOrthogonal( l23 ) ) printf("1\n");
	else printf("0\n");
    }

    return 0;
}

Measured memory_bytes: 1048
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int n,a,b,c,d;
vec x;
int cnt_rock=0,cnt_emp=0,max_rock=0,max_emp=0;
bool f(){
    if(max_rock>1)return false;
    if(c<d){
        return true;
    }else{
        rep2(i,b,d){
            if(x[i-1]==0&x[i]==0&x[i+1]==0)return true;
        }
        return false;
    }
}
int main(){
    n=in();
    a=in();
    b=in();
    c=in();
    d=in();
    string s=stin();
    x.resize(n+1);
    rep(i,n){
        if(s[i]=='#'){
            x[i+1]=1;
        }
        else{
            x[i+1]=0;
        }
    }
    rep2(i,a+1,c-1){
        if(x[i]==1){
            cnt_rock++;
        }
        else{
            cnt_rock=0;
        }
        max_rock=max(max_rock,cnt_rock);
    }
    cnt_rock=0;
    rep2(i,b+1,d-1){
        if(x[i]==1){
            cnt_rock++;
        }
        else{
            cnt_rock=0;
        }
        max_rock=max(max_rock,cnt_rock);
    }
    string ans=f()?"Yes":"No";
    cout<<ans<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N-1,0);
    for (int i = 0; i < N-1; i++) cin >> A.at(i);
    vector<int> ans(N);
    for (int i=0;i<N-1;i++) ++ans.at(A.at(i)-1);
    for (int i=0;i<N;i++) cout << ans.at(i) << endl;
    
    return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define maxs 100000
#define infty (1<<30)

class Edge{
public:
  int t,w;
  Edge(){}
  Edge(int t,int w):t(t),w(w){}
};

vector<Edge> g[maxs];
int n,d[maxs];

bool vis[maxs];
int cnt;

void bfs(int s){
  for(int i=0;i<n;i++)d[i]=infty;
  queue<int> q;
  q.push(s);
  d[s]=0;
  int u;
  while(!q.empty() ){
    u=q.front();q.pop();
    for(int i=0;i<g[u].size();i++){
      Edge e=g[u][i];
      if(d[e.t]==infty){
	d[e.t]=d[u]+e.w;
	q.push(e.t);
      }
    }
  }
}

void solve(){
  bfs(0);
  int maxv=0;
  int tgt=0;
  for(int i=0;i<n;i++){
    if(d[i]==infty)continue;
    if(maxv<d[i]){
      maxv=d[i];
      tgt=i;
    }
  }
  bfs(tgt);
  maxv=0;
  for(int i=0;i<n;i++){
    if(d[i]==infty)continue;
    maxv=max(maxv,d[i]);
  }
  cout<<maxv<<endl;
}

int main(){
  int s,t,w;
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>s>>t>>w;
    g[s].push_back(Edge(t,w) );
    g[t].push_back(Edge(s,w) );
  }
  solve();
  return 0;
}

Measured memory_bytes: 9876
import sys
import collections

from operator import itemgetter

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    AB = [[int(x) for x in input().split()] for _ in range(N)]

    C = []

    for i, (a, b) in enumerate(AB):
        C.append((a + b, i))

    C.sort(reverse=True)

    takahashi = 0
    aoki = 0
    for i in range(N):
        j = C[i][1]
        if i % 2 == 0:
            takahashi += AB[j][0]
        else:
            aoki += AB[j][1]

    print(takahashi - aoki)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39700
#line 1 "agc040_a.cpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  vector<ll> a;
  string s;
  cin >> s;
  int n = s.length();
  char init = s[0], last = s[n - 1];
  ll count = 1;
  FOR(i, 1, n) {
    if (s[i] == s[i - 1]) {
      count++;
    } else {
      a.push_back(count);
      count = 1;
    }
  }
  a.push_back(count);

  ll ans = 0;
  if (init == '>') {
    ans += a[0] * (a[0] + 1) / 2;
    a.erase(a.begin());
    if (a.empty()) {
      cout << ans << endl;
      return 0;
    }
  }
  REP(i, a.size() - 1) {
    if (i % 2 != 0)
      continue;
    ll mi = min(a[i], a[i + 1]);
    ll ma = max(a[i], a[i + 1]);
    ans += mi * (mi - 1) / 2;
    ans += ma * (ma + 1) / 2;
  }
  if (last == '<') {
    ans += a[a.size() - 1] * (a[a.size() - 1] + 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(0);
    ll L,R;cin >> L >> R;
    if((L / 2019) != (R / 2019)){
        cout << "0\n";return 0;
    }
    L %= 2019;R %= 2019;ll ans = 3e9 + 20;
    ll l = min(L,R);ll r = max(L,R);
    for(ll i = l ; i < r ;i++){
        for(ll j = i + 1 ; j <= r;j++){
            ll cur = i * j % 2019;
            ans = min(ans,cur);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
//#include <cstdio>
//#include <cstdlib>
//#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int a, b;
	// char ;

	cin >> a >> b;
	
	if(a < b) cout << "a < b" << endl;
	else if(a > b) cout << "a > b" << endl;
	else cout << "a == b"<<endl;

	return 0;
}

/*
for(i=0;i<N;i++){
	cin >> X[i];
}


for(i=0;i<N;i++){
	for(j=0;j<N;j++){
		cin >> X[i][j];
	}
}
*/

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int mult(int N, int64_t x){
  if(N > 0){
    N--;
    return ((mult(N,x)*x) % (1000000007));
  }else{
    return 1;
  }
}

int main(){//main_program
  int N;
  int64_t a,b,c,ANS;
  cin >> N;
  
  a = mult(N,10);
  b = mult(N,8);
  c = mult(N,9);
  ANS = ( a + b +1000000007+1000000007- 2 * c ) % (1000000007);
  
  //cout << a <<":"<< b <<":"<< c <<endl;
  //cout << a + b - 2 * c <<endl;
  cout << ANS <<endl;
}


Measured memory_bytes: 19160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int a, b; cin >> a;
	b = a % 100; a /= 100;
    if (!a && !b)cout << "NA\n";
	else if (!a && b <= 12)cout << "YYMM\n";
	else if (a <= 12 && !b)cout << "MMYY\n";
	else if (!a || !b)cout << "NA\n";
	else if (a <= 12 && b <= 12)cout << "AMBIGUOUS\n";
	else if (a <= 12 && b > 12)cout << "MMYY\n";
	else if (a > 12 && b <= 12)cout << "YYMM\n";
	else cout << "NA\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a;

        int ans = 0;

        for(int i=0;i<N;i++){
            a = sc.nextInt();

            while(a%2 == 0){
                a /= 2;
                ans++;
            }
        }


        System.out.println(ans);

    }
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; j < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
class segtree {
 private:
  int n;
  vector<T> data, lazy;

 public:
  segtree(int n_) {
    n = pow(2, ceil(log2(n_)));
    data.resize(n);
    lazy.resize(n);
    auto __x = data[0];
    repi(n) {
      data[i] = __vmin(__x);
      lazy[i] = 0;
    }
  }
};

int main() {
  int n;
  cin >> n;
  vector<double> v;
  v.resize(n);
  repi(n) cin >> v[i];
  int s = n;
  while (s > 1) {
    sort(v.begin(), v.end(), greater<int>());
    v[s - 2] = (v[s - 2] + v[s - 1]) / 2;
    v.pop_back();
    s--;
  }
  cout.precision(10);
  cout << v[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 28;
constexpr lint   INFL = 1LL << 60;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, t;
  cin >> n >> t;
  vector<pair<int, int>> ab(n);
  rep (i, n) cin >> ab[i].first >> ab[i].second;
  vector<vector<int>> dpl(n + 1, vector<int>(t)), dpr(n + 1, vector<int>(t));
  rep1 (i, n) {
    int li = i - 1, ri = n - i;
    rep (j, t) {
      int lnext = j + ab[li].first, rnext = j + ab[ri].first;
      dpl[i][j] = max(dpl[i][j], dpl[i - 1][j]);
      if (lnext < t) dpl[i][lnext] = max(dpl[i][lnext], dpl[i - 1][j] + ab[li].second);
      dpr[n - i][j] = max(dpr[n - i][j], dpr[n - i + 1][j]);
      if (rnext < t) dpr[n - i][rnext] = max(dpr[n - i + 1][rnext], dpr[n - i + 1][j] + ab[ri].second);
    }
  }
  int maxi = 0;
  rep (i, n) {
    rep (j, t) {
      int sum = dpl[i][j] + dpr[i + 1][t - 1 - j];
      maxi = max(maxi, sum + ab[i].second);
    }
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 70912
import Data.Array((!), listArray)
main = interact $ show.helper.(map read).words

helper (x:xs) = fonk x a 1
            where a = listArray (1, x) xs

fonk x a i = f i
        where 
            f i 
                | x == i = 0
                | x - 1 == i  = abs((a!i) - a!(i+1))
                | otherwise = min ((ll ! (i + 1)) + abs((a!i) - a!(i+1))) 
                    ((ll ! (i + 2)) + abs((a!(i)) - a!(i+2)))
            ll = listArray (1, x) $ map f [1..x]

Measured memory_bytes: 41340
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =998244353 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    ll n , d ;
    cin >> n >> d ;
    int ans = 0 ;
    for( int i = 0 ; i < n ; i++){
        ll x , y ;
        cin >> x >> y ;
        ll k = x*x+y*y;
        if(k <= d*d) ans++;
    }
    cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
//   cin >> t ;
    while(t--){
        solve( );
    }
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 5 * 10000 + 1
#define INF 1000000000
const int MAX_VALUE = int(1e5+10);
int n, w;
vector<ll> dp(MAX_VALUE, INF+1); // dp[i] is the minimum weight required to pack elements such that the total value sum is i. 
vector<pair<ll, ll> > elems;  // weight, value
ll a, b;
int main()
{
    cin >> n >> w;
    while(n--)
    {
        cin >> a >> b; // weight, value
        elems.push_back({a, b});
    }
    dp[0] = 0; // base case, we need a knapsack with capacity dp[0] = 0 to add up elements with total value i = 0.
    for (pair<ll, ll> elem: elems)
    {
        for (int i = MAX_VALUE; i - elem.second >= 0; --i)
        {
            dp[i] = min(dp[i], dp[i - elem.second] + elem.first);
        }
    }
    int ans = -1;
    for (int i = MAX_VALUE-1; i >= 0 && ans == -1; --i)
    {
        if (dp[i] <= w)
        {
            //printf("dp[%d] is %d\n", i, dp[i]);
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main()
{
	long long n,a,b;
	while(~scanf("%lld",&n))
	{a=sqrt(n)+1;
	 while(n%a!=0)
	 {a--;
	 }
	 b=n/a;
	 printf("%lld\n",a+b-2);
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
 
    static void Main()
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();
        int Sa = S.Length;
        int Ta = T.Length;
 
 
        int An = Ta - Sa;
 
        if (An == 1 && T.Substring(0, Sa) == S)
        {
            Console.WriteLine("Yes");
        }
        else
            Console.WriteLine("No");
 
 
 
    }



}



Measured memory_bytes: 25880
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif
 
const int mod = 1e9 + 7;
 
int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}
 
const int N = 4005;
int pre[3][N];
string ss = "RGB";
 
void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < 3; j++) {
			pre[j][i] = pre[j][i - 1] + (s[i - 1] == ss[j]);
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			if(s[i] == s[j]) continue;
			char ch = s[i] ^ s[j] ^ 'R' ^ 'B' ^ 'G';
			int k;
			for(int l = 0; l < 3; l++) {
				if(ss[l] == ch) k = l;
			}
			ans += pre[k][n] - pre[k][j];
			int kk = i + (j - i) * 2;
			if(kk < n && s[kk] == ch) {
				ans--;
			}
		}
	}
	cout << ans;
}
 
int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3696
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n;
    cin>>n;
    while(n--){
        int h,m;
        scanf("%d:%d",&h,&m);
        double h_angle,m_angle;
        h_angle = h/12.0 + m/720.0;
        m_angle = m/60.0;
        double d = fabs(h_angle - m_angle);
        d = min(d,1.0-d);
        if(d < 1.0/12)cout<<"alert"<<endl;
        else if(d >= 1.0/4)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }


    return 0;
}

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

signed
main(){
	string s;
	while(cin>>s, s[0]!='-'){
		int m; cin>>m;
		for(int i=0; i<m; i++){
			int h; cin>>h;
			rotate(s.begin(), s.begin()+h, s.end());
		}
		cout << s << endl;
	}
	return 0;
}



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

int main() {
	string a,b,c;
	cin>>a>>b;
	
	for(int i=0;i<a.length()+b.length();i++)
	{
	    if(i%2==0)
	    {
	        cout<<a[i/2];
	    }
	    else
	    {
	        cout<<b[i/2];
	    }
	    
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
  
struct node_t {
    int key;
    struct node_t *next;
};
typedef struct node_t Node;
  
Node *enqueue(Node *node, int key) {
  Node *p, *q;
   
  if (node == NULL) {
    node = malloc(sizeof(Node));
    node->key = key;
    node->next = NULL;
    return node;
  }
   
  for (p = node; p != NULL; p = p->next) {
    q = p;
  }
  q->next = malloc(sizeof(Node));
  q->next->key = key;
  q->next->next = NULL;
  return node;
}
 
Node *dequeue(Node *node, int *key) {
  Node *p;
   
  if (node != NULL) {
    *key = node->key;
    p = node->next;
    free(node);
        return p;
  }
  return NULL;
}
 
int main(void) {
  int num, i, j, k, u;
  int way[101][101] = {{0}};
  int d[101];
  Node *q = NULL;
   
  scanf("%d", &num);
  for (i = 0; i < num; i++) {
    scanf("%d %d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d", &way[u-1][j]);
    }
  }
  
  d[0] = 0;
  for (i = 1; i < num; i++) {
    d[i] = -1;
  }
  q = enqueue(q, 0);
   
  while (q != NULL) {
    q = dequeue(q, &u);
    for (i = 0; i < num; i++) {
      k = way[u][i] - 1;
      if (d[k] < 0) {
    d[k] = d[u] + 1;
    q = enqueue(q, k);
      }
    }
  }
   
  for (i = 0; i < num; i++) {
    printf("%d %d\n", i+1, d[i]);
  }
  return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main(){
    int n,m;
    int ms = 1900;
    int ms2 = 100;
    
    float r = 0;

    cin >> n >> m;

    r = ( (ms*m + (ms2*(n-m))) * (pow(2,m)) );

    cout << r << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define ll long long

ll c(ll n, ll r) {
  double ans = 1;
  ll sub = n - r;
  if (sub < r) {
    swap(sub, r);  
  }  
  int now = n;
  for (int i = 1; i <= r; i++) {
    ans = ans * now / i;
    now--;  
  }
  return (ll) ans;
}

int main () {
  ll n, a, b;
  cin >> n >> a >> b;
  ll v[n];
  map<ll, ll> count;
  for (ll i = 0; i < n; i++) {
    cin >> v[i];  
    count[v[i]]++;
  }  
  sort(v, v + n);
  ll ans2 = 0;
  double ans1 = 0;
  ll check = v[n - a];
  ll num = 0;
  for (ll i = 0; i < a; i++) {
    ans1 += v[n - 1 - i];  
    if (check == v[n - 1 - i]) {
      num++;  
    }
  }
  cout << fixed << ans1 / a << endl;
  for (ll i = a; i <= b; i++) {
    ll now = num + (i - a); // now回checkを使える.
    if (now > count[check]) {
      break;  
    }        
    if (i == a) {
      ans2 += c(count[check], now);
    }
    else {
      if (num == a) {
        ans2 += c(count[check], now);  
      }  
    }
  }
  cout << ans2 << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

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

int main(int argc, char** argv) {
  int a, b;
  while (~scanf("%d%d", &a, &b)) {
    printf("%d\n", gcd(a,b));
  }
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //

int main() {
	in(ll, N, K);
	YESNO((N+1)/2 >= K);
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

type Edge struct {
    i int
    j int
}

func main() {
    N := scanInt()
    var edges []Edge
    if N % 2 == 0 {
        for i := 1; i <= N; i++ {
            for j := 0; j <= N; j++ {
                if i < j && i + j != N + 1 {
                    edges = append(edges, Edge{ i, j })
                }
            }
        }
    } else {
        for i := 1; i <= N; i++ {
            for j := 1; j <= N; j++ {
                if i < j && i + j != N {
                    edges = append(edges, Edge{ i, j })
                }
            }
        }
    }
    fmt.Println(len(edges))
    for _, edge := range edges {
        fmt.Println(edge.i, edge.j)
    }
}

func scanInt() (num int) {
    fmt.Scan(&num)
    return
}

func scanInts(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanString() (str string) {
    fmt.Scan(&str)
    return
}

func scanStrings(len int) (strs []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scan(&str)
        strs = append(strs, str)
    }
    return
}

Measured memory_bytes: 1024
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int r;
    cin>>r;
    int s = 3*r*r;
    cout<<s<<endl;

    return 0;
}


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

const int END = -1;
struct StNod
{
  int m_nDept;
  int m_nHigh;
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
    m_nDept(END), m_nHigh(END), m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

void fnInput(vector<StNod>& rvoNod)
{
  StNod oNod;
  int nMaxSiz;

  cin >> nMaxSiz;
  rvoNod.resize(nMaxSiz, oNod);

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nParnt, nLeft, nRigt;
    cin >> nParnt >> nLeft >> nRigt;

    rvoNod[nParnt].m_nLeft = nLeft;
    rvoNod[nParnt].m_nRigt = nRigt;
    if (nLeft != END)  rvoNod[nLeft].m_nParnt = nParnt;
    if (nRigt != END)  rvoNod[nRigt].m_nParnt = nParnt;
  }
}

void fnSetDepth(vector<StNod>& rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nLeft != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLeft, nDept + 1);

  if (rvoNod[nx].m_nRigt != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRigt, nDept + 1);
}

int fnSetHight(vector<StNod>& rvoNod, int nx)
{
  int nLHigh = 0, nRHigh = 0;

  if (rvoNod[nx].m_nLeft != END)
    nLHigh = fnSetHight(rvoNod, rvoNod[nx].m_nLeft) + 1;
  if (rvoNod[nx].m_nRigt != END)
    nRHigh = fnSetHight(rvoNod, rvoNod[nx].m_nRigt) + 1;
  
  return rvoNod[nx].m_nHigh = max(nLHigh, nRHigh);
}

void fnBinTree(vector<StNod>& rvoNod)
{
  int nx = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  int nDept = 0;
  fnSetDepth(rvoNod, nx, nDept);
  fnSetHight(rvoNod, nx);
}

void fnResult(const vector<StNod>& cnrvoNod)
{
  for (int i = 0; i < cnrvoNod.size(); i++)
  {
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", sibling = ";

    if (cnrvoNod[i].m_nParnt == END)  cout << END;
    else
    {
      int nx = cnrvoNod[i].m_nParnt;
      if (i == cnrvoNod[nx].m_nLeft)  cout << cnrvoNod[nx].m_nRigt;
      else                            cout << cnrvoNod[nx].m_nLeft;
    }
    
    cout << ", degree = ";
    int nCCnt = 0;
    if (cnrvoNod[i].m_nLeft != END)  nCCnt++;
    if (cnrvoNod[i].m_nRigt != END)  nCCnt++;
    cout << nCCnt << ", depth = " << cnrvoNod[i].m_nDept << ", height = " << cnrvoNod[i].m_nHigh;

    if (!cnrvoNod[i].m_nDept)       cout << ", root";
    else if (!cnrvoNod[i].m_nHigh)  cout << ", leaf";
    else                            cout << ", internal node";
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnBinTree(voNod);
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 3144
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

string S;

bool atcg(char c) {
  return c == 'A' || c == 'T' || c == 'C' || c == 'G';
}

void input() {
  cin >> S;
}

void solve() {
  int max_ = 0;
  int count = 0;
  for (auto c: S) {
    if (atcg(c)) {
      count++;
      if (max_ < count) max_ = count;
    }
    else count = 0;
  }
  cout << max_ << endl;
}

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


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

using Weight = long long;
using Vertex = int;
struct Edge {Vertex from, to; Weight weight;};
using Graph = std::vector<std::vector<Edge>>;

std::vector<std::vector<Vertex>> connected_component(const Graph& G) {
  std::vector<std::vector<Vertex>> cc;
  std::vector<bool> used(G.size());
  std::function<void(int)> dfs = [&](int v) {
    cc.back().push_back(v);
    used[v] = true;
    for(const auto& e: G[v]) if(!used[e.to]) dfs(e.to);
  };
  for(Vertex v = 0; v < G.size(); ++v) if(!used[v]) {
    cc.push_back(std::vector<Vertex>());
    dfs(v);
  }
  return cc;
}

using I = long long;

I com2(I n) {return n * (n - 1) / 2;}

bool check(const auto& G, auto s) {
  vector<int> color(G.size(), -1);
  function<bool(Vertex, int)> dfs = [&](auto v, auto c) {
    if(color[v] != -1) return color[v] == c;
    color[v] = c;
    c ^= 1;
    for(const auto& e: G[v]) if(!dfs(e.to, c)) return false;
    return true;
  };
  return dfs(s, 0);
}

int main() {
  I N, M;
  cin >> N >> M;
  Graph G(N);
  for(auto i=0; i<M; ++i) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    G[u].push_back({u, v});
    G[v].push_back({v, u});
  }

  auto cc = connected_component(G);
  auto V = N - count_if(begin(cc), end(cc), [](const auto& v) {return v.size() == 1;});
  auto ans = N * N - V * V;
  I twocol = 0, obscure = 0;
  for(auto c: cc) if(c.size() != 1) {
    if(check(G, *begin(c))) ++twocol;
    else                    ++obscure;
  }
  ans += 2 * twocol + obscure;
  ans += 4 * com2(twocol) + 2 * com2(obscure);
  ans += 2 * twocol * obscure;
  cout << ans << endl;
}


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

int main() {
	int a, b, c, i, count;

	cin >> a >> b >> c;
	count = 0;
	for (i = a; i <= b; i++) {
		if ((c%i) == 0) {
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160