akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
    var n int64
    fmt.Scan(&n)
    prime := map[int64]int64{}
    for i := int64(2); i < 1e6; i++ {
        for {
            if n % i != 0 {
                break
            }
            prime[i] += 1
            n /= i
        }
    }
    if n > 1 {
        prime[n] += 1
    }

    ans := 0
    for _, cnt := range prime {
        i := int64(0)
        for {
            i += 1
            cnt -= i
            if cnt < 0 {
                break
            }
            ans += 1
        }
    }
    fmt.Println(ans)
}


Measured memory_bytes: 1832
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 550000;
const int K = 19;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int h, w, n;
    cin >> h >> w >> n;
    if (h < w) swap(h, w);
    if (n % h == 0) cout << n / h; else cout << n / h + 1;
}


Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

//↑template↑



int n, k[20005], mon[20005];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; mon[k[i] - 1] = i; }
	for (int i = 0; i < n; ++i) { mon[i] += 20000 * (n - i); }
	for (int i = 0; i < n; ++i) { cout << 20000 * (i + 1) << " "; }cout << endl;
	for (int i = 0; i < n; ++i) { cout << mon[i] << " "; }cout << endl;
}

Measured memory_bytes: 768
import java.math.BigDecimal;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		double b = sc.nextDouble();
		sc.close();
		long d = (long)(b *1000);
		long c = a*d;
		;
		c = c /100;
		System.out.println(new BigDecimal(a).multiply(new BigDecimal(d)).divideToIntegralValue(new BigDecimal("1000")));
	}
}

Measured memory_bytes: 29220
#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;


int			price[100];
bool		decided[100];
vector<int>	recipe[100];

int dfs(int index)
{
	if(decided[index])
	{
		return price[index];
	}
	if(recipe[index].empty())
	{
		decided[index] = true;
		return price[index];
	}

	int newprice=0;
	for(size_t i=0; i<recipe[index].size(); i++)
	{
		newprice+=dfs(recipe[index][i]);
	}
	price[index] = (newprice<price[index]?newprice:price[index]);

	decided[index] = true;
	return price[index];
}

int main()
{
	int N,M,p,l,idx;
	string s;
	while(cin >> N, N)
	{
		map<string,int> s2i;
		for(int i=0; i<N; i++)
		{
			cin >> s >> p;
			s2i[s] = i;

			price[i]   = p;
			decided[i] = false;
			recipe[i].clear();
		}

		cin >> M;
		for(int i=0; i<M; i++)
		{
			cin >> s >> l;
			idx = s2i[s];
			while(l--)
			{
				cin >> s;
				recipe[idx].push_back(s2i[s]);
			}
		}

		cin >> s;
		cout << dfs(s2i[s]) << endl;		
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		long n=s.nextLong();
		long a=s.nextLong();
		long b=s.nextLong();
		
		long set=n/(a+b);
		long rem=n%(a+b);
		
		long ans=a*set;
		
		ans=ans+Math.min(a,rem);
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    double w,h,x,y; cin >> w >> h >> x >> y;
    double area = w*h/2;
    int ans = (x + x == w && y + y == h ? 1:0);
    cout << area << " " << ans << endl;
}


Measured memory_bytes: 256
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  ll n,m;
  cin>>n>>m;
  ll a[n];
  ll s=0;
  rep(i,0,n) cin>>a[i],s+=a[i];
  sort(a,a+n);
  reverse(a,a+n);
  if(a[m-1]*4*m>=s){
    cout<<"Yes\n";
  } 
  else cout<<"No\n";
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

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

using namespace std;

int main() {
  int N, div4 = 0, div2 = 0;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if (a % 4 == 0)
      div4++;
    else if (a % 2 == 0)
      div2++;
  }
  bool ans = (div4 * 2 + max(1, div2) >= N);
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

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

using namespace std;
int main()
{
  string s;
  cin>>s;
  bool a,b;
  a  = false;
  b = false;
  for(int i = 0;i<3;i++)
      {
        if(s[i]=='A')
            a = true;
         else
            b = true;
           }
           if(a&b)
            cout<<"Yes";
           else
            cout<<"No";
           
           return 0 ;
           }


Measured memory_bytes: 256
n = gets.chomp.to_i
        t = gets.chomp.split.map &:to_i
        four = 0
        two = 0
        t.each do |d|
          if(d % 4 == 0)
            four += 1 
          elsif(d % 2 == 0)
            two += 1
          end
        end
        n -= four
        n -= four + 1
        n += 1 if(two >= 2)
        n -= two if(two >= 2)
        puts (n <= 0)? "Yes" : "No"

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

int main() {
	int n;
	char str[10001]={};
	scanf("%d", &n);
	scanf("%s", str);
	int len=strlen(str);
	for (int i = 0; i < len; i++) {
		str[i]=(str[i]-'A'+n)%26+'A';
	}
	printf("%s\n", str);
	return 0;
}


Measured memory_bytes: 128
loop do
  n, m, s, g = gets.split.map(&:to_i)
  break if n == 0
  graph = {}
  (0..n-1).each {|i| graph[i] = [] }
  m.times do
    i, j, l = gets.split
    graph[i.to_i] << [j.to_i, l]
  end

  # Reverse Bellman-Ford
  best_suffix = { g => "" }
  rbf = proc do
    new_suffix = best_suffix.dup
    (0..n-1).each do |i|
      graph[i].each do |j, l|
        next if !best_suffix[j]
        new_suffix[i] = [ new_suffix[i] || ?{, l + best_suffix[j] ].min
      end
    end
    best_suffix = new_suffix
  end

  (7 * n).times { rbf.call }
  if best_suffix[s] && best_suffix[s].size < 6 * n
    puts best_suffix[s]
  else
    puts 'NO'
  end
end


Measured memory_bytes: 23604
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int d[500005];
int t[500005];
bool s[500005];

priority_queue<P> q1;

int main(){
	int n,m,q;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	t[0]=m;
	for(i=0;i<n;i++){
		cin>>d[i];
		if(d[i]<t[i]*2)t[i+1]=abs(t[i]-d[i]);
		else t[i+1]=t[i];
	}
	cin>>q;
	for(i=0;i<q;i++){
		cin>>a;
		a--;
		q1.push(make_pair(a,i));
	}
	for(i=n-1,a=0;i>=0;i--){
		while(!q1.empty() && q1.top().first==i){
			j=q1.top().second,q1.pop();
			if(a>=t[i])s[j]=false;
			else s[j]=true;
		}
		if(a*2+1>=d[i])a+=d[i];
	}
	for(i=0;i<q;i++)print_YES_NO(s[i]);
	return 0;
}


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

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

	string s;
	cin >> s;
	for(auto ch : s) {
		if(ch == ',') cout << " ";
		else cout << ch;
	}
	cout << endl;
}


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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt() - (i + 1);
        }
        // sum( abs(a[i] - b) )を最小化する
        sc.close();
        // 中央値をとる
        int midNum;
        Arrays.sort(a);
        if (n % 2 == 0) {
            midNum = (a[n / 2] + a[n / 2 - 1]) / 2;
        } else {
            midNum = a[n / 2];
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans = ans + Math.abs(a[i] - midNum);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 89172
"use strict";

function main(input){
  const args = input.trim().split('\n').map(_=>_.split(' '));
  const n = parseInt(args[0][0],10);
  const k = parseInt(args[0][1],10);
  const h = args[1].map(_=>parseInt(_,10));
  
  const dp = Array(n).fill(0); // i => i-stepでの最小コスト
  for(let i=1; i<n; i++){
    let minCost = dp[i-1] + Math.abs(h[i] - h[i-1]);
    for(let j=2; j<=k; j++){
      if(i-j < 0) break;
      const cost = dp[i-j] + Math.abs(h[i] - h[i-j]);
      minCost = Math.min(minCost, cost);
    }
    dp[i] = minCost;
  }
  
  console.log(dp[n-1]);
}

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

Measured memory_bytes: 29592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<atcoder/all>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;


using mint = atcoder::modint998244353;

mint bit[220000], bit2[220000];

void add(mint* bit, int pos, mint x){
    pos++;
    while(pos < 220000){
        bit[pos] += x;
        pos += pos & -pos;
    }
}

mint sum(mint* bit, int pos){
    pos++;
    mint ans = 0;
    while(pos){
        ans += bit[pos];
        pos -= pos & -pos;
    }
    return ans;
}

int pos[220000];
mint all_sum[220000];


int main(){
    int n, k;
    cin >> n >> k;
    mint P = mint(k-1) / mint(k);
    mint Pinv = P.inv();
    for(int i = 0;i < n;i++){
        int x;
        cin >> x;x--;
        pos[x] = i;
        all_sum[i] = Pinv.pow(max(i, k-1));
        all_sum[i] += all_sum[i-1];
    }
    mint ans = 0;
    for(int i = 0;i < n;i++){
        int p = pos[i];
        ans += p - sum(bit2, p);
        add(bit2, p, 1);
                
        mint smaller = sum(bit, p);
        
        mint bigger = 0;
        if(p)bigger = all_sum[p-1] - smaller;

        ans += P.pow(max(p, k-1)) * smaller / mint(2);
        ans -= P.pow(max(p, k-1)) * bigger / mint(2);

        add(bit, p, Pinv.pow(max(p, k-1)));        
    }
    cout << ans.val() << endl;
    return 0;
}

Measured memory_bytes: 6376
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e5+10;
char s[maxn];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i+=2)
	{
		putchar(s[i]);
	}
	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i=0;i<n;i++) cin >> d[i];
    sort(d.begin(),d.end());

    cout << d[n/2]-d[n/2-1] << endl;
    
}

Measured memory_bytes: 640
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M, V, P := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	S := make([]int, N+1)
	S[0] = 0
	for i, a := range A {
		S[i+1] = S[i] + a
	}
	ans := 0
	//fmt.Println(A)
	//fmt.Println(S)
	for i := 1; i <= N; i++ {
		if search(A, A[i-1]) <= P-1 {
			ans++
			continue
		}
		changed := A[i-1] + M
		bigCount := search(A, changed)
		k := N - i + 1
		if !(bigCount <= P-1) {
			continue
		}
		diff := (i-P)*changed - (S[i-1] - S[P-1])
		//fmt.Println(i-1, P-1)
		//fmt.Println("i: %d, n: %d, changed: %d, diff: %d, S: %d", i, A[i-1], changed, diff, S[i-1]-S[P-1])
		if (P-1)*M+diff+k*M >= V*M {
			ans++
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}

// Aのなかでnより大きい要素数
func search(A []int, n int) int {
	ng := -1
	ok := len(A)
	for abs(ok-ng) > 1 {
		mid := (ok + ng) / 2
		if A[mid] <= n {
			ok = mid
		} else {
			ng = mid
		}
	}
	return ok
}


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

public class Main {

    class Pair {

        int x, y;

        Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N + 2];
        int[] B = new int[N + 2];
        int ans = 0;
        A[0] = 0;
        ans = A[0];
        A[N + 1] = 0;
        for (int i = 1; i < N + 1; i++) {
            A[i] = sc.nextInt();
        }
        for (int i = 1; i <= N + 1; i++) {
            B[i] = Math.abs(A[i] - A[i - 1]);
            ans += B[i];
        }
        for(int i=1;i<N+1;i++){
            System.out.println(ans-B[i]-B[i+1]+Math.abs(A[i+1]-A[i-1]));
        }
    }

}

Measured memory_bytes: 64756
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
const int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int n,m;
int sx,sy,tx,ty;
char mp[1005][1005];
int dist[1005][1005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>sx>>sy>>tx>>ty;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			cin>>mp[i][j];
	}
	memset(dist,0x3f,sizeof(dist));
	deque<pair<int,int> > q;
	q.push_back(make_pair(sx,sy));
	dist[sx][sy]=0;
	while(!q.empty())
	{
		pair<int,int> p=q.front();
		q.pop_front();
		for(int d=0;d<4;d++)
		{
			int xx=p.first+dx[d],yy=p.second+dy[d];
			if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&mp[xx][yy]=='.'&&dist[xx][yy]>dist[p.first][p.second])
			{
				dist[xx][yy]=dist[p.first][p.second];
				q.push_front(make_pair(xx,yy));
			}
		}
		for(int dx=-2;dx<=2;dx++)
			for(int dy=-2;dy<=2;dy++)
			{
				int xx=p.first+dx,yy=p.second+dy;
				if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&mp[xx][yy]=='.'&&dist[xx][yy]>dist[p.first][p.second]+1)
				{
					dist[xx][yy]=dist[p.first][p.second]+1;
					q.push_back(make_pair(xx,yy));
				}
			}
	}
	if(dist[tx][ty]>inf)
		cout<<-1<<endl;
	else cout<<dist[tx][ty]<<endl;
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    
    vector<int> v(26, 0);
    
    for (int i = 0; i < s.length(); i++)
        v[s[i] - 'A'] += 1;

    int cnt = 0;
    for (int i = 0; i < 26; i++){
        if (v[i] != 0)
            cnt += 1;
    }

    if (cnt == 2)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define deb(x) cout<<#x<<" is "<<x<<endl;
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++)   
        cin>>a[i];

    ll dp[n+1][n+1][2];
    for(int i=n;i>=0;i--)
    {
        for(int j=i;j<=n;j++)
        {
            if(i==n || j==n)
            {
                dp[i][j][0]=0;
                dp[i][j][1]=0;
            }
            else if(i==j)
            {
                dp[i][j][0]=a[i];
                dp[i][j][1]=-a[i];    

            }
            else
            {
                //consider range a[i...j]
                //take "i", or take "j" and maximise or minimise according to your objective
                dp[i][j][0]=max(a[i]+dp[i+1][j][1],a[j]+dp[i][j-1][1]);
                dp[i][j][1]=min(-a[i]+dp[i+1][j][0],-a[j]+dp[i][j-1][0]);    
            }

            // cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<endl;
        }
    }
    cout<<dp[0][n-1][0]<<endl;
}

Measured memory_bytes: 85484
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  cout << min(k, n) * x + max(0, n - k) * y << endl;
  return 0;	
}

Measured memory_bytes: 256
// Problem: B - Go to Jail
// Contest: AtCoder - AtCoder Beginner Contest 179
// URL: https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define printv(v)     \
  for (auto x : v)    \
    cout << x << " "; \
  cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define ump unordered_map
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
#define deb(x) cout << "test " << #x << "=" << x << jmp
#define deb2(x, y) cout << "test " << #x << "=" << x << "," << #y << "=" << y << jmp
using namespace std;
const ll nax = 1e5 + 5;
void solve()
{
  ll n;
  cin >> n;
  pair<ll, ll> a[n];
  for (ll i = 0; i < n; i++)
    cin >> a[i].ff >> a[i].ss;
  for (ll i = 0; i < n - 2; i++)
  {
    if (a[i].ff == a[i].ss && a[i + 1].ff == a[i + 1].ss && a[i + 2].ff == a[i + 2].ss)
    {
      cout << "Yes";
      return;
    }
  }
  cout << "No";
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int n;

	std::cin >> n;

	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int biggest = 0;
	int second_biggest = 0;
	int biggest_id;
	for (int i = 0; i < n; i++) {
		if (a[i] > biggest) {
			second_biggest = biggest;
			biggest = a[i];
			biggest_id = i;
		}
		else if (a[i] > second_biggest)
			second_biggest = a[i];
	}

	for (int i = 0; i < n; i++) {
		if (i == biggest_id) 
			cout << second_biggest << endl;
		else
			cout << biggest << endl;
	}

	return 0;
}

Measured memory_bytes: 2432
N, W = [int(x)for x in input().split()]
items = []
for i in range(N):
    items.append(tuple(int(x) for x in input().split()))
dp = [0]*(W+1)
for i in range(N):
    v, w = items[i]
    for j in reversed(range(w,W+1)):
        dp[j] = max(dp[j],dp[j-w]+v)

print(dp[-1])
    


Measured memory_bytes: 5924
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define Maxn 105
int num[Maxn][Maxn];
const int N1=44;
const int N2=20;

void rd(ll &x){
	x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	int z1=0,z2=0;
	if(ch=='.'){
		ch=getchar();
		while(ch>='0'&&ch<='9'){
			x=x*10+ch-'0';
			z1--;z2--;
			ch=getchar();
		}
	}
	while(x%2==0){
		z1++;
		x/=2;
	}
	while(x%5==0){
		z2++;
		x/=5;
	}
	z1+=N1;
	z2+=N2;
	num[z1][z2]++;
}

int main(){
	long long Ans=0;
	ll tmp;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		rd(tmp);
	}
	for(int i=0;i<=2*N1;++i)
	    for(int j=0;j<=2*N1;++j)
	         if(i+j>=2*N1){
	             for(int k=0;k<=2*N2;++k)
	                 for(int l=0;l<=2*N2;++l)
	                     if(k+l>=2*N2){
	                     	 if(i==j&&k==l)Ans+=1ll*num[i][k]*(num[i][k]-1);
	                     	 else Ans+=1ll*num[i][k]*num[j][l];
						 }
	                 }
	Ans/=2;
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 3240
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]
#CW = [list(map(int, list(input()))) for _ in range(H)]


N = int(input())
mod = 10**9+7
ans = 0
ten = 1
nine = 1
eight = 1

for i in range(N):
  ten = (10*ten)%mod
  nine = (9*nine)%mod
  eight = (8*eight)%mod

neight = 2*nine - eight

if(neight<0):
  neight += mod

ans = ten - neight

if(ans<0):
  ans += mod

print(ans%mod)




Measured memory_bytes: 75184
#include <iostream>
#include <vector>
using namespace std;
int t,num,i,j,f,res,sum,tmp,div;
vector<int>pat,v;
int dcnt(int n){return n?dcnt(n/10)+1:0;}
int main(){
  while(cin>>t>>num&&t){
    f=0,res=-1;
    for(i=0;i<1<<(dcnt(num)-1);i++){
      sum=0,tmp=num,div=10;v.clear();
      for(j=0;j<5;j++)	if((i>>j)&1){ sum+=tmp%div; v.push_back(tmp%div);tmp/=div; div=10;}else div*=10;
      sum += tmp;if(tmp)v.push_back(tmp);
      if(sum<=t)if(res<sum) res=sum,f=0,pat=v;else if(res==sum) f=1;
    }
    if(f) cout<<"rejected";
    else if(res<0) cout<<"error";
    else{ cout<<res;for(i=pat.size()-1;i>=0;i--) cout << " " << pat[i];}
    cout<<endl;
  }
}

Measured memory_bytes: 1216
import math
import itertools

N = int(input())

PList = tuple(map(int,input().split()))
QList = tuple(map(int,input().split()))

a = list(itertools.permutations(PList))
a.sort()
anum = a.index(PList) + 1
bnum = a.index(QList) + 1

print(abs(int(anum-bnum)))

Measured memory_bytes: 8052
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
#include<stdio.h>
#include<string>
#include<malloc.h>
#include<string.h>
#include<stack>
#include<algorithm>
#include<map>
#include<utility>//pair
#define MAX 0x3f3f3f3f
void solve(string s)
{
	int n = s.length();
	printf("%c%d%c\n", s.at(0), n - 2, s.at(n - 1));
}

int main()
{
	string s;
	while (cin >> s) {
		solve(s);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define pie pair<int,int>
using namespace std;

int32_t main(){

	string s;
	cin>>s;

	stack <char> F,S;
	int rev=0;
	int q;cin>>q;
	int type,pos;
	char c;
	while(q--){

		cin>>type;
		if(type==1)rev++;
		else{

			cin>>pos>>c;
			if(rev%2==0){
				if(pos==1){
					F.push(c);
				}else{
					S.push(c);
				}
			}else{
				if(pos==1){
					S.push(c);
				}else{
					F.push(c);
				}
			}
		}
	}

	string pre="",suf="";

	while(!F.empty()){
		pre+=F.top();
		F.pop();
	}
	while(!S.empty()){
		suf+=S.top();
		S.pop();
	}
	// reverse(pre.begin(),pre.end());
	reverse(suf.begin(),suf.end());
	// cout<<pre<<" "<<suf<<endl;
	string ans=pre+s+suf;
	if(rev&1)
		reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

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

using namespace std;

signed main(){
  int A[100],N;

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

  int count = 0;
  int flag = 1;
  while(flag) {
    flag = 0;
    for (int i=N-1;i>0;i--) {
      if (A[i] < A[i-1]) {
        count++;
        int tmp = A[i];
        A[i] = A[i-1];
        A[i-1] = tmp;
        flag = 1;
      }
    }
  }
  
  for (int i=0;i<N-1;i++) {
    cout << A[i] << " ";
  }
  cout << A[N-1] << endl;
  cout << count << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  int N; cin >> N;
  vi P(N); rep(i,N) cin >> P[i];
  int count = 0;
  int minA = P[0];
  rep(i,N){
    if (P[i] <= minA) {count++; minA = P[i];}
    if(minA == 1) break;
  } 
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



    int main(){
        string s;
        cin>>s;
        ll ns = s.size();
        ns--;
        if(s[ns]=='s'){
            cout<<s+"es"<<endl;
        }
        else{
            cout<<s+"s"<<endl;
        }        
    }

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;
int n;
int a[500];
int ans = 1e9;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int x = -100; x <= 100; x++)
    {
        int j = 0;
        for (int i = 0; i < n; i++)
        {
            j += (a[i] - x) * (a[i] - x);
        }
        ans = min(ans, j);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,sum = 0;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }
    sort(data.begin(), data.end());//小さい順に並べる
    reverse(data.begin(), data.end());//リバース
    for (int i = 0; i < n; i++){
        if(i == 0){
            sum += data.at(i) / 2;
        }else{
            sum += data.at(i);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3540
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long m){
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


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

const int MAX = 200001;

int main() {
  int n, k;
  cin >> n >> k;

  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  vector<int> nums(MAX);
  for (int i = 0; i < n; i++) nums[a[i]]++;

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

  int types = 0;
  for (int i = 0; i < MAX; i++) {
    if (nums[i] > 0) types++;
  }

  int first = 0;
  for (int i = 0; i < MAX; i++) {
    if (nums[i] > 0) {
      first = i;
      break;
    }
  }

  int ans = 0;
  while (types > k) {
    ans += nums[first++];
    types--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4852
a,b=map(int,input().split())
if a==1:
    if a==b:
        print("Draw")
    else:
        print("Alice")
elif b==1:
    if a==b:
        print("Draw")
    else:
        print("Bob")
else:
    if a<b:
        print("Bob")
    elif a>b:
        print("Alice")
    else:
        print("Draw")

Measured memory_bytes: 3060
#include<set>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011];
int C[100011];
bool B[100011];

bool valid(const VI &v) {
    REP (i, N-1) if (A[v[i]] == v[i+1]) return false;
    return true;
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i), A[i]--;

    REP (i, N) C[A[i]]++;
    set<pair<int, int> > FI;
    set<int> se;
    REP (i, N) {
	FI.emplace(C[i], i);
	se.insert(i);
    }

    VI guess;
    REP (t, N) {
	int rest = N-t;
	if (rest <= 4) {
	    VI tmp = guess;
	    VI v;
	    REP (j, N) if (!B[j]) v.push_back(j);
	    do {
		REP (j, v.size()) tmp.push_back(v[j]);

		if (valid(tmp)) {

		    EACH (e, tmp) (*e)++;
		    rprintf("%d", tmp.begin(), tmp.end());
		    return;
		}

		REP (j, v.size()) tmp.pop_back();
	    } while (next_permutation(v.begin(), v.end()));
	    break;
	}
	int k;
	if (FI.rbegin()->first == rest-1) {
	    k = FI.rbegin()->second;
	} else {
	    k = *se.begin();
	    if (t && A[guess.back()] == k) {
		k = *next(se.begin());
	    }
	}

	guess.push_back(k);
	FI.erase(make_pair(C[k], k));
	B[k] = true;
	se.erase(k);
	if (!B[A[k]]) {
	    FI.erase(make_pair(C[A[k]], A[k]));
	    C[A[k]]--;
	    FI.emplace(C[A[k]], A[k]);
	}
    }
    EACH (e, guess) (*e)++;
    puts("-1");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;
    int count = 0;
    for(int i = A; i <= B; i++) {
        int one = i%10;
        int ten = (i/10)%10;
        int thousands = (i/10/10/10)%10; 
        int tenThousands = (i/10/10/10/10)%10;
        
        if(one == tenThousands && ten == thousands) {
            count++;
        }
    }
    cout << count << endl;

}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetLongNumArray();
            var X = input[0];
            var Y = input[1];

            for (int i = 0; i < X + 1; i++)
            {
                var count = 2 * (X - i) + 4 * i;
                if (count == Y)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 28228
#include<bits/stdc++.h>
using namespace std;
#define LEN 25
int maze[LEN][LEN] = {};
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h,w;
	cin >> h >> w;
	for(int i=0; i<h; i++)
	{
		string str;
		cin >> str;
		for(int j=0; j<w; j++)
		{
			if(str[j]=='.')
				maze[i+1][j+1] = 1;
		}
	}
	int ans = 0;
	for(int i=1; i<=h; i++)
	{
		for(int j=1; j<=w; j++)
		{
			if(!maze[i][j]) continue;
			int dis[LEN][LEN] = {};
			memset(dis,-1,sizeof(dis));
			queue<int> qx, qy;
			qx.push(i), qy.push(j);
			dis[i][j] = 0;
			while(!qx.empty())
			{
				int x = qx.front(); qx.pop();
				int y = qy.front(); qy.pop();
				ans = max(ans,dis[x][y]);
				for(int d=0; d<4; d++)
				{
					int xx = x + dx[d];
					int yy = y + dy[d];
					if(maze[xx][yy] && dis[xx][yy]==-1)
					{
						dis[xx][yy] = dis[x][y]+1;
						qx.push(xx), qy.push(yy);
					}
				}
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import itertools
from collections import deque
sys.setrecursionlimit(10 ** 9)

# map(int, sys.stdin.read().split())


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    print(int(N*(N-1)//2))




if __name__ == "__main__":
    main()


Measured memory_bytes: 64280
#include <stdio.h>
int a[25],b[25],c[25];

int main()
{
    int n;scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++) scanf("%d",&b[i]);
    for (int i=1;i<n;i++)  scanf("%d",&c[i]);
    int ans=b[a[1]];
    for (int i=2;i<=n;i++)
    {
        ans+=b[a[i]];
        if ( a[i]==(a[i-1]+1) ) ans+=c[a[i-1]];
    }
    printf("%d\n",ans);
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
 
    void solve (){
        int k;
        cin>>k;
        string s="ACL";
        for(int i=0;i<k;i++)
            cout<<s;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 200010

ll x[N], s[N], s2[N], f[N];

int main(){
	int n;
	cin>>n;
	for(int i = 1; i <= n; i++){
		cin>>x[i]>>s[i];
	}
	x[n+1] = 1e15+1;
	for(int i = 1; i <= n; i++) s2[i] = s[i]+x[i]-x[i+1];
	for(int i = 1; i <= n; i++) f[i] = max(0LL, f[i-1])+s2[i];
	ll res = 0;
	for(int i = 1; i <= n; i++) res = max(res, f[i]-x[i]+x[i+1]);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int N;
ll K;
int A[(int)2e5 + 1];
int vis[(int)2e5 + 1] = {0};
vector<int> trip;

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    int p = 1;
    trip.push_back(1); // space holder
    for (ll i = 1; i <= K; i++) {
        p = A[p];
        if (vis[p] == 0)
        {
            vis[p] = i;
            trip.push_back(p);
        }
        else {
            int idx = vis[p];
            int loop = i - idx;
            p = trip[idx + (K - i) % loop];
            break;
        }
    }
    cout << p << endl;
}

Measured memory_bytes: 5816
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 3e5+5;
ll modpower(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modpower((x*x)%mod,n/2);
    else
        return (x*modpower((x*x)%mod,(n-1)/2))%mod;

}

void solve(){
	char a;
	cin >> a;
	if(a=='A')
		cout << "T";
	else{
		if(a=='T')
			cout << "A";
		else{
			if(a=='C')
				cout << "G";
			else
				cout << "C";
		}
	}
	
}

int main() {
	isc;
	solve();
	return 0;
}


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

int main() {
    int N; cin >> N;
    double p[N];
    REP(i, N) cin >> p[i];
    double dp[N+1][N+1];
    REP(i, N+1) REP(j, N+1) dp[i][j] = 0;
    dp[0][0] = 1;
    REP(i, N){
        REP(j, N){
            dp[i+1][j+1] += dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1-p[i]);
        }
    }
    double ans = 0;
    REP(i, N+1){
        if (i > N-i){
            ans += dp[N][i];
        }
    }
    cout << fixed << setprecision(12);
    cout << ans << endl;
}

Measured memory_bytes: 70528
s = input()

sf = int(s[:2])
sb = int(s[2:])

mmyy = (0 < sf and sf < 13)
yymm = (0 < sb and sb < 13)

if mmyy and yymm:
    print("AMBIGUOUS")
elif mmyy:
    print("MMYY")
elif yymm:
    print("YYMM")
else:
    print("NA")


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

int main()
{
    int n, count = 0;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int m;
        cin >> m;
        bool isPrime = true;
        for(int j = 2; j * j <= m; ++j){
            if(m % j == 0) {
                isPrime = false;
                break;
            }
        }
        if(isPrime) ++count;
    }
    cout << count << endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
  int n,t,a,i,best;
  scanf("%d",&n);
  scanf("%d %d",&t,&a);
  int h[n];
  double temp[n];
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }

  for(i=0;i<n;i++){
    temp[i]=t-h[i]*0.006;
  }
  best=0;
  for(i=1;i<n;i++){
    if(fabs(a-temp[best])>fabs(a-temp[i])) best = i;
  }
  printf("%d\n",best+1);
  return 0;
}


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

using namespace std;

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
  }
};


int main(){
  function<int(int, int)> add = [](int a, int b)->int{
    static int mod = 1e9 + 7;
    a %= mod;
    b %= mod;
    return (((a + b) % mod) + mod) % mod;
  };
  string K;
  assert(cin >> K);
  int D;
  assert(cin >> D);
  int N = (int) K.size();
  Vec <3,int> memo(N + 1, D, 2, -1);
  function <int(int, int, int)> dp = [&dp, &add, &K, &D, &N, &memo](int digit, int reminder, int state)->int{
    if(digit == N)return reminder == 0;
    int &ret = memo[digit][reminder][state];
    if(ret != -1)return ret;
    ret = 0;
    if(state){
      for(int i = 0; i <= 9; i++){
        ret = add(ret, dp(digit + 1, (reminder + i) % D, 1));
      }
    }else{
      ret = add(ret, dp(digit + 1, (reminder + K[digit] - '0') % D, 0));
      for(int i = 0; i < K[digit] - '0'; i++){
        ret = add(ret, dp(digit + 1, (reminder + i) % D, 1));
      }
    }
    return ret;
  };
  cout << add(dp(0, 0, 0), -1) << '\n';
  return 0;
}


Measured memory_bytes: 56704
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
ge = []
l = 1
r = n-1
for i in range(m):
    if i%2:
        ge.append([l,r])
    else:
        ge.append([r,l])
    l+= 1; r-= 1
ge.sort(reverse = True)
# print(ge)
x = 1
for i in range(m):
    a,b = ge[i]
    print(x,x+a)
    x += 1


Measured memory_bytes: 86384
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
int N ; cin >> N ;
  vector<int> A(N);
  for(int i = 0 ; i < N; i++){
    cin >> A[i];}
  
  sort(A.begin(), A.end());
  
  int s = A[0];
  int t = A[N-1];
  
  int max_cnt = 0;
 
 for(int X = s;  X <= t ; X++){
   
   int total = 0;
   
  auto c1 = lower_bound(A.begin(),A.end(), X-1);
  auto c2 = upper_bound(A.begin(),A.end(), X+1);
   //A[i] >= X - 1なる最初のi*はlower_boundで調べられる
   //A[j] <= X + 1 なる最後のj*は、upper_bound - 1で調べられる
   //求めたいのは cnt = j* - i* + 1 ==( c2 - 1 - c1 + 1 )== cnt2 - cnt1
  
   int cnt1 = distance(A.begin(),c1);
   int cnt2 = distance(A.begin(),c2);
   
   total += cnt2 - cnt1;
   
   max_cnt = max(max_cnt, total);}
   
   cout << max_cnt << endl;
  
  return 0;
}
     

Measured memory_bytes: 640