akhauriyash/Code-Regression huggingface dataset:
n = int(input())
l = []
ans = 1
for i in range(2,n+1):
    for j in range(2,i):
        if i % j == 0:
            break
    else:
        l.append(i)

for h in l:
    a = 1
    for i in range(1,n+1):
        while i % h == 0:
            i /= h
            a += 1
    else:
        ans *= a

print(ans % (10**9+7))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
int a[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(n%i==0)
        {
            int x=n/i;
            if(x<10&&i<10)
            {
                cout<<"Yes"<<'\n';
                return 0;
            }
        }
    }
    cout<<"No"<<'\n';

}


Measured memory_bytes: 3608
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

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

    YES(x==3 || x==5 || x==7)

}

Measured memory_bytes: 256
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sum=0
#print(A,B,C)

for i in range(N):
  sum=sum+B[A[i]-1]
  #print(i,A[i]-1,B[A[i]-1],sum)

j=0
while j < N-1:
  #print(A[j+1],A[j])
  if A[j+1]==A[j]+1:
    sum=sum+C[A[j]-1]
    #print(j,j+1,C[A[j]-1])
  j=j+1
    
print(sum)
               


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=998244353;
const long double Pi=acos(-1);
ll pow2(ll a,ll b){
  ll ans=1;
  while(b>=1){
    ans*=a;
    ans%=MOD;
    b--;
  }
  return ans;
}
int main(){
  ll N,S,a;
  cin>>N>>S;
  vector<ll> A(0);
  for(ll i=0;i<N;++i){
    cin>>a;
    if(a<=S){A.push_back(a);}//Sより大きいのをそもそも除外(部分集合に入るわけないから)
  }
  ll dp[3020][3020];//何乗？
  sort(A.begin(),A.end());//何となくソート(特に意味ないけど自分に分かりやすくするため)
  if(A.size()==0){cout<<0<<endl;return 0;}//そもそも要素が空だったら0を出力(条件を満たすことは不可能だから)
  dp[1][A.at(0)]=1;
  for(ll i=1;i<N;i++){dp[i][0]=pow2(2,i);}//定数項は2の指数乗に
  //以下、積のシグマ(2+x^(A.at(i)))を計算していき、x^sの項の係数(答え)を求める
  for(ll i=2;i<=N;i++){
    for(ll j=0;j<=S;j++){
      if(i-1<(ll)A.size()){
        if(j-A.at(i-1)>=0){
          if(dp[i-1][j-A.at(i-1)]>0){
            dp[i][j]+=dp[i-1][j-A.at(i-1)];
            dp[i][j]%=MOD;
          }
        }
      }
      if(j>0){
        dp[i][j]+=dp[i-1][j];
        dp[i][j]%=MOD;
        dp[i][j]+=dp[i-1][j];
        dp[i][j]%=MOD;
      }
    }
  }
  cout<<dp[N][S]%MOD<<endl;
}

Measured memory_bytes: 74428
#include <iostream>

using namespace std;


int main (void) {

  int N, K;

  cin >> N >> K;

  int cnt = 0;
  for (int i=0;i<N;i++) {
    int h;
    cin >> h;
    if(h >= K) cnt++; 
  }


  cout << cnt << endl;


  return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    string S, T;
    cin >> S >> T;
    int s = S.size(), t = T.size();
    VV<int> dp(s + 1, V<int>(t + 1, 0));
    rep(i, s + 1) dp[i][0] = i;
    rep(i, t + 1) dp[0][i] = i;

    rep2(i, 1, s + 1) rep2(j, 1, t + 1) {
        int m = min(dp[i][j - 1] + 1, dp[i - 1][j] + 1);  // 削除と挿入の比較
        if (S[i - 1] == T[j - 1]) {
            dp[i][j] = min(m, dp[i - 1][j - 1]);
        } else {
            dp[i][j] = min(m, dp[i - 1][j - 1] + 1);
        }
    }
    cout << dp[s][t] << endl;
    return 0;
}



Measured memory_bytes: 6852
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	string S, T;
	cin >> S >> T;
	cout << T + S << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	

	clock_t startTime=clock();

	ll n,m,k;
	cin>>n>>m>>k;
	ll ar[n],br[m];
	rep(i,0,n)
	{
		cin>>ar[i];
	}
	rep(i,0,m)
	{
		cin>>br[i];
	}

	rep(i,1,n)
	{
		ar[i]=ar[i]+ar[i-1];
	}
	rep(i,1,m)
	{
		br[i]=br[i]+br[i-1];
	}

	ll maxi=0;
	rep(i,0,n+1)
	{
		ll rem=k,taken=0;;
		if(i>0 and ar[i-1]<=rem)
		{
			rem-=ar[i-1];
			taken=i;
		}
		ll pos=upper_bound(br,br+m,rem)-br;
		taken+=pos;
		maxi=max(maxi,taken);
	}
	cout<<maxi<<endl;

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 6932
from collections import*
z,v,a=input,range,print
h,w,k=map(int,z().split());r,s,t,u=map(lambda x:int(x)-1,z().split());b=[z()for _ in v(h)];l=[[-1]*w for _ in v(h)];l[r][s]=0;d=deque([(r,s)])
while d:
  x,y=d.popleft();j=l[x][y]
  if(x==t)&(y==u):exit(a(j))
  for e,f in[[1,0],[-1,0],[0,-1],[0,1]]:
    for i in v(1,k+1):
      p,q=x+e*i,y+f*i
      if not((0<=p<h)&(0<=q<w))or b[p][q]=="@" or 0<=l[p][q]<=j:break
      if l[p][q]<0:d+=[(p,q)];l[p][q]=j+1
a(-1)

Measured memory_bytes: 93544
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,k;
    cin>>n>>k;
    map<int,int> ma;
    REP(i,n){
        int t;
        cin>>t;
        ma[t]++;
    }
    vi vec;
    for(auto itr:ma){
        vec.pb(itr.se);
    }
    sort(all(vec));
    int ans=0;
    int m=max(0,(int)vec.size()-k);
    REP(i,m){
        ans+=vec[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12028
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N; cin >> N;
    vector<pair<int, int>> A(N);
    set<int> s;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        A[i] = {a, i+1};
        s.insert(i+1);
    }
    s.insert(0);
    s.insert(-1);
    s.insert(N+1);
    s.insert(N+2);

    Int ans = 0;
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) {
        auto l1 = s.lower_bound(A[i].second);
        auto l2 = l1;
        auto r1 = l1;
        auto r2 = l1;
        r1++;
        r2++, r2++;
        l1--;
        l2--, l2--;
        
        if (1 <= *l1) {
            ans += (*l1 - *l2) * (*r1 - A[i].second) * A[i].first;
        }
        if (*r1 <= N) {
            ans += (*r1 - *r2) * (*l1 - A[i].second) * A[i].first;
        }
        s.erase(A[i].second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6144
while True:
    N = int(input())
    if N == 0:
        break
    effies = {}
    for _ in range(N):
        L, P, A, B, C, D, E, F, S, M = map(str, input().split())
        P = int(P)
        A = int(A)
        B = int(B)
        C = int(C)
        D = int(D)
        E = int(E)
        F = int(F)
        S = int(S)
        M = int(M)

        spend_time = A + B + C + (D+E) * M
        earn_amount = (F*M*S)-P
        effi = earn_amount/spend_time
        effies[L] = effi

    effies = sorted(effies.items(), key=lambda x :(-x[1], x[0]))
    for i in range(len(effies)):
        print(effies[i][0])
    print("#")


Measured memory_bytes: 5620
n,m = map(int,input().split())
e = [0]*m

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


class uf():
    def __init__(self,n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rank = [0]*(n+1)
    
    def find(self,x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
    
    def same(self,x,y):
        return self.find(x) == self.find(y)
    
    def cnt(self,x):
        return -self.root[self.find(x)]


u = uf(n)

ans = [0]*m
ans[0] = n*(n-1) // 2

for i in range(1,m):
    if u.same(e[i-1][0],e[i-1][1]):
        ans[i] = ans[i-1]
    else:
        ans[i] = ans[i-1] - u.cnt(e[i-1][0]) * u.cnt(e[i-1][1])
    u.unite(e[i-1][0],e[i-1][1])

for i in range(m):
    print(ans[m-1-i])

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

int main(){

    int A,B,N;
    int i,j,k;
    int min = 1000000000;
    int a,b,c,d;
    int count=0,count_two=0,v;
    
    cin >> N;

    for(i=0;i<N;i++){
        cin >> v;
        //if( (min < v ) && (v % 2 == 0))min = (v / 2);
        if(v % 2 == 0){
            count ++;
            while(v % 2 == 0){
                v /= 2;
                count_two++;
            }
            if(min > count_two){
                min = count_two;
            }
            count_two = 0;
        }
    }

    if(count == N)cout << min << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
x = math.floor(math.sqrt(n))
ans = 0
for m in range(1,x+1):
    ans += m*(m+math.floor(n/m))*(math.floor(n/m)+1-m)
print(int(ans-(((x+1)**4-x**4)-((x+1)**2-x**2))/12))

Measured memory_bytes: 63908
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N,M;cin>>N>>M;
    int m=M/N;
    double r=sqrt(M);
    int root=r/1;
    if(m<=root){
        while(M%m!=0)m--;
    }
    else{
        m=N;
        while(M%m!=0&&m<=root){
            m++;
        }
        if(m==root+1){
            m=N-1;
            while(M%m!=0)m--;
        }
        else m=M/m;
    }
    cout<<m<<endl;
    return 0;

}

Measured memory_bytes: 256
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

S = list(input())
for i in range(len(S)):
    if S[i] != "A" and S[i] != "C" and S[i] != "G" and S[i] != "T":
        S[i] = ' '
S2 = "".join(S)
L_ans = list(map(lambda x: len(x), S2.split()))
# print(L_ans)
if L_ans:
    print(max(L_ans))
else:
    print(0)


Measured memory_bytes: 9064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    vector<long long> a(3);
    for(int i=0;i<3;++i){
        cin>>a[i];
        if(a[i]%2==0){
            cout<<0<<endl;
            return 0;
        }
    }
    sort(a.begin(),a.end());
    cout<<a[0]*a[1]<<endl;
    return 0;
}

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

using namespace std;

int main() {

	long n, k, x, y;
	cin >> n >> k >> x >> y;

	if (n <= k) { cout << n * x << endl; return 0; }
	else {
		cout << k * x + (n - k)*y << endl;
	}
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
string s;

int main(){
    int cunt = 0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+') cunt++;
        else cunt--;
    }
    cout<<cunt<<"\n";
    return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int d, tmp;
    vector<bool> A(N);
    for (int i = 0; i < K; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> tmp;
            A.at(tmp-1) = true;
        }
    }

    int ret = 0;
    for (int i = 0; i < N; i++) {
        if (!A.at(i)) {ret++;}
    }
    cout << ret << endl;
}

Measured memory_bytes: 3644
while True:
    count=0
    n,x = map(int,input().split())
    if n == 0 and x == 0 :break
    for i in range(1, n-1):
        for j in range(1, n):
            for k in range(1,n+1):
                if i<j<k:
                    if i+j+k==x:count+=1
    print(count)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<int>arr1(n+1),arr2(n+1),arr3(n+1);
	for(int i=1; i<=n; i++)
	 cin>>arr1[i];
	for(int i=1; i<=n; i++)
	 cin>>arr2[i];
	for(int i=1; i<n; i++)
	 cin>>arr3[i];
	int ans=0;
	for(int i=1; i<=n; i++){
		ans=ans+arr2[arr1[i]];
	}
	for(int i=2; i<=n; i++){
		if(arr1[i]==arr1[i-1]+1){
			ans+=arr3[arr1[i-1]];
		}
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 3604
s=list(input())
n=len(s)
if n==2:
    if s[0]==s[1]:
        print(1,2)
    else:
        print(-1,-1)
else:
    for i in range(n-2):
        if s[i]==s[i+1] or s[i]==s[i+2] or s[i+1]==s[i+2]:
            print(i+1,i+3)
            exit()
    print(-1,-1)


Measured memory_bytes: 69008
use proconio::input;

fn main() {
    input! {
        n: i64,
    }

    let ans = match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        _ => "bon",
    };
    println!("{}", ans);
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
    int n;
    ll k; 
    cin >> n >> k;
    pii p[n];
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }

    sort(p, p + n);

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += p[i].second;
        if (sum >= k) {
            cout << p[i].first;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
string s;
int chi[800010][3];
int cnt[800010],ans[531450];
bool mrk[800010];
char str[200010]; 
int tac;
int build(int x,int y)
{
	int ti=tac;
	cnt[tac++]=y;
	if (x<n)
	{
		chi[ti][0]=build(x+1,y);
		chi[ti][1]=build(x+1,pow(3,x)+y);
		chi[ti][2]=build(x+1,pow(3,x)*2+y);
	}
	return ti;
}
void pushdown(int x)
{
	mrk[x]=0;
	if (chi[x][0]!=-1)
	{
		swap(chi[x][1],chi[x][2]);
		mrk[chi[x][0]]^=1;
		mrk[chi[x][1]]^=1;
		mrk[chi[x][2]]^=1;
	}
}
void dfs(int x)
{
	if (mrk[x]) pushdown(x);
	if (chi[x][0]==-1) return;
	swap(chi[x][0],chi[x][2]),swap(chi[x][1],chi[x][2]);
	dfs(chi[x][0]);
}
void getans(int x,int y,int dep)
{
	if (mrk[x]) pushdown(x);
	//cout <<x<<" "<<y<<" ################\n";
	//cout <<chi[x][0]<<" "<<chi[x][1]<<" "<<chi[x][2]<<" ##\n";
	if (chi[x][0]==-1)
	{
		ans[cnt[x]]=y;
		return;
	}
	getans(chi[x][0],y,dep+1);
	getans(chi[x][1],pow(3,dep)+y,dep+1);
	getans(chi[x][2],pow(3,dep)*2+y,dep+1);
}
int main()
{
	scanf("%d%s",&n,&str);
	memset(chi,-1,sizeof(chi));
	s=str;
	build(0,0);
	for (int i=0;i<s.size();i++)
	{
		if (s[i]=='S') mrk[0]^=1;
		else dfs(0);
	}
	getans(0,0,0);
	for (int i=0;i<pow(3,n);i++) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 19792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int Q;
  cin >> Q;
  long long A, B, C;
  for(int i; i < Q; i++){
    cin >> A >> B;
    if(A == B || A + 1 == B) cout << 2 * A - 2 << endl;
    else{
      C = sqrt(A * B);
      if(C * C == A * B) C--;
      if(C * (C + 1) >= A * B) cout << 2 * C - 2 << endl;
      else cout << 2 * C - 1 << endl;
    }
  }
}

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

using namespace std;

typedef long long ll;

vector<ll > adj[100005];
int colors[100005];
bool vis[100005];
map<pair<ll,ll>,ll> weight;

void dfs(int u,ll dis){

    vis[u]=true;
    for(ll v : adj[u]){
        if(!vis[v]){
            ll check=0;
            if(u>v){
                check=weight[{v,u}];
            }
            else{
                check=weight[{u,v}];
            }
            colors[v] = ((check+dis)%2==0? colors[1]:1-colors[1]);
            dfs(v,check+dis);
        }
    }
}

int main() {
    ll n;
    cin >> n;
    for(int i=1;i<n;i++){
        int u,v,w;
        cin >> u >> v >> w;
        adj[u].push_back(v);
        adj[v].push_back(u);
        if(u>v){
            swap(u,v);
        }
        weight[{u,v}]=w;
    }

    colors[1] = 1;
    dfs(1,0);

    for(int i=1;i<=n;i++){
        cout << colors[i]<<endl;
    }


    return 0;
}


Measured memory_bytes: 17408
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

long long Gcd(long long a, long long b) {
    return b ? Gcd(b, a%b) : a;
}

long long Lcm(long long a, long long b) {
    return a / Gcd(a, b) * b;
}

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

    Int N; cin >> N;
    Int T1; cin >> T1;
    Int res = T1;
    rep(i, 1, N) {
        Int T; cin >> T;
        res = Lcm(res, T);
    }

    cout << res << endl;
}


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

using namespace std;

int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7)
	cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
return 0;
}


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

using namespace std;

char S[8080];
vector <int> X, Y;
bool D[8080];
int x, y;

void die() { printf("No\n"); exit(0); }

int main()
{
	int i, d, s;
	
	scanf("%s%d%d", S, &x, &y);
	
	for(i=0; S[i] && S[i] != 'T'; i++);
	x -= i;
	
	if(!S[i] && (x || y)) die();
	
	x = abs(x); y = abs(y);
	
	for(d=1, s=0; S[i]; i++){
		if(S[i] == 'F') s ++; 
		else{
			if(s){
				(d? X : Y).push_back(s);
				(d? x : y) += s;
			}
			d = !d; s = 0;
		}	
	}
	
	if(s){
		(d? X : Y).push_back(s);
		(d? x : y) += s;
	}
	
	if((x & 1) || (y & 1)) die();
	x /= 2; y /= 2;
	
	D[0] = 1;
	
	for(int &t: X){
		for(i=x; i>=t; i--){
			D[i] |= D[i - t];
		}
	}
	
	if(!D[x]) die();
	
	for(i=1; i<=y; i++){
		D[i] = 0;
	}
	
	for(int &t: Y){
		for(i=y; i>=t; i--){
			D[i] |= D[i - t];
		}
	}
	
	if(!D[y]) die();
	
	printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 256
// ITP1_5_D:   Structured Programming
// 2017.7.27
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

void call(int n)
{
	int i = 1;
	int x;

	do {
		x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
		}
		else {
			do {
				if (x % 10 == 3) {
					printf(" %d", i);
					x = 0;
				}
				else x /= 10;
			} while (x);
		}
	} while (++i <= n);
	putchar('\n');
}

#if 1
int main()
{
	int n;

	scanf("%d", &n);
	call(n);
	return 0;
}
#endif


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; i++){
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2)
            cnt++;
        else
            cnt = 0;
        
        if (cnt >= 3){
            puts("Yes");
            return 0;
        }
    }

    puts("No");
}

Measured memory_bytes: 3592
#高速化heapqダイクストラ
from collections import *
from heapq import*
import sys
input=lambda:sys.stdin.readline()


def BFS(point,d):
    cost=[1e7]*(n+1)
    cost[point]=0
    Q=deque([(0,point)])
    
    while Q:
        c,p = Q.popleft()
        for np in d[p]:
            if cost[np]==1e7:
                cost[np]=c+1
                Q.append((c+1,np))
    return cost

n=int(input())
# d={}
d=[[] for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)
    
    # if a in d.keys():
    #     d[a].append(b)
    # else:
    #     d[a]=[b]
    # if b in d.keys():
    #     d[b].append(a)
    # else:
    #     d[b]=[a]
        
x=BFS(1,d)[1:]
y=BFS(n,d)[1:]

#print(x,y)

F=0
S=0

for s,t in zip(x,y):
    if s<=t:
        F+=1
    else:
        S+=1

if F<=S:
    print("Snuke")
else:
    print("Fennec")


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

int main(){
    int n, a;
    cin >> n;
    vector<int> t(int(1e+5+5), 0);
    for(int i=0; i<n; i++){
        cin >> a;
        t[a] += 1;
        t[a+1] += 1;
        t[a+2] += 1;
    }
    cout << *max_element(t.begin(), t.end()) << endl;
}

Measured memory_bytes: 640
#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>;
using Graph = vector<vector<int>>;

// header area

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

    int ans=0;
    if(a%1000 == 0) ans = 0;
    else ans = 1000*(a/1000 + 1) - a;
    cout << ans << endl;

    return 0;
}

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

int main()
{
    int A,B;
    cin >> A >> B;

    //Aの幅
    double atmp;
    int a1,a2;
    a1 = A/0.08;
    atmp = A/0.08;
    if((atmp - a1) > 0) a1++;
    a2 = (A + 0.99)/0.08;

    //Bの幅
    int b1,b2;
    b1 = B/0.1;
    b2 = (B + 0.99)/0.1;

    if(a1 > b1 && a1 < b2) cout << a1 << endl;
    else if(b1 > a1 && b1 < a2) cout << b1 << endl;
    else if(a1 == b1) cout << a1 << endl;
    else cout << "-1" << endl;
    
    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

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

int main() {
  string s; cin >> s;
  int n = s.size();

  int win_num = 0, lose_num = 0;
  int p_num = 0, g_num = 0;
  rep(i, n) {
    if (p_num == g_num) {
      g_num ++;
      if (s[i] == 'g') continue;
      else lose_num ++;
    } else {
      if (s[i] == 'g') {
        p_num ++;
        win_num ++;
      } else {
        p_num ++;
      }
    }
  }

  cout << win_num - lose_num << endl;
}

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

public class Main{	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n,r,p,c;
		int[] card;
		int[] tmp1;
		int[] tmp2;
		while(true){
			n = sc.nextInt();
			r = sc.nextInt();
			card = new int[n];
			for(int i=0;i<n;i++){
				card[i]=n-i;
			}
			if(n==0&&r==0){
				break;
			}
			for(int j=0;j<r;j++){
				p = sc.nextInt();
				c = sc.nextInt();
				tmp1 = Arrays.copyOfRange(card,0,p-1);
				tmp2 = Arrays.copyOfRange(card,p-1,c+p-1);
				for(int i=0;i<c;i++){
					card[i]=tmp2[i];
				}
				for(int i=0;i<p-1;i++){
					card[c+i]=tmp1[i];
				}
			}
			System.out.println(card[0]);
		}
		sc.close();
	}
}


Measured memory_bytes: 36768
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <iterator>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cmath>
#include <cstdlib>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

#define ALL(v) (v).begin(), (v).end()
#define endl "\n"
typedef long long int ll;

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

int SumDigitValues(int x)
{
	int sum = 0;
	while (x)
	{
		sum += x % 10;
		x = x / 10;
	}

	return sum;
}

int Factorial(int n)
{
	if (n < 0) return 0;
	if (n == 0) return 1;
	return n * Factorial(n - 1);
}

int factorial(int n)
{
	if (n > 1)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}

int gcd(int x, int y)
{
	if (y == 0)
		return x;
	else 
		return gcd(y, x % y);
}

vector<int> Divisors(int x)
{
	vector<int> divisors;
	divisors.push_back(1);
	for (int a = 2; a <= x; a++)
	{
		if (x % a == 0) divisors.push_back(a);
	}
	return divisors;
}

vector<int> CommonDivisors(int a, int b)
{
	vector<int> divisorsA = Divisors(a);
	vector<int> divisorsB = Divisors(b);
	vector<int> commonDivisors;
	set_intersection(divisorsA.begin(), divisorsA.end(), divisorsB.begin(), divisorsB.end(), std::back_inserter(commonDivisors));
	return commonDivisors;
}

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

	int x, a;
	cin >> x >> a;

	cout << ((x < a) ? 0 : 10) << endl;
}

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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

int main() {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll ans = b * d;
        if(a <= 0 && 0 <= b && ans < 0) {
                ans = 0;
        }
        if(c <= 0 && 0 <= d && ans < 0) {
                ans = 0;
        }
        ans = max(ans, a * c);
        ans = max(ans, a * d);
        ans = max(ans, b * c);
        ans = max(ans, b * d);
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int main() {
    long long a, b;
    cin >> a >> b;
    int uku = 0;
    for (int i = 1; i < 200000; i++) {
        if (a % i == 0 && b % i == 0)uku = i;
    }
    cout << a * b / uku << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0025
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
				var	v_min	= double.Parse( s );
				var	t	= v_min / 9.8;
				var	y	= 4.9 * t * t;
				for( int n = 1; ; n++ ) {
					if( 5 * n - 5 >= y ) {
						Console.WriteLine( n );
						break;
					}
				}  
			}
		}
	}
}

Measured memory_bytes: 20024
#include <iostream>
#include <string>

int h, w;
std::string s[51];

int main(){
  std::cin >> h >> w;
  for(int i=0; i<h; i++) std::cin >> s[i];

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

  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(s[i][j]=='#') continue;

      int num = 0;
      for(int d=0; d<8; d++){
        const int ni = i + dy[d];
        const int nj = j + dx[d];

        if(ni<0 or h<=ni) continue;
        if(nj<0 or w<=nj) continue;
        if(s[ni][nj]=='#') num++;
      }
      s[i][j] = char(num + '0');
    }
  }

  for(int i=0; i<h; i++) std::cout << s[i] << '\n';
}


Measured memory_bytes: 256
#include <string>
#include <cstdio>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <deque>
#include <stack>
#include <queue>
#define next Next
#include <map>
#include <unordered_map>
using namespace std;
const int N = 4e5 + 1;
int n;
long long m;
int a[N];
int next[N], sum[N], f[N], g[N], id[N], d[N];
void output(int x){
    if (!x) return;
    f[0] = 0;
    memset(sum, 0, sizeof(sum));
    for (int i = x; i <= n ; i ++) {
        if (!sum[a[i]]){
            f[++f[0]] = a[i];
            sum[a[i]] ++;
        } else {
            while (sum[a[i]]) sum[f[f[0] --]] --;
        }
    }
    for (int i= 1; i<= f[0]; i ++)
        printf("%d ", f[i]);
}
int main()
{
    scanf("%d %lld", &n, &m);
    for (int i = 1; i <= n ; i ++)
        scanf("%d", &a[i]), a[i + n] = a[i];
    for (int i = n + n ; i >= 1; i --) {
        next[i] = f[a[i]], f[a[i]] = i;
        if (!next[i])g[i] = i;
        else
            g[i] = g[next[i] + 1];
    }
    f[0] = 0;
    for (int i = 1; i <= n ; i ++) {
        if (!sum[a[i]]){
            f[++f[0]] = i;
            sum[a[i]] ++;
        } else {
            while (sum[a[i]]) sum[a[f[f[0] --]]] --;
        }
    }
    if (f[0])
        g[0] = f[1];
    int x = 0;
    while (!id[x]) {
        d[id[x] = ++d[0]] = x;
        x = g[x];
        if (x > n) x -=n;
    }
    d[++d[0]] =x;
    ++m;
    int len = d[0] - id[x];
    if (m <= d[0]) output(d[m]);
    else
    {
        m -= id[x];
        output(d[m % len + id[x]]);
    }
    return 0;
}

Measured memory_bytes: 11648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0001
{
	class Program
	{
		static void Main(string[] args)
		{
			int[]	height	= new int[ 10 ];
			for( int i = 0; i < 10; i++ ) {
				height[ i ]	= int.Parse( Console.ReadLine() );
			}
			Array.Sort( height );
			Console.WriteLine( height[ 9 ] );
			Console.WriteLine( height[ 8 ] );
			Console.WriteLine( height[ 7 ] );
		}
	}
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    map<int,int> mp;
    REP(i,m){
        int a,b;
        cin>>a>>b;
        mp[a]++;
        mp[b]++;
    }
    for(auto x:mp){
        if(x.second%2!=0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

int main() {
    int h,w,n;
    cin >> h >> w >> n;
    int x,y;
    cin >> x >> y;
    string a,b;
    cin >> a >> b;
    int flag = 0;

    int l = 1;
    int r = w;
    int u = 1;
    int d = h;

    drep(i,n){
        if(b[i] == 'L'){
            r++;
            if(r > w)r = w;
        }
        if(b[i] == 'R'){
            l--;
            if(l < 1)l = 1;
        }
        if(a[i] == 'L'){
            l++;
        }
        if(a[i] == 'R'){
            r--;
        }
        if(l > r){
            flag = 1;
            break;
        }

        if(b[i] == 'U'){
            d++;
            if(d > h)d = h;
        }
        if(b[i] == 'D'){
            u--;
            if(u < 1)u = 1;
        }
        if(a[i] == 'U'){
            u++;
        }
        if(a[i] == 'D'){
            d--;
        }
        if(u > d){
            flag = 1;
            break;
        }
    }

    //cout << u << ' ' << x << ' ' << d << endl;
    //cout << l << ' ' << y << ' ' << r << endl;
    
    if(flag == 0){
        if(y < l || r < y)flag = 1;
        if(x < u || d < x)flag = 1;
    }
    

    if(flag == 0)yn;
    return 0;
}
 
 


Measured memory_bytes: 776
use std::collections::*;
use std::io::*;
use std::*;
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>();
            ret
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    // iterator(splitted input-string) => iterator(output-type)
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:ty),+) => {
        ($(_get!($it; $t)),*)
    };
}

fn main() {
    let n = get!(i32);
    let a = get!([i32]);
    let mut ans = 0;
    for i in 0..n {
        if (i + 1) % 2 == 1 && a[i as usize] % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

void main_()
{
    int64_t N;
    vector<int64_t> As;
    cin >> N;
    copy_n(istream_iterator<int64_t>(cin), N, back_inserter(As));

    auto total_len = accumulate(begin(As), end(As), 0LL);
    int64_t left = 0;
    int64_t middle = 0;
    int64_t right = 0;
    for (int64_t i = 0, len = 0; i < N; ++i) {
        left = len;
        len += As[i];
        if (len >= total_len / 2) {
            middle = As[i];
            right = total_len - len;
            break;
        }
    }

    auto ans1 = min(left + middle - right, right + middle - left);

    cout << ans1 << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;

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

    vector<ll> A(N - 1);
    rep(i, N - 1) cin >> A[i];

    vector<ll> B(N, 0);
    rep(i, N - 1) { B[A[i] - 1]++; }

    rep(i, N) cout << B[i] << endl;

    return 0;
}

Measured memory_bytes: 6408
s = input()
count = 0
max_len = 0
flag = True
for i in s:
    if((i == "A") or (i == "G") or (i=="C") or (i == "T")) and flag:
        count+=1
        if max_len <= count:
            max_len = count
        flag = True
    else:
        count = 0
        flag = True
print(max_len)

Measured memory_bytes: 3060
function main(input){
    const f = Math.floor;
    const hour = f(input/60/60);
    const minute = f(f(input/60)%60);
    const second = f(input%60);
    console.log(hour+":"+minute+":"+second);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 15372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int n;
    cin>>n;
    int flag =0;
    vector<int> h(n);
    rep(i,n) cin >>h[i];
    rep(i,n-1){
        if (h[i]-1 <h[i+1]) continue;
        else if (h[i]-1 == h[i+1]) h[i+1]++;
        else {flag++; break;}
    }
    if (flag) cout  <<"No"<<endl;
    else cout << "Yes" <<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n, m; cin >> n >> m;
    vector<int> s(m), c(m);
    rep(i, m) cin >> s.at(i) >> c.at(i);

    rep(i, m) rep(j, m){
        if(s.at(i)==s.at(j) && c.at(i) != c.at(j)){
            cout << -1 << endl;
            return 0;
        }
    }

    if(n==1){
        rep(i,m){
            if(s.at(i)==1){
                cout << c.at(i) << endl;
                return 0; 
            }
        }
        if(m==0){
            cout << 0 << endl;
            return 0;
        }
    }
    else if(n==2){
        rep(i,m) {
            if(s.at(i)==1 && c.at(i) == 0){
                cout << -1 << endl;
                return 0;
            } 
        }
        
        string st = "10";
        rep(i, m){
            if(s.at(i)==1){
                st.replace(0,1, to_string(c.at(i)));
            }
            else if(s.at(i)==2){
                st.replace(1,1, to_string(c.at(i)));
            }
        }

        cout << st << endl;
        return 0;
    }

//n==3
    rep(i, m){
        if(s.at(i)==1 && c.at(i)==0){
            cout << -1 << endl;
            return 0;
        }
    }


    string st = "100";
    rep(i, m){
        if(s.at(i)==1){
            st.replace(0,1, to_string(c.at(i)));
        }
        else if(s.at(i)==2){
            st.replace(1,1, to_string(c.at(i)));
        }
        else if(s.at(i)==3) st.replace(2,1, to_string(c.at(i)));
    }

    cout << st << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int N;

int N_pos, N_neg;
pair<int, int> depth_pos[1000000], depth_neg[1000000];/*depth絶対値、height絶対値*/

string S[1000000];


int main() {
	/*
	'('は「1上がる」、')'は「1下がる」と読むことにする。
	このとき、(と)の列がカッコ列になるのは、
	最後が高さ0で、途中一度も高さが負にならないということと同値。
	
	まず、各S_iが高さ0から始まったとして、「一番低い場所」の高さと、「最後」の高さをチェック。
	最後の高さの合計が0でなければ不可能。

	最後の高さが「0以上」「0未満」で分ける。
	0以上のやつについて、深さの浅い順にソートして貪欲に使っていく。
	全部使えたらオッケー。
	*/

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	N_pos = 0; N_neg = 0;
	for (int i = 0; i < N; i++) {
		int depth = 0;
		int height = 0;
		for (int j = 0; j < S[i].length(); j++) {
			if (S[i][j] == '(') {
				height++;
			}else{
				height--;
			}
//			cout << height << " ";
			if (depth > height) {
				depth = height;
			}
		}
//		cout << "\n";
		if (height >= 0) {
			depth_pos[N_pos] = make_pair(-depth, height);
			N_pos++;
		}else{
			depth_neg[N_neg] = make_pair(-depth + height, -height);
			N_neg++;
		}
	}

	sort(depth_pos, depth_pos + N_pos);
	sort(depth_neg, depth_neg + N_neg);

//	cout << "positive\n";

	/*まずheightの和をチェック*/
	int check = 0;
	for (int i = 0; i < N_pos; i++) {
//		cout << "depth: " << depth_pos[i].first << "height: " << depth_pos[i].second << "\n";
		check += depth_pos[i].second;
	}
//	cout << "negative\n";
	for (int i = 0; i < N_neg; i++) {
//		cout << "depth: " << depth_neg[i].first << "height: " << depth_neg[i].second << "\n";
		check -= depth_neg[i].second;
	}
	if (check != 0) {
		cout << "No\n";
		return 0;
	}

	check = 0;
	for (int i = 0; i < N_pos; i++) {
		if (check < depth_pos[i].first) {
			cout << "No\n";
			return 0;
		}
		check += depth_pos[i].second;
	}

	check = 0;
	for (int i = 0; i < N_neg; i++) {
		if (check < depth_neg[i].first) {
			cout << "No\n";
			return 0;
		}
		check += depth_neg[i].second;
	}
	
	cout << "Yes\n";
	return 0;

}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))



int main(){
  int n;
  std::cin >> n;
  std::vector<long long> t(n), a(n);
  long long tmp=1;
  rep(i,n) std::cin >> t[i];
  rep(i,n) std::cin >> a[i];
  if(t[t.size()-1]!=a[0]) {
    std::cout << "0" << std::endl;
    return 0;
  }
  long long ma=a[0];
  bool b=false;
  rep(i,n){
    if(i==0||i==n-1) continue;
    if(t[i]==ma&&a[i]==ma) b=true;
    else if(t[i]==ma&&a[i]!=ma&&b==false){
      std::cout << "0" << std::endl;
      return 0;
    }
    if(t[i]==t[i-1]&&t[i]<=t[i+1]&&a[i]<=a[i-1]&&a[i]==a[i+1]){
      tmp*=min(a[i],t[i]);
      tmp%=1000000007;
    }
  }
  std::cout << tmp << std::endl;
}


Measured memory_bytes: 1792
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const LL P = 1000000007LL;

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

int inv(int a)
{
	int x, y;
	exgcd(a, P, x, y);
	return (x % P + P) % P;
}

LL fac[200010];

void factorial(void)
{
	fac[0] = 1;
	for (int i = 1; i <= 200000; ++i)
	{
		fac[i] = fac[i - 1] * i;

		if (fac[i] >= P)
			fac[i] %= P;
	}
}

class warp
{
public:
	int sx, sy;
	int ex, ey;

	warp(void) {};
	warp(int _sx, int _sy, int _ex, int _ey) :
		sx(_sx), sy(_sy), ex(_ex), ey(_ey) {};

	friend bool operator < (const warp &a, const warp &b)
	{
		if (a.sx != b.sx)
			return a.sx < b.sx;
		else
			return a.sy < b.sy;
	}
};

int n, m, k;

LL dp[100005];

warp warps[100005];

LL calc(int a, int b)
{
	if (a < 0 || b < 0)return 0LL;
	if (a == 0 || b == 0)return 1LL;
	return fac[a + b] * inv(fac[a]) % P * inv(fac[b]) % P;
}

signed main(void)
{
	factorial();

	while (cin >> n >> m >> k, n || m || k)
	{
		for (int i = 1; i <= k; ++i)
		{
			int sx, sy, ex, ey;
			cin >> sx >> sy >> ex >> ey;
			warps[i] = warp(sx, sy, ex, ey);
		}

		memset(dp, 0, sizeof(dp));

		sort(warps + 1, warps + 1 + k);

		warps[++k] = warp(n, m, n, m);

		for (int i = 1; i <= k; ++i)
		{
			dp[i] = calc(warps[i].sx - 1, warps[i].sy - 1);

			for (int j = 1; j < i; ++j)
			{
				dp[i] += (calc(warps[i].sx - warps[j].ex, warps[i].sy - warps[j].ey) * dp[j]) % P;
				dp[i] -= (calc(warps[i].sx - warps[j].sx, warps[i].sy - warps[j].sy) * dp[j]) % P;
				dp[i] = (dp[i] % P + P) % P;
			}
		}

		cout << dp[k] << endl;
	}

//	system("pause");
}

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

int gcd(int p,int q){
  int r=q%p;
  while(r>0){
    q=p;
    p=r;
    r=q%p;
  }
  return p;
}

int divide(int b,int i){
  while(b%(i*i)==0){
    b/=i;
  }
  return b;
}

int main(){
  int p,q;
  cin>>p>>q;
  int b=q/gcd(p,q);
  for(int i=2;i*i<=b;i++)
    b=divide(b,i);
  cout<<b<<endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define INF (1 << 31) - 1

int main() {
  string N;
  cin >> N;
  if(N.at(N.size()-1) == '2' )
    {cout << "hon" << endl;}
     if(N.at(N.size()-1) == '4' )
       {cout << "hon" << endl;}
     if(N.at(N.size()-1) == '5' )
       {cout << "hon" << endl;}
     if(N.at(N.size()-1) == '7' )
       {cout << "hon" << endl;}
     if(N.at(N.size()-1) == '9' )
  {cout << "hon" << endl;}
  if(N.at(N.size()-1) == '0' )
     {cout << "pon" << endl;}
     if(N.at(N.size()-1) == '1')
     {cout << "pon" << endl;}
     if(N.at(N.size()-1) == '6' )
     {cout << "pon" << endl;}
     if(N.at(N.size()-1) == '8' )
  {cout << "pon" << endl;}
  if(N.at(N.size()-1) == '3' )
  { cout << "bon" << endl;}
}

Measured memory_bytes: 3628