akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n;
int ans;
int main(){
	scanf("%d",&n);
	if(n<105){
		printf("0");
		return 0;
	}
	if(n<135){
		printf("1");
		return 0;
	}
	if(n<165){
		printf("2");
		return 0;
	}
	if(n<189){
		printf("3");
		return 0;
	}
	if(n<195){
		printf("4");
		return 0;
	}
	printf("5");
	/*
	for(int i=1;i<=n;i+=2){
		int sum=0;
		for(int j=1;j<=i;j++){
			if((i%j)==0)sum++;
		}
		ans+=(sum==8);
	}
	printf("%d",ans);
	*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int x;
    cin >> x;
    if(x == 3 or x == 5 or x == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  string A;
  cin>>A;
  ll c=0;
  FOR(i,0,A.size()-1){
    if(A[i]=='o')c++;
  }

  if(c+(15-A.size())>=8){
  cout<< "YES" <<endl;
  }else{
  cout<< "NO" <<endl;
  }

 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(ll (i)=0 ;i <(n); ++(i))
using namespace std;
#define REP(i,m,n) for(ll (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")

int solve(vector<int> p, int n) {
  vector<int> comp(n);
  rep(i, n) comp[i] = i+1;
  //cout << endl;
  int cnt=0;
  do {
    cnt++;
    // rep(i, n) {
    //   if (i==n-1) {
    //     cout << comp[i] << endl;
    //   }
    //   else {
    //     cout << comp[i] << ' ' << flush;
    //   }
    // }
    if (p == comp) return cnt;
  } while (next_permutation(comp.begin(), comp.end()));
  return cnt;
}

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  rep(i, n) cin >> p[i];
  rep(i ,n) cin >> q[i];

  int a = solve(p, n);
  int b = solve(q, n);
  cout << abs(a-b) << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import deque
INF = float("inf")


def solve(H: int, W: int, A: "List[str]"):
    # 黒の位置をx, y座標として持つ。黒からの距離も一緒に持つ
    black = []
    B = [[-1]*W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if A[i][j] == "#":
                black.append((i, j, 0))
                B[i][j] = 0

    q = deque()
    q.extend(black)

    while len(q) > 0:
        cy, cx, dis = q.popleft()
        for y, x in zip([cy-1, cy, cy+1, cy], [cx, cx-1, cx, cx+1]):
            if 0 <= y < H and 0 <= x < W and B[y][x] < 0:
                B[y][x] = dis+1
                q.append((y, x, dis+1))

    m = -INF
    for i in range(H):
        a = max(B[i])
        if m < a:
            m = a
    print(m)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [next(tokens) for _ in range(H)]  # type: "List[str]"
    solve(H, W, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 141536
H, W = map(int, input().split())
canvas = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if canvas[i][j] == '#':
            up_cell = canvas[i - 1][j] if i > 0 else '.'
            down_cell = canvas[i + 1][j] if i < H - 1 else '.'
            right_cell = canvas[i][j + 1] if j < W - 1 else '.'
            left_cell = canvas[i][j - 1] if j > 0 else '.'
            if up_cell == '.' and down_cell == '.' and right_cell == '.' and left_cell == '.':
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,ans=0;
  cin >> n;
  //ll n,k,ans=0;
  //cin >> n >> k;
  string s;
  cin >> s;

  for(int i=1;i<s.length();i++){
    if(s[i]==s[i-1]){
      ans += 0;
    }
    else{
      ans++;
    }
  }



  cout << ans+1 << endl;

}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def gcd(a, b):
    if a % b != 0:
        return gcd(b, a % b)
    else:
        return b

def hurui(n):
    is_prime = [0] * (n+10)
    for i in range(2, n+1):
        is_prime[i] = 1
    for i in range(2, n+1):
        if is_prime[i] == 1:
            j = i*2
            while j <= n:
                is_prime[j] = 0
                j += i
    return is_prime

def main():
    a, b = list(map(int, input().strip().split()))
    g = gcd(a, b)
    # is_prime = hurui(10**6+10)
    i = 2
    c = 0
    # print(g)
    ans = []
    while i**2 <= g:
        if g % i == 0:
            ans.append([i, 0])
            while g % i == 0:
                g /= i
                ans[-1][1] += 1
        i += 1
    if g != 1:
        ans.append([g, 1])
    # print(ans)
    print(len(ans)+1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

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

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		for (int i2 = i+1; i2 < N; i2++)
		{
			int dist = 0;
			for (int j = 0; j < D; j++)
			{
				dist += pow(X[i][j] - X[i2][j], 2);
			}

			int root = sqrt(dist);

			if(root*root == dist)ans++;
		}
	}

	cout<<ans<<endl;

	return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int n, k, res = 0; cin >> n >> k;
  while (n > 0){
    res++; n /= k;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 256
data = input().split()
n = len(data)

stack=[]

for i in data:
    if i == "+":
        x1 = int(stack.pop())
        x2 = int(stack.pop())
        stack.append(x1+x2)
    elif i == "-":
        x2 = int(stack.pop())
        x1 = int(stack.pop())
        stack.append(x1-x2)
    elif i == "*":
        x2 = int(stack.pop())
        x1 = int(stack.pop())
        stack.append(x1*x2)
    elif i == "/":
        x2 = int(stack.pop())
        x1 = int(stack.pop())
        stack.append(x1-x2)
    else:
        stack.append(int(i))
print(stack[0])

Measured memory_bytes: 7692
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

const int N = 1e5 + 5;
ll a[N];

ll dp[N][2];

void solve() {
	int n;
    sc(n);
    fr(i, 1, n) {
        sc(a[i]);
    }
    fr(i, 2, n + 1) {
        fr(j, 0, 1) {
            fr(k, 0, 1) {
                if(a[i - 1] >= j + k) {
                    dp[i][k] = max(dp[i][k], dp[i - 1][j] + k + (a[i - 1] - j - k) / 2);
                    // debug(i, k, dp[i][k]);
                }
            }
        }
    }
    cout << dp[n + 1][0];
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 6008
def main():
    n = int(input())
    a = [int(input()) for i in range(n)]
    b = sorted(a, reverse=True)

    for i in range(n):
        if a[i] == b[0]:
            print(b[1])
        else:
            print(b[0])

if __name__ == '__main__':
    main()



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

struct object
{
    int weight, value;
    object(){};
};

int main()
{
    int no_of_objects, capacity;
    cin >> no_of_objects >> capacity;

    vector<object> O(no_of_objects + 1);
    for (int i = 1; i <= no_of_objects; i++)
    {
        cin >> O[i].weight >> O[i].value;
    }

    long long total_value = 0;
    for (int i = 1; i <= no_of_objects; i++)
    {
        total_value += O[i].value;
    }

    int answer = 0;
    vector<long long> minimum_weight(total_value + 1, -1);
    total_value = 0;
    minimum_weight[0] = 0;

    for (int i = 1; i <= no_of_objects; i++)
    {
        total_value += O[i].value;
        for (int v = total_value; v >= O[i].value; v--)
        {
            if (minimum_weight[v - O[i].value] != -1)
            {
                long long weight_required = minimum_weight[v - O[i].value] + O[i].weight;
                if (weight_required <= capacity)
                {
                    answer = max(answer, v);
                }
                if (minimum_weight[v] == -1 || minimum_weight[v] > weight_required)
                {
                    minimum_weight[v] = weight_required;
                }
            }
        }
    }

    cout << answer;

    return 0;
}


Measured memory_bytes: 1152
import java.io.*;
import java.util.*;
import java.math.*;

public class Main{
	static final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static int tc;
	static final int MOD=1_000_000_007;
	public static int[] inputArray(String str){
		String[] s=str.split(" ");
		int[] array=new int[s.length];
		for(int i=0;i<s.length;i++) {
			array[i]=Integer.parseInt(s[i]);
		}
		return array;
	}
	public static void main(String[] args)throws IOException {
		//tc=Integer.parseInt(br.readLine());
		tc=1;
		while(tc-->0) {
			String predict=br.readLine();
			String actual=br.readLine();
			int count=0;
			for(int i=0;i<actual.length();++i) {
				if(predict.charAt(i)==actual.charAt(i))
					count++;
			}
			System.out.println(count);
		}
	}
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int H, W, h, w;
int maps[500][500];

int main() {
	cin >> H >> W >> h >> w;
	
	REP(i, H) REP(j, W) {
		int s = 1;
		if ((i + 1) % h == 0 && (j + 1) % w == 0) s = -(h * w) - 10000000;
		if (H % h != 0) {
			if ((i + 1) % h == 1 && (j + 1) % w == 0) s += 10000000;
		}
		else if (W % w != 0) {
			if ((i + 1) % h == 0 && (j + 1) % w == 1) s += 10000000;
		}
		maps[i][j] = s;
	}
	
	ll sum = 0;
	REP(i, H) REP(j, W) sum += maps[i][j];
	
	if (sum > 0) {
		puts("Yes");
		REP(i, H) REP(j, W) printf("%d%c", maps[i][j], j == W - 1 ? '\n' : ' ');
	}
	else {
		puts("No");
	}
	
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#define N 1000000007
using namespace std;
typedef long long ll;

int main(void) {
	ll n, m, ans = 1;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << 0 << endl;
		return 0;
	}
	else {
		if (n == m) {
			for (ll i = 1;i <= m;i++)ans = (ans*i) % N;
			for (ll i = 1;i <= m;i++)ans = (ans*i) % N;
			ans = (ans * 2) % N;
			cout << ans << endl;
			return 0;
		}
		else {
			if (n == m+1) {
				for (ll i = 1;i <= m;i++)ans = (ans*i) % N;
				for (ll i = 1;i <= n;i++)ans = (ans*i) % N;
				cout << ans << endl;
				return 0;
			}
			if(m==n+1) {
				for (ll i = 1;i <= n;i++)ans = (ans*i) % N;
				for (ll i = 1;i <= m;i++)ans = (ans*i) % N;
				cout << ans << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import itertools
import math

D, G = tuple(map(int, input().split()))

p_c_list = np.array([tuple(map(int, [100 * (i + 1)] + input().split())) for i in range(D)])

masks = itertools.product([False, True], repeat=len(p_c_list))

ret = np.inf
for mask in masks:
  maskedarr = p_c_list[np.array(mask), :]
  comp_sum = (maskedarr[:, 0] * maskedarr[:, 1] + maskedarr[:, 2]).sum()
  suc_num = maskedarr[:, 1].sum()
  if comp_sum < G:
    amari = (G - comp_sum) / p_c_list[~np.array(mask), 0][-1]
    if amari < p_c_list[~np.array(mask), 1][-1]:
      if ret > suc_num + amari:
        ret = suc_num + amari
    else:
      continue
  elif suc_num < ret:
    ret = suc_num
  else:
    continue
    
print(int(math.ceil(ret)))
  



Measured memory_bytes: 12496
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    long long n,k;
    long long ans=0;
    scanf("%lld%lld",&n,&k);
    if (k%2!=0){
        long long count=n/k;
        ans=count*count*count;
    } else {
        long long count=n/k;
        ans=count*count*count;
        count=0;
        for (int i=1; i<=n; i++){
            if (i%k==k/2){
                count++;
            }
        }
        ans+=count*count*count;
    }
    printf("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[105][105];
int main()
{
	int n,k,i,m,j,x,pd,ans=0;
	cin>>n>>k;
	for(i=1;i<=k;i++)
	{
		cin>>m;
		for(j=1;j<=m;j++)
		{
			cin>>x;
			a[x][i]=1;
		} 
	}
	for(i=1;i<=n;i++)
	{
		pd=0;
	  for(j=1;j<=k;j++)
	 {
		if(a[i][j])
		{
			pd=1;
			break;
		} 
	 }	
	  if(pd==0)ans++;	
	}
	cout<<ans;
} 

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

int main(){
    int n;
    cin>>n;
    int arr[n];
    for (int i=0;i<n;++i){
        cin>>arr[i];
    }
    int temp[n];
    for (int i=0;i<n;++i){
        cin>>temp[i];
    }
    int count = 0;
    for (int i=0;i<n;++i){
        count+=temp[arr[i]-1];
    }
    int final[n-1];
    // cout<<count;
    for (int i=0;i<n-1;++i){
        cin>>final[i];
    }
    for (int i=1;i<n;++i){
        if (arr[i]==arr[i-1]+1){
            count+=final[arr[i-1]-1];
        }
    }
    cout<<count;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define int long long
#define pb push_back

using namespace std;

const int N=52, MOD=1e9+7;
int n, k;

struct Matrix
{
    vector< vector<int> > mat;
    int rows;
    Matrix(vector< vector<int> > val): mat(val), rows(val.size()){}
    Matrix make_ID(int n)
    {
        vector< vector<int> > ID(n, vector<int> (n, 0));
        for(int a=0; a<n; a++)
            ID[a][a]=1;
        return ID;
    }
    Matrix operator*(const Matrix &other) const
    {
        int n=other.rows;
        vector<vector<int> >ret(n, vector<int>(n, 0));
        for(int a=0; a<n; a++)
            for(int b=0; b<n; b++)
                for(int c=0; c<n; c++)
                    ret[a][b]=(ret[a][b]+1LL*mat[a][c]*other.mat[c][b])%MOD;
        return Matrix(ret);
    }

};

Matrix mat_expo(Matrix m, int power)
{
    if(power==1)
        return m;
    Matrix ret=mat_expo(m, power/2);
    ret=ret*ret;
    if(power%2)
        ret=ret*m;
    return ret;
}

vector< vector<int> > adj;
vector<int> emp;
signed main()
{

	cin >> n >> k;
	for(int i = 0; i < n; i++)
	{
		adj.pb(emp);
		for(int j = 0; j < n; j++)
		{
			int x;
			cin >> x;
			adj[i].pb(x);
		}
	}
	Matrix p(adj);
	Matrix fin = mat_expo(p, k);
	int ans=0;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			ans+=fin.mat[i][j];
			ans%=MOD;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define INF 999999999
typedef long long int Int;
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
vector<pair<char,Int>> A;
vector<pair<char,Int>> B;
int N;
int partition(int p,int r){
    int x = A[r].second;
    int i = p-1;
    for(int j=p;j<r;j++){
        if(A[j].second<=x){
            i = i+1;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;    
}
void quicksort(int p,int r){
    if(p<r){
        int q = partition(p,r);
        quicksort(p,q-1);
        quicksort(q+1,r);
    }
}


int main(){
    cin >> N;
    A.resize(N);
    
    for(auto &i:A) cin >> i.first >> i.second;
    map<int,string> m1,m2;
    rep(i,N) m1[A[i].second] += A[i].first;
    quicksort(0,N-1);
    rep(i,N) m2[A[i].second] += A[i].first;
    bool flag = 1;
    for(int i=0;i<N;i++) flag&=m1[A[i].second]==m2[A[i].second];
    if(flag) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    rep(i,N){
        cout << A[i].first << " " << A[i].second << endl;
    }

}


Measured memory_bytes: 9992
def main():
    N = int(input())
    
    H = list(map(int, input().split()))
    
    ans = 0
    now = 0
    for i in range(N-1):
        if H[i] >= H[i+1]:
            now += 1
        else:
            ans = max(ans, now)
            now = 0
            
            
    print(max(ans, now))
            
    
main()

Measured memory_bytes: 14252
//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
//#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 1, 0, -1, 0 };
vi yy = { 0, 1, 0, -1 };
string dir = "LRUD";

const int N = 2e5 + 50, oo = 3e18 + 500;
//const int mod = 998244353;
const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-12, PI = 2 * acos(0.0);
int n, m, k;
long long cnt = 0;
int lg = 18;
set<int> g[N];
vi rg[N];
vi visit(N, 0);

void dfs(vi &pr, int v, int p = -1)
{
	pr[v] = p;
	for (auto to : g[v])
	{
		if (to == p)continue;
		dfs(pr, to, v);
	}
}

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("abbreviation.in", "r", stdin);
	freopen("abbreviation.out", "w", stdout);*/

	char c;
	cin >> c;

	if (c >= 'a' && c <= 'z')
	{
		cout << 'a';
	}
	else
	{
		cout << 'A';
	}

}



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

int n;
int a[40];

void solve(int n, int k, int c){
	if(n == 0){
		for(int i = 0; i < c - 1; i++) printf("%d ", a[i]);
		printf("%d\n", a[c - 1]);
		return;
	}
	for(int i = min(n, k); i >= 1; i--){
		a[c] = i;
		solve(n - i, i, c + 1);
	}
}

int main(){
	while(1){
		cin >> n;
		if(n == 0) break;
		solve(n, n, 0);
	}
	return 0;
}

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

int main(void)
{
	int A,B,K;
	scanf("%d%d%d",&A,&B,&K);
	int cnt=A+1,i;
	for(i=0;i<K;i++){
		do{
			cnt--;
		}while(A%cnt!=0||B%cnt!=0);
	}
	printf("%d",cnt);
	puts("");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n==111)
  {
      cout<<999;
  }
  else if(n==119)
  {
      cout<<991;
  }
  else if(n==191)
  {
      cout<<919;
  }
  else if(n==911)
  {
      cout<<199;
  }
  else if(n==991)
  {
      cout<<119;
  }
  else if(n==919)
  {
      cout<<191;
  }
  else if(n==199)
  {
      cout<<911;
  }
  else if(n==999)
  {
      cout<<111;
  }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long
const int M=1e9+7;

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

int expo(int x, int y) {int res=1;x=x%M;while(y>0){if(y&1)res=(1ll*res*x)%M;
	y=y>>1;x=(1ll*x*x)%M;} return res;}
	

signed main(){
	gearup;
	int t = 1;
	//cin >> t;
	while(t--){
		string s, ans ;
		cin >> s;
		ans = (s[3] == s[2] && s[4] == s[5]) ? "Yes" : "No";
		cout << ans ;
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
tarou_s = 0
hanako_s = 0
n.times{
  str1,str2 = gets.chomp.split
  if str1 < str2
    hanako_s += 3
  elsif str1 > str2
    tarou_s += 3
  else
    tarou_s += 1
    hanako_s += 1
  end
}

puts tarou_s.to_s + " " + hanako_s.to_s



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

int main() {
    ll n;
    cin >> n;
    int ans;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ans = int(floor(log10(n / i)));
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define repp(i,a,n) for(int i=a; i<int(n); ++i)
#define sz(x) int((x).size())
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T, size_t n> std::ostream& operator<<(std::ostream& os, const std::array<T, n> &input){for (size_t i=0; i<n; ++i) {os << input[i] << " ";}return os;}
template<class T1, class T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1,T2> &input){os << "(" << input.first << ", " << input.second << ')';return os;}
template<class T1, class T2> std::ostream& operator<<(std::ostream& os, const std::unordered_map<T1,T2> &input){for (auto const& i: input) {os << i << " ";}return os;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << H;debug_out(T...);}
#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

double startTime;
double getCurrentTime(){return ((double)clock() - startTime) / CLOCKS_PER_SEC;}

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<pi> vp;
typedef vector<ll> vl;
typedef vector<vi> vvi;

// === temeplate ===

const int maxn = 50;

void solve(){
	int n,x,t; cin >> n >> x >> t;
	cout << (n + x - 1) / x * t;
}

int main(){
    sync;
    int cas = 1;
    // cin >> cas;
    rep(ca, cas) solve();
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n, m; cin >> n >> m;
  vector<pair<int, int>> p(n);
  REP(i, n) {
    int a, b; cin >> a >> b;
    p[i] = make_pair(a, b);
  }
  sort(p.begin(), p.end(), [](pair<int, int> a, pair<int, int> b) -> bool{ return a.first < b.first; });

  ll ans = 0, total = 0;
  REP(i, n) {
    total += p[i].second;
    if (m <= total) {
      ans += p[i].first * (p[i].second - (total - m));
      break;
    }
    else ans += p[i].first * p[i].second;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include <algorithm>
#include <istream>
#include <stdio.h>
#include <iostream>
using namespace std;

int n;
int a[200200];

int main()
{
	cin >> n;
	for ( int i = 1; i <= n; i++) {
        cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++) {
        if ( a[i] == a[i - 1] ) {
            cout << "NO"; return 0;
        }
	}
	cout << "YES";
}


Measured memory_bytes: 1024
#include<fstream>
#include<iostream>
#include<string>
using namespace std;

int S[200];
int top = 0;

void push(int x) {
  S[top++] = x;
}

int pop() {
  return S[--top];
}

int main() {
  string s;
  char c;
  int a, b;
  // cin >> s;
  //getline(cin, s);
  //int i=0;
  //cout << s << endl;


  //for (char& c: s) {
    //cout << "c: "<< c << endl;
  //while(c = s[i]){
  while(cin >> s){
    //cout << "s: " << s << endl;
    if (s=="+") {
      a = pop();
      b = pop();
      push(a+b);
      //cout << "\t" << a+b << " push " << endl;
    } else if (s=="-") {
      a = pop();
      b = pop();
      //cout << "\t" << a-b << " push " << ", a: "<< a << ", b: "<< b << endl;
      push(b-a);
    } else if (s=="*") {
      a = pop();
      b = pop();
      push(a*b);
      //cout << "\t" << a*b << " push " << endl;
    } else {
      int numA = 0;
	  numA=0;
      for(int i=0;i<(int)s.size();i++){
    numA*=10;
    numA+=s[i]-'0';
      }
      push(numA);
      //cout << "\t" << numA << " push " << endl;
    }
  }
  cout << pop() << endl;;
  return 0;
}


Measured memory_bytes: 3196
# -*- coding: utf-8 -*-
import sys
from collections import deque

n, q = map(int, input().split())

counts = [0] * (n+1)
adjs = {a: [] for a in range(1,n+1)}

for i in range(n-1):
    a, b = map(int, input().split())
    adjs[a].append(b)
    adjs[b].append(a)

costs = [[int(x) for x in input().split()] for i in range(q)]

for cost in costs:
    counts[cost[0]] += cost[1]

visited = set()
queue = deque()
queue.append(1)

while len(queue) > 0:
    a = queue.popleft()
    visited.add(a)
    for b in adjs[a]:
        if b in visited:
            continue
        counts[b] += counts[a]
        queue.append(b)

for c in counts[1:]:
    print(c, end=" ")
print()




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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9+7;


signed main() {
    int N;
    cin >> N;
    for(int i=1; i<=N; i++) {
        if (i*(i+1)/2 >= N) {
            int d = (i*(i+1)/2) - N;
            for(int j=1; j<=i; j++) {
                if(j == d) { continue; }
                cout << j << endl;
            }
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>

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

  while(scanf("%d",&n)!=EOF){
    counter=0;
    for(a=0;a<=9;++a){
      for(b=0;b<=9;++b){
	for(c=0;c<=9;++c)
	  if(0 <= n-a-b-c && n-a-b-c <= 9)
	    counter++;
      }
    }
      printf("%d\n",counter);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;

struct node{
	int key;
	node *pre,*next;
};

struct list{
	node nilz;
	node *nil;
	
	list(){
		nil=&nilz;
		nil->pre=nil;
		nil->next=nil;
	}
	~list(){
		node *proc=nil->next;
		while(proc!=nil){
			node *del=proc;
			proc=proc->next;
			delete del;
		}
	}
	
	void insert(int x){
		node *proc=new node;
		proc->pre=nil;
		proc->next=nil->next;
		proc->next->pre=proc;
		nil->next=proc;
		proc->key=x;
	}
	void deleten(int x){
		node *proc=nil->next;
		while(proc!=nil){
			if(x==proc->key){
				proc->pre->next=proc->next;
				proc->next->pre=proc->pre;
				delete proc;
				return;
			}else{
				proc=proc->next;
			}
		}
	}
	void deleteFirst(){
		node *proc=nil->next;
		proc->next->pre=nil;
		nil->next=proc->next;
		delete proc;
	}
	void deleteLast(){
		node *proc=nil->pre;
		proc->pre->next=nil;
		nil->pre=proc->pre;
		delete proc;
	}
	void print(){
		node *proc=nil->next;
		while(true){
			cout<<proc->key;
			proc=proc->next;
			if(proc==nil){
				break;
			}else{
				cout<<" ";
			}
		}
		cout<<endl;
	}
};

int main(){
	int n;
	list l;
	cin>>n;
	for(int i=0;i<n;i++){
		char com[15];
		//cin>>com;
		scanf("%s",com);
		if(strcmp(com,"insert")==0){
			int tmp;
			//cin>>tmp;
			scanf("%d",&tmp);
			l.insert(tmp);
		}else if(strcmp(com,"delete")==0){
			int tmp;
			//cin>>tmp;
			scanf("%d",&tmp);
			l.deleten(tmp);
		}else if(strcmp(com,"deleteFirst")==0){
			l.deleteFirst();
		}else if(strcmp(com,"deleteLast")==0){
			l.deleteLast();
		}else{
			cerr<<"unknown command"<<endl;
		}
	}
	l.print();
	return 0;
}


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

int main() {
  int N,M;
  cin>>N>>M;
  int a=0;
  cin>>a;
  vector<int> vec(M);
for (int i = 0; i < M; i++) {
  cin >> vec.at(i);
  a+=vec.at(i);
  
}
  if(a<N+1){
    cout<<N-a<<endl;
  }
  else{
    cout<<-1<<endl;
  }


  
}

Measured memory_bytes: 3644
def main():
	n, a, b, c = map(int, input().split())
	l = [0]*n
	for i in range(n):
		l[i] = int(input())
	INF = 10 ** 9
	def dfs(cur, x, y, z):
		if cur == n:
			return abs(a-x) + abs(b-y) + abs(c-z) - 30 if min(x, y, z) > 0 else INF
		ret0 = dfs(cur+1, x, y, z)
		ret1 = dfs(cur+1, x+l[cur], y, z) + 10
		ret2 = dfs(cur+1, x, y+l[cur], z) + 10
		ret3 = dfs(cur+1, x, y, z+l[cur]) + 10
		return min(ret0, ret1, ret2, ret3)
	print(dfs(0, 0, 0, 0))

if __name__ == '__main__':
    main()

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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            
            int[] XY = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int X = XY[0], Y = XY[1];
            Console.WriteLine(X * Y);
            Console.Out.Flush();
        }

    }
}


Measured memory_bytes: 28256
a = input()
l1 = a[::2]
l2 = a[1::2]
x, y = 0, 0
for i in range(len(l1)):
  if l1[i] =='1':
    x +=1
for i in range(len(l2)):
  if l2[i] =='0':
    y +=1
print(min(x +y,len(l1)-x + len(l2)-y))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

bool cmp(pii a, pii b){
    if(a.ft == b.ft) return a.sd < b.sd;
    return a.ft > b.ft;
}
void solve(){
    ll n;
    string s;
    cin >> s;
    n = s.size();
    char a[] = {'A', 'T', 'G', 'C'};
    ll l = 0, ans = 0;
    for(ll i = 0; i < n; i++){
        ll f = 0;
        rep(j, 4){
            if(s[i] == a[j]){
                f = 1;
            }
        }
        if(f) {
            l++; ans = max(ans, l);
        }
        else l = 0;
    }
    cout << ans;
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, k);
  int ans = 0;
  rep(i, n) {
    in(int, h);
    if (h >= k) ++ans;
  }
  out(ans);
}


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

int main(){
  string s;
  cin >> s;
  if(s[5]=='1')cout<<"TBD";
  else if((s[6]=='1')||(s[6]=='2')||(s[6]=='3')||(s[6]=='4'))cout<<"Heisei";
  else cout<<"TBD";
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,M;
  cin>>N>>M;
  char S[N],T[M];
  REP(i,N)cin>>S[i];
  REP(i,M)cin>>T[i];
  lint n=N;
  lint m=M;
  lint r=n%m;
  while(r!=0){
    n=m;
    m=r;
    r=n%m;
  }
  n=(N*M)/m;
  for(lint i=0;i<N;i++){
    if((i*(n/N))%(n/M)==0){
      if((i*(n/N))/(n/M)>=M)continue;
      if(S[i]!=T[(i*(n/N))/(n/M)]){
        cout<<-1<<endl;
        return 0;
      }       
    }
  }
  cout<<n<<endl;
  return 0;
}


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

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

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

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

  int answer = d[N / 2] - d[N / 2 - 1];
  cout << answer << endl;
}

Measured memory_bytes: 640
def main():
    a, b, c, x, y = [int(i) for i in input().split()]

    y1 = a * x + b * y
    y2 = c * max(x, y) * 2
    if x >= y:
        y3 = c * y * 2
        y3 += a * (x - y)
    else:
        y3 = c * x * 2
        y3 += b * (y - x)
    print(min(y1, y2, y3))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#pragma GCC optimize ("O3")
#pragma GCC target("avx512f")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int N, a[200000], b[200000], ans = 0;
  scanf("%d", &N);
  rep(i, N) scanf("%d", &a[i]);
  rep(i, N) scanf("%d", &b[i]);
  rep(i, N) rep(j, N) ans ^= a[i] + b[j];
  printf("%d\n", ans);
}

Measured memory_bytes: 3216
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    int ans = 0;
    for (int i = S.length(); i > 0 ; i--){
      ans = ans + Integer.parseInt(S.substring(i-1,i));
    }
    if (ans % 9 == 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 49912
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
#define MOD (1e9+7)
typedef pair < ll, ll> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}


ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}
std::vector<int> Eratosthenes(const int N)
{
	std::vector<bool> is_prime(N + 1);
	for (int i = 0; i <= N; i++)
	{
		is_prime[i] = true;
	}
	std::vector<int> P;
	for (int i = 2; i <= N; i++)
	{
		if (is_prime[i])
		{
			for (int j = 2 * i; j <= N; j += i)
			{
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

ll N, M;
ll A[10000000],sz[1000000];
int main()
{
	cin >> N >> M;
	rep(i, N) cin >> A[i];
	sort(A, A + N);
	rep(i, N)sz[i + 1] = sz[i] + A[i];
	auto calc = [&](int X) {
		ll tot = 0, num = 0;
		rep(i, N) {
			int j = lower_bound(A, A + N, X - A[i]) - A;
			num += ll(N - j);
			tot += sz[N] - sz[j];
			tot+=A[i] * ll(N - j);
		}
		return make_pair(tot, num);
	};
	//cout << calc(100).second << endl;
	int lb = -1, ub = 2 * (1e5) + 5;
	while (ub - lb > 1) {
		int mid = (ub + lb) / 2;
		auto p = calc(mid);
		if (p.second >= M)lb=mid;
		else ub = mid;
	}
	//cout << ub <<" "<<lb<< endl;
	auto p = calc(lb);
	ll ans = p.first;
	ans -= (p.second-M) * lb;
	cout << ans << endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> ns(n);
	vector<int> nss(n);
	rep(i, n){
    	cin >> ns.at(i);
    	nss.at(i) = ns.at(i);
    }
	sort(nss.begin(), nss.end());
	int cou = 0;
	rep(i, n){
    	if(ns.at(i) != nss.at(i)) cou++;
    }
	if(cou == 2 || cou == 0){
		cout << "YES" << endl;
    }else{
		cout << "NO" << endl;
	}
}

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

const int MAXC = 100000000; /// maxim calcule

int n;
ll x[1000005];
signed main()
{
    cin >> n;
    for (int i = 1;i <= n; i++)
    {
        int v;
        cin >> v;
        x[i] = v - i;
    }
    sort(x + 1, x + n + 1);

    int b = x[(n + 1) / 2];

    ll sum = 0;
    for (int i = 1; i <= n; i++)
        sum += abs(x[i] - b);

    cout << sum;

    return 0;
}



Measured memory_bytes: 1792
import itertools
i = int(input())
s=list(range(1, i+1))
ss=list(itertools.permutations(s))
l1,l2=tuple(map(int, input().split())),tuple(map(int, input().split()))
l1c,l2c=0,0
for i, sss in enumerate(ss):
  if sss == l1:
    l1c=i+1
  if sss == l2:
    l2c=i+1
    
print(abs(l1c-l2c))

Measured memory_bytes: 8052