akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define MAX 100000

int n,k;
long long T[MAX];

int check(long long P){
    int i=0;
    for(int j=0;j<k;j++){
        long long s=0;
        while(s+T[i]<=P){
            s+=T[i];
            i++;
            if(i==n)return n;
        }
    }
    return i;
} 

int solve(){
    long long left = 0;
    long long right = 100000*10000;
    long long mid;
    while(right-left>1){
        mid=(left+right)/2;
        int v=check(mid);
        if(v>=n)right=mid;
        else left=mid;
    }
    return right;
}

int main() {
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>T[i];
    long long ans=solve();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  double pi = acos(-1);
  double a,b;cin>>a>>b;
  double h,m;cin>>h>>m;
  double kaku;

  kaku = min(abs(6.0*m-30.0*h-m/2.0),abs(360.0-abs(6.0*m-30.0*h-0.5*m)));
  double ans;
  //cout<<kaku<<endl;
  double ze = 0.0;
  if(kaku==180.0){printf("%.20lf",a+b);return 0;}
  if(kaku==0.0||kaku==360.0){printf("%.20lf",abs(a-b));return 0;}
  ans = sqrt(a*a+b*b-2*a*b*cos(pi*kaku/180.0));
  
  printf("%.20lf",ans);
  return 0;
}

Measured memory_bytes: 4216
n = int(input())
a = list(map(int, input().split()))
leaf = sum(a) - 1
now = 1
ans = 0
for i, num in enumerate(a):
    ans += now
    now -= num
    if leaf >= now:
        leaf -= now
        now *= 2
    elif leaf > 0:
        now += leaf
        leaf = 0
    if now < 0:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 20140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(std::string S, std::string T){
   //42
  int cnt = 0;
  REP(x, 3) {
    if (S.at(x) == T.at(x)) cnt++;
  }
  cout << cnt << endl;
}

signed main(){
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
}


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

using namespace std;
typedef long long i64;

const int INF = 1000000000;
const int N = 300005;

int solve(int n, int k) {
    if (n < k) return 0;
    if (n % k == 0) return n / k;
    int tmp = n / k + 1, mod = n % k;
    int t = max(mod / tmp, 1);
    return solve(n - t * tmp, k);
}
int main ()
{
    int n, a, k;
    cin >> n;
    int sg = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a >> k;
        sg ^= solve(a, k);
    }
    puts(sg == 0 ? "Aoki" : "Takahashi");
    return 0;
}


Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val Array(w, h, x, y) = in.readLine.split(" ").map(_.toLong)

  val ans = w.toDouble * h.toDouble / 2.0
  val other = if(w == x * 2 && h == y * 2) 1 else 0

  println(ans + " " + other)
}

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

vector<int> divisor(int n){
	vector<int> res;
	for(int i = 1; i*i <= n; i++){
		if(n%i==0){
			res.push_back(i);
			if(i*i != n) res.push_back(n/i);
		}
	}
	sort(res.rbegin(), res.rend());
	return res;
}

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	int sum = 0;
	rep(i,n) sum += a[i];
	
	vector<int> div;
    div = divisor(sum);
	
	rep(i,div.size()-1){
		vector<ll> moda(n);
		rep(j,n) moda[j] = a[j] % div[i];
		sort(moda.begin(), moda.end());
		
		vector<ll> moda2(n);
		rep(j,n) moda2[j] = div[i] - moda[j];
		reverse(moda2.begin(), moda2.end());

		vector<ll> cumminus;
		cumminus.push_back(moda[0]);
		rep(j,n-1) cumminus.push_back(cumminus[j] + moda[j+1]);
		
		vector<ll> cumplus;
		cumplus.push_back(moda2[0]);
		rep(j,n-1) cumplus.push_back(cumplus[j] + moda2[j+1]);
		
		rep(j,n-1){
			if(cumminus[j] == cumplus[n-2-j] && cumminus[j] <= k){
				cout << div[i] << endl;
				return 0;
			}
		}
        
	}

	cout << 1 << endl;
	return 0;
}

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

const int N = 250; //max size of vertex
const int inf = 1<<29;
int n,m,l;
int cap[N][N],flow[N][N];
int level[N];
int adj[N][N];
bool finished[N];

inline int residue(int s,int t) { return cap[s][t] - flow[s][t]; }

void makeLevel(int s) {
    memset(level, -1, sizeof(level));
    level[s] = 0;
    queue<int> Q; Q.push(s);
    while(!Q.empty()) {
        int here = Q.front(); Q.pop();
        for(int there=0; there<n*2+2; ++there) {
            if(level[there] < 0 && residue(here,there) > 0) {
                level[there] = level[here]+1;
                Q.push(there);
            }
        }
    }
}

int augment(int here,int curf,int t) {
    if(here == t || curf == 0) return curf;
    if(finished[here] != 0) return 0;
    finished[here] = 1;
    for(int there=0; there<n*2+2; ++there) {
        if(level[there] > level[here]) {
            int f = augment(there, min(curf, residue(here, there)), t);
            if(f > 0) {
                flow[here][there] += f;
                flow[there][here] -= f;
                finished[here] = false;
                return f;
            }
        }
    }
    return 0;
}

int Dinic(int s,int t) {
    memset(flow, 0, sizeof(flow));
    int ret = 0;
    for(bool cont = true; cont; ) {
        cont = false;
        makeLevel(s);
        memset(finished, 0, sizeof(finished));
        for(int f; (f = augment(s, inf, t)) > 0; cont = true)
            ret += f;
    }
    return ret;
}

int main() {
    int a,b,d;
    while(cin>>n>>m>>l) {
        for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) adj[i][j] = inf;
        for(int i=0; i<m; ++i) {
            cin>>a>>b>>d;
            a--,b--;
            adj[a][b] = min(d, adj[a][b]);
            adj[b][a] = adj[a][b];
        }

        for(int i=0; i<n; ++i) adj[i][i] = 0;

        //Warshall-Floyd
        for(int k=0; k<n; ++k) {
            for(int i=0; i<n; ++i) {
                for(int j=0; j<n; ++j)
                    adj[i][j] = min(adj[i][k]+adj[k][j], adj[i][j]);
            }
        }

        memset(cap, 0, sizeof(cap));
        memset(finished, 0, sizeof(finished));
        memset(flow, 0, sizeof(flow));

        for(int i=0; i<n; ++i) {
            for(int j=0; j<n; ++j) {
                if(adj[i][j] >= l) continue;
                // cout<<"add "<<i<<" "<<j<<endl;
                cap[i][j+n] = inf;
                cap[j][i+n] = inf;
            }
        }

        int p;
        for(int i=0; i<n; ++i) {
            cin>>p;
            cap[2*n][i] += p;
        }

        int k;
        for(int i=0; i<n; ++i) {
            cin>>k;
            cap[i+n][2*n+1] += k;
        }

        // for(int i=0; i<=2*n+1; ++i) {
        //     for(int j=0; j<=2*n+1; ++j) cout<<cap[i][j]<<" ";
        //     cout<<endl;
        // }

        cout<<Dinic(2*n,2*n+1)<<endl;
    }
}

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

int main()
{
    int N,X,Y,K;
    cin>>N>>K>>X>>Y;
    if(N<=K){
        cout<<N*X<<endl;
    }
    else{
        cout<<(K*X)+(N-K)*Y<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import sys

def is_enough(H, A, B, T):
    cnt = 0
    diff = A - B
    base = B * T
    for h in H:
        if h <= base:
            continue

        cnt += (h - base + diff - 1) // diff
        if cnt > T:
            return False

    return True


def main():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]

    R = (max(H) + B - 1) // B
    L = (min(H) + A - 1) // A
    while R != L:
        c = (R + L) // 2
        if is_enough(H,  A, B, c):
            R = c
        else:
            L = c + 1

    return L


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 7072
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	string s;
	cin >> s;
	ll k;
	cin >> k;
	char ans;

	for (int i = 0; i < k; ++i) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
	}

	cout << 1 << endl;
}



Measured memory_bytes: 256
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))

ans = 0
n,d = Mi()
d = d*d
for i in range(n):
  x,y = Mi()
  if d >= x**2+y**2:
    ans += 1
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);

    int beforeT = 0, beforeX = 0, beforeY =0;
    string ans = "Yes";

    for (int i = 0; i < N; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        if ( (x-beforeX)+(y-beforeY)+(t-beforeT) % 2 == 1 ) {
            ans = "No";
            break;
        }
        if ( fabs(x-beforeX) + fabs(y-beforeY) > (t-beforeT) ) {
            ans = "No";
            break;
        }
        beforeT = t;
        beforeX = x;
        beforeY = y;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
mod = 10**9+7
P = 13
 
dp = [[0 for _ in range(P)] for _ in range(N+1)]
dp[0][0] = 1
 
for i in range(N):
    x = S[-1-i]
    if x == '?':
        base = pow(10, i, P)
        for j in range(10):
            r = base*j % P
            for m in range(P):
                dp[i+1][(m+r)%P] = (dp[i+1][(m+r)%P] + dp[i][m]) % mod
    else:
        r = pow(10, i, P) * int(x) % P
        for j in range(P):
            dp[i+1][(j+r)%P] = max(dp[i+1][(j+r)%P], dp[i][j])
 
print(dp[-1][5])


Measured memory_bytes: 66524
#include <stdio.h>
#include <string.h>

int main()
{
        char str[10000];
        int a,b,i;

        while(~scanf("%s",str)){
                a=0;b=0;
                for(i=0;i<strlen(str)-2;i++){
                        if(str[i]=='J'&&str[i+1]=='O'&&str[i+2]=='I')a++;
                        if(str[i]=='I'&&str[i+1]=='O'&&str[i+2]=='I')b++;
                        }
                printf("%d\n%d\n",a,b);
        }
        return 0;
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ans,a,i,b;
  cin>>n;
  vector<int> suuretu(n-1);
  for(i=0; i<n-1; i++){
    cin>>suuretu.at(i);
  }
  ans=suuretu.at(0)+suuretu.at(n-2);
  for(i=0; i<n-2; i++){
    a=suuretu.at(i);
    b=suuretu.at(i+1);
    a=min(a,b);
    ans=ans+a;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
#include <set>

using namespace std;

int main(void){
    string s;
    int K;
    vector <string> str;
    
    cin >> s >> K;
    
    for(int i = 0; i < s.length(); i++){
        string sub;
        int j = 0;
        
        while(j < K && i + j < s.length()){
            if(j == 0){
                sub = s[i];
                str.push_back(sub);
            }
            else{
                sub.insert(sub.end(), s[i + j]);
                str.push_back(sub);
            }
            j++;
        }
    }
    
    // for(auto ite = str.begin(); ite != str.end(); ++ite){
    //     cout << *ite << " ";
    // }
    // cout << endl;
    
    sort(str.begin(), str.end());
    str.erase(unique(str.begin(), str.end()), str.end());
    
    // for(auto ite = str.begin(); ite != str.end(); ++ite){
    //     cout << *ite << " ";
    // }
    // cout << endl;
    
    cout << str[K - 1] << "\n";
}

Measured memory_bytes: 1160
N,K = map(int,(input().split()))
MOD = 10**9+7
l = list(range(N+1))
s = [0]*(N+1)
s[0] = l[0]
for i in range(1,N+1):
    s[i] = s[i-1] + l[i]

sr = [0]*(N+1)
sr[0] = l[N]
for i in range(1,N+1):
    sr[i] = sr[i-1] + l[N-i]

c = 0
for i in range(K,N+2):
    c += sr[i-1]-s[i-1] +1
    c %= MOD
print(c)

Measured memory_bytes: 70244
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}
template<typename T, int Begin, int End>
T& OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}
template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}

template<typename T, int N>
void Fill(T(&arr)[N], T val) {
	for (int i = 0; i < N; ++i) {
		arr[i] = val;
	}
}
template<typename T, int M, int N>
void Fill2D(T(&arr)[M][N], T val) {
	for (int i = 0; i < M; ++i) {
		Fill(arr[i], val);
	}
}


#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T>>;
#endif

int N, M;
int A[1000], B[1000], C[1000];
int D[100][100];
int main() {
	cin >> N >> M;
	REP(i, 0, M) {
		cin >> A[i] >> B[i] >> C[i];
		--A[i];
		--B[i];
	}
	Fill2D(D, INF);
	REP(i, 0, M) {
		D[A[i]][B[i]] = C[i];
		D[B[i]][A[i]] = C[i];
	}
	REP(k, 0, N) {
		REP(i, 0, N) {
			REP(j, 0, N) {
				D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}
	int cnt = 0;
	REP(i, 0, M) {
		if (C[i] > D[A[i]][B[i]]) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}

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

int cx = 0;
int cy = 0;
int ct = 0;
int n, x, y, t;

int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> t >> x >> y;
        int sum = std::abs((x - cx)) + std::abs((y - cy));
        int t_diff = std::abs(t - ct);
        if (t_diff < sum || sum%2 != t_diff%2) {
            std::cout << "No" << std::endl;
            return 0;
        }
        cx = x;
        cy = y;
        ct = t;
    }
    std::cout << "Yes" << std::endl;
}


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

int main() {
  string S, T;
  cin >> S;
  if(S=="Sunny") {
    T = "Cloudy";
  } else if(S=="Cloudy") {
    T = "Rainy";
  } else {
    T = "Sunny";
  }
  
  cout << T << endl;
  
 return 0;
}

Measured memory_bytes: 256
#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(){
    ll n;
    cin >> n;
    int minimum = 20;
    double k = sqrt(n);
    for(int a = 1; a <= k; a++){
        if(n%a != 0) continue;
        int b = n/a;
        int al = to_string(a).size();
        int bl = to_string(b).size();
        int f = max(al,bl);
        minimum = min(f,minimum);
    }
    cout << minimum << endl;
}

Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();

		if(a <= x && x <= a + b) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}

}


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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(N + 1, vector<int>(N + 1));
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      cin >> A[i][j];
    }
  }
  vector<vector<int>> bits_by_pop(N + 1, vector<int>());
  for (int bits = 0; bits < (1 << N); bits++) {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      if (bits & (1 << i)) {
        cnt++;
      }
    }
    bits_by_pop[cnt].push_back(bits);
  }
  vector<vector<modint>> dp(N + 5, vector<modint>((1 << N) + 5));
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int bits : bits_by_pop[i]) {
      for (int j = 0; j < N; j++) {
        if (bits & (1 << j) and A[i][j + 1]) {
          dp[i][bits] += dp[i - 1][bits ^ (1 << j)];
        }
      }
    }
  }
  cout << dp[N][(1 << N) - 1] << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 452156
#include<iostream>
#include<string>
using namespace std;
int main(){
        string S;
        int ret =0;
        int tmp =0;
        cin >> S;
        for(int i = 0; i < S.size(); i++){
                if(S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T'){
                        tmp++;
                        if(tmp > ret) ret = tmp;
                }else tmp = 0;
        }
        cout << ret << endl;
        return 0;
}

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

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

using namespace std;

#define F first
#define S second 

#ifdef __debug_leywar
#include <debug/debugger.h>
#else
#define db(...) ;
#endif

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

    string s ; 
    cin >> s ; 

    s = '_' + s ; 

    int ans = 0 , pt = n ; 

    for( int i = 1 ; i < pt ; i++ , pt-- )    
    {
        while( s[i] == 'R' ) 
            i++ ; 
        while( s[pt] == 'W' ) 
            pt-- ;

        if( i < pt ) 
            ans++ ; 
    }

    bool sol = false ; 
    int temp = 0 ; 

    for( int i = 1 ; i <= n ; i++ )
    {
        if( s[i] == 'W' )
            sol = true ; 
        
        temp += ( sol and s[i] == 'R' ) ; 
    }

    ans = min( ans , temp ) ;

    sol = false ;
    temp = 0 ; 
    for( int i = n ; i >= 1 ; i-- )
    {
        if( s[i] == 'R' )
            sol = true ; 

        temp += ( sol and s[i] == 'W' ) ;
    } 

    ans = min( ans , temp ) ; 

    cout << ans ; 

    return 0;
}

Measured memory_bytes: 3872
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int N, R; cin >> N >> R;
	if (N < 10)R += 100 * (10 - N);
	cout << R << endl;

	return 0;
}


Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

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

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vs s(h);
    rep(i, h) cin >> s[i];
    v wsum(w, 0);
    rep(i, w){
        rep(j, h){
            if(s[j][i] == '#') wsum[i] = 1;
        }
    }
    for(int i = 1; i < w; i++)
    {
        wsum[i] += wsum[i - 1];
    }
    v par;
    par.push_back(0);
    for(int i = 0; i < w - 1; i++)
    {
        if(wsum[i] == 0) continue;
        if(wsum[i] != wsum[i + 1]){
            par.push_back(i + 1);
        }
    }
    par.push_back(w);
    vector<vector<string>> result(h, vector<string>(w));
    int count = 1;
    for(int index = 0; index < par.size() - 1; index++)
    {
        int cherry = 0;
        for (int i = 0; i < h; i++)
        {
            for (int l = par[index]; l < par[index + 1]; l++)
            {
                result[i][l] = to_string(count);
                if(s[i][l] == '#'){
                    cherry++;
                }
            }
            if (cherry == 2){
                count++;
                for(int l = par[index]; l < par[index + 1]; l++) {
                    result[i][l] = to_string(count);
                }
                cherry = 1;
            }
        }
        count++;
    }
    rep(i, h){
        rep(j, w){
            cout << result[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 5888
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <bitset>

using namespace std;

int main()
{
    bitset<64> state;

    int q;
    cin >> q;

    int cmd, i;
    while (q--)
    {
        cin >> cmd;
        switch (cmd)
        {
            case 0: 
                cin >> i;
                cout << state.test(i) << endl;
                break;
            case 1: 
                cin >> i;
                state.set(i);
                break;
            case 2: 
                cin >> i;
                state.reset(i);
                break;
            case 3: 
                cin >> i;
                state.flip(i);
                break;
            case 4: 
                cout << state.all() << endl;
                break;
            case 5: 
                cout << state.any() << endl;
                break;
            case 6: 
                cout << state.none() << endl;
                break;
            case 7: 
                cout << state.count() << endl;
                break;
            case 8: 

                 cout << state.to_ulong() << endl;
                break;

        }

    }
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t start = clock();
#else
    //freopen("sabotage.in", "r", stdin);
    //freopen("sabotage.out", "w", stdout);
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


const int MOD=1e9+7,N=1e5+100,oo=1e12+10,A=26,M=(1<<14);


void smain() {

    int x,y;
    cin>>x>>y;
    int ans=1;
    while(x<=y/2){
        x*=2;
        ans++;
    }
    cout<<ans;
}



Measured memory_bytes: 3572
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();

		int max=max(a,b,c);


		int sum=a+b+c;

		int counter=0;

		while(true) {

			if(sum%3==0 && sum/3>=max) {
				break;
			}else {
				sum+=2;
				counter++;
			}

		}

		System.out.println(counter);

		sc.close();


	}

	public static int max(int a,int b,int c) {

		int buf=Math.max(a, b);

		return Math.max(buf,c);

	}


}


Measured memory_bytes: 22608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

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

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

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

signed main() {
    ll A, B, C, D; cin >> A >> B >> C >> D;

    A--;

    ll rh = B - B / C - B / D + B/(C * D / gcd(C, D));
    ll lh = A - A / C - A / D + A/(C * D / gcd(C, D));
    
    cout << (rh - lh) << endl;
}
 

Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

MOD = 10**9+7
N = int(input())
dic = defaultdict(int)
zero = 0
left_zero = 0
right_zero = 0
for i in range(N):
    a, b = map(int, input().split())
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b == 0:
        zero += 1
    elif a == 0:
        left_zero += 1
    elif b == 0:
        right_zero += 1
    else:
        g = math.gcd(a, b)
        a //= g
        b //= g
        dic[a,b] += 1
done = set()
ans = 1
for a,b in dic:
    k = (a, b)
    if k in done: continue
    rk = (-b, a)
    rk2 = (b, -a)
    done.add(k)
    done.add(rk)
    done.add(rk2)
    c = pow(2, dic[k], MOD)-1
    if rk in dic:
        c += pow(2, dic[rk], MOD)-1
    if rk2 in dic:
        c += pow(2, dic[rk2], MOD)-1
    c += 1
    ans *= c
    ans %= MOD
c1 = pow(2, left_zero, MOD)-1
c2 = pow(2, right_zero, MOD)-1
c = c1+c2+1
ans *= c
ans += zero
print((ans-1)%MOD)


Measured memory_bytes: 118776
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
//cout << std::fixed << std::setprecision(15);
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e9;
const long long MOD = 1e9+7;
signed main(){
    string s,t; cin >> s >> t;
    int a,b; cin >> a >> b;
    string u; cin >> u;
    if(s==u) cout<<a-1<<' '<<b<<endl;
    else cout<<a<<' '<<b-1<<endl;
    
}

Measured memory_bytes: 256
import bisect
s = input()
if s[-1] == "1" or s[0] == "0":
    print(-1)
    exit()

for i in range((len(s) - 1) // 2):
    # print(i,len(s)- i - 2)
    if s[i] != s[len(s) - i -2]:
        print(-1)
        exit()

sd = s[:-1] + '1'
plist = [i for i, v in enumerate(sd) if v == '1']
# print(plist)
for i,v in enumerate(s[:-1]):
    r = bisect.bisect(plist,i)
    print(i+1,plist[r] + 1)



Measured memory_bytes: 8724
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>

#define MAX 100
#define INFTY 1<<30 // 2^30
#define N 100
#define N2 10000  // N * N
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(o) (o).begin(), (o).end()

/*
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/


using namespace std;

typedef long long llong;

int V, E, R, S[500010], T[500010], D[500010];
int C[100010];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  cin >> V >> E >> R; // V ???????????° E ????????°
  REP(i,E)
    cin >> S[i] >> T[i] >> D[i];
  REP(i,V)
    C[i] = INFTY;
  C[R] = 0;
  int j;
  bool negative;
  for(j = 0; j < V; j++)
  {
    bool update = false;
    REP(i,E)
    {
      int s = S[i], t = T[i], d = D[i];
      if(C[s] < INFTY && C[s] + d < C[t])
      {
        C[t] = C[s] + d;
        update = true;
      }
    }
    if(!update) break;
  }
  if(negative = (j == V))
    cout << "NEGATIVE CYCLE" << endl;
  else
  {
    REP(i,V)
    {
      if(C[i] == INFTY) cout << "INF" << endl;
      else cout << C[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5312
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <double> v(n);
    generate(all(v),nxt);
    sort(all(v));
    double cur=(v[0]+v[1])/2;
    for(int i=2;i<n;i++)
        cur=(cur+v[i])/2;
    cout<<setprecision(15)<<cur<<endl;
    
    
    return 0;   
}


 
 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
signed main()
{
    int n; cin >> n;
    for(int i = 1; i <= n; i++)
    {
        if((int)(i * 1.08) == n)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> P;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(int a,int b){return b?gcd(b,a%b):a;};

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

int main(){
   cin >> S;
   ll diff = INF;
   REP(i, S.size() - 2){
      chmin(diff, abs(stoll(S.substr(i, 3)) - 753));
   }
   cout << diff << endl;

}

Measured memory_bytes: 256
import sys

w, h, n = map(int, input().split())

zahyo = [list(map(int, input().split())) for i in range(n)]

area = [[0 for i in range(h)] for j in range(w)]

for i in range(n):
    if zahyo[i][2] == 1:
        for j in range(zahyo[i][0]):
            for k in range(len(area[j])):
                area[j][k] = 1
    elif zahyo[i][2] == 2:
        for j in range(w - 1, zahyo[i][0] - 1, -1):
            for k in range(len(area[j])):
                area[j][k] = 1
    elif zahyo[i][2] == 3:
        for j in range(len(area)):
            for k in range(zahyo[i][1]):
                area[j][k] = 1
    elif zahyo[i][2] == 4:
        for j in range(len(area)):
            for k in range(h - 1, zahyo[i][1] - 1, -1):
                area[j][k] = 1

cnt_zero = 0
for i in range(len(area)):
    for j in range(len(area[i])):
        if area[i][j] == 0:
            cnt_zero += 1

print("{}".format(cnt_zero))

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def popcount(n):
    ret = 0
    while n:
        ret += n & 1
        n >>= 1
    return ret


def main():
    N = readint()
    X = readstr()
    s = sum(tuple(map(int, X)))
    s1 = s + 1
    s2 = s - 1 if s != 1 else 1
    m1 = int(X, 2) % s1
    m2 = int(X, 2) % s2
    t1 = [1]
    t2 = [1]
    for i in range(N):
        t1.append(t1[i] * 2 % s1)
        t2.append(t2[i] * 2 % s2)
    for i in range(N):
        ans = 0
        if X[i] == '0':
            x = (m1 + t1[(N - i - 1)]) % s1
        else:
            if s == 1:
                print(0)
                continue
            else:
                x = (m2 - t2[(N - i - 1)]) % s2
        d = sum(tuple(map(int, bin(x)[2:])))
        ans += 1
        while x:
            x %= d
            d = sum(tuple(map(int, bin(x)[2:])))
            ans += 1
        print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    int c[3][3];
    REP(i,9) cin>>c[i/3][i%3];
    bool ok = true;
    REP(i,3) REP(j,2) if(c[i][j+1]-c[i][j]!=c[(i+1)%3][j+1]-c[(i+1)%3][j]) ok=false;
    REP(i,3) REP(j,2) if(c[j+1][i]-c[j][i]!=c[j+1][(i+1)%3]-c[j][(i+1)%3]) ok=false;
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int N,K;
    cin >> N >> K;
    int ans = K;
    rep(i,N-1) ans *= K-1;
    pr(ans);
}

Measured memory_bytes: 256
import math
n=int(input())
A=[int(input()) for i in range(5)]

# flag=True
# for i in A:
#   if i<n:
#     flag=False
# if flag==True:
#   print(5)
#   exit()

# ans=0
# if n >A[0]:
#   ans+=(n//A[0] if n%A[0] else n//A[0]-1)
#   n=A[0]

# for a in A[1:]:
#   if n>a:
#     ans+=(n//a if n%a else n//a-1)
#     n=a
print(math.ceil(n/min(A))+4)

Measured memory_bytes: 3060
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);


#define max 10000
ll big=1e9+7;
ll ff=0;
vector<ll> p(max,1);
vector<ll> ip(max,1);

ll pow_ans(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
          res *= x;
          res %= big;
        }
        x *= x;
        x %= big;
        n >>= 1;
    }
    return res;
}

void initialize(){
  for(int i=1;i<max;i++){
    p[i]=p[i-1]*i%big;
  }
  for(int i=1;i<max;i++){
    ip[i]=pow_ans(p[i],big-2);
  }
}

ll nPk(int i,int j){
  if(ff==0){
    initialize();
    ff=1;
  }
  if(i<0||j<0||i<j)return 0;
  else{
    ll tem;
    tem=p[i]*ip[i-j]%big;
    return tem;
  }
}

ll nCk(int i,int j){
  if(ff==0){
    initialize();
    ff=1;
  }
  if(i<0||j<0||i<j)return 0;
  ll tmp=nPk(i,j);
  tmp=tmp*ip[j]%big;
  return tmp;
}

int main(){
  ll n,k;
  cin>>n>>k;
  for(ll i=1;i<=k;i++){
    ll ans=nCk(k-1,i-1);
    ans=(ans*nCk(n-k+1,i))%big;
    cout<<ans<<endl;
  }
}


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

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;

using ll = long long;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> X;

  for (ll a = -3000; a <= 3000; a++)
  for (ll b = -3000; b <= 3000; b++) {
    ll a4 = a * a, b4 = b * b;
    a4 *= a4;
    b4 *= b4;
    ll r = a * a4 - b * b4;
    if (r == X) {
      cout << a << " " << b << endl;
      return;
    }
  }


}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3580
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_adj_list = v_detail[2:]
        # assert len(v_adj_list) == int(v_detail[1])
        for each in v_adj_list:
            init_adj_matrix[int(v_detail[0]) - 1][int(each) - 1] = 1
    return init_adj_matrix


def graph_dfs(v_init):
    global time

    # init the first node of overall graph iterations(times >= 1)
    vertices_visit_stack.append(v_init)
    vertices_status_list[v_init] = VISITED_IN_STACK
    vertices_d_time[v_init] += time
    # init end

    while len(vertices_visit_stack) > 1:
        current_vertex = vertices_visit_stack[-1]
        next_vertex = get_adj_vertices(vertex=current_vertex)

        if next_vertex:
            if vertices_status_list[next_vertex] is UNVISITED:
                vertices_status_list[next_vertex] = VISITED_IN_STACK
                time += 1
                vertices_d_time[next_vertex] += time
                vertices_visit_stack.append(next_vertex)
        else:
            vertices_visit_stack.pop()
            vertices_status_list[current_vertex] = POPPED_OUT
            time += 1
            vertices_f_time[current_vertex] += time

    return None


def get_adj_vertices(vertex):
    index = int(vertex) - 1
    for j in range(vertices_num):
        if adj_matrix[index][j]:
            adj_matrix[index][j] = 0
            return j + 1
    return None


def dfs_start():
    global time
    for i in range(vertices_num):
        if vertices_status_list[i + 1] == UNVISITED:
            # print('round: ', i + 1)
            graph_dfs(v_init=i + 1)
            time += 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    vertices_info = list(map(lambda x: x.split(), _input[1:]))
    init_adj_matrix = tuple([[0] * vertices_num for _ in range(vertices_num)])
    # assert len(vertex_info) == vertex_num

    # config length = (vertex_num + 1)
    vertices_visit_stack = [-1]
    vertices_status_list = [UNVISITED] * vertices_num
    vertices_status_list.insert(0, -1)
    vertices_d_time, vertices_f_time = ([0] * (vertices_num + 1) for _ in range(2))

    adj_matrix = generate_adj_matrix(vertices_info)
    # timing start from 1
    time = 1
    dfs_start()
    for k in range(vertices_num):
        print(k + 1, vertices_d_time[k + 1], vertices_f_time[k + 1])

Measured memory_bytes: 7880