akhauriyash/Code-Regression huggingface dataset:
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  ll a, v, b, w, t;
  ci(a, v, b, w, t);
  t * (v - w) >= abs(a - b) ? co("YES") : co("NO");
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    if(n%2)
    {
        cout<<0;
        return 0;
    }
    n/=2;
    ll p5=0;
    while(n)
    {
        p5+=(n/5);
        n/=5;
    }
    cout<<p5;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int> > x(n);
    REP(i,n){
        int t;
        cin >> t;
        x[i] = make_pair(t,i);
    }
    sort(ALL(x));
    vint ans(n);
    REP(i,n){
        auto p = x[i];
        if(i<n/2){
            ans[p.se] = x[n/2].fi;
        }else{
            ans[p.se] = x[n/2-1].fi;
        }
    }
    REP(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

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

struct BipartiteMatching {
  vector<vector<int>> graph;
  vector<int> match, alive, used;  int timestamp;

  BipartiteMatching(int n){
    graph=vector<vector<int>>(n);
    alive=vector<int>(n,1);
    used=vector<int>(n,0);
    match=vector<int>(n,-1);
    timestamp=0;
  }

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match==-1 || (used[to_match]!=timestamp && dfs(to_match))) {
        match[idx]=to;  match[to]=idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i=0; i<graph.size(); i++) {
      if(alive[i]==0) continue;
      if(match[i]==-1){++timestamp; ret+=dfs(i);}
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {cout << i << "-" << match[i] << endl;}
    }
  }
};

int main() {
  int N; cin >> N;
  BipartiteMatching bm(2*N);
  vector<int> a(N),b(N),c(N),d(N);
  for(int i=0;i<N;i++)cin >> a[i] >> b[i];
  for(int i=0;i<N;i++)cin >> c[i] >> d[i];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(a[i]<c[j] && b[i]<d[j]){bm.add_edge(i,j+N);}
    }
  }
  cout << bm.bipartite_matching() << endl;
  //bm.output();
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, q;
string s;
int acc[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &q);

  cin >> s;

  int cnt_ac = 0;

  acc[0] = 0;

  for (int i = 1; i <= n - 1; ++i) {
    if (s[i] == 'C' && s[i - 1] == 'A') cnt_ac += 1;

    acc[i] = cnt_ac;
  }

  for (int i = 0; i < q; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);

    int tmp = acc[r - 1] - acc[l - 1];

    printf("%d\n", tmp);
  }

  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int min(int a,int b,int c){
	if(a<=b){
		if(a<c)return a;
	}
	else if(b<=a){
		if(b<c)return b;
	}
	if(c<=b){
		if(c<a)return c;
	}
}
int max(int a,int b,int c){
	if(a>=b){
		if(a>c)return a;
	}
	else if(b>=a){
		if(b>c)return b;
	}
	if(c>=b){
		if(c>a)return c;
	}
}
int main(){
	long int a,b,c;
	scanf("%ld %ld %ld",&a,&b,&c);
	printf("%d %d\n",min(a,b,c),max(a,b,c));
	return 0;
}


Measured memory_bytes: 2760
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int f[100000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(f, 0, sizeof(f));
    gi();
    int n = gi();
    char a[4];
    int rc = 0, rp = 0;
    for (int i = 0; i < n; i++) {
        int p = gi()-1;
        scanf("%s", a);
        if (f[p] == -1)
            continue;
        if (a[0] == 'W')
            f[p]++;
        else {
            rp += f[p];
            rc++;
            f[p] = -1;
        }
    }

    printf("%d %d\n", rc, rp);

    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int a[n-1];
	for(int i = 0;i < n-1;i++)
		cin >> a[i];
	int sum = a[0];
	for(int i = 0;i < n-2;i++){
		if(a[i] > a[i+1])
			sum += a[i+1];
		else 
			sum += a[i];
	}
	sum += a[n - 2];
	cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

/**
 * Created on 2017/10/20 7:19.
 */
public class Main {
    static int N;

    static boolean isReachable(boolean used[], boolean[][] t, int pos, int cutFrom, int cutTo) {
        if (pos == cutTo) {
            return true;
        }
        used[pos] = true;
        for (int i = 0; i < N; i++) {
            if (!used[i] && t[pos][i] && !(pos == cutFrom && i == cutTo || pos == cutTo && i == cutTo) && isReachable(used, t, i, cutFrom, cutTo)) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) throws IOException {
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);

        while (sc.hasNextInt()) {
            N = sc.nextInt();
            int M = sc.nextInt();
            boolean[][] t = new boolean[N][N];
            for (int i = 0; i < M; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;
                t[a][b] = t[b][a] = true;
            }
            int ans = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    if (!t[i][j]) {
                        continue;
                    }
                    boolean used[] = new boolean[N];
                    if (!isReachable(used, t, i, i, j)) {
                        ans++;
                    }
                }
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 23124
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9+7

R,C,K = map(int,input().split())

item = [[0]*C for _ in range(R)]
for i in range(K):
    r,c,v = map(int,input().split())
    item[r-1][c-1] = v
#print(item)

dp = [[0]*4 for _ in range(C)]
preview = [[0]*4 for _ in range(C)]

for i in range(R):
    for j in range(C):
        for k in range(1,4):
            #print(i,j,k)
            if k == 1:
                if i != 0:
                    if j != 0:
                        dp[j][k] = max(dp[j-1][k], dp[j-1][k-1] + item[i][j], max(preview[j]) + item[i][j])
                    else:
                        dp[j][k] = max(0, 0 + item[i][j], max(preview[j]) + item[i][j])
                else:
                    if j != 0:
                        dp[j][k] = max(dp[j-1][k], dp[j-1][k-1] + item[i][j])
                    else:
                        dp[j][k] = max(0, 0 + item[i][j])


            else:
                if j != 0:
                    dp[j][k] = max(dp[j-1][k], dp[j-1][k-1] + item[i][j])
                else:
                    dp[j][k] = max(0, 0 + item[i][j])

            #print(dp)
    preview = dp
print(max(dp[C-1]))

Measured memory_bytes: 146828
def main():
    s = list(map(int, input()))
    
    #startが0
    ans_0 = 0
    #startが1
    ans_1 = 0
    
    for i in range(len(s)):
        if i % 2 == 0 and s[i] != 0:
            ans_0 += 1
        elif i % 2 == 1 and s[i] != 1:
            ans_0 += 1
        if i % 2 == 0 and s[i] != 1:
            ans_1 += 1
        elif i % 2 == 1 and s[i] != 0:
            ans_1 += 1
    print(min(ans_0, ans_1))
        
   
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3956
S = input()

N = len(S)
ans = 0
for i in range(N):
    for j in range(i + 1, N + 1):
        T = S[i:j]
        flag = True
        for t in set(T):
            if t not in ['A', 'C', 'G', 'T']:
                flag = False
                break
        if flag:
            ans = max(ans, len(T))
print(ans)


Measured memory_bytes: 3060
n = gets.to_i
a = gets.split.map(&:to_i)

cnt = 0
for i in 1...n-1
    if a[i-1] < a[i] && a[i] < a[i+1]
        cnt+=1
    elsif a[i+1] < a[i] && a[i] < a[i-1]
        cnt+=1
    end
end

puts cnt


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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    if (500 * n >= k) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;i++) cin>>ar[i];
	int dp[n];
	memset(dp,0,sizeof(dp));
	dp[1]=abs(ar[1]-ar[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min((dp[i-1]+abs(ar[i]-ar[i-1])),(dp[i-2]+abs(ar[i]-ar[i-2])));

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


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define pai 3.1415926535


int main(void){

	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	int a, b, c;
	
	int count = 0;
	for (;;) {
		if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			break;
		}

		if (A == B && B == C) {
			printf("%d", -1);
			return 0;
		}
		a = A, b = B, c = C;
		A = 0, B = 0, C = 0;
		A += b / 2 + c / 2;
		B += a / 2 + c / 2;
		C += b / 2 + a / 2;
		count++;
	}
	printf("%d\n", count);

	return 0;


}

Measured memory_bytes: 128
#include<stdio.h>

int n;
double x[5],y[5],r[5];

int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%lf%lf%lf%lf%lf%lf",&x[0],&y[0],&r[0],&x[1],&y[1],&r[1]);
		if((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1])>(r[0]+r[1])*(r[0]+r[1]))printf("0\n");
		else if((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1])<(r[0]-r[1])*(r[0]-r[1])){
			if(r[0]>r[1])printf("2\n");
			else printf("-2\n");
		}else printf("1\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin>>n;
	int v[n], c[n], ans = 0;
	for(int i = 0; i < n; i++) cin >> v[i];
	for(int i = 0; i < n; i++) cin >> c[i];
	for(int i = 0; i < n; i++)
	{
		ans = max(ans, ans + (v[i] - c[i]));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;

long long x;


int main()
{
    //ifstream cin ("input1.txt");
    //ifstream fin ("output1.txt");
    //ofstream cout ("output1.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(25);
    cin >> x;
    cout << x / 500 * 1000 + (x % 500) / 5 * 5;
    return 0;
}


Measured memory_bytes: 256
n = input()
inf = 1000000000
M = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  str = map(int, raw_input().split())
  u = str[0]
  k = str[1]
  for j in range(k):
    v = str[2+2*j]
    c = str[3+2*j]
    M[u][v] = c
d = [inf for i in range(n)]
color = [0 for i in range(n)]
 
d[0] = 0
color[0] = 1
 
while 1:
  minv = inf
  u = -1
  for i in range(n):
    if minv>d[i] and color[i]!=2:
      u = i
      minv = d[i]
  if u == -1:
    break
  color[u] = 2
  for v in range(n):
    if color[v]!=2 and M[u][v]!=inf:
      if d[v]>d[u]+M[u][v]:
        d[v] = d[u] + M[u][v]
        color[v] = 1
for i in range(n):
  if d[i]==inf:
    print '%d -1' % i
  else:
    print '%d %d' % (i, d[i])

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
const int mod = 1e9 + 7;
int power(int a, int b){
    int res = 1;
    while(b > 0){
        if(b % 2){
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
        b /= 2;
    }
    return res;
}
int n, seg[4 * N];
void update(int node, int start, int end, int idx){
    if(start > end || idx < start || end < idx) return;
    if(start == end){
        seg[node] = 1;
        return;
    }
    int mid = (start + end) / 2;
    update(node << 1, start, mid, idx);
    update(node << 1 | 1, mid + 1, end, idx);
    seg[node] = seg[node << 1] + seg[node << 1 | 1];
}
int findl(int node, int start, int end, int l, int r){
    if(start > end || l > r || r < start || end < l || seg[node] == 0) return 0;
    if(start == end){
        return (seg[node] ? start : 0);
    }
    int mid = (start + end) >> 1;
    int idx = findl(node << 1 | 1, mid + 1, end, l, r);
    return (idx ? idx : findl(node << 1, start, mid, l, r));
}
int findr(int node, int start, int end, int l, int r){
    if(start > end || l > r || r < start || end < l || seg[node] == 0) return n + 1;
    if(start == end){
        return (seg[node] ? start : n + 1);
    }
    int mid = (start + end) >> 1;
    int idx = findr(node << 1, start, mid, l, r);
    return (idx != n + 1 ? idx : findr(node << 1 | 1, mid + 1, end, l, r));
}
int main(){
    int a, pos[N];
    long long ans = 0;
    stack<int> s;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a);
        pos[a] = i;
    }
    update(1, 0, n + 1, 0);
    update(1, 0, n + 1, n + 1);
    for(int i = n; i >= 1; i--){
        update(1, 0, n + 1, pos[i]);
        int l = findl(1, 0, n + 1, 0, pos[i] - 1);
        int ll = findl(1, 0, n + 1, 0, l - 1);
        int r = findr(1, 0, n + 1, pos[i] + 1, n + 1);
        int rr = findr(1, 0, n + 1, r + 1, n + 1);
        if(l){
            ans += 1LL * (l - ll) * (r - pos[i]) * 1LL * i;
        }
        if(r != n + 1){
            ans += 1LL * (rr - r) * (pos[i] - l) * 1LL * i;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //decimal[] input = Console.ReadLine().Split(" ").Select(x => decimal.Parse(x)).ToArray();
            decimal x = Console.ReadLine().Split(" ").Select(x => decimal.Parse(x)).ToArray()[0];
            string input = Console.ReadLine();
            decimal[] p = new decimal[1000];
            if (input != "")
            {
                p = input.Split(" ").Select(x => decimal.Parse(x)).ToArray();
                Array.Sort(p);
                int j = 0;
                while (true)
                {
                    if (Array.IndexOf(p, x - j) == -1)
                    {
                        Console.WriteLine(x - j);
                        break;
                    }
                    if (Array.IndexOf(p, x + j) == -1)
                    {
                        Console.WriteLine(x + j);
                        break;
                    }
                    j++;
                }
            }
            else
            {
                Console.WriteLine(x);
            }

        }
    }
}

Measured memory_bytes: 28408
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,q;
  cin >> n >> k >> q;
  ll a[q],point[n];
  fill(point,point+n,k-q);
  for(int i=0;i<q;i++){
    cin >>a[i];
    point[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    if(point[i]>0){
      cout <<"Yes\n";
    }else{
      cout <<"No\n";
    }
  }
}


Measured memory_bytes: 2176
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
using namespace std;
int fa[200005],sz[200005];
int find(int x)
{
    if(fa[x]==x) return x;
    return fa[x]=find(fa[x]);
}
int main() {
    int n, m, x, y, ans = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        fa[i] = i;
        sz[i] = 1;
    }
    for (int i = 1; i <= m; i++) {
        scanf("%d%d", &x, &y);
        if (find(x) != find(y)) {
            sz[fa[y]] += sz[fa[x]];
            fa[fa[x]] = fa[y];
        }
    }
    for (int i = 1; i <= n; i++) ans = max(ans, sz[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5216
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

const int mod = 109;
int cnt[mod];

int main(){
  int n;
  while(scanf("%d", &n), n){
    int ans = -1;
    const int n2 = n / 2;
    
    for(int i = 0; i < mod; i++){
      cnt[i] = 0;
    }
    
    for(int i = 0; i < n; i++){
      int a; scanf("%d", &a);
      int m = a % mod;
      if(++cnt[m] > n2) ans = a;
    }

    if(ans == -1)
      puts("NO COLOR");
    else
      printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int K;
    cin >> K;
    string S;
    cin >> S;
    int len = S.size();
    if (len <= K) cout << S << endl;
    else cout << S.substr(0,K) << "..." << endl;
}


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

#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
#define clr(x) memset(x,0,sizeof x)
#define RG register

#define px first
#define py second

using std :: max;
using std :: min;
using std :: pair;
using std :: make_pair;

typedef long long LL;
typedef pair<LL,LL> pll;
typedef pair<int,int> pii;

static const int INF = 1 << 30;
static const LL oo = 1LL << 60;
static const int maxm = 1e5 + 10;
static const LL mod = 1e9 + 7;

template <class T> inline bool chkmax(T &x, T y) {
    return x < y ? x = y,true : false;
}

template <class T> inline bool chkmin(T &x, T y) {
    return x > y ? x = y,true : false;
}

template <class T> inline void read (T &in) {
    in = 0; char ch = getchar(); T f = 1;
    for (;ch > '9' || ch < '0';ch = getchar()) if (ch == '-') f = -1;
    for (;ch >= '0' && ch <= '9';ch = getchar()) in = in * 10 + ch - '0';
    in = in * f;
}

int n, m;

int vis[100][100];

bool ok(int x, int y) {
	return x >= 1 && x <= n && y >= 1 && y <= m;
}

int main() {

	read(n); read(m);

	if(n == 1 && m == 1) return puts("1"), 0;
	if(n == 1) return printf("%d\n" , m - 2), 0;
	if(m == 1) return printf("%d\n", n - 2), 0;

	printf("%lld\n", 1LL * (n - 2) * (m - 2));
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	
	string s1,s2;
	cin>>s1>>s2;
	ll n1=s1.length(),n2=s2.length();
	if(n2==n1+1 && s1.compare(s2.substr(0,n1))==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3628
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int main()
{
	int h1=read(),m1=read(),h2=read(),m2=read();
	m1+=h1*60,m2+=h2*60; m2-=m1;
	printf("%d\n",m2-read());
	return 0;
}


Measured memory_bytes: 1604
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int solve(vector<int> v, vector<int> u){
    int n = v.size();
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if(v[i] != u[i]){
            int x = -1;
            for (int j = n-1; j >= i+1; --j) {
                if(v[j] == u[i]) x = j;
            }
            if(x == -1) return INF<int>;
            for (int k = x-1; k >= i; --k) {
                swap(v[k], v[k+1]);
                ans++;
            }
        }
    }
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n), u(n);
    for (auto &&i : v) scanf("%d", &i);
    int cur = 0;
    for (int i = 0; i < m; ++i) {
        int x;
        scanf("%d", &x);
        while(x--){
            u[cur++] = i&1;
        }
    }
    int ans = solve(v, u);
    for (int i = 0; i < n; ++i) {
        u[i] ^= 1;
    }
    ans = min(ans, solve(v, u));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b;
    cin >> a >> b;
    if (a-b<=0){
        cout << 0 << endl;
    }else{
        cout << a-b << endl;
    }
}


Measured memory_bytes: 256
n = int(input())

ts = [0]
xs = [0]
ys = [0]

for _ in range(n):
    t, x, y = map(int, input().split())
    ts.append(t)
    xs.append(x)
    ys.append(y)

ok = True
for i in range(n):
    dt = ts[i + 1] - ts[i]
    dist = abs(xs[i + 1] - xs[i]) + abs(ys[i + 1] - ys[i])
    if dt < dist:
        ok = False
        break
    else:
        if (dt - dist) % 2 != 0:
            ok = False
            break

if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 64088
h,w=map(int,input().split())
a=[input() for _ in range(h)]

ans = [ [ 12345678 for _ in range(w) ] for d in range(h)]

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            ans[i][j] = 0

for i in range(h):
    for j in range(1,w):
        ans[i][j] = min(ans[i][j], ans[i][j-1]+1)
    for j in range(w-1-1,-1,-1):
        ans[i][j] = min(ans[i][j],ans[i][j+1]+1)

for j in range(w):
    for i in range(1,h):
        ans[i][j] = min(ans[i][j], ans[i-1][j]+1)
    for i in range(h-1-1,-1,-1):
        ans[i][j] = min(ans[i][j], ans[i+1][j]+1)

ma =-4
for x in ans:
    for y in x:
        ma = max(ma,y)
print(ma)

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

int main(){
	/*input*/
	int n;	cin >> n;
	vector<int>a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	/*calculation*/
	vector<int>ans(n);
	int m = 0;
	for(int i = n; i > 0; i--){	//i:box number
		int sum = 0;
		for(int j = 2; i*j <= n; j++){
			if(ans[i*j - 1] == 1)sum++;
		}
		if(a[i - 1] == 0){
			if(sum%2){
				ans[i - 1] = 1;
				m++;
			}else{
				ans[i - 1] = 0;
			}
		}else{
			if(sum%2){
				ans[i - 1] = 0;
			}else{
				ans[i - 1] = 1;
				m++;
			}
			
		}
	}
	vector<int>b(m);
	for(int i = 0, j = 0; i < n; i++){
		if(ans[i] == 1){
			b[j++] = i + 1;
		}
	}
	/*output*/
	cout << m << endl;
	for(int i = 0; i < m; i++){
		cout << b[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2944
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let mut count = 0;
    let mut i = 0;
    let mut j = s.len() - 1;
    while i < j {
        if s[i] != s[j] {
            count += 1;
        }
        i += 1;
        j -= 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

subtotal = sum(b)
bonus = 0

for i in range(n - 1):
    if a[i + 1] - a[i] == 1:
        bonus = bonus + c[a[i] - 1]

total = subtotal + bonus
print(total)

Measured memory_bytes: 3064
import sys
n = int(input())
a = [[-1 for _ in range(n)] for _ in range(n)]
for i in range(n):
    j = int(input())
    for s in range(j):
        x, y = map(int, input().split())
        a[i][x-1] = y
r = 0
for i in range(2**n):
    s = bin(i)
    t = s[2:]
    t = t.rjust(n, '0')
    c = 1
    for j in range(n):
        if t[j] == '0':
            continue
        else:
            for p in range(n):            
                    if int(t[p]) == a[j][p] or a[j][p] == -1:
                        continue
                    else:
                        c = 0
                        break
    if c:
        r = max(r, sum(map(int, list(t))))
print(r)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 2e9;



int main() {
	int n; cin >> n;
	vector<int> a(n),b;
	rep(i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	rep(i, 0, n) b.push_back(abs(i - (n - i - 1)));
	sort(b.begin(), b.end());
	bool flag = true;
	rep(i, 0, n) {
		if (a[i] != b[i]) flag = false;
	}
	if (flag) {
		int ans = 1;
		rep(i, 0, n / 2) ans = (ans * 2) % mod;
		printf("%d", ans);
	}
	else printf("0");
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  int n;cin>>n;
  int p[n][n];
  rep(i,0,n)rep(j,0,n)p[i][j]=-1;
  rep(i,0,n){
    int a;cin>>a;
    rep(j,0,a){
      int b,c;cin>>b>>c;
      --b;
      p[i][b]=c;
    }
  }
  ll ans=0;
  rep(bit,0,(1<<n)){
    vector<int> d(n);
    rep(i,0,n)if(bit&(1<<i)){
      d[i]=1;
    }
    bool ok=true;
    ll count=0;
    rep(i,0,n){
      if(d[i]){
        count++;
        rep(j,0,n){
          if(p[i][j]==-1)continue;
          if(p[i][j]!=(d[j]))ok=false;
        }
      }
    }
    if(ok)ans=max(ans,count);
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  ll n;
  cin>>n;
  vi a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum%(n*(n+1)/2)){
    cout<<"NO"<<endl;
    return 0;
  }
  int k=sum*2/(n*(n+1));
  vi d(n);
  rep(i,n)
    d[i]=a[(i+1)%n]-a[i];
  bool ans=true;
  rep(i,n){
    if(d[i]>k)ans=false;
    if((k-d[i])%n)ans=false;
  }
  if(ans)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int w=scan.nextInt();
int h=scan.nextInt();
int x=scan.nextInt();
int y=scan.nextInt();
int r=scan.nextInt();
if(y+r>h||y+r<0||x+r>w||x+r<0||y+r>w||x+r>h){
	System.out.println("No");
}
else{
	System.out.println("Yes");
}
	}
}

Measured memory_bytes: 26368
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

  int ans = 0;
  while (true) {
    if (*max_element(h.begin(), h.end()) == 0) break;
    int i = 0;
    while (i < N) {
      if (h[i] == 0) ++i;
      else {
        ++ans;
        while (i < N && h[i] > 0) {
          --h[i];
          ++i;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


while True:
    N = int(input())
    if N == 0:
        break
    table = list(map(int,input().split()))

    tmp_sum = 0
    for i in range(len(table)):
        tmp_sum += table[i]
    B = tmp_sum/len(table) #平均

    squared_sum = 0
    for i in range(len(table)):
        squared_sum += table[i]*table[i]
    A = squared_sum/len(table)

    print("%.10f"%(math.sqrt(A-B*B)))


Measured memory_bytes: 6396
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = ToIntArray(input.ReadLine(), n);
        var bb = ToIntArray(input.ReadLine(), n);
        var cc = ToIntArray(input.ReadLine(), n);

        Array.Sort(aa, (x, y) => y - x);
        Array.Sort(bb, (x, y) => y - x);
        Array.Sort(cc, (x, y) => y - x);

        long sum = 0;
        long sumsum = 0;

        int ia = 0;
        int ib = 0;
        int ic = 0;

        for (; ia < n; ia++) {
            var a = aa[ia];
            for (; ib < n && bb[ib] > a; ib++) {
                var b = bb[ib];
                for (; ic < n && cc[ic] > b; ic++) {
                }
                sumsum += ic;
            }
            sum += sumsum;
            //Debug.WriteLine(sum);
        }

        return sum;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 34596
#N,K=map(int,input().split())
#N=int(input())
S=list(input())
T=S.pop()

if T=="2" or T=="4" or T=="5" or T=="7" or T=="9":
    print("hon")
elif T=="0" or T=="1" or T=="6" or T=="8":
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N, A ,B;
    cin >> N >> A >> B;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    int uA = 0;
    int AuB = 0;
    int oB = 0;
    rep(i,N){
        if (vec[i] <= A) uA++;
        else if (vec[i] <= B) AuB++;
        else oB++;
    }
    cout << min(uA, min(AuB, oB)) << endl;
}

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

int main() {
  int n;
  cin >>n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
  	cin >> d.at(i);
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(i==n-1) break;
  	for(int j=i+1;j<n;j++){
      sum += d.at(i)*d.at(j);
     }
  }
  cout << sum << endl;
  return 0;
}


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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;

	vector<int> begin;
	begin.push_back(0);
	for (int i = 1; i < N; i++) {
		if (s[i] != s[i - 1])begin.push_back(i);
	}
	begin.push_back(N);
	int ans = 0;
	for (int i = 0; i < begin.size() - 1; i++) {
		if (s[begin[i]] == '0')ans = max(ans, begin[min((i + 2 * K), (int)(begin.size() - 1))] - begin[i]);
		else ans = max(ans, begin[min((i + 2 * K + 1), (int)(begin.size() - 1))] - begin[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1020
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int count = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] % 2 != 0){
      count++;
    }
  }
  if(count % 2 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
import sys
import numpy as np
input = sys.stdin.readline
n,C = map(int,input().split())
a = np.zeros((C,10**5),dtype="int")
for _ in range(n):
  s,t,c = map(int,input().split())
  a[c-1,s-1:t] = 1
print(max(np.sum(a,axis=0)))

Measured memory_bytes: 37688
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

//最大公約数
ll gcd(ll a,ll b){
    if(b == 0LL) return a;
    return gcd(b , a % b);
}

//最小公倍数
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;

}

int main(){

    ll a;
    ll b;
    cin >> a >> b;

    ll ans = lcm(max(a,b),min(a,b));

    cout << ans << endl;

    



    return 0;
}

Measured memory_bytes: 256
s = input().strip()
len_s = len(s)
i = a = bc = ans = 0
while i < len_s:
    if s[i] == 'A':
        a += 1
        i += 1
    elif s[i:i+2] == 'BC':
        bc = 1
        ans = ans + bc * a
        i += 2
    else:
        a = bc = 0
        i += 1

print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
signed main(){
	ll n,m; cin>>n>>m;
	string s,t; cin>>s>>t;
	ll L=(n*m)/(__gcd(n,m));
	map<ll,ll> mp;
	rep(i,0,n){
		ll k=i*(L/n);
		mp[k]++;
	}
	rep(i,0,m){
		ll k=i*(L/m);
		mp[k]++;
	}
	bool ok=true;
	for(auto c:mp){
		if(c.second<2)continue;
		char a=s[c.first/(L/n)];
		char b=t[c.first/(L/m)];
		if(a!=b)ok=false;
	}
	cout << (ok ? L:-1)<<endl;
	return 0;
}

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

namespace ABC183A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            string s;
            a = int.Parse(Console.ReadLine());
            s = Console.ReadLine();
            if (a>=3200)
            {
                Console.WriteLine(s);
            }
            else if(a<3200)
            {
                Console.WriteLine("red");
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <set>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    long long ren;
    cin>>ren;
    long long sz[5];
    long long min;
    for(int i=0;i<5;i++)
    {
        cin>>sz[i];
    }
    min=sz[0];
    for(int i=1;i<5;i++)
    {
        if(sz[i]<min)
            min=sz[i];
    }
    if(ren%min!=0)
    {
        cout<<ren/min+1+4<<endl;
    }
    else
    {
        cout<<ren/min+4<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp;

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

fn main() {
  let n: i64 = read();
  let a: i64 = read();
  let b: i64 = read();
  
  let x = n / (a + b) * a;
  let y = n % (a + b);
  println!("{}", x + cmp::min(y, a));
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = 0;
		String str = sc.next();
		int count = 0;
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == 'A' || str.charAt(i) == 'C' || str.charAt(i) == 'G' || str.charAt(i) == 'T') {
				count++;
				
				if (max < count) {
					max = count;
				}
			} else {
				count = 0;
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 22228
#include<iostream>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int sum=0,x=i;
		while(x)
		{
			sum+=(x%10);
			x/=10;
		}
		if(sum>=a&&sum<=b)
		    ans+=i;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e3+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,m,tp,ans,prv,fa[MAXN][MAXN],f[MAXN][MAXN];vector<int>G[MAXN];
void dfs(int x,int f){fa[tp][x]=f;for(int i=0,len=G[x].size(),y;i<len;i++)if((y=G[x][i])!=f)dfs(y,x);}
void dfs2(int x,int prv){if(x!=tp&&f[prv][x]==x)ans++,prv=x;for(int i=0,len=G[x].size(),y;i<len;i++)if((y=G[x][i])!=fa[tp][x])dfs2(y,prv);}
void add(int x,int y){
	if(f[x][y]==y||f[y][x]==x)return;
	if(f[x][y]!=x)return add(f[x][y],y);if(f[y][x]!=y)return add(x,f[y][x]);
	f[x][y]=y,f[y][x]=x;vector<pint>S;queue<int>q;q.push(y);
	for(int cu;!q.empty();q.pop()){
		cu=q.front();
		for(int i=0,len=G[cu].size(),cv;i<len;i++)if((cv=G[cu][i])!=fa[x][cu])
			if(f[x][cv]==x)q.push(cv),f[x][cv]=y;else S.push_back(mk(y,cv));
	}q.push(x);
	for(int cu;!q.empty();q.pop()){
		cu=q.front();
		for(int i=0,len=G[cu].size(),cv;i<len;i++)if((cv=G[cu][i])!=fa[y][cu])
			if(f[y][cv]==y)q.push(cv),f[y][cv]=x;else S.push_back(mk(x,cv));
	}for(int i=0,len=S.size();i<len;i++)add(S[i].fir,S[i].sec);
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read();
	Rep(i,1,n-1){int x=read(),y=read();G[x].push_back(y),G[y].push_back(x);}
	Rep(i,1,n)tp=i,dfs(i,0);
	Rep(i,1,n)Rep(j,1,n)f[i][j]=i;
	for(;m--;)add(read(),read());
	Rep(i,1,n)tp=i,dfs2(i,i);cout<<ans/2;
	return 0;
}




Measured memory_bytes: 35420
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	int ans = 0;
	ans += min(k, a);
	k -= min(k, a);
	k -= min(k, b);
	ans -= min(k, c);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int n, a[30][30];
const int mod = 1e9 + 7;
// man i, woman j
long long dp[(1 << 22)][22];
long long f(int mask, int i){ // womans tomadas
	if(i == n) return mask == 0;
	if(dp[mask][i] != -1) return dp[mask][i];
	long long c = 0;
	for(int j = 0; j < n; ++j){
		if( (mask & (1<<j)) == 0) continue;
		if(a[i][j]){
			c+= f(mask - (1<<j), i + 1);
			c%=mod;
		}
	}
	return dp[mask][i] = c%mod;
}
int main() {
	memset(dp,-1,sizeof(dp));
	cin >> n;
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < n; ++j) cin >> a[i][j];

	cout << f((1<<n) - 1, 0);
	return 0;
}

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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int X, Y; cin >> X >> Y;

	bool ans = true;

	int a_ = (4 * X - Y);
	int b_ = (-2 * X + Y);

	if (a_ % 2 != 0 || b_ % 2 != 0)ans = false;
	if (a_ < 0 || b_ < 0)ans = false;

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#define INF 1000000
using namespace std;
int main(void){
    int n, ma, mb, ans, dp[2][401][401];;
    cin >> n >> ma >> mb;
    for(int j=0;j<=400;j++){
        for(int k=0;k<=400;k++){
            dp[0][j][k] = INF;
        }
    }
    dp[0][0][0] = 0;
    for(int i=1;i<=n;i++){
        int a, b, c;
        cin >> a >> b >> c;
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++){
                dp[i%2][j][k] = dp[1-i%2][j][k];
                if(j >= a && k >= b){
                    dp[i%2][j][k] = min(dp[i%2][j][k], dp[1-i%2][j-a][k-b] + c);
                }
            }
        }
    }
    ans = INF;
    for(int i=1;ma*i<=400&&mb*i<=400;i++){
        ans = min(ans, dp[n%2][ma*i][mb*i]);
    }
    if(ans >= INF)ans = -1;
    cout << ans << endl;
    
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;

  if (S.at(K-1) == 'A') {
    S.at(K-1) = 'a';
  }
  else if (S.at(K-1) == 'B') {
    S.at(K-1) = 'b';
  }
  else if (S.at(K-1) == 'C') {
    S.at(K-1) = 'c';
  }

  cout << S << endl;
}


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

int main(){
    int a,b;
    cin >> a >> b;

    if(a < 2*b) cout << 0 << endl;
    else cout << a- 2*b << endl;
    return 0;
}

Measured memory_bytes: 256