akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

int main() {
  int a, b, c;
  int count_five = 0, count_seven = 0;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);

  if (a == 5) count_five++;
  if (a == 7) count_seven++;
  if (b == 5) count_five++;
  if (b == 7) count_seven++;
  if (c == 5) count_five++;
  if (c == 7) count_seven++;

  if (count_five == 2 && count_seven == 1)
  {
    printf("YES");
  } else
  {
    printf("NO");
  }
}


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数
vector<long long> fact, fact_inv, inv;

//二項係数前処理計算量O(SIZE)
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
    
//nCk　計算量(1)
ll nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

int main(){
    ll H,W,A,B;
    cin>>H>>W>>A>>B;
    init_nCk(200010);
    ll ans=0;
    ll i=H-A;
    ll j=B+1;
    while(i>0&&j<=W){
        ll k=H-(i);
        ll l=W-(j);
        ans+=(nCk(i+j-2,i-1)*nCk(k+l,k))%MOD;
        ans%=MOD;
        i--;
        j++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7948
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
    int N;
    cin>>N;
    long long X;
    cin>>X;
    vector<long long> b(N), l(N), u(N);
    for (int i=0; i<N; i++)
        cin>>b[i]>>l[i]>>u[i];

    if (accumulate(b.begin(), b.end(), 0LL)==0)
    {
        cout<<0<<endl;
        return 0;
    }

    vector<tuple<long long, long long, long long, long long>> V;
    for (int i=0; i<N; i++)
        V.push_back(make_tuple(-(X*u[i]-b[i]*(u[i]-l[i])), b[i], l[i], u[i]));
    sort(V.begin(), V.end());
    for (int i=0; i<N; i++)
    {
        b[i] = get<1>(V[i]);
        l[i] = get<2>(V[i]);
        u[i] = get<3>(V[i]);
    }

    auto f = [&](long long x) -> bool
    {
        int c = (int)(x/X);
        long long A = 0;
        long long B = 0;
        for (int i=0; i<c; i++)
        {
            A += X*u[i];
            B += b[i]*u[i];
        }
        for (int i=c; i<N; i++)
            B += b[i]*l[i];

        for (int i=0; i<N; i++)
        {
            long long imp = x%X>b[i] ? u[i] : l[i];
            long long A2 = A + x%X*imp;
            long long B2 = B + b[i]*imp;

            if (i<c)
            {
                A2 -= X*u[i];
                B2 -= b[i]*u[i];

                B2 -= b[c]*l[c];
                A2 += X*u[c];
                B2 += b[c]*u[c];
            }
            else
                B2 -= b[i]*l[i];

            if (A2 >= B2)
                return true;
        }
        return false;
    };

    long long L = 0;
    long long R = N*X;
    while (R-L>1)
    {
        long long m = (L+R)/2;
        (f(m) ? R : L) = m;
    }
    cout<<L+1<<endl;
}


Measured memory_bytes: 8816
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;
    if (s == "AAA" || s == "BBB") std::cout << "No" << std::endl;
    else std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	long long n, k;
	cin >> n >> k;
	long long waru = n / k;
	long long plus = n - waru * k;
	long long mainasu = n - ((waru + 1) * k);
	if (abs(plus) >= abs(mainasu))
	{
		cout << abs(mainasu);
	}
	else
	{
		cout << plus;
	}
}


Measured memory_bytes: 31488
#include<stdio.h>
  
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;
 
       
     
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}


Measured memory_bytes: 2112
-- https://github.com/minoki/my-atcoder-solutions

main = do
  s <- getLine
  print $ case s of
    "SUN" -> 7
    "MON" -> 6
    "TUE" -> 5
    "WED" -> 4
    "THU" -> 3
    "FRI" -> 2
    "SAT" -> 1


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

const int N = (1e5) + 5;
int n, a[N];
int L[N];
int R[N];

// claudio van
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    L[i] = __gcd(L[i - 1], a[i]);
  }
  for (int i = n; i >= 1; --i) {
    R[i] = __gcd(a[i], R[i + 1]);
  }
  int mx = 1;
  for (int i = 1; i <= n; ++i) {
    mx = max(mx, __gcd(L[i - 1], R[i + 1]));
  }
  printf("%d\n", mx);
  return 0;
}

Measured memory_bytes: 1408
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 1005;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

int n, m;
char arr[maxn][maxn];

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

int dx[] = {0, 1};
int dy[] = {1, 0};

ll dp[maxn][maxn];

ll dfs (int x, int y){
    if (!ok(x, y) || arr[x][y] == '#') return 0LL;
    if (x == n && y == m){
        return 1LL;
    }

    ll &ans = dp[x][y];

    if (ans != -1) return ans % mod;

    ans = 0;
    for (int i = 0; i < 2; i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        ans = (ans + dfs(nx, ny)) % mod;
    }

    return ans % mod;
}

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

    memset(dp, -1, sizeof dp);

    cin >> n >> m;

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            cin >> arr[i][j];
        }
    }

    cout << dfs(1, 1) % mod << "\n";

    return 0;
}


Measured memory_bytes: 9216
using System;
using System.Collections.Generic;
using System.Linq;
class program{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    bool[] table = new bool[1000001];
    Array.Sort(a);
    if(a[0] == 1){
      if(n == 1){
        Console.Write(1);
        return;
      }
      if(a[1] == 1){
        Console.Write(0);
        return;
      }else{
        Console.Write(1);
        return;
      }
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
      if(!table[a[i]]){
        if(i+1 < n){
          if(a[i] != a[i+1]) ans++;
        }else{
          ans++;
        }
        for(int j = a[i];j <= 1000000; j += a[i]) table[j] = true;        
      }
    }
    Console.Write(ans);
  }
}

Measured memory_bytes: 43484
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    vector<int> A(3);
    for (int i = 0; i < 3; i++) cin >> A[i];
    sort(A.begin(), A.end());
    if (A[0] == A[1] && A[1] != A[2]) {
        cout << "Yes" << endl;
        return;
    }
    if (A[0] != A[1] && A[1] == A[2]) {
        cout << "Yes" << endl;
        return;
    }
    else {
        cout << "No" << endl;
        return;
    }
}


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

Measured memory_bytes: 256
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    int a,b,c;
    cin>>a>>b>>c;
    cin>>k;
    if(k<=a) cout<<k<<ln;
    else if(k<=a+b) cout<<a<<ln;
    else cout<<a-1*(k-a-b)<<ln;
}


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

void IOinit() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}

int main() {
  IOinit();
  string s;
  cin >> s;
  bool flag = true;
  if (s[0] != 'A') flag = false;
  int n = s.size();
  int c = 0;
  for(int i = 1; i < n; i++) {
    if ((2 <= i) && (i < n-1) && (s[i] == 'C')) c++;
    else if (isupper(s[i])) flag = false;
  }
  if (c != 1) flag = false;
  if (flag) cout << "AC" << "\n";
  else cout << "WA" << "\n";
  return 0;
}

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

int main(void) 
{
    int n;
    cin >> n;
    ll ans =0;

    for(int i =1; i<=n ; ++i)
    {
        if(i%3 == 0 || i%5 ==0)
            continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)

using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;

int main()
{
    //cout << "Hello world!" << endl;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    if(k<=a){
        cout<<k<<endl;
    }else if(k<=a+b){
        cout<<a<<endl;
    }else{
        cout<<a-(k-(a+b))<<endl;
    }


    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a<=c&&c<=b)cout<<"Yes"<<endl;
  else{cout <<"No" << endl;}
  return 0;
}

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

using ll = long long;

struct node
{
	int size = 1;
	ll val;
	ll lazy;
};

struct tree
{
	vector<node> t;
	int size = 1;

	tree(int n)
	{
		while(size < n)
			size *= 2;
		t.resize(size * 2);
		for(int i = size - 1; i >= 1; i--)
			t[i].size = t[i * 2].size * 2;
	}

	void propagate(int v)
	{
		for(int x = v * 2; x <= v * 2 + 1; x++)
		{
			t[x].val += t[v].lazy;
			t[x].lazy += t[v].lazy;
		}

		t[v].lazy = 0;
	}

	void update(int v)
	{
		t[v].val = max(t[v * 2].val, t[v * 2 + 1].val);
	}

	void add(int l, int r, ll val, int v = 1)
	{
		if(l == 0 && r == t[v].size - 1)
		{
			t[v].val += val;
			t[v].lazy += val;
			return;
		}

		propagate(v);

		int m = t[v].size / 2;
		if(r < m)
			add(l, r, val, v * 2);
		else if(m <= l)
			add(l - m, r - m, val, v * 2 + 1);
		else 
			add(l, m - 1, val, v * 2), add(0, r - m, val, v * 2 + 1);

		update(v);
	}

	ll get(int l, int r, int v = 1)
	{
		if(l == 0 && r == t[v].size - 1)
			return t[v].val;

		propagate(v);

		int m = t[v].size / 2;
		if(r < m)
			return get(l, r, v * 2);
		else if(m <= l)
			return get(l - m, r - m, v * 2 + 1);
		else
			return max(get(l, m - 1, v * 2), get(0, r - m, v * 2 + 1));
	}
};

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

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

	vector<pair<int, int>> v(m);
	vector<vector<int>> beg(n + 1), end(n + 1);
	for(int i = 0; i < m; i++)
	{
		int l, r, a;
		cin >> l >> r >> a;
		beg[l].emplace_back(i);
		end[r].emplace_back(i);
		v[i] = {l - 1, a};
	}

	tree tree(n + 1);
	for(int i = 1; i <= n; i++)
	{
		for(int id : beg[i])
			tree.add(0, v[id].first, v[id].second);

		ll ans = tree.get(0, i - 1);
		tree.add(i, i, ans);

		for(int id : end[i])
			tree.add(0, v[id].first, -v[id].second);
	}

	cout << tree.get(0, n) << "\n";
}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<int> es;
  for (ll d = 2; d * d <= n; d++) {
    int e = 0;
    while (n % d == 0) {
      n /= d;
      e++;
    }
    es.push_back(e);
  }
  if (n > 1) {
    es.push_back(1);
  }
  int sol = 0;
  for (auto &e : es) {
    int cur = 1;
    while (e >= cur) {
      e -= cur;
      cur++;
      sol++;
    }
  }
  cout << sol << "\n";
  return 0;
}


Measured memory_bytes: 7364
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
S = input()

ans = 0
tmp = 0
for x in S:
	if x == "I":
		tmp += 1
	else:
		tmp -= 1
	ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 3892
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

alias R = Tuple!(long, "x", long, "y", long, "p");

void main()
{
    auto N = readln.chomp.to!int;
    R[] rs;
    foreach (_; 0..N) {
        auto r = readln.split.to!(long[]);
        auto x = r[0];
        auto y = r[1];
        auto p = r[2];
        rs ~= R(x, y, p);
    }

    auto xs = new long[][](N, 1<<N);
    auto ys = new long[][](N, 1<<N);
    foreach (b; 0..2^^N) {
        foreach (i, r; rs) {
            xs[i][b] = abs(r.x) * r.p;
            ys[i][b] = abs(r.y) * r.p;
            foreach (j; 0..N) if (b & (1<<j)) {
                xs[i][b] = min(xs[i][b], abs(r.x - rs[j].x) * r.p);
                ys[i][b] = min(ys[i][b], abs(r.y - rs[j].y) * r.p);
            }
        }
    }

    auto res = new long[](N+1);
    res[] = long.max;
    foreach (b; 0..3^^N) {
        int c;
        uint x, y;
        foreach (i; 0..N) {
            if (b%3 == 1) {
                x |= (1<<i);
                ++c;
            } else if (b%3 == 2) {
                y |= (1<<i);
                ++c;
            }
            b /= 3;
        }
        long s;
        foreach (i; 0..N) s += min(xs[i][x], ys[i][y]);
        res[c] = min(res[c], s);
    }
    foreach (r; res[0..N+1]) writeln(r);
}

Measured memory_bytes: 10880
import collections
def solve(n, a):
    a_list = [int(i) for i in a.split()]
    count = collections.Counter()

    for i in a_list:
        count[i] += 1
        count[i+1] += 1
        count[i-1] += 1

    return max(count.values())

if __name__ == "__main__":
    n = int(input())
    a = input()
    print(solve(n, a))

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

    ll ans = 0;
    REP(i, N){
        cin >> A[i];
        ans += A[i]-1;
    }

    cout << ans << endl;
    return 0;
}

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

#include <iostream>
#include <vector>
#include <cstdlib>

// // vector
// #define MAX_ELE(vec) *max_element(vec.begin(), vec.end())
// #define SORT(vec) sort(vec.begin(), vec.end());


// // ---------------------------------------

// // string
// #define TO_UP(str) transform(str.cbegin(), str.cend(), str.begin(), ::toupper)

// // ---------------------------------------



using namespace std;

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;
}

    int N, W;
    int w[110];
    long long v[110];
    long long dp[110][100010];

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

    cin >> N >> W;

    for (int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }
    
    for (int i = 0; i < N; i++)
    {
        for (int sum_w = 0; sum_w <= W; sum_w++)
        {
            if (sum_w - w[i] >= 0)
            {
                chmax(dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }
            
            
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
        
        
    }

    cout << dp[N][W] << "\n";
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int n,t[205],ans=0;
	cin>>n;
	for(int i=1;i<=2*n;i++)cin>>t[i];
	sort(t+1,t+2*n+1);
	for(int i=2*n-1;i>=1;i-=2)ans+=t[i];
	cout<<ans<<endl;
	return 0;
}

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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;


struct att {
	LL damege;
	LL throwindex;
	bool isthrow = false;
};

int main() {

	LL sumthrowdamage = 0;

	LL N, H;
	cin >> N >> H;

	//vector<LL> atack(N), thatack(N);

	vector<att> at;
	LL maxattack = 0; int maxindex;
	REP(i, N) {
		LL a, b;
		cin >> a >> b;
		//atack[i] = a;
		//maxattack = max(maxattack, a);

		if (a > maxattack) {
			maxattack = a;
			maxindex = i;
		}

		att aa;
		aa.damege = a;
		aa.throwindex = i;
		att bb;
		bb.damege = b;
		bb.throwindex = i;
		bb.isthrow = true;

		at.push_back(aa);
		at.push_back(bb);


		//thatack[i] = b;
		sumthrowdamage += b;
	}

	//if (sumthrowdamage >= H) {
	//	cout << N << endl;
	//	return 0;
	//}


	sort(ALL(at), [&](att& a, att& b) {return a.damege>b.damege;  });
	//sort(ALL(atack), std::greater<LL>());
	int atknum = 0;
	
	for (int i = 0; i<at.size(); i++) {
		if (at[i].isthrow){

			H -= at[i].damege;
			//at.erase(i + at.begin());
			atknum++;
			if (H <= 0) { cout << atknum << endl; return 0; }
		}
		else {
			atknum += ((H +at[i].damege-1)/ at[i].damege);
			cout << atknum << endl;

			return 0;

		}
	}
	
	cout << atknum << endl;
}


Measured memory_bytes: 8048
#include <cstdio>
#include <cstring>

int main(){
    char s[101],t[101];
    scanf("%s\n%s",s,t);
    char a;
    for(int i = 0; s[i] != 0; i++){
        for(int j = i + 1; s[j] != 0; j++){
			if(s[i] > s[j]){
				a = s[i];
				s[i] = s[j];
				s[j] = a;
			}
		}
	}
    for(int i = 0; t[i] != 0; i++){
        for(int j = 0; t[j] != 0; j++){
            if(t[i] > t[j]){
                a = t[i];
                t[i] = t[j];
                t[j] = a;
            }
        }
    }
    if(strcmp(s, t) < 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 16

int main(void){
	int w,h,n;
	int ng[MAX][MAX], num[MAX][MAX];
	
	while (scanf("%d%d",&w,&h), w){
		// reset NG points and num of routes;
		for (int i=0;i<w;i++){
			for (int j=0;j<h;j++){
				ng[i][j] = num[i][j] = 0;
			}
		}
		// set NG points;
		scanf("%d", &n);
		for (int i=0;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			ng[x-1][y-1] = 1;
		}
		// count num of routes;
		num[0][0] = 1;
		for (int i=1;i<=(w-1)+(h-1); i++){
			for (int j=0;j<=i; j++){
				int x, y;
				x = j; y = i-j;
				if (x<w && y<h && !ng[x][y]){
					if (x>=1) num[x][y] += num[x-1][y];
					if (y>=1) num[x][y] += num[x][y-1];
//					printf("\tnum of rt. to (%d,%d): %d\n", x, y, num[x][y]);
				}// else printf("(%d,%d) is out of field\n",x,y);
			}
		}
/*		puts("result:");
		for (int y=h-1;y>=0;y--){
			for (int x=0;x<w;x++){
				printf("%02d ", num[x][y]);
			}
			puts("");
		}
		*/
		printf("%d\n",num[w-1][h-1]);
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

def main():
    K = int(input())
    if K % 2 == 0:
        print(-1)
        exit(0)
    if K % 5 == 0:
        print(-1)
        exit(0)
    i = 1
    term = 7
    # L = 9 * K
    # if K % 7 == 0:
    #     L = 9 * (K // 7)
    while True:
        amari = term % K
        if amari == 0:
            print(i)
            exit(0)
        term = amari * 10 + 7
        i += 1

if __name__ == '__main__':
    main()


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

class union_find {
public:
vector<int> par,rank,lsize;
union_find(int n): par(n),rank(n),lsize(n){
   for (int i=0;i < n;i++){
      par[i]=i;
      rank[i]=0;
      lsize[i]=1;
   }
}

int find(int x){
   if (par[x]==x){
      return x;
   }
   else{
      return par[x] = find(par[x]); 
   }
}

void unite(int x ,int y){
   x=find(x);
   y=find(y);
   if (x==y) return;
   if (rank[x] < rank[y]){
      lsize[y] += lsize[x];
      lsize[x] = -1;
      par[x] = y;
   }else{
      lsize[x] += lsize[y];
      lsize[y] = -1;
      par[y]=x;
      if (rank[x]==rank[y]) rank[x]++;
   }   
}

bool same(int x, int y){
   return find(x) == find(y);
}

int size(int x){
   if (lsize[x] == -1){
      x=find(x);
   }
   return lsize[x];
}
};

int main(){
  int n,m;
  cin >> n >> m;
  union_find tree(n);
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--;y--;
    tree.unite(x,y);
  }
  int ans = 0;
  rep(i,n){
    ans = max(ans,tree.size(i));
  }
  cout << ans << endl;

  
  return 0;
}


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

int main(){
    ll n,x;
    cin>>n>>x;
    ll sum=0;
    vector<ll> m(n);
    for(ll i=0;i<n;++i){
        cin>>m[i];
        sum += m[i];
    }
    sort(m.begin(), m.end());
    ll flag=(x-sum)/m[0];
    cout<<flag+n<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		int[] dp = new int[100100];
		int[] h = new int[n];
		for (int i = 0; i < h.length; i++) {
			h[i] = sc.nextInt();
		}
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		for (int i = 1; i < n; i++) {
			dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			if(i > 1) dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		}

		System.out.println(dp[n - 1]);
	}
}

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

int main(){
  int a,sum,m[300];
  cin >> a;
  for(int i=0;i<a*2;i++){
    cin >> m[i];
  }
  sort(m,m+a*2);
  sum=0;
  for(int i=0;i<a*2;i+=2){
    sum+=m[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
using namespace std;
using ll=long long;

int main(int argc, char const *argv[]) {
  string a,b,c;
  std::cin >> a >> b >> c;
  char dif='A'-'a';
  printf("%c%c%c",a[0]+dif,b[0]+dif,c[0]+dif );
  return 0;
}


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

#define debug(x) cout << (#x) << " is " << x << endl;
#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;


int main()
{
    int has = 1, a, b, ans=0;
    cin >> a >> b;
	while(has < b){
		has--;
		has += a;
		ans++;
	}
	cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)	cin>>a[i];
  sort(a,a+n);
  for(int i=1;i<n;i++){
    if(a[i]==a[i-1]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

ll n,a,b;
ll calc(ll a,ll b){
	if(a>b)swap(a,b);
	ll l = a;
	b-= a;
	a = 1;
	return l+(b-a)/2;
}
int main() {
	read(n);read(a);read(b);
	if(a%2 == b%2){
		if(a<b)swap(a,b);
		cout<<(a-b)/2<<endl;
	}else{
		cout<<min(calc(a,b),calc(n+1-a,n+1-b))<<endl;
	}
	return 0;
}


Measured memory_bytes: 764
N = int(input())
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[N-1])

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

typedef long long int llint;

int main()
{
  map<string, bool> mp;
  int n;
  cin>> n;

  string fst;
  cin>> fst;
  char c = fst[fst.size() - 1];
  mp[fst] = true;

  bool flg = true;
  
  for(int i = 1; i < n; i++) {
    string s;
    cin>> s;

    if(s[0] != c || mp[s]) flg = false;
    c = s[s.size() - 1];
    mp[s] = true;
  }
    
  if(flg) cout<< "Yes" <<endl;
  else    cout<< "No" <<endl;
  
  return 0;
}


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

int main(void){
	int n,t[1000],a[1000];
	long int box,x=0,y=0,px,py,res=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> t[i] >> a[i];
		if(i==0){
			x += t[i];
			y += a[i];
			res = x + y;
		}else{
			px = x;
			py = y;
			box = max(x/t[i],y/a[i]);
			x = box * t[i];
			y = box * a[i];
			if(px > x ||py > y){
				x += t[i];
				y += a[i];
			}
			res = x + y;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd

N, X = map(int, input().split())
x = list(map(int, input().split()))

tmp = [0] * N
x.sort()
tmp[0] = abs(X - x[0])

for i in range(N - 1):
    tmp[i + 1] = x[i + 1] - x[i]

ans = 0
for i in range(N):
    ans = gcd(ans, tmp[i])

print(ans)

Measured memory_bytes: 16300
import math
N=int(input())
d=[]
l=[]
for i in range(N):
  x,y=map(int,input().split())
  l.append([x,y])
for i in range(N-1):
  for j in range(i+1,N):
    x1,y1=l[i][0],l[i][1]
    x2,y2=l[j][0],l[j][1]
    d.append(math.sqrt((x1-x2)**2+(y1-y2)**2))
print(2*sum(d)/N)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb push_back
#define len(x) x.size()
#define all(x) x.begin(), x.end()

int get_height(vector<string> inc) {
	vector<pii> v;
	for (auto s : inc) {
		int lowest = INT_MAX;
		int order = 0;
		for (char c : s) {
			order += c == '(' ? 1 : -1;
			lowest = min(lowest, order);
		}
		v.pb({lowest, order});
	}
	sort(all(v));
	reverse(all(v));
	int order = 0;
	for (auto p : v) {
		if (order + p.x < 0) return -1; 
		order += p.y;
	}
	return order;
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int N;
	cin >> N;
	vector<string> inc;
	vector<string> dec;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		int order = 0;
		for (char c : s) {
			if (c == '(') order++;
			if (c == ')') order--;
		}
		if (order >= 0) inc.pb(s);
		else dec.pb(s);
	}

	for (auto &s : dec) {
		for (char &c : s) {
			c = c =='(' ? ')' : '(';
		}
		reverse(all(s));
	}

	int res1 = get_height(inc);
	int res2 = get_height(dec);
	// printf("%d %d\n", res1, res2);
	if (res1 == -1 || res2 == -1) {
		cout << "No\n";
		return 0;
	}
	if (res1 == res2) {
		cout << "Yes\n";
		return 0;
	} else {
		cout << "No\n";
		return 0;
	}
}


Measured memory_bytes: 58140
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

public class Program
{
    public static void Main(string[] args)
    {
        new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
        var x = cin.ReadInt;

        var quotient = x / 100;
        var surplus = x % 100;
        if (surplus <= quotient * 5)
        {
            WriteLine(1);
        }
        else
        {
            WriteLine(0);
        }
        ReadKey();
    }
}

public class ConsoleInput
{
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
        this._separator = separator;
        this._stream = stream;
        inputStream = new Queue<string>();
    }
    public string Read
    {
        get
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(_separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}


Measured memory_bytes: 11220
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;i++)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
#define sum(v)+x            accumulate(v.begin(), v.end(),x);
#define debug(x)            cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int x;
    cin>>x;
    for(int i=-1000;i<=1000;i++)
    {
        for(int j=-1000;j<=1000;j++)
        {
            if((pow(i,5)-pow(j,5))==x)
            {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    
    

    
    
    
    
    
    return 0;
}

Measured memory_bytes: 4008
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        int C = scn.nextInt();
        int ans = 0;
        if(A*C > B) {
            ans = B/A;
        } else {
            ans = C;
        }
        System.out.println(ans);
        scn.close();
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#define ABS(a) ((a < 0)? -a : a)
#define MIN(a, b) ((a < b)? a : b)

void solve(int *x, int n, int k) {
    int i, min = 1e9+7, tmp, tmp1, tmp2;
    for(i = 0; i < n-k+1; ++i) {
        tmp1 = ABS(x[i]) + ABS(x[k - 1 + i] - x[i]);
        tmp2 = ABS(x[k - 1 + i]) + ABS(x[k - 1 + i] - x[i]);
        tmp = MIN(tmp1, tmp2);
        min = MIN(tmp, min);
    }
    printf("%d\n", min);
}

int main(void)
{
    int N, K, i;
    scanf("%d %d", &N, &K);
    int *x = (int*)malloc((N+1)*sizeof(int));
    for(i = 0; i < N; ++i) { scanf("%d", &x[i]); }
    solve(x, N, K);
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var s = Read();
            var ans = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != 'A' && s[i] != 'T' && s[i] != 'G' && s[i] != 'C') continue;
                var count = 1;
                for (int j = i+1; j < s.Length; j++)
                {
                    if (s[j] != 'A' && s[j] != 'T' && s[j] != 'G' && s[j] != 'C')
                        break;
                    count++;
                }
                ans = Math.Max(ans, count);
            }
            Console.WriteLine(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
bitset<5010> can;
int fa[5010],a[5010],f[5010];
vector <int> des[5010];
int main()
{
	int n;scanf("%d",&n);
	for (int i=2;i<=n;i++) {scanf("%d",&fa[i]);des[fa[i]].push_back(i);}
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int s=n;s>=1;s--)
	{
		int all=0,ad=0;
		for (int k=0;k<des[s].size();k++)
		{
			all+=min(a[des[s][k]],f[des[s][k]]);
			ad+=max(a[des[s][k]],f[des[s][k]])-min(a[des[s][k]],f[des[s][k]]);
		}
		if (a[s]<all) {puts("IMPOSSIBLE");return 0;}
		can.reset();can[0]=1;
		for (int k=0;k<des[s].size();k++)
			can|=(can<<(max(a[des[s][k]],f[des[s][k]])-min(a[des[s][k]],f[des[s][k]])));
		for (int i=a[s]-all;i>=0;i--) if (can[i]) {f[s]=ad-i;break;}
		//cout<<s<<' '<<f[s]<<endl;
	}
	puts("POSSIBLE");
} 

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

typedef long long ll;
typedef long double ld;

using namespace std;

const ll maxn = 100 * 1001;
const ll INF = 1e18;
const ll mod = 1e9+7;

vector<ll> g[maxn];
ll n , m , k;
string s;

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

    cin>> s; ll t = 0, sum = 0; n = s.size();
    for(ll i = 0; i < s.size(); i++)
        if(s[i] == 'B')
        {
           t++;
           sum += n - i;
        }

    cout<< sum - t*(t+1)/2;
}







Measured memory_bytes: 3152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n,m,u,v,vis[N];
VI e[N],ret;
void dfs(int u) {
	ret.pb(u); vis[u]=1;
	for (auto v:e[u]) if (!vis[v]) {
		dfs(v);
		break;
	}
}
int main() {
	scanf("%d%d",&n,&m);
	rep(i,0,m) {
		scanf("%d%d",&u,&v);
		e[u].pb(v); e[v].pb(u);
	}
	vis[v]=1;
	dfs(u);
	reverse(all(ret));
	vis[v]=0;
	dfs(v);
	printf("%d\n",SZ(ret));
	for (auto p:ret) printf("%d ",p);
}

Measured memory_bytes: 9720
# coding: utf-8
#-------------------------------------------------------------------
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

N = int(input())						# 5
d = sorted(list( map(int, input().split()) ))	# 1 2 3 4 5 ...(ソート付き)

n=N//2

a=d[:n]
b=d[n:]

p(d)
p(a)
p(b)

ans=max(0, b[0]-a[-1])

print(ans)


Measured memory_bytes: 14396
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))

from fractions import gcd

l_gcd = [0 for _ in range(n)]
r_gcd = [0 for _ in range(n)]

for i in range(n):
    l_gcd[i]=gcd(l_gcd[i-1],a[i])
for i in range(n-1,-1,-1):
    if i == n-1:
        r_gcd[i]=a[i]
    else:
        r_gcd[i]=gcd(r_gcd[i+1],a[i])
ret = 1

for i in range(n):
    if i==0:
        ret = max(ret,gcd(0,r_gcd[i+1]))
    elif i==n-1:
        ret = max(ret,gcd(l_gcd[i-1],0))
    else:
        ret = max(ret,gcd(l_gcd[i-1],r_gcd[i+1]))
print(ret)

Measured memory_bytes: 85344
a,b=list(map(int,input().split()))
c = [0] * a
for i in range(b):
	x,y=list(map(int,input().split()))
	c[x-1]=c[x-1]+1
	c[y-1]=c[y-1]+1

for j in range(a):
	print(c[j])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;

  std::vector<int> w(n);
  for (auto&& wi : w) std::cin >> wi;

  std::vector<int> cum(n);
  cum[0] = w[0];
  for (int i = 1; i < n; ++i) cum[i] = w[i] + cum[i - 1];

  int min = cum[n - 1];
  for (int i = 0; i < n; ++i) {
    const auto s1 = cum[i];
    const auto s2 = cum[n - 1] - cum[i];
    const auto diff = std::abs(s1 - s2);
    if (min > diff) min = diff;
  }
  std::cout << min << std::endl;
}


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

int n;
string s;

int main(){
	cin >> n;
	int ans = 0;
	int a,b,ab;
	a = b = ab = 0;
	for(int j=1;j<=n;j++){
		cin >> s;
		for(int i=0;i<s.size()-1;i++){
			if(s[i] == 'A' && s[i+1] == 'B') ans++;
		}
		int bob = 0;
		if(s[0] == 'B'){
			bob++;
		}
		
		if(s[s.size()-1] == 'A'){
			bob+=2;
		}
		if(bob == 1) b++;
		else if(bob == 2) a++;
		else if(bob == 3) ab++;
	}
	int tmp = max(0,ab-1);
	if(ab > 1) ab = 1;
	if(ab > 0){
		if(a > 0) a--, tmp++;
		if(b > 0) b--, tmp++;
	}
	tmp+=min(a,b);
	printf("%d\n",ans+tmp);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX / 10;
const ll LINF = LLONG_MAX / 10;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n;
	cin >> n;
	int c[4] = { 0 };

	rep(i, n) {
		string s;
		cin >> s;
		if (s[0] == 'A') c[0]++;
		else if (s[0] == 'W') c[1]++;
		else if (s[0] == 'T') c[2]++;
		else c[3]++;
	}

	cout << "AC x " << c[0] << endl;
	cout << "WA x " << c[1] << endl;
	cout << "TLE x " << c[2] << endl;
	cout << "RE x " << c[3] << endl;

}


Measured memory_bytes: 3624
#include<iostream>

using namespace std;

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

    while(cin>>a>>b>>c&&!(a==-1&&b==-1&&c==-1))
    {
        if(a==-1||b==-1)
        {
            cout<<"F";
        }else if(a+b>=80)
        {
            cout<<"A";
        }else if(a+b>=65)
        {
            cout<<"B";
        }else if(a+b>=50)
        {
            cout<<"C";
        }else if(a+b>=30)
        {
            if(c>=50)
            {
                cout<<"C";
            }else
            {
                cout<<"D";
            }
        }else
        {
            cout<<"F";
        }
        cout<<endl;
    }


    return 0;
}



Measured memory_bytes: 3068