akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Windows;
using System.Collections.Generic;
using System.Linq;

class Program
{
  static int[] A;
  static int n;
    static void Main(string[] args)
    {
      //入力を受け取る
      n = int.Parse(Console.ReadLine());
      A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
      var q = int.Parse(Console.ReadLine());
      var m = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
      
      for(int i = 0; i < q ; i++){
        if(Solve(0,m[i])){
          Console.WriteLine("yes");
        }else{
          Console.WriteLine("no");
        }
      }
      
    }
  
    static bool Solve(int i,int m){
      if(m == 0){
        return true;
      }
      if(i >= n){
        return false;
      }
      var res = Solve(i+1,m)||Solve(i+1,m-A[i]);
      return res;
    }
  

}


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

using namespace std;

int sum(string n)
{
    int sum=0;
    for (int i=0; i<n.length(); ++i) {
        sum+=n[i]-'0';
    }
    return sum;
}

int main()
{
    string N;
    cin>>N;
    
    int max=0;
    for (int i=N.length()-1; i>=0; --i) {
        string copy = N;
        if(i-1>=0&&N[i-1]!='0')
        {
            for (int j=N.length()-1; j>=i; j--)
            {
                copy[j]='9';
            }
            copy[i-1]=(char)(copy[i-1]-1);
        }
        int s = sum(copy);
        max = max<s?s:max;
    }
    
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e6 + 120;
 


int main(){FAST;
    int a ,b;
    cin >> a >> b;
    if(a == b || a < b)
      cout << a;
           else
             cout << a - 1;
   return 0;
}
 












Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
vector<vector<int>> G;
int main(){
	cin>>N;
	G.resize(N+N-1);
	rep(i,N-1){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(N+i);
		G[y].pb(N+i);
		G[N+i].pb(x);
		G[N+i].pb(y);
	}
	int V = N+N-1;
	vector<vector<int>> d(V,vector<int>(V,1e9));
	rep(i,V) d[i][i] = 0;
	rep(i,V) for(int j:G[i]) d[i][j] = 1;
	rep(i,V) rep(j,V) rep(k,V) chmin(d[j][k],d[j][i]+d[i][k]);

	int A = 1e9;
	long long B = 0;

	rep(root,V){
		int R = 0;
		rep(i,V) chmax(R,d[root][i]);
		int a = R/2+1;
		long long L = 1;
		rep(dep,R){
			int mx = 0;
			rep(v,V) if(d[root][v]==dep){
				chmax(mx,(int)G[v].size());
			}
			if(dep>0) mx--;
			L *= mx;
		}
		if(A>a || (A==a && B>L)){
			A = a, B = L;
		}
	}
	cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <algorithm>
#include <map>
#include <numeric>
#include <iomanip>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 100;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */

/* main */
int main() {

    deque<int> dq;
    int q; cin >> q;
    while (q--) {

        int op; cin >> op;
        int x; cin >> x;
        if (op == 1) {
            cout << dq[x] << '\n';
        }
        else if (op == 2) {
            if (x == 0)
                dq.pop_front();
            else 
                dq.pop_back();
        }
        else {
            int y; cin >> y;
            if (x == 0)
                dq.push_front(y);
            else 
                dq.push_back(y);
        }
    }
}



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

const int MAX = 100105;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    COMinit();
    long long ans = 1;
    int m = M;
    for (int i = 2; i * i <= M; i++) {
        if (m % i != 0) continue;
        int cnt = 0;
        while (m % i == 0) {
            m /= i;
            cnt++;
        }
        ans = ans * COM(cnt + N - 1, N - 1) % MOD;
    }
    if (m != 1) ans = ans * N % MOD;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2560
a="0"+input()
b="1"+input()
dp=[[0]*len(b) for i in range(len(a))]
for i in range(len(a)):
    for j in range(len(b)):
        if a[i]==b[j]:
            if i>0 and j>0:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=1
        else:
            if i>0 and j>0:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])
            elif i==0 and j>0:
                dp[i][j]=dp[i][j-1]
            elif i>0 and j==0:
                dp[i][j]=dp[i-1][j]
            else:
                dp[i][j]=0

ans = []
x,y=len(a)-1,len(b)-1
lcs = dp[x][y]
while x > 0 or y > 0:
    if x-1 >= 0 and dp[x-1][y] == lcs:
        x -= 1
    elif y-1 >= 0 and dp[x][y-1] == lcs:
        y -= 1
    else:
        ans.append(a[x])
        y -= 1
        x -= 1
        
        lcs -= 1
print("".join(ans[::-1]))

Measured memory_bytes: 112220
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int k, x;
	cin >> k >> x;

	vector<int> bef(k-1);
	vector<int> aft(k-1);

	rep(i, k - 1) {
		bef[i] = x - 1 - i;
		aft[i] = x + 1 + i;
	}
	rep(i, k - 1)cout << bef[k - 2 - i] << endl;
	cout << x << endl;
	rep(i, k - 1)cout << aft[i] << endl;

	return 0;
}


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

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

  vector<int> a(4);
  a[0]=n[0]-'0';
  a[1]=n[1]-'0';
  a[2]=n[2]-'0';
  a[3]=n[3]-'0';

  vector<int> op(3);
  for (int bit = 0; bit < (1<<3); bit++)
  {
    int ans=a[0];
    for (int i = 0; i < 3; i++)
    {
      if((1<<i)&bit){
        ans+=a[i+1];
        op[i]=1;
      }
      else {
        ans-=a[i+1];
        op[i]=0;
      }
    }
    if(ans==7) break;    
  }

  for (int i = 0; i < 3; i++)
  {
    cout << a[i];
    if(op[i]) cout << '+';
    else cout << '-';
  }
  cout << a[3] << "=7" << endl;
}

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

using namespace std;

int n,m1,m2;

int p[100001], sz[100001];
int ans[100001];

int anc(int x)
{
	if (p[x] == x) return x;
	return p[x] = anc(p[x]);
}

void join(int x,int y)
{
	sz[anc(y)] += sz[anc(x)];
	p[anc(x)] = anc(y);
}

vector<int> Adj_1[100001], Adj_2[100001];

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

	cin >> n >> m1 >> m2;
	for (int i=1;i<=n;i++)
	{
		p[i] = i;
		sz[i] = 1;
	}
	for (int i=1;i<=m1;i++)
	{
		int u,v;
		cin >> u >> v;
		Adj_1[u].push_back(v);
		Adj_1[v].push_back(u);
		if (anc(u) != anc(v))
			join(u,v);
	}
	for (int i=1;i<=m2;i++)
	{
		int u,v;
		cin >> u >> v;
		Adj_2[u].push_back(v);
		Adj_2[v].push_back(u);
	}
	for (int i=1;i<=n;i++)
	{
		set<int> tmp;
		for (int j=0;j<Adj_1[i].size();j++)
			tmp.insert(Adj_1[i][j]);
		for (int j=0;j<Adj_2[i].size();j++)
			if (anc(i) == anc(Adj_2[i][j]))
				tmp.insert(Adj_2[i][j]);
		ans[i] = sz[anc(i)] - tmp.size() - 1;	
	}
	for (int i=1;i<=n;i++)
		cout << ans[i] << ' ';
}

Measured memory_bytes: 18296
n,k = map(int,input().split())
cnt = 0
snuke = [0]*n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        snuke[j-1] += 1
for i in snuke:
    if i == 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 67704
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}

class ModCom {
    public:
        vector<long long> fac;
        vector<long long> finv;
        vector<long long> inv;
        ModCom(int _n, long long _mod){
            assert(_n>=2);
            n = _n+1;
            mod = _mod;
            fac.assign(n,0);
            finv.assign(n,0);
            inv.assign(n,0);
            init();
        }

        long long com(int _n, int k){
            if(_n < k){return 0;}
            if(_n < 0 || k < 0){return 0;}
            return fac.at(_n) * (finv.at(k) * finv.at(_n - k) % mod) % mod;
        }

    private:
        int n;
        long long mod;

        void init(void){
            fac.at(0) = fac.at(1) = 1;
            finv.at(0) = finv.at(1) = 1;
            inv.at(1) = 1;
            for(int i = 2;i < n; i++){
                fac.at(i) = fac.at(i - 1) * i % mod;
                inv.at(i) = mod - inv.at(mod % i) * (mod / i) % mod;
                finv.at(i) = finv.at(i - 1) * inv.at(i) % mod;
            }
            return;
        }
};

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    vector<ll> x(N),csum(N+10, 0);
    rep(i,N) {cin>>x[i];}
    ModCom com(N+100, MOD);
    rep(i,N-1) {
        csum[i+1] = (csum[i] + com.fac[N-1] * com.inv[i+1]) % MOD;
    }
    ll res = 0;
    rep(i,N-1) {
        ll d = x[i+1] - x[i];
        res = (res + d * csum[i+1]) % MOD;
    }
    cout << res << endl;
    return 0;
}


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

string solve() {
  int D; cin >> D;
  if (D == 25) return "Christmas";
  if (D == 24) return "Christmas Eve";
  if (D == 23) return "Christmas Eve Eve";
  if (D == 22) return "Christmas Eve Eve Eve";
  assert(false);
}

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  cout << solve() << endl;
	   

  return 0;
}



Measured memory_bytes: 256
def solve():
    h, n = map(int, input().split())
    l = [list(map(int, input().split())) for i in range(n)]

    mxA = 10 ** 4
    dp = [[10**15 for i in range(h+1+mxA)] for i in range(n+1)]

    for i in range(n+1):
        dp[i][0] = 0

    for i in range(n):
        for sum_dam in range(h+1+mxA):
            if sum_dam-l[i][0]>=0:
                dp[i+1][sum_dam] = min(dp[i+1][sum_dam],  \
                                dp[i][sum_dam - l[i][0]] + l[i][1],  \
                                dp[i+1][sum_dam-l[i][0]] + l[i][1])
            dp[i+1][sum_dam] = min(dp[i+1][sum_dam], dp[i][sum_dam])

    print(min(dp[-1][h:h+mxA+1]))

if __name__ == '__main__':
    solve()

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

int main(void){
  int a, b, c, x;
  std::cin >> a >> b >> c >> x;

  int count = 0;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if (i*500 + j*100 + k*50 == x){
          count++;
        }
      }
    }
  }

  std::cout << count << std::endl;
  return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	x := nextInt()
	a := x / 500
	x -= a * 500
	c := a * 1000
	debugf("%d\n", c)
	a = x / 5
	x -= a * 5
	c += a * 5
	debugf("%d\n", c)

	_, _ = fmt.Fprintf(writer, "%d", c)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)

int main(){
  int x,y;
  cin >> x >> y;
  if(y%2==1){
    cout << "No" << endl;
  }
  else if(y/2-x<0||2*x-y/2<0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9 + 7;




int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);


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

	for (int i = 1; i <= n; i++)
	{
		if (cnt[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	

	return 0;
}


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

int main(){
 //N→各都市から何本の道路が伸びているかを管理する配列の長さ
 int N, M;
 cin >> N >> M;
  
 int NMMAX = 50;
 int A[NMMAX],B[NMMAX]; 
  
 for (int i = 0;i < M;i++) {
   cin >> A[i] >> B[i];
 }
  
 int road[NMMAX];
 for (int i = 0;i < N; i++) {
   road[i] = 0;
 }
  
 for (int i = 0; i < M; i++) {
   //23,24行目はある道路の両端が都市aと都市bだったときにインクリメントするよってこと
   road[A[i] - 1] += 1;
   road[B[i] - 1] += 1;
 }
  
 for (int i = 0; i < N; i++) {
   cout << road[i] << endl;
 }
}


Measured memory_bytes: 256
n = int(input())
h = []
for i in range(n):
  	h.append([int(x) for x in input().split(" ")])

dp = [[-float("inf")] *3 for i in range(n)]
for i in range(3):
  	dp[0][i] = h[0][i]

for i in range(n-1):
  dp[i+1][0] = max(dp[i+1][0], dp[i][1]+h[i+1][0], dp[i][2]+h[i+1][0])
  dp[i+1][1] = max(dp[i+1][1], dp[i][0]+h[i+1][1], dp[i][2]+h[i+1][1])
  dp[i+1][2] = max(dp[i+1][2], dp[i][0]+h[i+1][2], dp[i][1]+h[i+1][2])
  
print(max(dp[-1]))

Measured memory_bytes: 83032
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define SZ(x) (long long)x.size()
#define endl '\n'
#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define tc                                                                     \
  int tc;                                                                      \
  cin >> tc;                                                                   \
  while (tc--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define REPO(i, b, a) for (int i = b - 1; i >= a; i--)
#define REPI(i, a, b) for (int i = a; i <= b; i++)
#define MOD 1000000007
bool comp(pair<int, int> v, int val) { return v.ff < val; }
inline int read() {
  int t = 0;
  char c;
  while ((c = getchar_unlocked()) != '\n' && c != ' ' && c != EOF) {
    t = t * 10 + c - 48;
  }
  return t;
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
bool checkValidity(int a, int b, int c) {
  if (a + b <= c || a + c <= b || b + c <= a)
    return false;
  else
    return true;
}

int32_t main() {
  FAST;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("output.txt", "w", stderr);
#endif
  int n = read(), x = read(), t = read();
  if (n < x) {
    cout << t;
  } else if (n % x == 0) {
    cout << (n / x) * t;
  } else {
    cout << ((n / x) + 1) * t;
  }
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>                                                             
#include <string>                                                               
                                                                                
using namespace std;                                                            
                                                                                
int main(void) {                                                                
  string str;                                                                   
  int ans(0);                                                                   
  cin >> str;                                                                   
  for (int i(0); i < 4; i++) {                                                  
    if (str[i] == '+')                                                          
      ans++;                                                                    
    else                                                                        
      ans--;                                                                    
  }                                                                             
  cout << ans;                                                                  
  return 0;                                                                     
}   

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

namespace ConsoleApp15
{
    class Class374
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var G = new List<Tuple<int,int>>[N];
            for (int i = 0; i < N; i++) G[i] = new List<Tuple<int, int>>();
            for (int i = 0; i < N-1; i++)
            {
                var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
                G[r[0] - 1].Add(Tuple.Create(r[1] - 1, r[2]));
                G[r[1] - 1].Add(Tuple.Create(r[0] - 1, r[2]));
            }
            int[] ans = Enumerable.Repeat(-1, N).ToArray();
            ans[0] = 0;
            var que = new Queue<Tuple<int, int>>();
            que.Enqueue(Tuple.Create(0, 0));
            while (que.Count > 0)
            {
                var t = que.Dequeue();
                foreach(var i in G[t.Item1])
                {
                    if(ans[i.Item1] == -1)
                    {
                        ans[i.Item1] = (t.Item2 + i.Item2) % 2;
                        que.Enqueue(Tuple.Create(i.Item1, ans[i.Item1]));
                    }
                }
            }
            foreach(int i in ans)
                Console.WriteLine(i);
        }
    }
}


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

int gcd(int m, int n) {
	if(n==0||m==0)return m+n;
	return gcd(n%m, m);
}

int main() {
	int n;
	cin>>n;
	int a[3] = {};
	int g;
	if(n==2) {
		cin>>a[0]>>a[1];
		sort(a,a+n);
		g = gcd(a[0],a[1]);
		for(int i=1;i<=g;i++) {
			if(g%i==0)cout<<i<<endl;
		}
	}else if(n==3) {
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+n);
		g = gcd(a[0],a[1]);
		g = gcd(g, a[2]);
		for(int i=1;i<=g;i++) {
			if(g%i==0)cout<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1176
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    H, W = nm()
    h, w = nm()
    print((H - h) * (W - w))


if __name__ == '__main__':
    main()


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

//解説参考
int main() {
	string s;
	cin >> s;


	reverse(s.begin(), s.end());

	while (s != "") {
		if (s.substr(0, 5) == "maerd") s = s.substr(5);
		else if (s.substr(0, 7) == "remaerd") s = s.substr(7);
		else if (s.substr(0, 5) == "esare") s = s.substr(5);
		else if (s.substr(0, 6) == "resare") s = s.substr(6);
		else break;
	}


	cout << ((s.size()) ? "NO" : "YES") << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main(void){
    long int i, n, min = 0, max = 0;
    scanf("%ld", &n);
    
    for( i = 1; i <= sqrt(n); i++ ){
        if( n % i == 0 ){
            min = i;
        }
    }
    
    max = n / min;
    printf("%ld\n", min+max-2);
    return 0;
}

Measured memory_bytes: 128
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

int main(){
    FASTIO
    ll a, b, k;
  cin >> a >> b >> k;
  ll t = min(a, k);
  a -= t;
  k -= t;
  t = min(b, k);
  b -= t;
  k -= t;
    cout << a << " " << b;
     return 0;
}


Measured memory_bytes: 256
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
mod = 10**9 + 7

n = int(input())
a = [int(x) for x in input().split()]
g = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v = map(int, input().split())
    g[u - 1].append(v - 1)
    g[v - 1].append(u - 1)
from collections import defaultdict
import bisect
def dfs(u):
    ans = [-1]*n # 各最長増加部分列の長さ
    stack = [u] # u: 頂点
    operation = defaultdict(list) # 行った操作
    used = [False]*n # 1回目: False 2回目: True
    dp = [float("inf")]*n
    dp[0] = a[u]
    used[u] = False
    length = 1
    operation[0] = [0, float("inf"), 0]
    ans[0] = 1
    while stack:
        # print(dp)
        u = stack[-1]
        if used[u] == False:
            used[u] = True
            idx = bisect.bisect_left(dp, a[u])
            operation[u] = [idx, dp[idx], length]
            dp[idx] = a[u]
            length = max(length, idx + 1)
            ans[u] = length
            for i in g[u]:
                if ans[i] > 0:
                    continue
                stack.append(i)
        else:
            idx, value, length = operation[u]
            dp[idx] = value
            stack.pop()
    return ans, used, dp
ans, used, dp = dfs(0)
print(*ans, sep="\n")
# print(used, dp)
                
            

Measured memory_bytes: 175996
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, Q;
    cin >> N >> Q;
    dsu U(N);
    for(int i = 0; i < Q; i++){
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) U.merge(u, v);
        else{
            if(U.same(u, v)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}

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

using namespace std;

int h[100005];
int n, k;

int dp[100005];

int solve(int i){

    if (i >= n-1) return 0;
    
    if(dp[i] != -1){
        return dp[i];
    }
    
    int ans = 1e9+7;

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

}


int main(){
    
    cin >> n >> k;
    
    memset(dp, -1, sizeof(dp));
    
    for(int i=0; i<n;i++){
        cin >> h[i];
    }
        
    cout << solve(0) << endl;

}

Measured memory_bytes: 5760
import java.util.*;
import java.awt.geom.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			double xa, ya, ra, xb, yb, rb, d; 
			for(int i=0;i<n;i++){
				xa = sc.nextDouble();
				ya = sc.nextDouble();
				ra = sc.nextDouble();
				xb = sc.nextDouble();
				yb = sc.nextDouble();
				rb = sc.nextDouble();
				d = Point2D.distance(xa, ya, xb, yb);

				if(ra+rb<d) System.out.println("0");
				else if(ra>rb && ra-rb>d) System.out.println("2");
				else if(rb>ra && rb-ra>d) System.out.println("-2"); 
				else System.out.println("1");
			}

		}
	}	
}

Measured memory_bytes: 20512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s,t;
	cin>>s;
	t=s;
	reverse(t.begin(),t.end());
	ll ans=0;
	ll cnt=(s.size()+2-1)/2;
	for(ll i=0;i<cnt;i++){
		if(s[i]!=t[i]){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main() {
  int N;
  cin>>N;
  int stat[N-1][3];//0;列車時間　１，スタート　２，間隔
  rep(i,N-1){
    rep(j,3){
      cin>>stat[i][j];
    }
  }
  int time[N][N];
  rep(i,N){
    time[i][i]=0;
  }
  rep(i,N){
    rep2(j,i,N-1){
      if(time[i][j]<stat[j][1]){
        time[i][j+1]=stat[j][1]+stat[j][0];
      }
      else if(time[i][j]%stat[j][2]==0){
        time[i][j+1]=time[i][j]+stat[j][0];
      }
      else{
        time[i][j+1]=(time[i][j]/stat[j][2]+1)*stat[j][2]+stat[j][0];
      }

    }
  }
  rep(i,N){
    cout<<time[i][N-1]<<endl;
  }
return 0;
}



Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    ll h,w;
    cin>>h>>w;
    ll ans=LLONG_MAX;
    vec(a,3);
    if(w%3==0||h%3==0){
        op(0);
        return 0;
    }
    ll j=h%3;
    for(;j>=0;j--){
        ll k=w%2;
        for(;k>=0;k--){
            a[0]=w*(h/3+j);
            a[1]=(h-(h/3+j))*(w/2+k);
            a[2]=(h-(h/3+j))*(w-(w/2+k));
            sort(all(a));
            ans=min(ans,(a[2]-a[0]));
        }
    }
    swap(h,w);
    j=h%3;
    for(;j>=0;j--){
        ll k=w%2;
        for(;k>=0;k--){
            a[0]=w*(h/3+j);
            a[1]=(h-(h/3+j))*(w/2+k);
            a[2]=(h-(h/3+j))*(w-(w/2+k));
            sort(all(a));
            //cout<<(a[2]-a[0])<<endl;
            ans=min(ans,(a[2]-a[0]));
        }
    }
    if(ans>min(h,w)){
        op(min(h,w));
    }else 
    op(ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

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

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

    int ai;
    int cnt4 = 0;
    int cnte = 0;
    int cnto = 0;
    REP(0, i, N) {
        cin >> ai;

        if (ai % 4 == 0) {
            cnt4++;
            continue;
        }

        if (ai % 2 == 0) {
            cnte++;

            if (cnte % 2 == 0) {
                cnte--;
            }

            continue;
        }

        cnto++;
    }

    // cout << "N=" << N << endl;
    // cout << "cnt4=" << cnt4 << endl;
    // cout << "cnto=" << cnto << endl;
    // cout << "cnte=" << cnte << endl;
    if (cnte + cnto - cnt4 > 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end
n = gets_i

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
a1 = gets_i_list
a2 = gets_i_list

max = 0
0.upto(n-1) do |i|
  max = [a1[0..i].sum + a2[i..n-1].sum, max].max
end

puts max

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

int main() {
  long long A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A >= K){
  cout << K << endl;
  }else if(A + B >= K){
  cout << A << endl;
  }else{
  cout << A - (K-(B+A)) << endl;
  }
}

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

int cnt[100005];
bool red[100005];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	red[0] = true;
	fill(cnt, cnt + n, 1);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		--a;--b;

		if (red[a]) red[b] = true;
		--cnt[a]; ++cnt[b];
		if (cnt[a] == 0) red[a] = false;
	}

	printf("%d\n", accumulate(red, red + n, 0));;
}


Measured memory_bytes: 768
N,M,C = list(map(int, input().split()))

B = list(map(int, input().split()))
A = []

ans = 0

for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)

for i in range(N):
    k = C
    for j in range(M):
        k += A[i][j] * B[j]
    if k > 0:
        ans += 1
    
print(ans)

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

using namespace std;

int main(){

	string A;
	char R;
	cin >> A;

	for(int i = 0; i < A.length()/2 ;++i){
		R = A[i];
		A[i] = A[A.length() - i - 1];
		A[A.length() - i - 1] = R;
	}
	cout << A << '\n';

	return 0;

}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>

int main()
{
  int A, B, Q;
  std::cin >> A >> B >> Q;
  std::vector<long long> ss(A);
  for (auto& val: ss)
    std::cin >> val;
  std::vector<long long> ts(B);
  for (auto& val: ts)
    std::cin >> val;
  std::sort(begin(ss), end(ss));
  std::sort(begin(ts), end(ts));
  std::vector<std::pair<long long, char>> both;
  both.reserve(A + B);
  for (auto& val: ss)
    both.emplace_back(val, 0);
  for (auto& val: ts)
    both.emplace_back(val, 1);
  std::sort(begin(both), end(both));

  std::vector<long long> answers(Q);
  for (auto& ans: answers)
  {
    ans = std::numeric_limits<long long>::max();
    long long x;
    std::cin >> x;
    auto itr = std::lower_bound(begin(both), end(both), std::make_pair(x, static_cast<char>(-1)));
    if (itr != end(both))
    {
      long long candidate = 0;
      candidate += std::abs(itr->first - x);
      std::vector<long long>& vec = itr->second ? ss : ts;
      auto itr1 = std::lower_bound(begin(vec), end(vec), itr->first);
      if (itr1 == end(vec))
      {
        --itr1;
        candidate += std::abs(*itr1 - itr->first);
      }
      else if (itr1 == begin(vec))
      {
        candidate += std::abs(*itr1 - itr->first);
      }
      else
      {
        auto prev = itr1 - 1;
        candidate += std::min(std::abs(*itr1 - itr->first), std::abs(*prev - itr->first));
      }
      ans = std::min(ans, candidate);
    }
    if (itr != begin(both))
    {
      --itr;
      long long candidate = 0;
      candidate += std::abs(itr->first - x);
      std::vector<long long>& vec = itr->second ? ss : ts;
      auto itr1 = std::lower_bound(begin(vec), end(vec), itr->first);
      if (itr1 == end(vec))
      {
        --itr1;
        candidate += std::abs(*itr1 - itr->first);
      }
      else if (itr1 == begin(vec))
      {
        candidate += std::abs(*itr1 - itr->first);
      }
      else
      {
        auto prev = itr1 - 1;
        candidate += std::min(std::abs(*itr1 - itr->first), std::abs(*prev - itr->first));
      }
      ans = std::min(ans, candidate);
    }
  }

  for (auto& val: answers)
    std::cout << val << "\n";
  std::cout << std::flush;

  return 0;
}



Measured memory_bytes: 7040
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
  long long h,hlog,sum=1,s=1;
  cin >> h;
  hlog=log2(h);
  if(h==1){cout << 1 << endl;}
  else{
    for(long long i=0; i<hlog; i++){
      s*=2;
      sum+=s;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();
#include <map>
#include <queue>

bool solve(priority_queue<int>& que, int h, int w, int cnt){
    if ((h==0||w==0)||(h*w)==1) {
        for (int i=0;i<cnt;i++){
            int tmp=que.top();
            if (tmp>=2){
                tmp-=2;
                que.pop();
                que.push(tmp);
            }else return false;
        }
        return true;
    }
    else{
        if ((h==1 || w==1)){
            h = max(h,w);
            w = 1;
            int tmp=que.top();
            if (tmp >= 2){
                tmp-=2;
                que.pop();
                que.push(tmp);
                solve(que,h-2,w,cnt);
            }else return false;
        }else{
            int tmp = que.top();
            if (tmp >= 4){
                tmp-=4;
                que.pop();
                que.push(tmp);
            }else return false;
            for (int i=0;i<(h-2)/2;++i){
                int tmp = que.top();
                if (tmp >= 4){
                    tmp-=4;
                    que.pop();
                    que.push(tmp);
                }else return false;
            }
            for (int i=0;i<(w-2)/2;++i){
                int tmp = que.top();
                if (tmp >= 4){
                    tmp-=4;
                    que.pop();
                    que.push(tmp);
                }else return false;
            }
            if (h%2 == 1)cnt++;
            if (w%2 == 1)cnt++;
            
            return solve(que,h-2,w-2,cnt);
        }
    }

}

int main()
{
    int H,W;
    cin>>H>>W;
    map<char,int> counter;
    char S[H][W];
    REP(i,H){
        REP(j,W) {
            cin>>S[i][j];
            counter[S[i][j]]++;
        }
    }
    priority_queue<int> que;
    for (pair<char,int> cur:counter){
        que.push(cur.second);
    }
    bool ans = solve(que,H,W,0);
    if (ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    // for (pair<char, int> cur:counter){
    //     cout<<cur.first << ':'<<cur.second<<endl;
    // }


    return 0;
}

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

typedef long long ll;
const ll MOD = 1000000007;

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

    for (int x = N; x < 100000; x++) {
        int tmp = x;
        int cnt = 0;
        vector<int>s;
        while (tmp != 0) {
            s.push_back(tmp % 10);
            tmp /= 10;
        }
        bool flag = true;

        for (int i = 0; i < K; i++) {
            if (count(s.begin(), s.end(), D[i]) > 0) flag = false;
        }

        if (flag) {
            cout << x << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	int m;				// 行と列
	
	// 行列のサイズを入力
	cin >> n;
	cin >> m;
	
	// 動的配列の確保
	int **arrayA = new int *[n];
	int *arrayB  = new int [m];
	int answer   = 0;
	
	// arrayAは2次元配列なので、各行でnewをして2次元の動的配列を作成
	for(int i = 0; i < n; i++)
	{
		arrayA[i] = new int[m];
	}
	
	// 行列の要素を入力
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> arrayA[i][j];
		}
	}
	
	for(int i = 0; i < m; i++)
	{
		cin >> arrayB[i];
	}
	
	// 各行の積を計算して出力
	for(int i = 0; i < n; i++)
	{
		answer = 0;
		for(int j = 0; j < m; j++)
		{
			answer += arrayA[i][j] * arrayB[j];
		}
		cout << answer << endl;
	}
	
	// 動的配列の削除
	for(int i = 0; i < n; i++)
	{
		delete [] arrayA[i];
	}
	delete [] arrayA;
	delete [] arrayB;
	
	return 0;
}


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

int main(){
    struct data{
        int fh; int fm; int fs;
        int eh; int em; int es;
        int dh; int dm; int ds;
    } n;
    
    for(int i = 0 ; i < 3 ; i++){
    cin >> n.fh >> n.fm >> n.fs >> n.eh >> n.em >> n.es;
        n.dh = n.eh - n.fh;
        n.dm = n.em - n.fm;
        n.ds = n.es - n.fs;
        
        if(n.ds < 0){
            n.ds += 60;
            n.dm--;
        }
        if(n.dm < 0){
            n.dm += 60;
            n.dh--;
        }
        
        cout << n.dh << ' ' << n.dm << ' ' << n.ds << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.buffer.readline
input = sys.stdin.readline

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())

def main():
	ACGT="ACGT"
	s=input()
	ans=0
	cnt=0
	for i in s:
		if i in ACGT:
			cnt+=1
		else:
			cnt=0
		ans=max(ans,cnt)
	print(ans)














if __name__ == "__main__":
	main()


Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <list>
#include <vector>
#include <string>

using namespace std;

#define MIN(x, y) x<y?x:y

int main()
{
	string s;

	cin>>s;

	if(s=="ABC") {
		cout<<"ARC"<<endl;
	} else {
		cout<<"ABC"<<endl;
	}

	return 0;
}


Measured memory_bytes: 3596
N = int(input())
h = list(map(int,input().split()))
dp = [0]*N
dp[1] = abs(h[1]-h[0])
for i in range(N-2):
  dp[i+2] = min( dp[i+1]+abs(h[i+2]-h[i+1]) , dp[i]+abs(h[i+2]-h[i]) )
print(dp[-1])  

Measured memory_bytes: 13928
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;
int accumFailTime[100001];
int ac_k[100001];
int ac[100001];
int failTime[100001];
int firstZeroLen = -1;
int main() {
    int N, M;
    int m[100001];
    int Q;
    int l[100001];
    cin >> N >> M;
    for (int i=0; i<M; i++) cin >> m[i];
    cin >> Q;
    for (int i=0; i<Q; i++) cin >> l[i];

    int m_head = 0;
    int zero_len = 0;
    for (int i=1; i<=N; i++) {
        if (m_head < M && m[m_head] == i) {
            if (zero_len > 0) {
                accumFailTime[zero_len]++;
            }
            if (firstZeroLen == -1) firstZeroLen = zero_len;
            zero_len = 0;
            m_head++;
        }
        else {
            zero_len++;
        }
    }
    if (zero_len > 0) {
        accumFailTime[zero_len]++;
    }
    if (firstZeroLen == -1) firstZeroLen = zero_len;

    int ak = 0;
    int a = 0;
    for (int i=N; i>=1; i--) {
        ak += i * accumFailTime[i];
        a += accumFailTime[i];
        ac_k[i] = ak;
        ac[i] = a;
    }
    for (int i=1; i<=N; i++) {
        failTime[i] = ac_k[i] - ac[i] * (i-1);
        if (firstZeroLen > 0) {
            if (i == 2) failTime[2] += 1;
            if (i > 2 && firstZeroLen >= i) failTime[i] += i-1;
            if (i > 2 && firstZeroLen < i) failTime[i] += firstZeroLen;
        } 
        failTime[i] *= -1;

        //cerr << "failtime:" << i << ":" << failTime[i] << endl;
    }
    //cerr << endl;

    for (int i=0; i<Q; i++) {
        int* index = lower_bound(failTime+1, failTime+N+1, -l[i]);
        int answer = index - failTime;
        if (answer > N) answer = -1;
        cout << answer << endl;
    }   
        
    return 0;
}





Measured memory_bytes: 5048
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

template<class T>
vector<vector<T>> TSP(const vector<vector<T>>& dist) {
    int n = dist.size();
    vector<vector<T>> dp(1 << n, vector<T>(n, INF));
    dp[0][0] = 0;
    for (int s = 0; s < 1 << n; s++) {
        for (int cur = 0; cur < n; cur++) {
            if (dp[s][cur] == INF) continue;
            for (int to = 0; to < n; to++) {
                if (s & (1 << to)) continue;
                if (dist[cur][to] < 0) continue;
                T& res = dp[s | 1 << to][to];
                res = min(res, dp[s][cur] + dist[cur][to]);
            }
        }
    }
    return dp;
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> dist(n, vector<int>(n, -1));
    for (int i = 0; i < m; i++) {
        int s, t, d; cin >> s >> t >> d;
        dist[s][t] = d;
    }
    vector<vector<int>> dp = TSP(dist);
    int ans = dp[(1 << n) - 1][0];
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 6212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int mult = n * a;
		if (mult <= b) {
			System.out.println(mult);
		} else {
			System.out.println(b);
		}
	}
}


Measured memory_bytes: 22740
m = int(input())
for _ in range(m):
    s = input()
    pat = set()
    for i in range(1,len(s)):
        f = s[:i]; r = s[i:]
        pat.add(f+r)
        pat.add(r+f)
        pat.add(f[::-1]+r[::-1])
        pat.add(r[::-1]+f[::-1])
        pat.add(f+r[::-1])
        pat.add(r+f[::-1])
        pat.add(f[::-1]+r)
        pat.add(r[::-1]+f)
    print(len(pat))


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const long long MOD = 1000000007;
const int MAX_N = 2000, MAX_M = 2000;
int n,m;
int s[MAX_N];
int t[MAX_M];
ll dp[MAX_N+1][MAX_M+1];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> m;
  forn(i,n) cin >> s[i];
  forn(i,m) cin >> t[i];

  forn(i,n+1) dp[i][0] = 1;
  forn(j,m+1) dp[0][j] = 1;
  dp[0][0] = 1;
  forn1(i,n) forn1(j,m) {
    dp[i][j] = (dp[i][j] + dp[i-1][j] - dp[i-1][j-1] + MOD) % MOD;
    dp[i][j] = (dp[i][j] + dp[i][j-1] - dp[i-1][j-1] + MOD) % MOD;
    dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % MOD;
    if (s[i-1] == t[j-1]) {
      dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % MOD;
    }
  }

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

  return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pow2(x) (ll(1)<<x)
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
#define scan(n) int n;scanf("%d", &n);
using namespace std;
const int sz = 1e5 + 7;
int n,w;
ll dp[102][sz];
vector<pair<int,int> > v;
ll solve(int i=0,int sum=0)
{
    if(i>=n)
        return 0;
    if(dp[i][sum] != -1)
        return dp[i][sum];
    if(sum + v[i].first <= w)
        return dp[i][sum] = max(solve(i+1,sum + v[i].first) + v[i].second, solve(i+1,sum));
    else return solve(i+1,sum);
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>w;
    v.resize(n);
    For(i,n)
        scanf("%d%d", &v[i].first, &v[i].second);
    cout<<solve()<<endl;
}

Measured memory_bytes: 83380