akhauriyash/Code-Regression huggingface dataset:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, S = na()
a = na()
mod = 998244353

def go(f, t, step, a, S):
    dp = [0] * (S+1)
    dp[0] = 1
    ret = [0] * (S+1)
    while f != t:
        for i in range(S, a[f]-1, -1):
            dp[i] += dp[i-a[f]]
            if dp[i] >= mod:
                dp[i] -= mod
        for i in range(S+1):
            ret[i] += dp[i]
        f += step
    for i in range(S+1):
        ret[i] %= mod
    return ret

def dfs(l, r, a, S):
    if r-l <= 1:
        return 1 if a[l] == S else 0
    h = (l+r)//2
    L = go(h-1, l-1, -1, a, S)
    R = go(h, r, 1, a, S)
    # print(l, r, L, R)
    return sum(L[i] * R[S-i] for i in range(S+1)) + dfs(l, h, a, S) + dfs(h, r, a, S)

print(dfs(0, n, a, S) % mod)


Measured memory_bytes: 61148
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, x, t; cin >> n >> x >> t;
    ll p = n/x;
    ll q = n%x;
    if(q == 0) cout << p*t << endl;
    else cout << p*t+t << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 13;

string s[MAX_N];
vector<int> vec[MAX_N];
vector<char> c;
int dame[26];
int mp[26];
int cnt;
int n;

int main()
{
    while(1){
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        cnt = 0;
        rep(i,n){
            vec[i].clear();
        }
        c.clear();
        rep(i,26){
            dame[i] = 0;
        }
    	rep(i,n){
    		cin >> s[i];
    	}
        rep(i,n){
            rep(j,s[i].length()){
                if(j == 0 && s[i].length() > 1){
                    dame[(int)(s[i][j]-'A')] = 1;
                }
                c.push_back(s[i][j]);
                vec[i].push_back((int)(s[i][j] - 'A'));
            }
        }
        sort(c.begin(),c.end());
        c.erase(unique(c.begin(),c.end()),c.end());
        rep(i,c.size()){
            mp[(int)(c[i]-'A')] = i;
        }
        vector<bool> v(10);
        fill(v.end() - c.size(), v.end(), true);
        do {
            vector<int> pm;
            for (int i = 0; i < 10; ++i) {
                if (v[i]) {
                    pm.push_back(i);
                }
            }
            do{
                bool flag = false;
                rep(i,26){
                    if(dame[i] > 0){
                        if(pm[mp[i]] == 0){
                            flag = true;
                            break;
                        }
                    }
                }
                if(flag){
                    continue;
                }
                int a[MAX_N];
                rep(i,n){
                    ll hoge = 0;
                    ll dig = 1;
                    for(int j = vec[i].size()-1;j>=0;j--){
                        hoge += pm[mp[vec[i][j]]] * dig;
                        dig *= 10LL;
                    }
                    a[i] = hoge;
                }
                ll sm = 0;
                rep(i,n-1){
                    sm += a[i];
                }
                if(a[n-1] == sm){
                    cnt++;
                }
            }while(next_permutation(pm.begin(), pm.end()));
        } while (next_permutation(v.begin(), v.end()));
        printf("%d\n",cnt);
    }
	return 0;
}

Measured memory_bytes: 3136
#include <iostream>
using namespace std;
int main(){
    char d[101][101],ch;
    int w,h,i,j;
    while(cin>>h>>w,h){
        for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>d[i][j];
        i=j=0;
        while(d[i][j]!='.'&&d[i][j]!='X'){
            ch=d[i][j];
            d[i][j]='X';
            switch (ch){
                case '>':j++;break;
                case '<':j--;break;
                case 'v':i++;break;
                case '^':i--;break;
            }
        }
        (d[i][j]=='.')?(cout<<j<<" "<<i<<endl):(cout<<"LOOP"<<endl);
    }

}

Measured memory_bytes: 1168
n = int(input())
pretime, prex, prey = 0, 0, 0
for i in range(n):
    nowtime, nowx, nowy = map(int, input().split())
    time = nowtime - pretime
    x = abs(nowx - prex)
    y = abs(nowy - prey)
    if x+y > time:
        print("No")
        exit()
    if (x+y) % 2 != time % 2:
        print("No")
        exit()
    pretime = nowtime
    prex, prey = nowx, nowy
else:
    print("Yes")

Measured memory_bytes: 3064
/****************************
** In the name of Allah    **
** Author: Farhad          **
** From  : IIT,JU          **
*****************************/
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    map<string , int> MP;
    int a,b,c,n,m,ans,ass=0,maxi=-1;
    cin>>n;
    getchar();
    string blue;
    string red;
    int cnt[200];
    memset(cnt,0,sizeof(cnt));
    for(int i=0;i<n;i++)
    {
        cin>>blue;
        if(MP.find(blue)==MP.end())
        {
            MP[blue]=ass;
            ass++;
        }
        cnt[MP[blue]]++;
    }
    cin>>m;
    getchar();
    for(int i=0;i<m;i++)
    {
        cin>>red;
        if(MP.find(red)!=MP.end())
        {
           cnt[MP[red]]--;
        }
    }
    for(int i=0;i<200;i++)
        if(cnt[i]>maxi)
        maxi=cnt[i];
    cout<<maxi<<endl;

    return 0;
}


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

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

    vector<int> L(N);
    rep(i, N) {
        cin >> L.at(i);
    }

    sort(L.begin(), L.end());

    ll count = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L.at(i) + L.at(j) <= L.at(k)) {
                    break;
                }
                else {
                    count++;
                }
            }
        }
    }

    cout << count++ << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
typedef long long ll;
typedef pair<int,int> pii;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

// graph //
int V,E,r,from,to,weight;

struct Edge{
    int from,to,cost;
    Edge(int from,int to,int cost) : from(from),to(to),cost(cost){}
};

vector<vector<Edge> >  G;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> V >> E >> r;
    G.resize(V);
    REP(i,E){
        cin >> from >> to >> weight;
        G[from].emplace_back(from,to,weight);
    }

    priority_queue<pii,vector<pii>, greater<pii> > pq;
    pq.push(pii(0,r));
    vector<ll> dist(V,INF);
    dist[r] = 0;
    while(!pq.empty()){
        pii v = pq.top();pq.pop();
        for(auto e : G[v.second]){
            if(dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                pq.push(pii(dist[e.to],e.to));
            }
        }
    }

    REP(i,V){
        if(dist[i]==INF) cout << "INF" << '\n';
        else cout << dist[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 15684
#include <stdio.h>

int main()
{
	long long L, R;
	scanf("%lld %lld", &L, &R);

	if (R / 2019 - (L - 1) / 2019 > 0) {
		printf("0\n");
		fflush(stdout);
		return 0;
	}
	
	int i, j, l = L % 2019, r = R % 2019, min = 2019;
	for (i = l; i < r; i++) {
		for (j = l + 1; j <= r; j++) {
			if (i * j % 2019 < min) min = i * j % 2019;
		}
	}
	
	printf("%d\n", min);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define maxn 1000010
using namespace std;
int id[2][3][maxn], cnt, father[maxn], x[maxn], y[maxn], z[maxn], visit[2][maxn];
int work(int n)
{
	if (father[n] == n) return n;
	else return father[n] = work(father[n]);
}
int gcd(int a, int b)
{
	if (a == 0) return b;
	if (b == 0) return a;
	int y = a % b;
	while (y)
	{
		a = b;
		b = y;
		y = a % b;
	}
	return b;
}
int main()
{
	int n, m, q, mod, g, tmp;
	scanf("%d%d%d%d", &n, &m, &q, &mod);
	for (int i = 0; i <= 1; i++)
		for (int j = 0; j <= 2; j++)
			for (int k = 1; k <= n; k++)
				id[i][j][k] = ++cnt;
	for (int i = 1; i <= m; i++)
		scanf("%d%d%d", &x[i], &y[i], &z[i]);
	for (int i = 1; i <= cnt; i++)
		father[i] = i;
	for (int i = mod; i >= 1; i--)
		if (mod % i == 0)
		{
			int flag = 1;
			for (int j = 2; j <= m; j++)
				if (z[j] % i != z[1] % i) {flag = 0; break;}
			if (flag) {g = i; break;}
		}
	tmp = z[1] % g;
	mod = gcd(mod, 3 * g);
	for (int i = 1; i <= m; i++)
		for (int j = 0; j <= 1; j++)
			for (int k = 0; k <= 2; k++)
			{
				int cur = (z[i] - tmp) / g, u = id[j][k][x[i]], v = id[j ^ 1][(k * 2 + cur) % 3][y[i]];
				father[work(u)] = work(v);
				u = id[j][k][y[i]]; v = id[j ^ 1][(k * 2 + cur) % 3][x[i]];
				father[work(u)] = work(v);
			}
	int now = tmp;
	while (visit[0][now] == 0)
	{
		visit[0][now] = 1;
		now = now * 4 % mod;
	}
	now = tmp * 2 % mod;
	while (visit[1][now] == 0)
	{
		visit[1][now] = 1;
		now = now * 4 % mod;
	}
	for (int i = 1; i <= q; i++)
	{
		int x, y, z, flag = 0;
		scanf("%d%d%d", &x, &y, &z);
		for (int j = 0; j <= 1; j++)
			for (int k = 0; k <= 2; k++)
			{
				int u = id[0][0][y], v = id[j][k][x], need;
				need = ((z + tmp - k * g) % mod + mod) % mod;
				if (work(u) == work(v) && visit[j][need]) flag = 1;
			}
		if (flag) puts("YES");
		else puts("NO");
	}
	return 0;
}

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

using namespace std;

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp
    unordered_map<char, vector<int>> d;
    unordered_set<string> ret;

    int n = 0;
    cin >> n;

    string pin = "";
    cin >> pin;

    for (int i = 0; i < pin.size(); ++i) {
        d[pin[i]].push_back(i);
    }

    /*for(auto p : d) {
        cout << p.first << endl;
        for (auto c : p.second) cout << c << " ";
        cout << endl;
    }*/

    for (int i = 0; i < 1000; i++) {
        string s = to_string(i);
        while(s.size() != 3) {
            s = "0" + s;
        }
        
        bool flag = false;
        if(ret.find(s) == ret.end()) {
            for(int j = 0; j < 3; ++j) {
                if(d.find(s[j]) == d.end()) {
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                int a = d[s[0]][0];
                int b = -1;
                int c = -1;

                
                for (auto& index : d[s[1]]) {
                    if (index > a) {
                        b = index;
                        break;
                    }
                }
                if (b == -1) continue;
                
                for (auto& index : d[s[2]]) {
                    if (index > b) {
                        c = index;
                        break;
                    }
                }
                if (c == -1) continue;

                // cout << a << b << c << endl;
                ret.insert(s);
            }
        }
    }

    cout << ret.size() << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N= 501;
const int M= 31;

int ar[N][N];
int cost[M][M];
int ne[M][N];
int v[N][N];

void solve() {

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

        for (int i= 1; i< N; i++)
                for (int j= 1; j< N; j++) v[i- 1][j- 1]= (i+ j)% 3;

        for (int i= 1; i<= m; i++)
                for (int j= 1; j<= m; j++) cin >> cost[i][j];

        for (int i= 0; i< n; i++)
                for (int j= 0; j< n; j++) cin >> ar[i][j];

        for (int i= 0; i< n; i++)
                for (int j= 0; j< n; j++) ne[v[i][j]][ar[i][j]]++;

        int f[4]= { 0 }, ans= 1e18;

        auto calc= [&]() {
                int an= 0;
                for (int i= 1; i<= m; i++) {
                        an+= ne[0][i]* cost[i][f[0]];
                }
                for (int i= 1; i<= m; i++) {
                        an+= ne[1][i]* cost[i][f[1]];
                }
                for (int i= 1; i<= m; i++) {
                        an+= ne[2][i]* cost[i][f[2]];
                }
                return an;
        };

        for (int i= 1; i<= m; i++) {
                for (int j= 1; j<= m; j++) {
                        if (i== j) continue;

                        for (int k= 1; k<= m; k++) {
                                if (i== k|| j== k) continue;
                                f[0]= i;
                                f[1]= j;
                                f[2]= k;
                                ans= min(ans, calc());
                        }
                }
        }
        cout << ans<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 7560
def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = [list(map(int, input().split())) for _ in range(M)]
    BC.sort(reverse=True, key=lambda x:x[1])
    cnt = 0
    for B,C in BC:
        A.extend([C for _ in range(B)])
        cnt += B
        if cnt >= N:
            break
    A.sort(reverse=True)
    ans = 0
    for i in range(N):
        ans += A[i]
    print(ans)

main()

Measured memory_bytes: 34780
import java.util.Scanner;

public class Main {

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

		int h = sc.nextInt();
		int w = sc.nextInt();

		int[][] ans = new int[h][w];
		for (int i = 0; i < h; i++) {
			String s = sc.next();
			for (int j = 0; j < w; j++) {
				if (s.charAt(j) != '#') {
					continue;
				}
				ans[i][j] = -99;
				for (int k = i - 1; k <= i + 1; k++) {
					if (k < 0 || h <= k) {
						continue;
					}
					for (int l = j - 1; l <= j + 1; l++) {
						if (l < 0 || w <= l || (k == i && l == j)) {
							continue;
						}
						ans[k][l]++;
					}
				}
			}
		}

		for (int[] arr : ans) {
			for (int n : arr) {
				System.out.print(n < 0 ? "#" : n);
			}
			System.out.println();
		}

		sc.close();
	}
}


Measured memory_bytes: 22228
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll a[maxn],k,n;
bool check(ll x){
	ll c=0;
	for(int i=0;i<n;i++){
		if(a[i]%x!=0) c+=a[i]/x;
		else c+=a[i]/x-1;
	}
	if(c<=k) return true;
	return false;
}

int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	ll l=1,r=1e9,ans;
	while(l<=r){
		ll mid=(l+r)>>1;
		if(check(mid)){
			r=mid-1;ans=mid;
		} 
		else l=mid+1;
	}
	cout<<ans;
	return 0;	
} 

Measured memory_bytes: 4724
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 1;										/* デバッグプリント 提出時は0 */

int dp[10001] = {0};

int main()
{
	int		N,W,v[101],w[101],i,j;
	//int		*dp;
	scanf("%d %d", &N, &W);
	for(i=1; i<=N; i++) {
		scanf("%d %d",&v[i],&w[i]);
	}
/*
	for(i=1;i<=N;i++) {
		for(j=0;j+w[i]<=W;j++) {
				dp[j+w[i]] = max( dp[j+w[i]] , dp[j]+v[i]);
		}
	}
*/
	for(i=1;i<=N;i++) {
		for(j=w[i];j<=W;j++) {
				dp[j] = max( dp[j] , dp[j-w[i]]+v[i]);
		}
	}

	printf("%d\n",dp[W]);

	return 0;
}



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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	int l=a[0],r=a[n-2];
	int aim=a[n-1]/2+(a[n-1]%2==0?0:1);
	int now;
	int dis=0x3f3f3f3f;
	for(int i=0;i<n-1;i++)
	{
		if(abs(a[i]-aim)<dis)
		{
			dis=abs(a[i]-aim);
			now=a[i];
		}
	}
	cout << a[n-1] <<' ' << now;
	
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)

signed main(){
    int n; cin>>n; cout<<n+n*n+n*n*n<<endl;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] lines = br.readLine().split(" ");
        double[] xList = new double[n];
        double[] yList = new double[n];
        int i = n;
        while (i-- > 0) {
            xList[i] = Double.parseDouble(lines[i]);
        }
        i = n;
        lines = br.readLine().split(" ");
        while (i-- > 0) {
            yList[i] = Double.parseDouble(lines[i]);
        }
        double result = 0.0;
        for (i = 1; i < 4; i++) {
            result = 0;
            for (int j = 0; j < n; j++) {
                result += Math.pow(Math.abs(xList[j] - yList[j]), i);
            }
            result = Math.pow(result, 1.0 / i);
            System.out.printf("%f\n", result);
        }
        result = 0.0;
        for (i = 0; i < n; i++) {
            result = Math.max(Math.abs(xList[i] - yList[i]), result);
        }
        System.out.printf("%f\n", result);
    }
}

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/
int H,W;
char s[100][100];
int flag[100][100];


int main(){
  
  cin >> H >> W;
  
  memset(flag,0,sizeof flag);
  
  rep(i,H) rep(j,W) cin >> s[i][j];
   
  int c = 0;
  
  rep(i,H){
    rep(j,W){
      if(s[i][j] == '#'){
        if(i > 0 && s[i-1][j] == '#') continue;
        if(i < H-1 && s[i+1][j] == '#') continue;
        if(j > 0 && s[i][j-1] == '#') continue;
        if(j < W && s[i][j+1] == '#') continue;
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
  
  
}

  


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

string digits[10];

int main(void){
	rep(i,10){
		digits[i]="";
		if(i>=5)
			digits[i]+=" *=";
		else
			digits[i]+="* =";
		rep(j,5){
			if(i%5==j)
				digits[i]+=" ";
			else
				digits[i]+="*";
		}
	}
	string in;
	bool first=true;
	while(cin >> in ){
		if(cin.eof())
			break;
		else if(first)
			first=false;
		else
			cout << endl;
		while(in.size() < 5)
			in = "0"+in;
		rep(i,8){
			rep(j,5)
				cout << digits[(in[j]-'0')][i];
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const a = read<double>();
	auto const b = read<double>();
	auto const x = read<double>();
	double h0 = 2.0 * x / (a * a) - b;
	if (h0 >= 0.0) {
		writeln((180.0 / M_PI) * atan2(b - h0, a));
		return;
	}
	double w0 = 2.0 * x / (a * b);
	writeln((180.0 / M_PI) * atan2(b, w0));
}

Measured memory_bytes: 256
using System;

public class Program {
  public static void Main(string[] args) {
    var str = Console.ReadLine();
    int n = int.Parse(str);
    var str2 = Console.ReadLine().Split();
    int[] a = new int[n];
    
    for (int i = 0; i < n; i++) {
      a[i] = int.Parse(str2[i]);
    }
    
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)) {
        Console.WriteLine("DENIED");
        return ;
      }
    }
    
    Console.WriteLine("APPROVED");
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	int a, b;
	cin >> a >> b;
	bool have[4] = {0 ,0, 0};
	have[a] = have[b] = true;
	for(int i = 1; i<=3; i++) if (!have[i]) cout << i << endl;
	return 0;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    int64_t num0 = count(A.begin(), A.end(), (int64_t)0);
    if (num0 > 0) {
        cout << 0 << endl;
        return 0;
    }

    int64_t ans = 1;
    for (int64_t a : A) {
        double after = (double)ans * a;
        if (after > 5e18) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a;
        if (ans > (int64_t)1e18) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4056
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] p = new Integer[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        int result = 0;
        for (int i = 1; i < n - 1; i++) {
            if (Math.max(p[i-1], p[i+1]) >= p[i] && Math.min(p[i-1], p[i+1]) <= p[i]) {
                result++;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


//for(i=0; i<N; i++) cin >> a[i];


int main(void) {
  ll i, j, k, l;
  
  ll N;
  cin >> N;
  ll a[MAX*2];
  ll cnt[66][66]={};
  pll f[MAX*2]={};
  
  map<double, ll> mp;
  for(i=0; i<N; i++) {
    double tt;
    cin >> tt;
    a[i]=llround(tt*1e9);
    
    ll t=a[i];
    ll c2=0, c5=0;
    while(t%2==0) {c2++; t/=2;}
    while(t%5==0) {c5++; t/=5;}
    cnt[c2][c5]++;
    f[i]={c2, c5};
  }
  
  
  ll ans=0;
  for(i=0; i<N; i++) {
    ll n2=max(18-f[i].ft, 0LL);
    ll n5=max(18-f[i].sc, 0LL);
    
    for(j=n2; j<66; j++) {
      for(k=n5; k<66; k++) {
        ans+=cnt[j][k];
      }
    }
    
    if(n2<=f[i].ft && n5<=f[i].sc) ans--;
  }
  ans/=2;
  pt(ans);
}


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

long long gcd(long long number1, long long number2)
{
  //最大公約数
  long long m = number1;
  long long n = number2;

  if (number2 > number1)
  {
    m = number2;
    n = number1;
  }
  long long r = n % m;
  while (r != 0)
  {
    n = m;
    m = r;
    r = n % m;
  }

  return m;
}

int main()
{
  int N;
  cin >> N;
  vector<long> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }

  long ans = A[0];
  rep(i, N - 1)
  {
    ans = gcd(ans, A[i + 1]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int shakkin = 100000;
    int n;

    cin >> n;

    for (int i = 0; i < n; i++){
        shakkin += (shakkin * 0.05);
        if ( (shakkin % 1000) != 0) {
            shakkin -= (shakkin % 1000);
            shakkin += 1000;
        }
    }

    cout << shakkin << endl;
}


Measured memory_bytes: 3088
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

#define INF 0x3f3f3f3f

using namespace std;

typedef long long LL;
typedef pair<int,int>PII;

const int maxn = 1e5 + 10;

int vis[maxn],cnt[maxn];
int fa[maxn],sz[maxn],deg[maxn];

int ans = 0;

int get(int x) {
	return x == fa[x] ? x : fa[x] = get(fa[x]);
}

void Union(int x,int y) {
	int xx = get(x);
	int yy = get(y);
	if(xx == yy) return ;
	fa[yy] = xx;
	sz[xx] += sz[yy];
	return ;
}

int main(void) {
	int n,m,k;
	int u,v;
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i ++) {
		fa[i] = i;
		sz[i] = 1;

	}
	for(int i = 1; i <= m; i ++) {
		cin >> u >> v;
		deg[u] ++;
		deg[v] ++;
		Union(u,v);
	}
	for(int i = 1; i <= k; i ++) {
		cin >> u >> v;
		if(get(u) == get(v)) {
			cnt[u] --;
			cnt[v] --;
		}
	}
	for(int i = 1; i <= n; i ++) {
		cout << sz[get(i)] - deg[i] + cnt[i] - 1<< " ";
	}
	return 0;
}

Measured memory_bytes: 2944
N = int(input())
W = input()
L = []
L.append(W)
last = W[-1]
ans = 'Yes'
for _ in range(N-1):
    w = input()
    if w in L:
        ans = 'No'
    if last == w[0]:
        last = w[-1]
        L.append(w)
    else:
        ans = 'No'
print(ans)

Measured memory_bytes: 3064
import bisect

n=int(input())
s=list(input())

#アルファベットの各文字に対してからのリストを持つ辞書
alpha={chr(i):[] for i in range(97,123)}

#alpha[c]で各文字ごとに出現場所をソートして保管
for i,c in enumerate(s):
    bisect.insort(alpha[c],i+1)

for i in range(int(input())):
    p,q,r=input().split()
    if p=='1':
        q=int(q)
        b=s[q-1]
        if b!=r:
            alpha[b].pop(bisect.bisect_left(alpha[b],q))
            bisect.insort(alpha[r],q)
            s[q-1]=r
    else:
        count=0
        for l in alpha.values():
            pos=bisect.bisect_left(l,int(q))
            if pos<len(l) and l[pos]<=int(r):
                count+=1
        print(count)


Measured memory_bytes: 123764
// 2020-07-18 10:41:19
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct mint {
  ll divisor = 1000000007;
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % divisor) {
    if (val < 0) val += divisor;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = divisor, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += divisor;
    u %= divisor;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= divisor) val -= divisor;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += divisor;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % divisor;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % divisor;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
  friend std::string debug_s (mint a) noexcept {
    return std::to_string(a.val);
  }
};

void answer() {
  int n, k;
  cin >> n >> k;
  map<int, mint> mp;
  mint ans = 0;
  REPCM(x, k, 1) {
    mp[x] = modpow(mint(k/x), n);
    int y = x + x;
    while(y <= k) {
      mp[x] -= mp[y];
      y += x;
    }
    ans += mp[x] * x;
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 9892
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	long A, B, N;
	cin >> N >> A >> B ;
	
	long C = A + B;
	long  L = N % C;
	
	long ans = N / C * A + min(L, A);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        String s = sc.next();
        Integer[] l = new Integer[q];
        Integer[] r = new Integer[q];
        for (int i = 0; i < q; i++) {
            l[i] = Integer.parseInt(sc.next());
            r[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        int[] arr = new int[n];
        for (int i = 1; i < n; i++) {
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') {
                arr[i] = arr[i - 1] + 1;
            } else {
                arr[i] = arr[i - 1];
            }
        }

        String[] arrS = new String[q];
        for (int i = 0; i < q; i++) {
            arrS[i] = Integer.toString(arr[r[i] - 1] - arr[l[i] - 1]);
        }

        // 出力
        String result = String.join("\n", arrS);
        System.out.println(result);
    }
}


Measured memory_bytes: 64632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
		
		boolean[] ac = new boolean[n + 1];
		int[] wa = new int[n + 1];
		int acCount = 0;
		int penalty = 0;
		
		for(int i = 0; i < m; i++) {
			tmpArray = br.readLine().split(" ");
			int p = Integer.parseInt(tmpArray[0]);
			String str = tmpArray[1];
			
			if(!ac[p]) {
				if(str.equals("AC")) {
					ac[p] = true;
					acCount++;
					penalty += wa[p];
				}
				else {
					wa[p]++;
				}
			}
		}
		
		System.out.println(acCount+" "+penalty);
	}

}


Measured memory_bytes: 47828
#include<stdio.h>
#include<stdlib.h>

#define MAX 500001

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count=0; 

int main(){
  int n,i;
  int S[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i]<0 || S[i]>1000000000){
      exit(1);
    }
  }

  mergeSort(S,0,n);

  for(i=0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n",S[n-1]);
  printf("%d\n",count);

  return 0;
}

//Conquer
void merge(int *A,int l,int m,int r){
  int n1=m-l;
  int n2=r-m;
  int i,j,k;
  int *L,*R;

  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));

  for(i=0;i<=n1-1;i++){
    L[i]=A[l+i];
  }

  for(j=0;j<=n2-1;j++){
    R[j]=A[m+j];
  }

  L[n1]=1000000000;
  R[n2]=1000000000;

  i=0;
  j=0;

  for(k=l;k<=r-1;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }else{
      A[k]=R[j];
      j=j+1;
    }

    count++;
  }

  free(L);
  free(R);
}

//Solve
void mergeSort(int *A,int left,int right){
  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4476
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll 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;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    ll H,W; cin>>H>>W;
    vector<string> S(H);
    rep(i,0,H) cin>>S[i];
    string ans="Possible";
    rep(i,1,H){
        rep(j,1,W){
            if(S[i][j-1]=='#'&&S[i-1][j]=='#') ans="Impossible";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int M;
	cin >> M;

	cout << 48 - M;

	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


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

	if (n == 1 && i == 1) {
		cout << 1 << endl;
		return 0;
	}

	cout << n - i + 1 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool vis[3];
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	a--,b--;vis[a]=1,vis[b]=1;
	for(int i=0;i<3;++i)
	{
		if(!vis[i])
		{
			printf("%d\n",i+1);
			break;
		}
	}
	return 0;
} 

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

int main() {
	int n,m,left = 1,right = 1e5 + 5;
	cin >> n >> m;
	for ( int i = 0; i < m; ++i){
		int l,r;
		cin >> l >> r;
		left = max(left,l);
		right = min(right,r);
	}
	cout << max(right - left + 1,0) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char A[11]={'\0'};
    char B[11]={'\0'};
    char C[11]={'\0'};
    scanf("%s%s%s",A,B,C);
    if(A[strlen(A)-1]==B[0]&&B[strlen(B)-1]==C[0])printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

bool ATGC(char s){
	if(s == 'A' || s == 'T' || s == 'G' || s == 'C')
      return true;
  	return false;
}
  
void f() {
  string s;
  cin >> s;
  int count;
  int ans = 0;
  int n = s.size();
  forn(i, n){
    count = 0;
    for(int j = i; j < n; j++){
        if(ATGC(s[j])){
              count++;
        }
      	else
          break;
     }
     ans = max(ans, count);
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,a,b;
    cin>>n>>a>>b;
    if (a%2==b%2){
        cout<<(b-a)/2;
    }
    else {
        cout<<min(a-1,n-b)+1+(b-a-1)/2;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

bool check(string& s, ll a, ll b) {
    --a, --b;
    ll n = s.size();
    while(a < b) {
        if(a + 1 < n && s[a + 1] == '.') ++a;
        else if(a + 2 < n && s[a + 2] == '.') a += 2;
        else return false;
    }
    return true;
}

bool check2(string& s, ll a, ll b) {
    --a, --b;
    for(ll i = a; i <= b; i++) {
        if(s.substr(i - 1, 3) == "...") return true;
    }
    return false;
}

bool solve() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    if(!check(s, a, c)) return false;
    if(!check(s, b, d)) return false;
    if(d < c && !check2(s, b, d)) return false;
    return true;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cout << (solve() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int x[N],y[N];
  long long int h[N];
  for(int i=0;i<N;i++) cin>>x[i]>>y[i]>>h[i];
  for(int cx=0;cx<=100;cx++) for(int cy=0;cy<=100;cy++){
    long long int ch[N],ans;
    memset(ch,0,sizeof ch);
    for(int i=0;i<N;i++){
      if(h[i]) ch[i]=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
      if(ch[i]) ans=ch[i];
    }
    int i=0;
    for(i;i<N;i++){
      if(ch[i] && ch[i]!=ans) break;
      if(!ch[i] && ans-abs(x[i]-cx)-abs(y[i]-cy)>0) break;
    }
    if(i==N) {cout<<cx<<" "<<cy<<" "<<ans;return(0);}
  }
}

Measured memory_bytes: 256
import sys
import math

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

n = ni()
s = []

ans = []
x = 0
for i in range(n):
    s.append(nsl())
    s[i].sort()
    if(len(s[x]) > len(s[i])):
        x = i


for c in ''.join(s[x]):
    e = True
    while(e):
        for i in range(n):
            if(c not in s[i]):
                e = False
                break
            else:
                s[i].remove(c)
                if(i == n-1):
                    ans.append(c)

print(''.join(ans))





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

int main()
{
    int a,b,k,mi,ma,cnt=0;
    cin >> a >> b >> k;
    mi = min(a,b);
    ma = max(a,b);
    for(int i=mi;i>0;i--)
    {
        if((a%i == 0)&&(b%i==0))
        {
            cnt +=1;
        }
        if(cnt == k)
        {
            cout << i;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
using namespace std;
int main(){
  ll n,c,num,max=0,tmp;
  scanf("%lld%lld",&n,&c);
  ll x[n],v[n],left[n],right[n],lmax[n],rmax[n];
  for(int i=0;i<n;i++){
    scanf("%lld%lld",&x[i],&v[i]);
    if(i!=0){
      right[i]=right[i-1]+v[i]-(x[i]-x[i-1]);
      rmax[i] = (rmax[i-1]>right[i])?rmax[i-1]:right[i];
    }else{
      right[0] = v[0]-x[0];
      rmax[0] = (right[0]>0)?right[0]:0;
    }
    max = (rmax[i]>max)?rmax[i]:max;
  }
  for(int i=0;i<n;i++){
    if(i!=0){
      left[i]=left[i-1]+v[n-1-i]-(x[n-i]-x[n-i-1]);
      lmax[i] = (lmax[i-1]>left[i])?lmax[i-1]:left[i];
    }else{
      left[0] = v[n-1]-(c-x[n-1]);
      lmax[0] = (left[0]>0)?left[0]:0;
    }
    max = (lmax[i]>max)?lmax[i]:max;
  }
  for(int i=0;i<n-1;i++){
    tmp = (lmax[n-2-i]-x[i]>0)?lmax[n-2-i]-x[i]:0;
    num = right[i]+tmp;
    max = (num>max)?num:max;
    
    tmp = (rmax[n-2-i]-(c-x[n-1-i])>0)?rmax[n-2-i]-(c-x[n-i-1]):0;
    num = left[i]+tmp;
    max = (num>max)?num:max;
  }
  printf("%lld\n",max);
}


Measured memory_bytes: 4864
def main():
  N, K = map(int, input().split(' '))
  # N本の木があって，i本目の木はh_i[m]
  # K本選んで電飾する.
  # 木の内一番高いのをh_max[m], 低いものをh_min[m]
  # min(h_max - h_min)をしたい.
  trees = [int(input()) for _ in range(N)]
  trees.sort()
  trees = [n - trees[0] for n in trees]
  # print(trees[K-1] - trees[0]) -> これだと，最初の方はかなり分散が大きい配列で，後ろの方が分散が小さい配列だとダメ
  # 例[0, 100, 101, 102] から2個選ぶ時, 上記だと100が帰ってくる.
  # MIN = 100000000000000
  # print(trees)
  # for n in range(K):
  # for n in range(N - K + 1):
  #   t = trees[n+K-1] - trees[n]
  #   MIN = min(t, MIN)
  MIN = min([trees[n+K-1] - trees[n] for n in range(N-K+1)])
  print(MIN)

main()

Measured memory_bytes: 11216
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int x, n;
    cin >> x >> n;
    map<int, int> m;
    vector<int> v;
    rep(i, n) {
        int ent;
        cin >> ent;
        m[ent] = 1;
    }
    int ma = INF;
    for(int i = -201; i < 201; i++) {
        if(m[i] != 1) {
            if(abs(x - i) < ma) v.pb(i);
            ma = abs(x - i);
        }
        // cout << ma << " ";
    }
    cout << v[v.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 3664