akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;
constexpr int ESP = 1e-9;
constexpr double PI = acos(-1);

int a[100000];

int main(void) {
    int i, n, m;
    scanf("%d%d",&n,&m);
    int odd = 0;
    REP (i,m) {
        scanf("%d",&a[i]);
        if (a[i] % 2) odd++;
    }

    if (odd > 2) {
        cout << "Impossible" << endl;
        return 0;
    }

    vector<int> newa;
    REP (i,m) if (a[i] % 2) {
        newa.push_back(a[i]);
        break;
    }
    REP (i,m) if (a[i] % 2 == 0) newa.push_back(a[i]);
    if (odd == 2) {
        RREP (i,m) if (a[i] % 2) {
            newa.push_back(a[i]);
            break;
        }
    }

    REP (i,m) printf("%d%c",newa[i],i<m-1?' ':'\n');
    vector<int> b;
    if (m == 1) {
        b.push_back(1);
        if (newa[0] > 1) b.push_back(newa[0]-1);
    }
    else {
        if (newa[0] > 1) b.push_back(newa[0]-1);
        b.push_back(2);
        REP (i,1,m-2) b.push_back(newa[i]);
        if (newa[m-1] > 1) b.push_back(newa[m-1]-1);
    }
    printf("%d\n",b.size());
    REP (i,b.size()) printf("%d%c",b[i],i<b.size()-1?' ':'\n');
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [list(map(int,input().split())) for i in range(2)]
xa = a[0][0]
xb = sum(a[1])
mx = xa + xb

for i in range(n-1):
    xa += a[0][i+1]
    xb -= a[1][i]
    if xa + xb >= mx:
        mx = xa + xb
print(mx)

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


int main()
{
    int k;
    cin >> k;
    int x;
    cin >> x;
    vector<int> ans(k);
    for (int i = 0; i < k; i++)
    {
     ans[i]= x-i;
    }
    sort(ans.begin(), ans.end());
   for(int i = 0; i < k-1; i++){
       cout << ans[i] << " ";
   }

    for(int i = 0;i < k;i++){
        cout << x+i << " ";
    }
    


    
    
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ac_list=[None]*n
wa_list=[0]*n
ans=0
for i in range(m):
    q,status=input().split()
    q=int(q)
    if status=="AC" and ac_list[q-1]==None:
        ac_list[q-1]=True
        ans+=wa_list[q-1]
    elif status=="WA" and ac_list[q-1]==None:
        wa_list[q-1]+=1
x=ac_list.count(True)
print(x,ans)

Measured memory_bytes: 4596
import Control.Applicative
import Control.Monad
import Data.Maybe
import Data.List

main = read . head . words <$> getLine >>= flip replicateM getLine >>= mapM_ (putStrLn . unwords . map (show . fromMaybe (-1)) . tail . scanl (\m c -> if c=='c' then Just 0 else (+1) <$> m) Nothing)


Measured memory_bytes: 4612
from collections import Counter
import math
n = int(input())
s_list = ["".join(map(str,sorted(input()))) for i in range(n)]
s_counter = Counter(s_list)
s_len = len(s_counter)
s_most = s_counter.most_common()
#print(s_counter)
ans = 0
for i in range(s_len):
    if s_most[i][1] != 1:
        dum = s_most[i][1]
        ans += (dum * (dum-1)) // 2
    else:
        break
print(ans)

Measured memory_bytes: 77784
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include<iomanip>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 1001001001;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}


int main() {
    ll A,B,c,d;
  cin >> A>> B >> c>>d;
  cout << max(A*B,c*d) << endl;
}


Measured memory_bytes: 256
package main

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

func solve() {
	sp := getRunes()
	t := getRunes()
	ls, lt := len(sp), len(t)

	idx := -1
	for i := 0; i < ls-lt+1; i++ {
		str := sp[i : i+lt]
		flag := true
		for j := range str {
			if !(str[j] == t[j]) && !(str[j] == '?') {
				flag = false
			}
		}

		if flag == true {
			idx = i
		}
	}

	if idx == -1 {
		fmt.Fprintln(wr, "UNRESTORABLE")
		return
	}
	ans := ""
	for i := 0; i < ls; i++ {
		switch {
		case i == idx:
			ans += string(t)
			i += lt - 1
		case sp[i] == '?':
			ans += "a"
		default:
			ans += string(sp[i])
		}
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j) vector<vector<ll>> name(i,vector<ll>(j))
#define vec2f(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k)))
#define vec3f(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define vec4(name,i,j,k,l) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l))))
#define vec4f(name,i,j,k,l,m) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l,m))))
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

int main(){
    string s, t; cin >> s >> t;
    ll ans = 0;
    REP(i,s.size()){
        if (s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

long long n,m;
long long a[maxn];
long long pre[maxn];
long long x;
bool check(long long mid)
{
	long long num=0;
	for(int i=1;i<=n;i++)
	{
		long long p=lower_bound(a+1,a+1+n,mid-a[i])-a;
		num+=(n-p+1);
	}
	return num>=m;
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]+a[i];

	long long l=0,r=maxn;
	while(l<=r)
	{
		long long mid=(l+r)>>1;
		if(check(mid))
		{
			x=max(x,mid);
			l=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	long long num=0;
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		long long p=lower_bound(a+1,a+1+n,x-a[i])-a;
		ans+=pre[n]-pre[p-1];
		ans+=(n-p+1)*a[i];
		num+=(n-p+1);
	}	
	ans-=(num-m)*x;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
#define ff first
#define ss second

const int inf = 1e9;

void solve(){
	ll n, w;
  cin >> n >> w;
  ll dp[w+1] = {0};
  for(int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    for(ll j = w - x; j >= 0; j--) {
      dp[x+j] = max(dp[x+j], dp[j] + y);
    }
  }
  //for(int i = 0; i <=w; i++)
  //  cout << dp[i] << ' ';
  //cout << endl;
  cout << *max_element(dp, dp+w+1) << endl;
}

int main(){
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1, tt = 0;
	//	cin >> t;
		while(t--){
			//tt++;
			//cout << "Case #" << t << ": ";
			solve();
		}
	return 0;
}


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

int main(){
    int n, m, c;
    vector<int> b;
    cin >> n >> m >> c;
    for(int i = 0; i < m; i++)
    {
        int x = 0;
        cin >> x;
        b.push_back(x);
    }
    int num = 0;
    for(int i = 0; i < n; i++)
    {
        int sum = 0;
        for(int j = 0; j < m; j++)
        {
            int x = 0;
            cin >> x;
            sum += x * b[j];
        }
        sum += c;
        if (sum > 0) {
            num++;
        }
        
    }
    cout << num << "\n";
}

Measured memory_bytes: 256
function main()
	N=parse(Int,readline())
	pos=Pair{Int,Int}[]
	neg=Pair{Int,Int}[]
	for _=1:N
		s=readline()
		cnt=0
		mc=0
		for c=s
			if c=='('
				cnt+=1
			else
				cnt-=1
			end
			mc=min(mc,cnt)
		end
		if cnt>=0
			push!(pos,-mc=>cnt)
		else
			push!(neg,mc-cnt=>cnt)
		end
	end
	now=0
	flag=true
	for (a,b)=sort(pos)
		if now-a<0
			flag=false
		end
		now+=b
	end
	for (a,b)=sort(neg)
		if now+a+b<0
			flag=false
		end
		now+=b
	end
	println(flag&&now==0 ? "Yes" : "No")
end
main()


Measured memory_bytes: 227400
#include <stdio.h>

int main(void)
{
	float m1, m2, n1, n2;
	float ans_m1, ans_n1;
	float x, y;
	float a, b, c;
	float a1, b1, c1;
	
	while (scanf("%f %f %f %f %f %f", &m1, &m2, &ans_m1, &n1, &n2, &ans_n1) != EOF){
		a = (m1 * n2) - (m2 * n1);
		b = 1.0 / a;
		a1 = m1;
		m1 = n2 * b;
		m2 = -1 * m2 * b;
		n1 = -1 * n1 * b;
		n2 = a1 * b;
		
		x = (m1 * ans_m1) + (m2 * ans_n1);
		y = (n1 * ans_m1) + (n2 * ans_n1);
		
		printf("%.3f %.3f\n", x, y);
	}
	
	return (0);
}

Measured memory_bytes: 648
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
        mut a:[i64;n],
        mut b:[i64;n],
    }
    let mut cnt = 0;
    for i in 0..n {
        if a[i] < b[i] {
            cnt += (b[i] - a[i]) / 2;
        } else {
            cnt -= a[i] - b[i];
        }
    }
    yn(cnt >= 0);
}
pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2492
#include "bits/stdc++.h"
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<30;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)





//配列用意
int d[510][510] = {};
int m[510][510] = {};
ll a[3][30] = {0};

//vector< vector<int> > v (max1, vector<in t>(max2) );

int main() {
	using namespace std;
	//入力
	int n,c;
	cin >>n>>c;
	
	rep(i, c)rep(j, c)cin >> d[i][j];
	rep(i, n)rep(j, n)cin >> m[i][j];
	
	rep(i, n)rep(j, n)rep(k, c) {
		a[(i + j) % 3][k] += d[m[i][j]-1][k];
	}
	
	ll ans = INF;
	rep(i, c)rep(j, c)rep(k,c) {
		if (i == j or j == k or i == k)continue;
		ans = min(a[0][i] + a[1][j] + a[2][k],ans);
	}


	cout << ans << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 1280
// This file is a "Hello, world!" in C++ language by Clang for wandbox.
#include <iostream>
#include <vector>
#include<numeric>

int main()
{
    std::uint64_t n,x,m;
    std::cin>>n>>x>>m;
    std::vector<uint64_t> mini = {x};
    uint64_t subindex=0;
    std::vector<uint64_t> memo(m, INT64_MAX);
    memo[x]=0;
    for(uint64_t i=1;i<n;++i){
        auto x = mini[i-1];
        auto x2 = x*x%m;
        if(memo[x2]!=INT64_MAX){
            subindex = memo[x2];
            break;
        }
        memo[x2]=i;
        mini.push_back(x2);
    }
    
    auto len = mini.size() - subindex;
    uint64_t zero = 0;
    auto t0 = std::accumulate(mini.begin(),mini.begin()+subindex,zero) ;
    auto t1 = std::accumulate(mini.begin()+subindex, mini.end(),zero) * ((n-subindex)/len);
    auto t2 = std::accumulate(mini.begin()+subindex, mini.begin() + subindex + (n-subindex)%len,zero);
    std::cout<<t0+t1+t2;
    
}

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

int main(){
  string s; cin>>s;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, d, A;
    cin >> n >> d >> A;
    vector<pii>a(n);
    rep(i,n)cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());
    ll ans = 0;
    ll sum = 0;
    int id = 0;
    vector<ll> dp(n + 2);
    show(a);
    rep(i,n){
        while(id + 1< n and a[id + 1].first - a[i].first <= 2 * d){
            id++;
        }
        show(i, id);
        a[i].second -= dp[i];
        show(a[i].second);
        if(a[i].second < 0){
            dp[i+1] += dp[i];
            continue;
        }
        ll num = (a[i].second + A - 1) / A;
        ans += num;
        dp[id + 1] -= num * A;
        dp[i] += num * A;
        dp[i+1] += dp[i];
    }
    cout << ans << endl;
}


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

int main() {
    ll n;
    std::cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    std::cout << ans << std::endl;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define EPS         1e-9
#define INF         1e18
#define PI          3.14159265358979323846
#define MAXI        1000000
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define N 100005

signed main()
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		string s1,s2;
		cin>>s1>>s2;
		int n=s1.size();
		int m=s2.size();
		int i,j,k;
		int dp[n+1][m+1];
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=m;j++)
			{
				if(i==0||j==0) dp[i][j]=0;
				else if(s1[i-1]==s2[j-1])
				{
					dp[i][j]=dp[i-1][j-1]+1;
				}
				else
				{
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
//		cout<<dp[n][m]<<endl;
		string ans="";
		i=n,j=m;
		while(i>0&&j>0)
		{
			if(s1[i-1]==s2[j-1])
			{
				ans+=s1[i-1];
				assert(s1[i-1]==s2[j-1]);
				i--;
				j--;
			}
			else if(dp[i-1][j] > dp[i][j-1])
			{
				i--;
			}
			else
			{
				j--;
			}
		}
		reverse(all(ans));
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 73980
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#define ll long long
using namespace std;
int a[100010],tong1[100010],tong2[100010];
int read()
{
	int flag=1,x=0;char c=getchar();
	while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();	}
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*flag;
}
int main()
{
	int n=read(),Max1=0,Maxx1=0,Max2=0,Maxx2=0,ind1,ind2;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		if(i&1)
		{
			tong1[a[i]]++;
		}
		else 
		{
			tong2[a[i]]++;
		}
	}
	for(int i=0;i<=100000;i++)
	{
		if(tong1[i]>Max1)
		{
			Max2=Max1;
			Max1=tong1[i];
			ind1=i;
		}
		else if(tong1[i]>Max2)
		{
			Max2=tong1[i];
		}
			
		if(tong2[i]>Maxx1)
		{
			Maxx2=Maxx1;
			Maxx1=tong2[i];
			ind2=i;
		}
		else if(tong2[i]>Maxx2)
		{
			Maxx2=tong2[i];
		}
	}
//	cout<<Max1<<' '<<Max2<<endl;
	if(ind1!=ind2) cout<<n-Max1-Maxx1;
	else cout<<min(n-Max1-Maxx2,n-Max2-Maxx1);
//	cout<<n/2-sum1+n/2-sum2;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    int a[1000];
    lp(i,1000){
      a[i]=0;
    }
    int count=0;   
    char x[100];
    lp(i,n){
      cin>>x[i];
    }
    int first=0,second=0,ans=-1;
    char firstmem,ans1;
    lp(i,n){
      a[x[i]-'A']++;
      if(a[x[i]-'A']>n/2) {
	ans=i+1;
	ans1=x[i];
	break;
      }
      if(first==0||first<a[x[i]-'A']){
	first=a[x[i]-'A'];
	firstmem=x[i];
      }
      else if(second<a[x[i]-'A']&&firstmem!=x[i]){
	second=a[x[i]-'A'];
      }
      if(first>second+n-i-1){
	ans=i+1;
	ans1=firstmem;
	break;
      }
    }
    if(ans==-1){
      cout<<"TIE"<<endl;
    }
    else{
      cout<<ans1<<" "<<ans<<endl;
    }
  }
      
  return 0;
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;
ll k;

int main(void) {
  // Here your code !
  cin >> s;
  scanf("%lld", &k);

  int n = s.size();

  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == 'a') continue;
    
    int cur_remain = (int)('z' - s[i]);

    if ((ll)(cur_remain) + 1LL > k) {
      continue;
    }

    s[i] = 'a';
    k -= (cur_remain + 1);
  }

  int cur_pos = (int)(s.back() - 'a');

  k += (ll)(cur_pos);
  
  int mod = (int)('z' - 'a') + 1;

  int last_pos = k % mod;

  s[n - 1] = (char)('a' + last_pos);

  cout << s << endl;

  return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto x : v){cout << x << " ";} cout << endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(vv) for(auto v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

bool dfs(string s) {
    if (s == "ABC") {
        return true;
    } else if (s.find("ABC") == string::npos) {
        return false;
    }

    vector<bool> valid(3, true);
    {
        string t;
        int i = 0;
        while (i < s.size()) {
            if (i <= (int)s.size() - 3 && s.substr(i, 3) == "ABC") {
                i += 3;
            } else {
                t += s[i];
                i++;
            }
        }
        rep(i, t.size()) {
            valid[t[i] - 'A'] = false;
        }
    }

    bool ret = false;
    rep(k, 3) {
        if (!valid[k]) continue;
        string t;
        int i = 0;
        while (i < s.size()) {
            if (i <= (int)s.size() - 3 && s.substr(i, 3) == "ABC") {
                t += 'A' + k;
                i += 3;
            } else {
                t += s[i];
                i++;
            }
        }
        ret |= dfs(t);
    }
    return ret;
}

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

    string s;
    cin >> s;
    cout << (dfs(s) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 21816
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int h,w;cin>>h>>w;
  vector<string> a,b;
  REP(i,h){
    string aa;cin>>aa;
    a.push_back(aa);
  }
  int y=0,x=0;
  REP(i,h){
    REP(j,w){
      if(a[i][j]=='#'){
        b.push_back(a[i]);
        y++;
        break;
      }
    }
  }
  // REP(i,y){
  //   P(b[i]);
  // }
  vector<int> v;
  REP(i,w){
    REP(j,y){
      if(b[j][i]=='#'){
        v.push_back(i);
        break;
      }
    }
  }
  REP(i,y){
    string s;
    for(auto index:v){
      s+=b[i][index];
    }
    P(s);
  }
  return 0;
}


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


int main() {
    int A,B,C,cnt=0;
    cin >> A >> B >> C;

    if(A==B&&A!=C)cnt++;
    else if(A==C&&A!=B)cnt++;
    else if (C==B&&A!=C)cnt++;

    if(cnt==1)cout << "Yes" << endl;
    else cout << "No" << endl;


}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    string s;
    
    cin >> s;
    for(int i = 0; i < s.size(); i+=2)
        cout << s[i];
    cout << endl;
    
    return 0;
}

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

int main(){
  string S;
  cin>>S;
  int a,b,c,d;
  a=S.at(0)-'0';
  b=S.at(1)-'0';
  c=S.at(2)-'0';
  d=S.at(3)-'0';

  int x=10*a+b;
  int y=10*c+d;

  if(x>12&&y<=12&&y>0){
    cout<<"YYMM"<<endl;
  }else if(x<=12&&y>12&&x>0){
    cout<<"MMYY"<<endl;
  }else if(x<=12&&y<=12&&x>0&&y>0){
    cout<<"AMBIGUOUS"<<endl;
  }else if(y>0&&y<=12&&x==0){
    cout<<"YYMM"<<endl;
  }else if(x>0&&x<=12&&y==0){
    cout<<"MMYY"<<endl;
  }else{
    cout<<"NA"<<endl;
  }
}


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

typedef long long ll;

ll dist(ll x, ll y) {
    return x * x + y * y;
}

int main() {
    ll n, d;
    cin >> n >> d;
    d = d * d;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ll x, y;
        cin >> x >> y;
        if (dist(x, y) <= d) {
            ans++;
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  vector<int> N(3);
  cin >> N[0];
  cin >> N[1];
  cin >> N[2];
  sort(N.begin(),N.end());
  if(N[2]==N[0]+N[1]){
  	cout << "Yes"<<endl;
  }else{
	cout << "No" <<endl;
  }
  
    return 0;
}


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

long long int N, D;

int main(){
    scanf("%lld%lld", &D, &N);
    if(N == 100) ++N;
    for(int i = 0; i < D; ++i)N *= 100;
    cout << N << endl;
    return 0;
}


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

int main(){
    size_t N;
    scanf("%ld", &N);

    deque<pair<int_fast64_t, int_fast64_t>> a(N, pair<int_fast64_t, int_fast64_t>(0, 1));

    for(size_t i = 0; i < N; ++i)scanf("%ld", &(a[i].first));
    sort(a.begin(), a.end());

    uint_fast64_t A(0);
    for(; !a.empty();){
        auto v = a.back();
        a.pop_back();
        if(v.second){
            auto k = pair<int_fast64_t, int_fast64_t>((1LL << (64 - __builtin_clzll(v.first))) - v.first, 1);
            auto t = lower_bound(a.begin(), a.end(), k);
            if(t != a.end() && t -> first == k.first){
                ++A;
                t -> second = 0;
            }
        }
    }

    cout << A << endl;
    return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n), q(n);
    rep(i, 0, n) cin >> p[i];
    rep(i, 0, n) cin >> q[i];
    ll a, b;
    int array[]={1,2,3,4,5,6,7,8};
    ll itr = 0;
    do{
        itr++;
        bool pf = true, qf = true;
        for(int i=0; i<n; i++){
            if(array[i] != p[i]) pf = false;
            if(array[i] != q[i]) qf = false;
        }
        if(pf) a = itr;
        if(qf) b = itr; 
    }while(next_permutation(array,array+n));
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 3656
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    ans=0
    for i in 1:4
        ans+=ifelse(s[i]=='+',1,-1)
    end
    println(ans)
end
main()

Measured memory_bytes: 109452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stdlib.h>
using namespace std;

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

	int res = 10;
	if (X < A)
	{
		res = 0;
	}

	cout << res << endl;

	return 0;
}

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


int main(){
    ll N; string S; cin >> N >> S;
    rep(i,sz(S)){
        S[i] = 'A' + ((S[i] + N - 'A') % 26);
    }
    pr(S);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
int main(){
	ll N;
	cin >> N;
	vector<string> S(N);
	REP(i, N){
		cin >> S[i];
	}
	bool p = false, w = false, g = false, y = false;
	REP(i, N){
		if(S[i] == "P"){
			p = true;
		} else if(S[i] == "W"){
			w = true;
		} else if(S[i] == "G"){
			g = true;
		} else if(S[i] == "Y"){
			y = true;
		}
	}
	ll count = 0;
	if(p){
		count++;
	}
	if(w){
		count++;
	}
	if(g){
		count++;
	}
	if(y){
		count++;
	}
	if(count == 3){
		cout << "Three" << endl;
	} else if(count == 4){
		cout << "Four" << endl;
	}
}



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

int main(){

  string S;
  cin >> S;
  set<char> cset = {'A', 'T', 'C', 'G'};
  int count = 0;
  int ans = 0;
  for(int i = 0; i< S.size(); i++){
    if(cset.find(S[i]) != cset.end()){
      count++;
    } else {
      ans = max(ans, count);
      count = 0;
    }
  }
  ans = max(ans, count);
  cout << ans << endl;

}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
c = Counter()


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

for i in range(1, n + 1):
    c.update(prime_factorize(i))
    
ans = 1
mod = 10**9+7
for v in c.values():
    ans *= v + 1
    ans %= mod 

print(ans)


Measured memory_bytes: 9420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ft first
#define sd second
#define get(t, x) get<x>(t)
#define pb push_back
#define len length
#define dbgn(x) cerr << #x << ": " << x << '\n'
#define dbg(x) cerr << #x << ": " << x << ' '
#define MAX 1100000

using namespace std;
using namespace __gnu_pbds;

using lli = long long int;
using pll = pair<lli, lli>;
using pii = pair<int, int>;
using mii = map<int, int>;
using ti3 = tuple<int, int, int>;
using pqpi_min = priority_queue<pii, vector<pii>, greater<pii>>;
using ost = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T>
void print(T* a, int sz) {for(int i=0;i<sz;++i) cerr<<a[i]<<' ';cerr<<endl;}
istream &operator>>(istream &is, pii &p) {is >> p.ft >> p.sd;return is;}
ostream &operator<<(ostream &os, const pii &p) {os << "[" << p.ft << ", " << p.sd << ']'; return os;}
//int+string
//cin.ignore();

constexpr int M = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;

void solve()
{
    int n,y,j=0,k,i;
    cin>>n>>y;
    int a = 10000,b = 5000, c = 1000;
    while(j<=n) {
        if ((a*n-y-(a-b)*j)>=0 && (a*n-y-(a-b)*j)%(a-c)==0) {
            k = (a*n-y-(a-b)*j)/(a-c);
            if (n-k-j>=0) {i=n-j-k;break;}
        }
        ++j;
    } 
    if (j<=n) cout<<i<<' '<<j<<' '<<k;
    else cout<<"-1 -1 -1";
}   
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
def solve(A,V,B,W,T):
    if V<=W:
        return "NO"
    elif abs(B-A)%(V-W)==0 and abs(B-A)//(V-W)<=T:
        return "YES"
    elif abs(B-A)//(V-W)+1<=T:
        return "YES"
    else:
        return "NO"

A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
print(solve(A,V,B,W,T))


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

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    string s, t;
    cin >> s >> t;
    pri(t+s);
    return 0;
}


Measured memory_bytes: 256
#include <vector> // vectorを使うためにインクルードする
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	vector<int> mountain; // <T>でT型のvector
	int n;
	cin >> n;
	while(n--) {
		int x;
		cin >> x;
		mountain.push_back(x);
	}
	int ans = 1;
	for(int i=0; i < mountain.size()-1; i++){
		if(mountain[i+1]-mountain[i]>=0){
			bool b = true;
			for(int j=0; j < i+1; j++){
				if(mountain[i+1]-mountain[j]<0){
					b=false;
					break;
				}
			}
			if(b==true) ans+=1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        s: Chars
    };
    let mut pre = s[0];
    let mut count = 0;
    for c in s {
        if c != pre {
            count += 1;
            pre = c;
        }
    }
    print!("{}", count);
}


Measured memory_bytes: 2484
int z(int*a,int*b){return *a-*b;}a[3],b[3],w;main(s){for(;~scanf("%d%d%d",a,a+1,a+2);w++){qsort(a,3,4,z);if(a[0]+a[1]<=a[2])break;s=a[2]*a[2]-a[0]*a[0]-a[1]*a[1];b[s<0?1:s>0?2:0]++;}printf("%d %d %d %d\n",w,b[0],b[1],b[2]);exit(0);}

Measured memory_bytes: 600
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    string s;
    cin>>s;
    for(int i=0;i<4;i++) cout<<s[i];
    cout<<" ";
    for(int i=4;i<12;i++) cout<<s[i];
    cout<<endl;
}



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

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

  for (int i = 0; i < 3; i++) {
    if (n[i]=='1') n[i]='9';
    else n[i]='1';
  }

  cout << n << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
main(){
  int n,key;
  int data[100];
  int i,j,k;
  scanf("%d",&n);
  for(k=0;k<n;k++)
    scanf("%d",&data[k]);
    for(k=0;k<n;k++){
      if(k)
        printf(" ");
      printf("%d",data[k]);
    }
    printf("\n");
  for(i=1;i<n;i++){
    key=data[i];
    if(data[i-1]>key){
      j=i;
      do{
        data[j]=data[j-1];
        j--;
      }while(j>0 && data[j-1]>key);
      data[j]=key;
    }

    for(k=0;k<n;k++){
      if(k)
        printf(" ");
      printf("%d",data[k]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
from collections import Counter

from math import floor
from collections import Counter

def factoring(n):
    sup = floor(pow(n,1/2))
    for i in range(2,sup+1):
        while n % i == 0:
            c[i] += 1
            n //= i
    if n != 1:
        c[n] += 1
    return c

N = int(input())
c = Counter()

# 1~Nまで素因数分解して合算を求める
for i in range(1, N + 1):
    factoring(i)

# 素因数の数がvalue以上となるような素因数の数
t = Counter()
for _, values in c.items():
    if values >= 2:
        t[2] += 1
    if values >= 4:
        t[4] += 1
    if values >= 14:
        t[14] += 1
    if values >= 24:
        t[24] += 1
    if values >= 74:
        t[74] += 1

ans = t[74] + t[24] * (t[2] - 1) + t[14] * (t[4] - 1) + t[4] * (t[4] - 1) * (t[2] - 2) // 2
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

ll smaller[15];

ll count(ll m, bool q=1){
	ll x = m;
	string s;
	while(x){
		s += '0' + (x%10);
		x/=10;
	}
	reverse(all(s));
	int n = s.length();
	vector<ll> eq(n,0);
	vector<vector<ll>> dp(n, vector<ll>(10,0));
	++eq[0];
	rep(i,1,s[0]-'0')dp[0][i] = 1;
	rep(i,0,n-1){
		rep(j,0,10){
			if(j-1>=0){
				dp[i+1][j-1]+=dp[i][j];
			}
			if(j+1<10){
				dp[i+1][j+1]+=dp[i][j];
			}
			dp[i+1][j]+=dp[i][j];
		}
		if(abs(s[i+1]-s[i]) <= 1)eq[i+1] = eq[i];
		if(eq[i] && s[i+1]>=s[i] ){
			rep(j,max((int)s[i]-'0'-1,0),min((int)s[i]-'0'+2, (int)s[i+1]-'0')){
				++dp[i+1][j];
			}
		}
	}
	ll cnt = eq[n-1] + accumulate(all(dp[n-1]),0LL);
	if(q){
		rep(i,0,n)cnt+=smaller[i];
	}
	return cnt;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll mul = 10;
	rep(i,1,15){
		smaller[i] = count(mul-1,0);
		mul*=10;
	}
	ll k;
	cin >> k;
	ll l = 1, r = 1LL << 34;
	ll ans = 0;
	while(l <= r){
		ll m = l + (r-l)/2;
		if(count(m) >= k){
			ans = m;
			r = m - 1;
		}
		else{
			l = m + 1;
		}
	}
	cout << ans << '\n';
}


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

using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
 
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
ll sum(ll l, ll r){
    return (l+r)*(r-l+1)/2;
}
int main(){
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    
    for(ll i = k; i <= n+1; i++){
        ll l =  sum(0,i-1);
        ll r = sum(n-i+1, n);
        res += r - l + 1;
        res %= mod;
    }
    
    cout << res;
    return 0;
}



Measured memory_bytes: 3636
const main = input => {
  const [[K], [S]] = input

  if (S.length <= Number(K)) return [[S]]

  return [[S.slice(0, K) + '...']]
}

const wrapper = data => {
  const input = data.split('\n').map(line => line.split(' '))
  const output = main(input)
  console.log(output.map(line => line.join(' ')).join('\n'))
}

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


Measured memory_bytes: 29628
n=int(input())
s=input()

abc='abcdefghijklmnopqrstuvwxyz'
res=[]

for i in range(1,n):
	l=s[:i]
	r=s[i:]
	n_l=len(l)
	n_r=len(r)
	cnt=0
	for j in range(26):
		x=abc[j]
		for k in range(n_l):
			if l[k]==x:
				for m in range(n_r):
					if r[m]==x:
						cnt+=1
						break
				break
	res.append(cnt)

print(max(res))

Measured memory_bytes: 3064
# dpE - Knapsack 2
import sys
input = sys.stdin.readline

def main():
    n, W = tuple(map(int, input().rstrip().split()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    _, v = zip(*A)
    lim = sum(v)
    dp = [0] + [float("inf")] * lim
    for i in range(n):
        for j in range(lim, A[i][1] - 1, -1):
            dp[j] = min(dp[j], dp[j - A[i][1]] + A[i][0])
    ans = max(v for v, w in enumerate(dp) if w <= W)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 70732
n, k = map(int, input().split())
p = [int(i) - 1 for i in input().split()]
c = list(map(int, input().split()))

def mymax(max_variable, candidate):
    if max_variable is None:
        return candidate
    else:
        return max(max_variable, candidate)

max_cost = None
for start in range(n):
    seen = []
    next_ = p[start]
    cost_sum = []
    cost = 0
    while next_ != start:
        seen.append(next_)
        cost += c[next_]
        cost_sum.append(cost)
        next_ = p[next_]

    seen.append(start)
    cost += c[start]
    cost_sum.append(cost)

    l = len(seen)
    s = cost_sum[-1]
    for end in range(len(seen)):
        moves = end + 1
        remain_moves = k - moves
        if remain_moves < 0:
            continue
        cand_cost = cost_sum[end] + max(0, s) * int(remain_moves / l)
        max_cost = mymax(max_cost, cand_cost)
print(max_cost)



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

int main() {
  int n;
  scanf("%d", &n);
  char s[n][11];
  long cnt[5] = {0}, ans = 0;
  for (int i=0; i<n; i++) {
    scanf("%s", s[i]);
    if (s[i][0] == 'M') cnt[0]++;
    if (s[i][0] == 'A') cnt[1]++;
    if (s[i][0] == 'R') cnt[2]++;
    if (s[i][0] == 'C') cnt[3]++;
    if (s[i][0] == 'H') cnt[4]++;
  }
  for (int i=0; i<3; i++) {
    for (int j=i+1; j<4; j++) {
      for (int k=j+1; k<5; k++) {
        ans += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;
int dp[100010],h[100010],n;
int main(void){
    cin >> n;
    for(int i = 0;i < n;i++) cin >> h[i];
    for(int i = 0;i < 100010;i++){
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    for(int i = 0;i < n-2;i++){
        dp[i+2] = min(dp[i]+abs(h[i+2]-h[i]),dp[i+1]+abs(h[i+2]-h[i+1]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

int nmax = 100;

ll f(ll x){
  int two=0;
  while(x%2 == 0){
    two++;
    x /= 2;
  }
  return(two);
}

ll g(ll x){
  int five=0;
  while(x%5 == 0){
    five++;
    x /= 5;
  }
  return(five);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<vector<ll>> list(nmax,vector<ll>(nmax,0));
  rep(i,n){
    long double x;
    cin >> x;
    a[i] = (ll)(x * 1e9+0.5);
  }
  
  rep(i,n){
    int two=0,five=0;
    two = f(a[i]);
    five = g(a[i]);
    list[two][five]++;
  }
  
  ll ans=0;
  
  rep(i,nmax)rep(j,nmax)rep(k,nmax)rep(l,nmax){
    if(make_pair(i,j) <= make_pair(k,l) && i+k >= 18 && j+l >= 18){
      if(i==k && j == l){
        ans += list[i][j] * (list[i][j] - 1) / 2;
      }else{
        ans += list[i][j] * list[k][l];
      }
    }
  }
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 4816
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n,k,ans=0;
    cin>>n>>k;
    ll cnt[200010]={};
    rep(i,k){
        if(i<=n%k&&i!=0){
            cnt[i]+=n/k+1;
        }
        else cnt[i]+=n/k;
    }

    rep(i,k){
        ll a=i,b=(k-i)%k,c=(k-b)%k;
        if((a+c)%k!=0) continue;
        ans+=cnt[a]*cnt[b]*cnt[c];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    
    vector<int> l(2*n);
    
    for (int i = 0; i < 2*n; i++) cin >> l[i];
    
    sort(l.begin(), l.end());
    
    int ans = 0;
    
    for (int i = 0; i < 2*n; i+=2) ans += l[i];
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <iomanip>

typedef long long ll;
typedef long double ld;

using namespace std;
using Graph = vector<vector<ll>>;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)
#define ALL(a) (a).begin(),(a).end()

const ll inf = 1e18+7;
const ll mod = 1e9+7;

int main(){
    ll N,ans=0,mn=mod;
    cin >> N;
    vector<ll> P(N,0);
    vector<ll> DP(N,mod);
    rep(i,N){
        cin >> P[i];
        if(i==0){
            mn=P[0];
            ans++;
        }else{
            if(mn>=P[i]){
            mn = P[i];
            ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
int main()
{int a,b,c;
 while(~scanf("%d%d%d",&a,&b,&c))
 {if(c>=a&&c<=b)
  printf("Yes\n");
  if(c<a||c>b)
  printf("No\n");
 }
    return 0;
}


Measured memory_bytes: 128
using System;
using System.IO;

class Solve
{
    static void Main(string[] args) {
        var S = Console.ReadLine();
        var len = S.Length;
        var answer = 753;
        for (int i = 1; i < len - 1; i++) {
            var x = int.Parse(S[(i - 1)..(i + 2)]);
            answer = Math.Min(answer, Math.Abs(x - 753));
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27408