akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc122/tasks/abc122_d

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }
map<string, ll> mp;
// 文字列長、今までの文字列
ll rec(int n, string s) {
    regex re(".*(A.?GC|AG.?C|GAC|ACG)");
    bool result = regex_match(s, re);
    if (result) {
        return 0;
    }
    if (n == 0) {
        // cout << s << endl;
        return 1;
    }
    ll ret = 0;
    //末尾から3桁の文字列 + ":" + 残り文字数
    int pos = max(0, (int)s.length() - 3);
    string ends = s.substr(pos) + ":" + to_string(n);
    if (mp.count(ends) == 0) {
        ret = rec(n - 1, s + "A") + rec(n - 1, s + "G") + rec(n - 1, s + "C") +
              rec(n - 1, s + "T");
        mp[ends] = ret;
    } else {
        ret = mp[ends];
    }
    return ret % MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;

    cout << rec(n, "") << endl;

    return 0;
}


Measured memory_bytes: 1152
/* ABC146-B
   Takatan */

#include<stdio.h>
#include<string.h>
int main(void){
    char string[101];
    int count, length, i;
    count = 0;

    scanf( "%s" , string);
    length = strlen(string);
    for(i=0; i < length/2; i++){
        if(string[i]!=string[length-1-i]){
            count++;
        }
    }
    printf( "%d\n" , count);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
ll pr[mx],ar[mx],br[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
int main()
{
    ll a,b;
    cin>>a>>b;
    ll mn=min(a,b);
    ll mx=max(a,b);
    for(ll i=1; ; i++)
    {
        ll ans=mn*i;
        if(ans%mx==0)
        {
            cout<<mn*i<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int t = scan.nextInt();
		
		int x = t/a;
		int y = x * b;
		
		System.out.println(y);
	}
}


Measured memory_bytes: 21588
#include <cstdio>
#define abs __builtin_fabs
#define cos __builtin_cos
#define sqrt __builtin_sqrt
#define PI 3.1415926535897932
using namespace std;

int main(int argc, char** argv)
{
	int a, b, h, m;
	scanf("%d%d%d%d", &a, &b, &h, &m);
	int mangle = m * 6;
	double hangle = h * 30 + m * 0.5;
	double theta  = abs(hangle - mangle);
	if(theta > 180) theta = 360 - theta;
	theta = theta / 180 * PI;
	printf("%.13lf\n", sqrt(double(a * a + b * b) - 2.0 * a * b * cos(theta)));
	return 0;
}

Measured memory_bytes: 2580
n = int(input())
xs = map(int, input().split())

mp = dict()

for x in xs:
    if x in mp:
        mp[x] = mp[x] + 1
    else:
        mp[x] = 1

res = 0
for x in mp.keys():
    v = mp[x]
    if v < x:
        res += v
    else:
        res += v - x

print(res)



Measured memory_bytes: 23288
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;
const int inf = 2e9;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

int main() {
    string S;
    getline(cin, S);

    vector<ll> modcounts(2019, 0);
    ll premod = 0;
    ll tensmod = 1;
    for (ll i = S.length() - 1; i >= 0; i--) {
        ll c = (ll)S.at(i) - '0';
        ll m = (c * tensmod + premod) % 2019;
        modcounts[m]++;
        tensmod = (tensmod * 10) % 2019;
        premod = m;
    }
    ll result = 0;
    for (ll m = 0; m < modcounts.size(); m++) {
        if (m == 0 && modcounts[m] >= 1) {
            result += (modcounts[m] + 1) * modcounts[m] / 2;
        } else if (modcounts[m] >= 2) {
            result += modcounts[m] * (modcounts[m] - 1) / 2;
        }
    }
    print(result);
}


Measured memory_bytes: 3724
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N, K;
	static double[][] a;

	public static void main(String[] args) {
		N = sc.nextInt();
		K = sc.nextInt();
		a = new double[N][2];
		for (int i = 0; i < N; ++i) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int r = sc.nextInt();
			double angle = Math.atan2(y, x);
			double diff = Math.asin(r / Math.sqrt(x * x + y * y));
			if (angle - diff <= -Math.PI) {
				a[i][0] = angle - diff + 2 * Math.PI;
				a[i][1] = Math.PI;
			} else {
				a[i][0] = Math.max(angle - diff, 0);
				a[i][1] = Math.max(Math.min(angle + diff, Math.PI), 0);
			}
		}
		ArrayList<Range> ranges = new ArrayList<Range>();
		for (int i = 0; i < N; ++i) {
			boolean ok = true;
			for (int j = 0; j < N; ++j) {
				if (a[i][0] > a[j][0] && a[i][1] < a[j][1]) {
					ok = false;
					break;
				}
			}
			if (ok) ranges.add(new Range(a[i][0], a[i][1]));
		}
		ranges.add(new Range(-1, -1));
		Collections.sort(ranges);
		double[][] dp1 = new double[ranges.size()][K + 1];
		double[][] dp2 = new double[ranges.size()][K + 1];
		for (int i = 0; i < ranges.size(); ++i) {
			Arrays.fill(dp1[i], -999);
			Arrays.fill(dp2[i], -999);
			dp1[i][0] = dp2[i][0] = 0;
		}
		for (int i = 1; i < ranges.size(); ++i) {
			int prev = i;
			for (int j = i - 1; j >= 0; --j) {
				if (ranges.get(j).e < ranges.get(i).s) break;
				prev = j;
			}
			if (prev != i) {
				for (int j = 1; j <= K; ++j) {
					dp1[i][j] = Math.max(dp1[i][j], dp1[prev][j - 1] + ranges.get(i).length(ranges.get(prev).e));
				}
			}
			for (int j = 1; j <= K; ++j) {
				dp1[i][j] = Math.max(dp1[i][j], dp2[prev - 1][j - 1] + ranges.get(i).length());
			}
			for (int j = 0; j <= K; ++j) {
				dp2[i][j] = Math.max(dp2[i - 1][j], dp1[i][j]);
			}
		}
		double ans = 0;
		for (int j = 0; j <= K; ++j) {
			ans = Math.max(ans, dp2[ranges.size() - 1][j]);
		}
		System.out.printf("%.12f\n", ans / Math.PI);
	}

	static class Range implements Comparable<Range> {
		double s, e;

		public Range(double s, double e) {
			this.s = s;
			this.e = e;
		}

		double length() {
			return e - s;
		}

		double length(double prev) {
			if (prev > e) return 0;
			return e - Math.max(s, prev);
		}

		public int compareTo(Range o) {
			if (this.s < o.s - 1e-9) return -1;
			if (this.s > o.s + 1e-9) return 1;
			return this.e < o.e ? -1 : 1;
		}
	}

}

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

using namespace std ;

#define N 1010
#define ll long long 

int n ;
ll c[ N ][ 4 ] ;
ll h[ N ] , ans = 0 ;
map< ll , ll > mp ;

ll hash( ll *a ) {
	ll res = 0 ;
	for( int i = 0 ; i < 4 ; i ++ ) {
		res |= ( a[ i ] << ( i * 10ll ) ) ;
	}
	return res ;
}

void upd( ll  x , ll d ) {
	for( int i = 0 ; i < 4 ; i ++ , x = ( ( x&1023ll ) << 30ll ) | ( x >> 10ll ) ) {
		mp[ x ] += d ;
	}
}

int main() {
	scanf( "%d" , &n ) ;
	for( int i = 1 ; i <= n ; i ++ ) {
		for( int j = 0 ; j < 4 ; j ++ ) {
			scanf( "%lld" , &c[ i ][ j ] ) ;
		}
		h[ i ] = hash( c[ i ] ) ;
		upd( h[ i ] , 1ll ) ;
	}
	for( int i = 1 ; i <= n - 5 ; i ++ ) {
		upd( h[ i ] , -1ll ) ;
		for( int j = i + 1 ; j <= n ; j ++ ) {
			upd( h[ j ] , -1ll ) ;
			for( int a = 0 ; a < 4 ; a ++ ) {
				ll res = 1ll , val[ 4 ] ;
				bool check = 0 ;
				for( int b = 0 ; b < 4 ; b ++ ) {
					ll x[] = { c[ i ][ ( b + 1 ) & 3 ] , c[ i ][ b ] , c[ j ][ ( 3 - b + a ) & 3 ] , c[ j ][ ( 6 - b + a ) & 3 ] } ;
					val[ b ] = hash( x ) ;
					if( !mp.count( val[ b ] ) ) {
						check = 1 ; 
						break ;
					}
				}
				if( !check ) {
					for( int k = 0 ; k < 4 ; k ++ ) {
						res = res * mp[ val[ k ] ] ;
						upd( val[ k ] , -1ll ) ; 
					}
					ans += res ;
					for( int k = 0 ; k < 4 ; k ++ ) {
						upd( val[ k ] , 1ll ) ;
					}
				}
			}
			upd( h[ j ] , 1ll ) ; 
		}
	}
	printf( "%lld" , ans ) ;
}

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


int main(){
    int a,b,c;
    cin >> a >>b >> c;
    REP(i,b){
        if(i*a%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::vector<long long> A){
  ll ans = 0 , x = 0;
  for (int i = 0; i < N; i++) {
    if(ans < A[i]){
      ans = A[i];
      x = i;
    }
  }
  sort(all(A));
  for (int i = 0; i < N; i++) {
    if(i != x)cout << ans << endl;
    else cout << A[N-2] << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
}


Measured memory_bytes: 3200
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ :=  strconv.ParseInt(nextLine(), 10, 0)
	if n % 2 != 0 {
		fmt.Println(0)
		return
	}
	total := int64(0)
	for j := n; j > 0; j = j / 5  {
		total += j / 10
	}
	fmt.Println(total)
}


Measured memory_bytes: 640
N, Ma, Mb = map(int, input().split())
INF = 10 ** 9
# dp[a][b] = min_cost
dp = {(0, 0): 0}

for _ in range(N):
    a, b, c = map(int, input().split())
    for (pa, pb), pc in dp.copy().items():
        dp[pa + a, pb + b] = min(dp.get((pa + a, pb + b), INF), pc + c)

ans = min(dp.get((i * Ma, i * Mb), INF) for i in range(1, 401))
print(ans if ans != INF else -1)

Measured memory_bytes: 8208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(1e6)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll mod = 1e9+7;
ll expo(ll a, ll b){
    if(b == 0) 
		return 1;
    ll x = expo(a, b/2);
    return (b & 1 ? ((x*x)%mod*a)%mod : (x*x) % mod);
}
 
int n, m;
ll p[1005];
ll open[1005];
ll dp[4][(1<<15)];
 
int main() {
	memset(dp, -1, sizeof dp);
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int k;
		cin >> p[i] >> k;
		while(k--) {
			ll x;
			cin >> x;
			x--;
			open[i] |= (1<<x);
		}
	}
	
	for(int i = 0; i < 4; i++)
		for(int j = 0; j < (1<<14); j++)
			dp[i][j] = LINF;
			
	for(int i = 0; i < 4; i++)
		dp[i][(1<<n)-1] = 0;
		
	for(int i = m-1; i >= 0; i--)
		for(int mask = (1<<n)-2; mask >= 0; mask--)
			dp[i & 1][mask] = min(dp[~i & 1][mask | open[i]] + p[i], dp[~i & 1][mask]);
	cout << (dp[0][0] >= LINF ? -1 : dp[0][0]) << endl;
 
}


Measured memory_bytes: 1280
def main():
    a = [list(map(int, input().split())) for _ in range(3)]

    N = int(input())

    # b = [int(input()) for _ in range(N)]

    result = [[False for i in range(3)] for j in range(3)]

    for i in range(N):
        b = int(input())
        for j in range(3):
            for k in range(3):
                if b == a[j][k]:
                    result[j][k] = True

    ans = "No"

    for i in range(3):
        if result[i][0] and result[i][1] and result[i][2] is True:
            ans = "Yes"

    for i in range(3):
        if result[0][i] and result[1][i] and result[2][i] is True:
            ans = "Yes"

    if result[0][0] and result[1][1] and result[2][2] is True:
        ans = "Yes"

    if result[2][0] and result[1][1] and result[0][2] is True:
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;
#define NIL -1
#define MAX 500000
int n;
int T[MAX+2];
void maxHeapify(int i){
    int l = 2*i;
    int r = 2*i+1;
    int largest;
    //选出左右子节点及他自己中的最大值
    if(l<=n&&T[l]>T[i]) largest = l;
    else largest = i;
    if(r<=n&&T[r]>T[largest]) largest = r;

    if(largest!=i){
        swap(T[i],T[largest]);
        maxHeapify(largest);
    }
}
void buildMaxHeap(){
    for(int i=n/2;i>=1;i--){
        maxHeapify(i);
    }
}
int main()
{
    for(int i=0;i<252;i++){
        T[i] = NIL;
    }
    cin>>n;
    for(int i=1;i<n+1;i++){
        cin>>T[i];
    }
    buildMaxHeap();
    for(int i=1;i<n+1;i++){
        cout<<" "<<T[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 5004
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define MAX 1000001
using namespace std;
int main(){
    long n,a[200001];
    bool dp[MAX];
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    std::sort(a,a+n);
    long n_max = a[n-1]+1;
    rep(i,n_max){
        dp[i]=true;
    }
    long i,j;

    for(i=0;i<n;){
        if(dp[a[i]]){
            for(j=a[i]*2;j<=n_max;j+=a[i]){
                dp[j]=false;
            }
        }
        if(a[i] == a[i+1]) dp[a[i]]=false;
        for(i++;i<n;i++){
            if(dp[a[i]]){
                break;
            }
        }
        /*rep(i,n){
            cout << dp[a[i]];
        }
        cout << endl;*/
    }
    int ans = 0;
    rep(i,n){
        if(dp[a[i]]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6176
//AGC B
#include <bits/stdc++.h>
#define N 200005

using namespace std;

long long n, m, v, p;
long long a[N];

bool check(int pos) {
	long long tmp = (v - p - pos + 1) * m, MAX = a[pos] + m;
	for (int i = pos + 1; i <= n - p + 1; ++i) {
		if (a[i] > MAX) return false;
		tmp -= MAX - a[i];
	}

	if (tmp <= 0) return true;
	else return false;
}

int main() {
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);

	scanf("%lld%lld%lld%lld", &n, &m, &v, &p);
	for (int i = 1; i <= n; ++i) scanf("%lld", a + i);
	sort(a + 1, a + n + 1);

	int l = 1, r = n - p + 1, mid, ans;
	while (l <= r) {
		mid = l + r >> 1;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}

	printf("%lld\n", n - ans + 1);
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;

int n, a[100], ans;

int main() {
    scanf("%d", &n);
    for (int i = 0 ; i < n ; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    for (int i = 0 ; i < n ; i++) {
        for (int j = i + 1 ; j < n ; j++) {
            for (int k = j + 1 ; k < n ; k++) {
                if (a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) continue;
                if (a[i] + a[j] > a[k]) ans++;
            }
        }
    }
    printf("%d", ans);
}


Measured memory_bytes: 1736
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x= sc.nextLong();
        long sum = 100;
        int y = 0;

        while(true){
            if(sum>=x){
                break;
            }
            y++;
            sum = sum + (long)Math.floor(sum*0.01);       
        }

            System.out.println(y);
    }
}


Measured memory_bytes: 35860
from sys import stdin

MOD = 2019
L, R = [int(x) for x in stdin.readline().split(' ')]

# 2019最大と最小の間が2019以上だったらピッタリ2019で割り切れる値が作れる
if R - L >= 2019:
    print(0)
    exit()

min_val = 2 * 10**9

for i in range(L, R):
    for x in range(i+1, R+1):
        a = (i % MOD * x % MOD) % MOD

        if a == 0:
            print(0)
            exit()

        if a < min_val:
            min_val = a

print(min_val)


Measured memory_bytes: 8948
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
int dp[1000005][7];
void solve(long long N, std::vector<long long> a)
{
  dp[0][3] = true;
  int NN = N - 1;
  rep(i, N)
  {
    int v = (NN == (NN | (NN - i)));
    rep(j, 7)
    {
      if (!dp[i][j])
        continue;
      //cout << i << " " << j << endl;
      for (int k = -2; k <= 2; k++)
      {
        int piyo = j + (v ? (k * 2 + 1) : 2 * k) * a[i];
        //cout << piyo << endl;
        if (piyo < 7 && piyo >= 0)
          dp[i + 1][piyo] = true;
      }
    }
  }
  int ans = 3;
  rep(i, 7) if (dp[N][i]) chmin(ans, abs(i - 3));
  cout << ans << endl;
}
void solve_naive(std::vector<long long> &a)
{
  if (a.size() == 1)
  {
    cout << a[0] << endl;
    return;
  }
  else
  {
    vector<long long> b(a.size() - 1);
    rep(i, a.size() - 1) b[i] = abs(a[i + 1] - a[i]);
    solve_naive(b);
  }
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  string s;
  cin >> s;
  rep(i, N) a[i] = s[i] - '1';
  if (N <= 1000)
  {
    solve_naive(a);
  }
  else
  {
    solve(N, std::move(a));
  }
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 64004
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
//#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int mod_pow(int x, int n, int mm) {
    int res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mm;
        x = x * x % mm;
        n >>= 1;
    }
    return res;
}
signed main() {
    string s;
    cin >> s;
    int N = s.size();
    vector<int> V(N);
    rep(i, N) {
        V[i] = s[i] - '0';
    }
    vector<int> R(N + 1, 0);
    rep(i, N) {
        int n = V[N - i - 1];
        R[i + 1] = (R[i] + n * mod_pow(10, i, 2019)) % 2019;
    }
    vector<int> M(2019, 0);
    rep(i, N + 1) M[R[i]]++;
    int ans = 0;
    rep(i, 2019) ans += M[i] * (M[i] - 1) / 2;
    cout << ans << endl;
}


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

int main() {
    string S;
    int N;
    cin >> S;
    N = S.length();

    // Condition 1
    rep(i, (N - 1) / 2) {
        if (S[i] != S[N - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    // Condition 2
    rep(i, (N - 1) / 4) {
        if (S[i] != S[(N - 1) / 2 - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    // Condition 3
    for (int i = (N + 3) / 2; i < N; i++) {
        if (S[i] != S[N - 1 - i]) {
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; 
  cin >> N;

  cout << setprecision(8);
  
  if (N % 2 == 0){
    cout << 0.5000000 << endl;
  } else {
    cout << (N/2 + 1.0)/N  << endl;
  }
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    cin >> N;
    vec<int> a(N);
    int cnt = 1;
    REP(i, N){
        cin >> a[i];
        if(a[i] == cnt){
            cnt++;
        }
    }
    if(cnt == 1){
        cout << -1 << el;
    }else{
        cout << N-cnt+1 << el;
    }
}



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


int N, X;
vector<int> x;


void input() {
    cin >> N >> X;
    x = vector<int>(N);
    rep(i, N) cin >> x[i];
}


ll gcd(ll a, ll b) {
    while (b) {
        ll tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}


int main() {
    input();
    ll ans = max(x[0] - X, X - x[0]);
    for (int i = 1; i < N; i++) ans = gcd(ans, max(x[i] - X, X - x[i]));
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
using namespace std;
 
int main () {
  int r;
  cin >> r;
  double pi = 3.141592;
  cout << pi * 2 * r;
  
  

  return 0;
}

Measured memory_bytes: 3784
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 2e5 + 7;
int n, p[N], t;
char s[N];
ll ans;

int main() {
	rds(s, n);
	for (int i = 1; i <= n; i++)
		if (s[i] == 'B') p[++t] = i;
	for (int i = 1; i <= t; i++)
		ans += n - t + i - p[i];
	print(ans);
	return 0;
}


Measured memory_bytes: 4592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;cin>>a;
    string s; cin>>s;
    cout<< (a>=3200 ? s : "red")<<endl;
}

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

typedef long long ll;

//#define DMY_IN

// DP[i][ i-1文字目とi文字目の間を区切るか ][ i文字目とi+1文字目の間を区切るか ]
ll DP[200005][2][2];

int main() {
  string S;
#ifdef DMY_IN
#else
  cin >> S;
#endif

//  std::chrono::system_clock::time_point  start, end; // 型は auto で可
//  start = std::chrono::system_clock::now(); // 計測開始時間

  int N = S.length();

  // 左端（0文字目よりも前）は必ず区切りありとして扱うので、その時だけ 1
  DP[0][0][1] = 0;
  DP[0][1][0] = 1;
  DP[0][1][1] = 1;
  for( int i=0; i<N-1;i++ ) {
    DP[i+1][0][1] = DP[i][1][0];
    DP[i+1][1][0] = max( DP[i][0][1], DP[i][1][1] ) + 1;
    DP[i+1][1][1] = DP[i][0][1] + 1;
    if( S[i] != S[i+1] ) {
      DP[i+1][1][1] = max( DP[i+1][1][1], DP[i][1][1] + 1 );
    }
//    cout << i+1 << ":" << S[i] << "-" << S[i+1] << " : " << DP[i+1][0][1] << " " << DP[i+1][1][0] << " " << DP[i+1][1][1] << endl;
  }
  // 右端（N-1文字目よりも後）は必ず区切りありとして扱うので、N-1の右に区切りがある場合のみ結果に採用
  ll ans = max( DP[N-1][0][1], DP[N-1][1][1] );
  cout << ans << endl;

//  end = std::chrono::system_clock::now();  // 計測終了時間
//  double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count(); //処理に要した時間をミリ秒に変換
//  std::cout << elapsed << " ms" << std::endl;
  
}




Measured memory_bytes: 6916
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int K;
  while(cin>>K && K){
    string s, t;
    cin>>s>>t;
    queue<string> que;
    que.push(s);
    map<string, int> d;
    while(!que.empty()){
      string r = que.front(); que.pop();
      int x = d[r];
      int idx = -1;
      REP(i, K) if(r[i] != t[i]){
        idx = i;
        break;
      }
      if(idx == -1) break;
      int dif = (t[idx] - r[idx] + 10) % 10;
      for(int e = idx; e < K; e++){
        r[e] = '0' + (r[e] - '0' + dif) % 10;
        if(!d.count(r)){
          d[r] = x + 1;
          que.push(r);
        }
      }
    }
    cout<<d[t]<<endl;
  }
  return 0;
}

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



int main(){
    double N, K;
    int n;
    cin >> N >> K;
    double exp = 0;
    for (n =1 ;n<=N;n++){
        exp += pow(0.5, fmax(0,ceil(log2(K/n))));
    }
    //exp +=N-K+1;
    std::cout << std::fixed;
    std::cout << std::setprecision(12);
    std::cout << (exp/N) <<endl;
    return 0;
}



Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
using namespace std;
const int INF=1e9+7;
const int max_n=300001;
int bit[max_n+1];
int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i -= i & -i;
	}
	return s;
}
void add(int i, int x){
	while(i<=max_n){
		bit[i]+=x;
		i += i & -i;
	}
}
int main(){
    ll n; cin>>n;
    int a[100001];
    FOR(i,0,n) cin>>a[i];
    int st=0,en=INF;
    while(st+1<en){
        int mid=(st+en)/2;
        int b[100001]={};
        b[0]=120000;
        FOR(i,0,n){
            if(a[i]>=mid) b[i+1]=b[i]+1;
            else b[i+1]=b[i]-1;
        }
        memset(bit,0,sizeof(bit));
        ll c=0;
        FOR(i,0,n+1){
            c+=sum(b[i]);
            add(b[i],1);
        }
        if(2*c>=n*(n+1)/2) st=mid;
        else en=mid;
    }
    cout<<st<<endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define maxx 100010
using namespace std;
int x,k,peso[maxx][3],dp[maxx][3];

int main() {
	cin >> x;
	for(int i = 0; i < x; i++){
		cin >> peso[i][0] >> peso[i][1] >> peso[i][2];
	}
	dp[0][0] = peso[0][0];
	dp[0][1] = peso[0][1];
	dp[0][2] = peso[0][2];
	
	for(int i = 1; i < x; i++){
		for(int j = 0; j < 3; j++){
			dp[i][j] = max(dp[i-1][(j+2)%3],dp[i-1][(j+1)%3]) + peso[i][j];
		}
	}
	int ans = max(max(dp[x-1][0],dp[x-1][1]),dp[x-1][2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])

ans = 1
bus_num = 1
bus_time = t[0]

for i in range(1, n):
	if t[i] > bus_time + k or bus_num == c:
		ans += 1
		bus_num = 1
		bus_time = t[i]
	else:
		bus_num += 1

print(ans)

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

using namespace std;

int problem[100005], penalty[100005];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

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

	int correct = 0, total_penalty = 0;
	int submission;
	string verdict;

	for (int i = 0; i < m; ++i) {
		cin >> submission >> verdict;
		if (verdict == "AC") problem[submission] = 1;
		else if (verdict == "WA" && !problem[submission]) penalty[submission]++;
	} 
	for (int i = 1; i <= n; ++i) {
		if (problem[i]) {
			correct++;
			total_penalty += penalty[i];
		}
	}
	cout << correct << ' ' << total_penalty << '\n';
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  bool ans= true;
  int tmp_x= 0;
  int tmp_y= 0;
  int tmp_t= 0;
  for(int i=0; i<N; i++){
  	int t,x,y;
    cin >> t >> x >> y;
    
    int d= abs(x-tmp_x)+ abs(y-tmp_y);
    if( t-tmp_t < d || (t-tmp_t-d)%2 != 0 ){
      ans= false;
      break;
    }
    else{
      tmp_x= x;
      tmp_y= y;
      tmp_t= t;
    }
  }
  
  if( ans ){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 10000
 
int main(){
  int t,i,j,C[N+1];
  unsigned short *A,*B;
 
  scanf("%d",&t);
 
  A = malloc(sizeof(short)*t+1);
  B = malloc(sizeof(short)*t+1);
 
 for(i=0 ; i<=N ; i++){
    C[i]=0;
  }
 
  for(i=1 ; i<=t ; i++){
    scanf("%d",&A[i]); 
    C[A[i]]++;
  } 
 
  for(i=1 ; i<=N ; i++){
    C[i] = C[i] + C[i-1];
  }
 
  for (j=1 ; j<=t ; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
 
  for(i=1 ; i<t ; i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[t]);
  
  return 0;
}
 
   
   

Measured memory_bytes: 9648
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
     while(t--){
        int n,k;
        cin>>n;
        vector<int> arr(n);
        vector<int> left(n);
        vector<int> right(n);
        int p=0;
        for(int i=0;i<n;i++){
        	cin>>arr[i];
        	left[i]=p;
        	p=p^arr[i];
		}
		p=0;
		for(int i=n-1;i>=0;i--){
        	right[i]=p;
        	p=p^arr[i];
		}
		for(int i=0;i<n;i++){
			cout<<(left[i]^right[i])<<" ";
		}
		cout<<"\n";
    }
}

Measured memory_bytes: 5568
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
 
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
void solve(){
	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);
	ll n = g;
	ll cnt = 1;
	for(ll i = 2; i <= sqrt(g); i++) {
		if (n % i == 0) {
			cnt++;
			while(!(n % i)) {
				n /= i;
			}
		}
	}
	if (n > 1) cnt++;
	cout << cnt;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll H,W;
int N;
vector<pair<int,int> > mass;
vector<pair<int,int> > zero;
int a[100001];
int b[100001];
ll  ans[10];

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

  for(int i = 0; i < N; i++)cin>>a[i]>>b[i];

  for(int i = 0; i < N; i++){
    for(int j = a[i]-2; j <= a[i]; j++){
      for(int k = b[i]-2; k<= b[i]; k++){
	pair<int,int> p(j,k);
	mass.push_back(p);
      }
    }
  }
  sort(mass.begin(),mass.end());

  
   for(int i = 0; i < mass.size(); i++){
     if(mass[i].first > 0 && mass[i].second > 0 && mass[i].first <= H-2 && mass[i].second <= W-2){
      int j = 0;
      pair<int,int> p(mass[i]);
      zero.push_back(p);
      while(true){
	if(p == mass[i]){
	  j++;
	  i++;
	}
	else {
	  ans[j]++;
	  i--;
	  break;
	}
      }
    }
  }
     
  ans[0] = ((W-2)*(H-2)) - zero.size();

  for(int i = 0; i < 10; i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 20328
d, q = list(map(int, input().split())), int(input())
dd = {v: k for k, v in enumerate(d)}
dms = ((1, 2, 4, 3), (0, 3, 5, 2), (0, 1, 5, 4), (0, 4, 5, 1), (0, 2, 5, 3), (1, 3, 4, 2))

while q:
    t, f = map(int, input().split())
    dm = dms[dd[t]]
    print(d[dm[(dm.index(dd[f]) + 1) % 4]])
    q -= 1

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

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

typedef int64_t ll;

const ll MOD = 1e9 + 7;

const int MAXN = 101;
const int MAXK = 100001;

int N, K;
vector<int> a;

vector<vector<ll>> memo(MAXN, vector<ll>(MAXK, -1));

ll dp(int i, int k) {
  if ((k < 0) || (i > N)) return 0;
  if (memo[i][k] != -1) return memo[i][k];
  if (i == N) {
    if (k == 0) return memo[i][k] = 1;
    else return memo[i][k] = 0;
  }

  // ll ret = 0;
  // REP(j, a[i] + 1) ret = (ret + dp(i + 1, k - j)) % MOD;
  ll ret = (dp(i, k - 1) + dp(i + 1, k)) % MOD;
  ret = (ret - dp(i + 1, k - 1 - a[i]) + MOD) % MOD;

  return memo[i][k] = ret;
}

int main(){
  cin >> N >> K;
  a.resize(N);
  REP(i,N) cin >> a[i];

  cout << dp(0, K) << endl;
  return 0;
}



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

int main(){
    string S;
    cin >> S;

    S += " ";
    string s_tmp, ans;
    s_tmp = ans = "";
    for(int i = 0; i < S.size(); ++i){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            s_tmp += S[i];
        }else{
            if(s_tmp.size() > ans.size()){
                ans = s_tmp;
            }
            s_tmp = "";
        }
    }

    cout << ans.size() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int S,h,m,s;
    scanf("%d" ,&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-(h*3600+m*60);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    int t[]={0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    
    scanf("%d%d", &a, &b);
    
    if (t[a]==t[b]) {
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
}



Measured memory_bytes: 1708
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
# import itertools
# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
# from collections import Counter

from operator import mul
from functools import reduce

# def lcm(n,m):
#     return int(n*m/gcd(n,m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


# import random
# import time

n = int(input().strip())
S = [0 for i in range(n)]
S1 = []
S2 = []
for i in range(n):
    S[i] = int(input().strip())
    if S[i] % 10 == 0:
        S1.append(S[i])
    else:
        S2.append(S[i])

if sum(S) % 10 != 0:
    ans = sum(S)
elif S2.__len__() == 0:
    # eprint("debug")
    ans = 0
else:
    S2.sort()
    ans = sum(S) - S2[0]
print(ans)


Measured memory_bytes: 63852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    vector<vector<ll>> dp(h, vector<ll>(w, INF));
    if(s[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;
    REP(i, h) REP(j, w) {
        if(i != 0) {
            ll cost = s[i-1][j]=='.' && s[i][j]=='#';
            chmin(dp[i][j], dp[i-1][j] + cost);
        }
        if(j != 0) {
            ll cost = s[i][j-1]=='.' && s[i][j]=='#';
            chmin(dp[i][j], dp[i][j-1] + cost);
        }
    }
    cout << dp[h-1][w-1] << endl;

    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
n = int(input())
a = [[0 for i in range(3)] for i in range(n)]
dp = [[0 for i in range(3)] for i in range(n+1)]
for i in range(n):
    a[i] = list(map(int, input().split()))

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])

print(max(dp[n]))


Measured memory_bytes: 81500
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

const static int MAX = 10;
int n, l, maxl, sum;

int main() {
    scanf("%d", &n);
    maxl = 0;
    sum = 0;

    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &l);
        maxl = max(maxl, l);
        sum += l;
    }

    if ( maxl < sum - maxl ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    
    return 0;
}



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

int main(){
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  string S;
  cin >> S;
  const int len = S.length();
  int ans = 0;
  for(int i = 0; i < len / 2; ++i)
    if(S[i] != S[len - i - 1])++ans;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long x;
  cin>>x;
  for(int a=-200;a<=200;a++){
    long long a5=1;
    for(int i=0;i<5;i++){
      a5*=a;
    }
    for(int b=-200;b<=200;b++){
      long long b5=1;
      for(int i=0;i<5;i++){
        b5*=b;
      }
      if(a5-b5==x){
        cout<<a<<" "<<b<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

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

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint S, W; cin >> S >> W;
    cout << (S <= W ? "unsafe" : "safe") << '\n';
}

Measured memory_bytes: 3648
n,k = map(int,input().split())
s = input()
k -= 1

if s[k] == 'A':
    reply = 'a'
elif s[k] == 'B':
    reply = 'b'
elif s[k] == 'C':
    reply = 'c'

print(s[:k] + reply + s[k+1:])

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define INF ((int)1e9)
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define mod (7 + (int)1e9)
#define N 100005

ll solve(ll arr[], int n) {
    ll ret = 0;
    FOR0(i, n) {
        ret += (arr[i] * (n-i-1)) % mod;
        ret %= mod;
    }
    FOR0(i, n) {
        ret -= (arr[i] * i) % mod;
        ret %= mod;
    }
    return (ret + mod) % mod;
}
int main() {
    SYNC
    int n, m;
    ll x[N], y[N];
    cin >> n >> m;
    FOR0(i, n) cin >> x[i];
    FOR0(i, m) cin >> y[i];
    sort(x, x + n, greater<ll> ());
    sort(y, y + m, greater<ll> ());
    cout << ((solve(x, n)*solve(y,m)) % mod + mod) % mod;
}

Measured memory_bytes: 1792