akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
dic = defaultdict(int)
for a in A:
    dic[a] += 1

ans = 0
for a in A:
    if dic[a] != 0:
        b = 2**(a.bit_length()) - a
        if dic[b] != 0:
            if b == a and dic[b] == 1:
                continue
            ans += 1
            dic[a] -= 1
            dic[b] -= 1

print(ans)

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

using namespace std;

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

  string S; cin>>S;
  int N = S.size()+1;

  char p = S[0];
  int len = 1;
  vector<pair<char, int>> rl;
  for (int i = 1; i < S.size(); i++) {
    if (S[i] == p) {
      len++;
    } else {
      rl.emplace_back(p, len);
	  len = 1;
    }
    p = S[i];
  }
  rl.emplace_back(p, len);

  long ans = 0;
  int i = 0;
  if (rl[0].first == '>') {
	long l = rl[0].second;
    ans += l*(l+1)/2;
    i = 1;
  }
  for (; i < rl.size(); i+=2) {
    if (i+1 < rl.size()) {
      if (rl[i].second >= rl[i+1].second) {
        long l = rl[i].second;
        ans += l*(l+1)/2;
        l = rl[i+1].second;
        ans += l*(l-1)/2;
      } else {
		long l = rl[i].second;
		ans += l*(l-1)/2;
		l = rl[i+1].second;
		ans += l*(l+1)/2;
      }
    } else {
	  long l = rl[i].second;
	  ans += l*(l+1)/2;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3352
n = int(input())
s = input()
min = 0
for i in range(1,n):
    if s[i] == 'E':
        min += 1
cont = min
for j in range(1,n):
    if s[j-1] == 'W':
        cont += 1
    if s[j] == 'E':
        cont -= 1
    if cont < min:
        min = cont
print(min)

Measured memory_bytes: 3676
# D - Number of Amidakuji

import itertools

H, W, K = map(int, input().split())
MOD = 10**9 + 7

if W == 1:
    print(1)
    exit()

# move[i][j] 左iから左jに移動できる横棒のパターン数
move = [[0]*W for _ in range(W)]
for horizontal_line_pattern in list(itertools.product([0,1], repeat=W-1)):
    for i in range(W-2):
        if horizontal_line_pattern[i] == 1 and horizontal_line_pattern[i+1] == 1:
            break
    else:
        for i in range(W-1):
            if horizontal_line_pattern[i] == 1:
                move[i][i+1] += 1
                move[i+1][i] += 1
            else:
                if i == 0:
                    move[0][0] += 1
                elif i == W-2:
                    move[W-1][W-1] += 1
                try:
                    if horizontal_line_pattern[i+1] == 0:
                        move[i+1][i+1] += 1
                except IndexError:
                    pass

# dp[i][j] 0段目左0から辿るとi段目の移動の後で左jに到達するようなアミダクジのパターン数
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1

for i in range(1, H+1):
    for j in range(W):
        for k in [-1, 0, 1]:
            try:
                dp[i][j] += dp[i-1][j+k] * move[j][j+k]
                dp[i][j] %= MOD
            except IndexError:
                pass

print(dp[H][K-1])

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

void bingo_check(vector<vector<int> > &vec);

int main(){
    vector<vector<int> > A(3,vector<int>(3));
    for(int i=0;i<3; i++){
        for(int j=0;j<3; j++){
            cin >> A.at(i).at(j);
        }
    }
    vector<vector<int> > check(3,vector<int>(3));
    int N;
    cin >> N;
    vector<int> b(N);
    for(int k=0;k<N;k++){
        cin >> b.at(k);
        for(int i=0;i<3; i++){
            for(int j=0;j<3; j++){
                if(A.at(i).at(j) == b.at(k)){
                    check.at(i).at(j) = 1;
                }
            }
        }
    }
    

    bingo_check(check);
}

void bingo_check(vector<vector<int> > &vec) {
    // 縦方向ビンゴのチェック
    int down1=0;
    int down2=0;
    int down3=0;
    for(int i=0; i<3; i++){
        // 横方向ビンゴのチェック
        int cnt=0;
        for(int j=0; j<3; j++){
            if(vec.at(i).at(j) == 1){
                cnt++;
            }
            if(vec.at(i).at(j) == 1 && j==0){
                down1++;
            }
            if(vec.at(i).at(j) == 1 && j==1){
                down2++;
            }
            if(vec.at(i).at(j) == 1 && j==2){
                down3++;
            }
        }
        if(cnt == 3){
            cout << "Yes" << endl;
            return;
        }
    }

    // 斜めビンゴのチェック
    int across=0;
    if(vec.at(2).at(2) == 1 && vec.at(1).at(1) == 1 && vec.at(0).at(0) == 1){
        across=3;
    }
    if(vec.at(1).at(1) == 1 && vec.at(0).at(2) == 1 && vec.at(2).at(0) == 1){
        across=3;
    }

    if(down1 == 3 || down2 == 3 || down3 == 3 || across == 3){
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
    return;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
public static Scanner sc = new Scanner (System.in);
     public static void main(String []args){
        
        int N = sc.nextInt();
        int[][] F = input(N,10);
        int[][] P = input(N,11);
        int ans = 0;
        //System.out.println(Arrays.toString(F[0]));
        for (int b=1;b<(1<<10);b++){
            int cc = 0;
            for (int i=0;i<N;i++){
                int c = 0;
                for(int j=0;j<10;j++)if(((b>>(9-j)&1)==F[i][j])&&F[i][j]==1)c++;
                cc += P[i][c];
            }
            if(b==1)ans=cc;
            ans = Math.max(ans,cc);
        }
        //for(int i=0;i<N;i++)System.out.println(Arrays.toString(F[i]));
        //for(int i=0;i<N;i++)System.out.println(Arrays.toString(P[i]));
        System.out.println(ans);
        
     }
     
     public static int[][] input(int N,int n){
         int[][] a = new int[N][n];
         for (int i=0;i<N;i++) for (int j=0;j<n;j++) a[i][j]=sc.nextInt();
         return a;
     }
}

Measured memory_bytes: 27520
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  string s; cin >> s;
  int n = s.size();
  cout << s.at(0) << n-2 << s.at(n-1) << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Test {
	static void Main(string[] args) {
      var inputs = System.Console.ReadLine()
    	.Split(' ')
    	.Select(s => long.Parse(s))
    	.ToArray();
      long X = Math.Abs(inputs[0]);
      long K = inputs[1];
      long D = inputs[2];
      long result = X;
      if((long) (X / D) > K){
        result = X - D * K;
      }else{
        result = X - (long) (D * ((long) X / D));
        K = K - ((long) X / D);
        if(K % 2 == 1){
          result = Math.Abs(result - D);
        }
      }
      Console.WriteLine(result);
	}
}

Measured memory_bytes: 19012
n = int(input())
a = input()
b = input()

ans = 3
i = 0
if a[0] != b[0]:
    i += 1
    ans += 3

while i < n-1:
    if a[i]==b[i]:
        if a[i+1]==b[i+1]:
            ans *= 2
        else:
            ans *= 2
            i += 1
    else:
        if a[i+1]==b[i+1]:
            ans *= 1
        else:
            ans *= 3
            i += 1
    i += 1
    ans %= 1000000007
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin >> n;vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
        int sum = 0;
        for(int i = 1; i < n; i++){
            if(v[i] - v[i - 1] < 0)
            sum += abs(v[i] - v[i - 1]);
        }
    sum += v[n -1];
    cout << sum << endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  for (int i = n - 1; i > 0; --i) {
    if (h[i] < h[i - 1]) h[i - 1]--;
  }

  
  bool is_valid = true;
  for (int i = 0; i < n - 1; ++i) {
    if (h[i + 1] < h[i]) is_valid = false;
  }

  if (is_valid) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}



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

using namespace std;

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

//int dxy[5] = {0, 1, 0, -1, 0};
// 01Trie BIT CHT DFT FFT avl cmd cusum dijkstra dinic geo2 gin graph kruskal lca lcm matrix ncm next_combination ppuf segtree st tmp topcoder uf vi

int fact[4400000];

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

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else { x = 1; y = 0; }
    return d;
}

int repow(int x, int n, int mod)
{
    if (n == 0) return 1;
    int res = repow(x * x % mod, n / 2, mod);
    if (n & 1) res = res * x % mod;
    return res;
}

int mod_inverse(int a, int m)
{
    int x, y;
    extgcd(a, m, x, y);
    return ( m + x % m ) % m;
}

int table(int n, int p)
{
    int sum = 1;
    fact[0] = 1;
    Rep(i, n+2) {
        sum *= i;
        sum %= p;
        fact[i] = sum;
    }
    return 0;
}

int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0) return 1;
    int res = mod_fact(n / p, p, e);
    e += n / p;

    if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}

int mod_comb(int n, int k, int p) {
    if (n < 0 || k < 0 || n < k) return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n-k, p, e3);
    if (e1 > e2 + e3) return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

signed main()
{
    table(4000000, MOD);

    Int(n);
    string st;
    cin >> st;
    int k = st.size();

    int len = n + k;

    int ans = repow(26, len, MOD);

    rep(i, k) {
        ans = (ans - (repow(25, len - i, MOD) * mod_comb(len, i, MOD) % MOD) + MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 36576
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

ll fre[N];

void solve()
{
	ll n;
	cin >> n;
	ll a[n];
	ll ag = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		ag = __gcd(ag, a[i]);

		if (a[i] % 2 == 0)fre[2]++;
		while (a[i] % 2 == 0)
		{
			a[i] /= 2;
		}
		for (int j = 3; j * j <= a[i]; j += 2 )
		{
			if (a[i] % j == 0)fre[j]++;
			while (a[i] % j == 0)
			{
				a[i] /= j;
			}
		}
		if (a[i] > 2)fre[a[i]]++;
	}
	for (int i = 0; i < N; ++i)
	{
		if (fre[i] >= 2)
		{
			if (ag == 1) {
				cout << "setwise coprime" << endl;
				return;
			}
			else cout << "not coprime" << endl;
			return;
		}
	}
	cout << "pairwise coprime" << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

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

ll N, K, A[100005], dp[100005];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> N >> K;
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}
	dp[0] = 0;
	for (ll i = 1; i < N; i++) {
		dp[i] = 1e18;
		for (ll j = 1; j <= K; j++) {
			if (i - j >= 0) {
				dp[i] = min(dp[i], dp[i-j] + abs(A[i]-A[i-j]));
			}
		}
	}
	cout << dp[N-1] << "\n";

	return 0;
}

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

INF = 10**8
dp = [INF]*(N+1)
dp[0] = 0

for i in range(1, N+1):
    for j in range(M):
        if i < C[j]:
            continue
        dp[i] = min(dp[i], dp[i-C[j]]+1)
print(dp[-1])



Measured memory_bytes: 7256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n,m = sc.nextInt
  val seq = Seq.fill(m)((sc.nextInt, sc.next))
  
  val grouped = seq.groupBy(_._1).map{case (_, v) => v}
  val ac = grouped.filter(_.exists(_._2 == "AC")).size
  val wa = (for {
    i <- grouped
    index = i.indexWhere(_._2 == "AC")
    if index >= 0
  } yield index).toSeq.sum
  
  println(s"$ac $wa")
}

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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B>C+D){
    cout<<"Left"<<endl;
  }else if(A+B<C+D){
    cout<<"Right"<<endl;
  }else{
    cout<<"Balanced"<<endl;
  }
}


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

int main(){
    int N, X, Y;
    int buf;
    cin >> N >> X >> Y;
    int dist_count[N];
    REP(i,N) dist_count[i] = 0;
    for(int i=1;i<N;i++){
        for(int j=i+1;j<=N;j++){
            buf = min(abs(X-i)+abs(j-Y)+1,abs(X-j)+abs(Y-i)+1);
            buf = min(abs(j-i),buf);
            dist_count[buf-1] += 1;
        }
    }
    REP(i,N-1) cout << dist_count[i] << endl;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = h[0];
	rep(i, n - 1) {
		if (h[i] < h[i + 1]) ans += h[i + 1] - h[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
l = input()
dp = [[0 for j in range(2)] for k in range(len(l)+1)]
dp[0][0] = 1
for i in range(len(l)):
    #a+b=1
    if l[i] == '0':
        dp[i+1][1] = dp[i][1]*2
    else:
        dp[i+1][1] = dp[i][1]*2
        dp[i+1][0] = dp[i][0]*2
    
    #a+b = 0
    if l[i] == '0':
        dp[i+1][1] += dp[i][1]
        dp[i+1][0] += dp[i][0]
    else:
        dp[i+1][1] += dp[i][1]+dp[i][0]
        
    dp[i+1][1] %= 10**9+7
    dp[i+1][0] %= 10**9+7
print((dp[len(l)][0]+dp[len(l)][1])%(10**9+7))

Measured memory_bytes: 21248
import numpy as np
import math

N = int(input())

C = np.zeros([10,10], dtype = int)
D = np.zeros([10,10], dtype = int)

for n in range(1,N+1):
    k = math.floor(math.log10(n)) + 1
    i = n//10**(k-1)
    j = n%10
    C[i][j] += 1
    D[j][i] += 1

ans = np.sum(C*D)
print(ans)

Measured memory_bytes: 14404
#include<stdio.h>
int main(){
int n,q,i,j;
scanf("%d %d",&n,&q);
int top=0;
int participant[n];
int x[q];
int y[q];
for(i=0;i<n;i++){
participant[i]=0;
}
for(i=0;i<q;i++){
int a,v;
scanf("%d %d",&a,&v);
participant[a-1]+=v;
if(a-1!=top){
if(participant[top]<participant[a-1]){
top=a-1;
}else if((participant[top]==participant[a-1])&&(top>a-1)){
top=a-1;
}
}else{
top=0;
for(j=1;j<n;j++){
if(participant[top]<participant[j]){
top=j;
}
}
}
x[i]=top;
y[i]=participant[top];
}
for(i=0;i<q;i++){
printf("%d %d\n",x[i]+1,y[i]);
}
return 0;
}

Measured memory_bytes: 5284
#include <iostream>
#include <vector>
#include <algorithm>
// #include <string>
// #include <map>
// #include <set>
// #include <cmath>

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

// void p() {
//     cout << "\n";
// }
// template<class Head, class... Body>
// void p(Head head, Body... body) {
//     cout << head << ",";
//     p(body...);
// }

int main(int argc, char const *argv[]) {
    int A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    int N, M, C;
    cin >> N >> M >> C;

    vector<int> B(M);
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }

    int ans = 0;
    for (int j = 0; j < N; j++) {
        int sum = 0;
        for (int i = 0; i < M; i++) {
            int Ai;
            cin >> Ai;

            sum += Ai * B[i];
        }
        sum += C;

        if (sum > 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nab[0];
			int a = nab[1];
			int b = nab[2];

			long ans = 0;
			for (int i = 1; i <= n; i++) {
				int sum = 0;
				int m = i;
				while (m > 0) {
					sum += m % 10;
					m /= 10;
				}

				if (sum >= a && sum <= b) {
					ans += i;
				}
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    int cnt[26] = {};
    REP(i,H) {
        string tmp; cin >> tmp;
        REP(j,W){
            cnt[tmp[j]-'a']++;
        }
    }
    if(H%2 == 0 && W%2 == 0){
        REP(i,26){
            if(cnt[i]%4 != 0){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else if(H % 2 != 0 && W % 2 != 0){
        int cnt1 = 0;
        int memo1 = -1;
        REP(i,26){
            if(cnt[i]%2 != 0){
                cnt1++;
                memo1 = i;
                if(cnt1 >= 2){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        cnt[memo1]--;
        int cnt2 = 0;

        REP(i,26){
            if(cnt[i]%4 != 0){
                cnt2++;
                if(cnt2 > H/2 + W/2){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        cout << "Yes" << endl;
    }else{
        if(H % 2 == 0) swap(H,W);
        int cnt1 = 0;

        REP(i,26){
            if(cnt[i]%2 != 0){
                cout << "No" << endl;
                return 0;
            }
        }

        REP(i,26){
            if(cnt[i]%4 != 0){
                cnt1++;
                if(cnt1 > W/2){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        cout << "Yes" << endl;
    }



}


Measured memory_bytes: 256
import java.util.*;

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

Measured memory_bytes: 22996
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))

int min(int x,int y)
{
	if(x > y)
	{
		return y;
	}
	else
	{
		return x;
	}
}

int max(int x,int y)
{
	if(x < y)
	{
		return y;
	}
	else
	{
		return x;
	}
}

void swap_chpt(char* x,char* y)
{
	char* tmp = x;
	x = y;
	y = tmp;
}

void swap_int(int* x,int* y)
{
	int tmp = *x;
	*x = *y;
	*y = tmp;
}

int main()
{
	int n;
	int i,j;
	scanf("%d",&n);
	for(i = 0;i < n;i++)
	{
		char str[2][1000];
		scanf("%s",str[0]);
		scanf("%s",str[1]);
		int s = 0;
		int len[2] = {strlen(str[0]),strlen(str[1])};
		int llen = max(len[0],len[1]);
		if(llen > 80)
		{
			printf("overflow\n");
			continue;
		}
		char* pt = str[0];
		for(j = llen;j >= 0;j--)
		{
			if((j-llen+len[0]-1) >= 0)
			{
				str[0][j] = str[0][j-llen+len[0]-1];
			}
			else
			{
				str[0][j] = '0';
			}
			if((j-llen+len[1]-1) >= 0)
			{
				str[1][j] = str[1][j-llen+len[1]-1];
			}
			else
			{
				str[1][j] = '0';
			}
		}
		str[0][llen+1] = '\0';
		str[1][llen+1] = '\0';
		int c = 0;
		for(j = llen;j > 0;j--)
		{
			int sum = str[0][j] - '0' + str[1][j] - '0' + c;
			str[0][j] = '0'+(sum%10);
			c = sum/10;
		}
		if(c == 1)
		{
			if(llen == 80)
			{
				printf("overflow\n");
				continue;
			}
			str[0][0] = '1';
		}
		else
		{
			pt++;
		}
		printf("%s\n",pt);
	}
	return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,m;

    cin>>n>>m;

    li tp=n+m;

    li total=(tp*(tp-1))/2;

    total-=n*m;

    cout<<total;

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m;
int g[5050][5050];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> m;
    rep(i, m) {
        int a, b, x;
        cin >> a >> b >> x;
        g[a][b] += 1;
        g[a][b + 1] -= 1;
        g[a + x + 1][b] -= 1;
        g[a + x + 2][b + 1] += 1;
        g[a + x + 1][b + x + 2] += 1;
        g[a + x + 2][b + x + 2] -= 1;
    }
    rep(i, 5010)rep(j, 5010) g[i][j + 1] += g[i][j];
    rep(i, 5010)rep(j, 5010) g[i + 1][j] += g[i][j];
    rep(i, 5010)rep(j, 5010) g[i + 1][j + 1] += g[i][j];
    int ans = 0;
    rep(i, 5010)rep(j, 5010) {
        if (g[i][j] > 0) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
	int a[3][3];
	int check[3][3] = {0};
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin >> a[i][j];
		}
	}
	
	int n;
	cin >> n;
	
	int b[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> b[i];
	}
	
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 3; ++k)
			{
				if (b[i] == a[j][k])
				{
					check[j][k] = 1;
				}
			}
		}
	}
	/*
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cout << check[i][j] << " ";
		}
		cout << endl;
	}
	*/
	
	int i, j, ans = 0;
	i = 0;
	ans = 0;
	for (int j = 0; j < 3; ++j)
	{
		if (check[i][j] == 1)
		{
			ans++;
		}
	}
	if (ans == 3)
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	i = 1;
	ans = 0;
	for (int j = 0; j < 3; ++j)
	{
		if (check[i][j] == 1)
		{
			ans++;
		}
	}
	if (ans == 3)
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	i = 2;
	ans = 0;
	for (int j = 0; j < 3; ++j)
	{
		if (check[i][j] == 1)
		{
			ans++;
		}
	}
	if (ans == 3)
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	
	
	i = 0;
	ans = 0;
	for (int j = 0; j < 3; ++j)
	{
		if (check[j][i] == 1)
		{
			ans++;
		}
	}
	if (ans == 3)
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	i = 1;
	ans = 0;
	for (int j = 0; j < 3; ++j)
	{
		if (check[j][i] == 1)
		{
			ans++;
		}
	}
	if (ans == 3)
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	i = 2;
	ans = 0;
	for (int j = 0; j < 3; ++j)
	{
		if (check[j][i] == 1)
		{
			ans++;
		}
	}
	if (ans == 3)
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	
	ans = 0;
	for (int i = 0; i < 3; ++i)
	{
		if (check[i][i] == 1)
		{
			ans++;
		}
	}
	if (ans == 3)
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	ans = 0;
	j = 2;
	for (int i = 0; i < 3; ++i)
	{
		if (check[i][j] == 1)
		{
			ans++;
		}
		j--;
	}
	if (ans == 3)
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
int main(){
  string n;
  cin>>n;
  if(n[1]==n[2]){
    if(n[0]==n[1] || n[3]==n[1]){
      cout<<"Yes"<<endl;return 0;
    }
  } 
  cout<<"No"<<endl;
 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	if (n % 2)cout << 2 * n << endl;
	else cout << n << endl;
	return 0;
}

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

int main(){

  long long n;
  cin >> n;

  
  unordered_map<string,int> mp;
  for(int i=0;i<n;i++){
  string s;
  
cin >>s;
    sort(s.begin(),s.end());
    
    mp[s]++;
  }
  
  

long long  count=0;
  for(auto& p : mp){
  long long c=p.second;
    count+= c*(c-1)/2;
  
  }
  
  cout << count << endl;



}


Measured memory_bytes: 10660
n, k = gets.chomp.split(" ").map(&:to_i)

a = n / k
if k.odd?
  puts a**3
else
  b = k / 2
  if n - k * a >= b
    puts a**3 + (a + 1)**3
  else
    puts (a**3) * 2
  end
end

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

int main(){
  int n;
  cin >> n;
  int dp[n];
  dp[0]=0;
    for ( int i = 1 ; i < n + 1 ; i ++){
        dp[i] = dp[i - 1] + 1;
    }

    for (int six = 1; six <= n; six *= 6) {
        for (int j = 1; j < n + 1; j++) {
            if (j - six < 0) {
                continue;
            }
            dp[j] = min(dp[j - six] + 1, dp[j]);
        }
    }

    for (int nine = 1; nine < n + 1; nine *= 9) {
            for (int j = 1; j < n + 1; j++) {
                if (j - nine < 0) {
                    continue;
                }
                dp[j] = min(dp[j - nine] + 1, dp[j]);
            }
        }
    cout << dp[n] << endl;
}

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

#define ff first
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
inline void fastio(){ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);}

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



int main(){
	fastio();

	ll n; cin>>n;
	ll d[n]; f(i,0,n-1) cin>>d[i];

	ll ans=0;
	f(i,0,n-1){
		f(j,i+1,n-1) ans+=(d[i]*d[j]);
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 256
// EはDPのD
// DP 要復習
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int n,t;
    cin>>n>>t;
    vp a(n);
    cin>>a;
    sort(all(a));
    REP(i,n)dprint(a[i]);
    vvi dp(n, vi(t));

    REP(i,n-1){
        REP(j,t){
            dp[i+1][j]=dp[i][j];
        }
        REP(j,t-a[i].F){
            chmax(dp[i+1][j+a[i].F], dp[i][j] + a[i].S);
        }
    }
    int ma=0;
    chmax(ma, a[0].S);
    REP(i,n){
        chmax(ma, dp[i][t-1] + a[i].S);
    }
    //REP(i,n)dprint(dp[i]);
    cout<<ma<<endl;
}


Measured memory_bytes: 35584
#include <stdio.h>
int main()
{
	int a,b,c,i,j,k,ans=0,x;
	scanf("%d %d %d %d",&a,&b,&c,&x);
	for(i=0;i<=a;i++)
		for(j=0;j<=b;j++)
			for(k=0;k<=c;k++)
			{
				if(i*500+j*100+k*50==x)
					ans++;
				if(i*500+j*100+k*50>x)
					break;
			}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n, m;
	scanf("%d%d", &n, &m);
	bool[][] g = new bool[][](n,n);
	foreach (i; 0..n) foreach (j; 0..n) {
		if (i != j) g[i][j] = true;
	}
	foreach (i; 0..m) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		g[a][b] = g[b][a] = false;
	}
	//if (n*(n-1)/2 == m) {
	//	int s = n/2, t = n-s;
	//	m -= s*t;
	//	writeln(m);
	//	return;
	//}

	int[] color = new int[n];
	color[] = -1;

	int[] cnt;
	bool dfs(int v, int c) {
		if (color[v] != -1) {
			if (color[v] != c) return false;
			return true;
		}
		color[v] = c;
		cnt[c]++;
		foreach (u; 0..n) {
			if (g[v][u]) {
				if (!dfs(u,c^1)) return false;
			}
		}
		return true;
	}
	int l = 0;
	int[] a;
	foreach (i; 0..n) {
		if (color[i] != -1) continue;
		cnt = new int[2];
		if (!dfs(i,0)) {
			writeln(-1);
			return;
		}
		cnt.sort;
		l += cnt[0];
		if (cnt[0] < cnt[1]) a ~= cnt[1]-cnt[0];
	}
	bool[] dp = new bool[n+1];
	dp[0] = true;
	foreach (x; a) {
		foreach_reverse (i; 0..n-x+1) {
			dp[i+x] |= dp[i];
		}
	}
	int ans = m;
	int im = n*(n-1)/2-m;
	foreach (i; 0..n+1) {
		if (!dp[i]) continue;
		int s = l+i, t = n-s;
		ans = min(ans, m-(s*t-im));
	}
	writeln(ans);
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll all_sum = 0;
    rep(i,N) all_sum += A[i];
    vector<ll> B(N);
    B[0] = A[0];
    rep(i,N - 1) B[i + 1] = B[i] + A[i + 1];
    ll min_ans = 1000000000000000000;
    rep(i,N){
        ll ans_sub = abs(2 * B[i] - all_sum);
        min_ans = min(min_ans, ans_sub);
    }
    cout << min_ans << endl;
}


Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

constexpr double eps = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    for(int i=0; i<N; ++i) {
        cin >> x[i] >> y[i];
    }
    if(N % 2 == 1) {
        cout << "NA" << endl;
    } else {
        double px = (x[0] + x[N/2]) / 2, py = (y[0] + y[N/2]) / 2;
        bool ok = true;
        for(int i=0; i<N; ++i) {
            double vx = px - x[i], vy = py - y[i];
            ok &= fabs(px + vx - x[(i+N/2) % N]) < eps && fabs(py + vy - y[(i+N/2)%N]) < eps;
        }
        if(ok) {
            cout << fixed << setprecision(10) << px << " " << py << endl;
        } else {
            cout << "NA";
        }
    }
}


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

int main()
{
	int N;

	while ( cin >> N, N != 0 ) {

		while ( N > 0 ) {
			int a, b, c;
			cin >> a >> b >> c;
			if ( a == 100 || b == 100 || c == 100 || a + b + c >= 240 || a + b >= 180 ) {
				cout << "A" << endl;
			} else if ( a + b + c >= 210 || a + b + c >= 150 && (a >= 80 || b >= 80) ) {
				cout << "B" << endl;
			} else {
				cout << "C" << endl;
			}
			N--;
		}
	}

	return ( 0 );
}



Measured memory_bytes: 2992
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def calc(i):
    s = str(i)
    sums = 0
    for e in s:
        sums += int(e)
    return sums

N = I()
lis = []
for i in range(1,N):
    lis.append(calc(i))
ans = 10**10
for i in range(N//2):
    ans = min(ans,lis[i]+lis[N-2-i])
print(ans)


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n=s.size()-1;
	for (int i=0;i<s.size()-1;i++){
		string s1,s2;
		if (n%2!=0){n--;continue;}
		s1=s.substr(0,n/2
		);
		s2=s.substr(n/2,n/2);
		//cout<<s1<<" "<<s2<<endl;
		if (s1==s2){
			cout<<n<<endl;
			return 0;
		}
		n--;
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back
#define fir first
#define sec second

char s[200006];
ll c[128];

ll C2(ll x) { return x * (x + 1) / 2; }

int n;

int main() {
	scanf("%s", s);
	n = strlen(s);
	
	for (int i = 0; i < n; ++i)
		++c[s[i]];
	
	ll ans = C2(n) + 1;
	for (auto i : c) if (i) {
		ans -= C2(i);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
n, w = map(int, input().split())

weights = [0]*n
values = [0]*n

for i in range(n):
    weights[i], values[i] = map(int, input().split())

v = sum(values)

dp = [[float('inf') for _ in range(v+1)] for _ in range(n+1)]

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

for i in range(1, n+1):
    for j in range(1, v+1):
        if values[i-1] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(weights[i-1] + dp[i-1][j-values[i-1]], dp[i-1][j])

for j in range(v,-1,-1):
    if dp[-1][j] <= w:
        print(j)
        break

Measured memory_bytes: 346204
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.math;
import std.format;

void main() {
  int[] q;

  foreach (string line; stdin.lines) {
    int n = line.chomp.to!int;

    if (n == 0) {
      q.back.writeln;
      q.popBack;
    } else {
      q ~= n;
    }
  }
}

Measured memory_bytes: 1056
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n";
using namespace std;
typedef long long int ll;

bool possible(int mid,vector<int>a,int k)
{
    for(auto i:a)
    {
        k-=(i+mid-1)/mid -1;
    }
    if(k>=0)return true;
    return false;
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int mn =0,mx=1000000001;
    while(mn<mx-1)
    {
        int mid = (mn)+(mx-mn)/2;
        if(possible(mid,a,k))
            mx = mid;
        else
            mn = mid;
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main(){
    int H,W;
    cin >> H >> W;
    int cnt=0;
    for(int i=0;i<H*W;i++){
        char x;
        cin >> x;
        if(x == '#') cnt++;
    }
    if(cnt == H+W-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

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

void main()
{
    auto n = readln.chomp.to!int;
    auto as = readln.split.to!(int[]);
    auto ss = new bool[](2000*n+1);
    
    void solve(int i, int s) {
        if (i == n) return;
        solve(i+1, s);
        s += as[i];
        ss[s] = true;
        solve(i+1, s);
    }
    solve(0, 0);

    auto m = readln.chomp.to!int;
    foreach (q; readln.split.to!(int[])) {
        writeln(ss[q] ? "yes" : "no");
    }
}


Measured memory_bytes: 2500
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int M1 = stdIn.nextInt();
		int D1 = stdIn.nextInt();
		int M2 = stdIn.nextInt();
		int D2 = stdIn.nextInt();
		
		if(M2 == M1+1) System.out.println(1);
		else System.out.println(0);

	}

}

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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF = 1LL << 60;



//大文字小文字気をつけろ


int main(){
int n,a[100];
cin >> n;
FOR(i,3){
  cin >> a[i];
}
int l[1000];
FOR(i,n){
  cin >> l[i];
}
int mini=100000000;
int sum,acount,bcount,ccount,atake,btake,ctake;
for(int i=1;i<pow(4,n);i++){
  sum=i;
  acount=0;bcount=0;ccount=0;
  atake=0;btake=0;ctake=0;
  for(int j=0;j<n;j++){
    if(sum%4==1){acount++;atake+=l[j];}
    if(sum%4==2){bcount++;btake+=l[j];}
    if(sum%4==3){ccount++;ctake+=l[j];}
    sum/=4;
  }
  if(acount==0 || bcount==0 || ccount==0)continue;
  chmin(mini,(abs(atake-a[0])+abs(btake-a[1])+abs(ctake-a[2])+(acount+bcount+ccount-3)*10));
}

cout << mini << endl;



}


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

int main(){
  string s;
  cin >> s;
  map<string, int> vec;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 1; j <= 5; j++) {
      vec[s.substr(i, j)] = 1;
    }
  }
  int k;
  cin >> k;
  int cnt = 1;
  for (auto p: vec) {
    if (cnt == k) {
      cout << p.first << endl;
      return 0;
    }
    cnt++;
  }
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	
	int h[n];
	for(int i=0; i<n; i++) cin >> h[i];
	
	int ans=0;
	for(int i=0; i<n; i++){
		bool flag=true;
		for(int j=0; j<i; j++){
			if(h[j]>h[i]){ //自分より高い山があったらfalse
				flag=false;
				break;
			}
		}
		if(flag) ans++; //自分より高い山がない=true
	}
	cout << ans << endl;
}

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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int dp[110][4][4][4];
int main() {
    int N;
    cin>>N;
    int mod=1e9+7;
    dp[0][3][3][3]=1;
    REP(i,N){
        REP(j,4){
            REP(k,4){
                REP(l,4){
                    if(dp[i][j][k][l]==0) continue;
                    REP(a,4){
                        if(a==2 && j==1 && k==0) continue;
                        if(a==2 && j==0 && k==1) continue;
                        if(a==1 && j==2 && k==0) continue;
                        if(a==2 && k==1 && l==0) continue;
                        if(a==2 && j==1 && l==0) continue;
                        dp[i+1][a][j][k]+=dp[i][j][k][l];
                        dp[i+1][a][j][k]%=mod;
                    }
                }
            }
        }
    }
    int ans=0;
        REP(j,4){
            REP(k,4){
                REP(l,4){
                    ans+=dp[N][j][k][l];
                    ans%=mod;
                }
                }
                }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

int main() {

int n,m;
bool ans = false;

cin >> n >> m;

vector<bool> a(n,false),b(n,false);
int ina,inb;

for(int i = 0;i < m;i++){
    cin >> ina >> inb;
    if(ina == 1){
        a[inb] = true;
    }else if(inb == n){
        b[ina] = true;
    }
}

for(int i = 0;i < n;i++){
    if(a[i] && b[i]){
        ans = true;
        break;
    }
}
if(ans) cout << "POSSIBLE" << endl;
else    cout << "IMPOSSIBLE" << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a,b;

int main(){
    cin>>a>>b;
    if (a>b && b != 1){
        cout<<"Alice"<<endl;
    }else if (b>a && a != 1){
        cout<<"Bob"<<endl;
    }else if (a == b){
        cout<<"Draw"<<endl;
    }else if (a==1){
        cout<<"Alice"<<endl;
    }else cout<<"Bob"<<endl;

    return 0;

}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> L[i];
        sum += L[i];
    }
    sum -= *max_element(all(L));
    string ans;
    if (*max_element(all(L)) < sum) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
def standard_form(N):
    # 長さNの標準形を返す。
    if N == 1:
        return ["a"]
    ans = []
    std_forms = standard_form(N - 1)
    max_char_idx = 2

    for std_form in std_forms:
        max_char_idx = max([ord(ch) for ch in std_form])

        for i in range(ord('a'), max_char_idx + 2):
            append_char = chr(i)
            ans.append(std_form + append_char)

    return ans


if __name__ == '__main__':
    N = int(input())
    ans = standard_form(N)
    ans.sort()
    for a in ans:
        print(a)


Measured memory_bytes: 12984
s = input()
r = 0
l = 0
ls = [0]*len(s)
for i in range(len(s)):
    
    if s[i] == 'R':
        if l > 0 :
            left = (l+1)//2 + r//2
            right = l//2 + (r+1)//2
            ls[i-l] = left
            ls[i-l-1] = right
            r = 0
            l = 0
        r += 1
    else :
        l += 1
left = (l+1)//2 + r//2
right = l//2 + (r+1)//2
ls[len(s)-l] = left
ls[len(s)-l-1] = right
print(*ls)


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

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

const int MAX = 100;
const int INF = (1<<12);

int main() {
  int n, k, c = 0;

  cin >> n;
  cin >> k;

  rep(i,n){
    int y;
    cin >> y;
    int ca = 2 * y;
    int cb = 2 * abs(k - y);
    c += min(ca,cb);
  }
  cout << c << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  long sum = 0;
  
  for(int i = 1; i <= N; i++){
    if( i % 3 == 0){
      continue;
    }
    else if( i % 5 == 0){
      continue;
    }
    else { sum += i; }
  }
  cout << sum << endl;
}
  
  

Measured memory_bytes: 3616