akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

bool bipartite(vector<string> &S) {
    int N = S.size();
    vector<int> color(N, -1);
    color[0] = 0;
    queue<int> Q;
    Q.push(0);
    while(!Q.empty()) {
        int cur = Q.front(); Q.pop();
        int nc = (color[cur] + 1) %2;
        for(int to=0; to<N; ++to) {
            if(S[cur][to] == '0') continue;
            if(color[to] == -1) color[to] = nc, Q.push(to);
            if(color[to] != nc) return false;
        }
    }
    return true;
}

int dist[201][201] = {};
const int INF = 1001001001;

void solve(vector<string> &S) {
    int N = S.size();
    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) {
            if(i == j) dist[i][j] = 0;
            else if(S[i][j] == '1') dist[i][j] = 1;
            else dist[i][j] = INF;
        }
    }

    for(int k=0; k<N; ++k) {
        for(int i=0; i<N; ++i) {
            for(int j=0; j<N; ++j) {
                if(dist[i][k] == INF || dist[k][j] == INF) continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

int main() {
    int N; cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; ++i) cin >> S[i];

    if(!bipartite(S)) {
        cout << -1 << endl; return 0;
    }

    solve(S);
    int diam = 0;
    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) {
            diam = max(diam, dist[i][j]);
        }
    }
    cout << diam + 1 << endl;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  string a;
  cin >> a;

  int cnt[26];
  m0(cnt);

  for (int i = 0; i < a.size(); i++) {
    int tmp = a[i] - 'a';
    cnt[tmp]++;
  }

  int ans = 1;
  for (int i = 0; i < 26; i++) {
    for (int j = i + 1; j < 26; j++) {
      ans += cnt[i] * cnt[j];
    }
  }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	int ng = 0, ok = 0;
	vector<int> v(n);
	while (n--) {
		int t;
		cin >> t;
		v.push_back(t);
		ok += t;
		ng = max(ng, t-1);
	}
	auto f = [&](int mid) {
		int sum = 0;
		int cnt = 1;
		for (auto& x : v) {
			sum += x;
			if (sum > mid) {
				sum = x;
				cnt++;
			}
		}
		return cnt <= k;
	};
	while (ok - ng > 1) {
		int mid = (ok+ng) / 2;
		if (f(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}


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

bool is_prime(int x) {
  if (x <= 3)
    return x > 1;
  if (x % 2 == 0 || x % 3 == 0)
    return false;
  for (int i = 5; i * i <= x; i += 6)
    if (x % i == 0 || x % (i + 2) == 0)
      return false;
  return true;
}

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

  while (true) {
    if (is_prime(X)) {
      cout << X << endl;
      return 0;
    }
    ++X;
  }
}

Measured memory_bytes: 256
MODE = "stdiro"
#require 'matrix'
#include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '3
  4
  3
  2'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end


n = line[0].to_i

arr=[]
(1..n).each do |num|
  arr << line[num].to_i
end


minv = arr[0]
maxv = -10**9
(1..n-1).each do |j|
  maxv = [maxv, arr[j]-minv].max
  minv = [minv, arr[j]].min
end

puts maxv

Measured memory_bytes: 26008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll k,x;
	cin>>k>>x;
	for(ll i=k-1;i>=0;i--){
		cout << x-i<<" ";
	}
	for(ll i=0;i<k-1;i++){
		cout << x+i+1<<" ";
	}
	// your code goes here
	return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Console.ReadLine();
		
		Console.WriteLine(p[2] == p[3] && p[4] == p[5] ? "Yes" : "No");
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;
using ld = long double;

bool check(string l, string r) {
	for (int i = 0; i < l.size(); ++i) {
		if (l[i] == r[i] || r[i] == '_') {

		}
		else {
			return false;
		}
	}
	return true;
}

int main() {
	string A,B;cin>>A>>B;
	for (int i = 0; i < A.size() - B.size() + 1; ++i) {
		string b=A.substr(i,B.size());
		if (check(b,B)) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int n, a[1000], i, j, m, hol=0, x[2], y[2], t=0, c;
    scanf("%d %d", &n, &m);
    for(i=1;i<=m;i++)
    {
        scanf("%d", &a[i]);
        if(a[i]%2)
        {
            hol++;
            if(hol==1)
            {
                x[0]=i;
                x[1]=a[i];
            }
            else if(hol==2)
            {
                y[0]=i;
                y[1]=a[i];
            }
        }
            
        }
    if(hol>=3)
        printf("Impossible");
    else
    {
        if(hol>=1)
            {
                c=a[1];
                a[1]=a[x[0]];
                a[x[0]]=c;
            }
        if(hol==2)
        {
            c=a[y[0]];
            a[y[0]]=a[m];
            a[m]=c;
        }
        for(i=1;i<=m;i++)
            printf("%d ", a[i]);
        printf("\n");
        if(m==1)
        {
            if(n==1)
                {
                    printf("%d\n%d", 1, 1);
                    
                }
                else
                {
            printf("%d\n", 2);
            printf("%d %d", 1, n-1);
                }
        }
        else
        {
        t+=(a[1]==1)+(a[m]==1);
        printf("%d\n", m+1-t);
        if(a[1]==1)
        {
            a[1]=2;
            if(a[m]==1)
            {
                for(i=1;i<=m-1;i++)
                    printf("%d ", a[i]);
            }
            else
            {
                a[m]-=1;
                for(i=1;i<=m;i++)
                    printf("%d ", a[i]);
            }
        }
        else
        {
            printf("%d %d ", a[1]-1, 2);
            if(a[m]==1)
            {
                for(i=2;i<=m-1;i++)
                    printf("%d ", a[i]);
            }
            else
            {
                a[m]-=1;
                for(i=2;i<=m;i++)
                    printf("%d ", a[i]);
            }
        }
        }
    }
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let n = read::<usize>();
    let bv = read_vec::<usize>();

    let mut ret = 0;
    for i in 0..n {
        if i == 0 {
            let a = bv[i];
            ret += a;
        } else if i == n - 1 {
            let a = bv[i-1];
            ret += a;
        } else {
            let b_i_1 = bv[i-1];
            let b_i = bv[i];
            let a = std::cmp::min(b_i_1, b_i);
            ret += a;
        }
    }

    println!("{}", ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
/*input
CODEFESTIVAL
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	string s;
	cin>>s;
	for(int i=0;i<s.size()-8;++i)
		cout<<s[i];
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 整数の入力
n = int(input())

# スペース区切りの整数の入力
a = [int(x) for x in input().split()]
print("a", a, file=sys.stderr)
#n, d = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a.sort()
def doloop():
  res = 0
  for x in a:
    res ^= x
  
  return res == 0

def doit():
  if doloop():
    return "Yes"
  else:
    return "No"

#print(doit([0] * 4))
#doit(s)
#print(doit())
try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)


Measured memory_bytes: 14888
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    sum = a[0]+a[1]
    ans =sum //2
    if sum%2 ==1:
        ans +=1

    print(ans)

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b=0,c,i,j,d,e=0,f=0;
    string s,ss;
    cin>>s;
    a=s.size();
    c=(a-1)/2;
    d=(a+3)/2;
    for(i=0; i<a; i++)
    {
        if(s[i]!=s[a-i-1])
            b=1;
    }
    if(b!=1)
    {
        for(i=0; i<c; i++)
        {
            if(s[i]!=s[c-i-1])
                e=1;
        }
        if(e!=1)
        {
            for(i=d-1; i<a; i++)
            {
                if(s[i]!=s[a-i-1])
                    f=1;
            }
        }
    }
    if(b!=1 && e!=1 && f!=1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
stack push pop top
queue push pop front
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <sstream>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF 1<<20
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////
ll f(ll n)
{
  if(n==0) return 1;
  else return n*f(n-1);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  ll n;
  cin >> n;
  cout << f(n) << endl;
  return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
#include<iostream>
using namespace std;

int main(void)
{
	int a, b, c, d, e,ondo,f;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	if (a > 0)
	{
		f = b - a;
		ondo=f*e;
	}
	else if (a < 0)
	{
		ondo = -a*c + d + b*e;
	}
	else if (a == 0)
	{
		ondo = d + b*e;
	}
	printf("%d\n", ondo);
		return 0;
}

Measured memory_bytes: 3196
A, B, C = map(int, input().split())
dp = [-1] * 100
_A = A
while True:
    if A % B == C:
        print("YES")
        break
    if dp[A%B] != -1:
        print("NO")
        break
    dp[A%B] = 1
    A = A % B + _A
    #print(A)



Measured memory_bytes: 61768
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func toInt(value string) int {
    num, _ := strconv.Atoi(value)
    return num
}

func splitWithInt(value string) []int {
    vals := strings.Split(value, " ")
    nums := make([]int, len(vals))
    for index, elem := range vals {
        nums[index] = toInt(elem)
    }
    return nums
}

// C
func main() {
    inputs := splitWithInt(gets())
    n, k := inputs[0], inputs[1]
    var result, tmp float64
    for i := 1; i <= n; i++ {
        tmp = 1
        for j := i; j < k; j *= 2 { tmp /= 2 }
        result += tmp
    }
    fmt.Println(result / float64(n))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    ll sum = 0;
    REP(i, M) {
        cin >> A[i];
        sum += A[i];
    }
    if (sum > N) {
        cout << -1 << endl;
    } else {
        cout << N - sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, s;
	cin >> n >> s;
	if (n < s) cout << "-1\n";
	else if (n == s) cout << n + 1 << "\n";
	else {
		bool ok = false;
		ll ans, i = 1;
		for (; i < n; i++) {
			if (i * i > n) break;
			if ((n - s) % i == 0) {
				ll b = i + 1, tmp = n, now = 0;
				while (tmp != 0) {
					now += tmp % b;
					tmp /= b;
				}
				if (now == s) {
					ok = true;
					ans = b;
					break;
				}
			}
		}
		for (; i >= 1; i--) {
			if (!ok && (n - s) % i == 0) {
				ll b = (n - s) / i + 1, tmp = n, now = 0;
				while (tmp != 0) {
					now += tmp % b;
					tmp /= b;
				}
				if (now == s) {
					ok = true;
					ans = b;
					break;
				}
			}
		}

		cout << (ok ? ans : -1) << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll num;
	cin>>num;
	ll ans=0;
	for(ll i=1;i<=num;i++)
	{
		if(i%3==0||i%5==0) continue;
		else ans+=i;
	}
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;

    if(t1*a1+t2*a2 == t1*b1+t2*b2){
        cout << "infinity" << endl;
        return 0;
    }else if(t1*a1>t1*b1 && t1*a1+t2*a2>t1*b1+t2*b2){
        cout << 0 << endl;
        return 0;
    }else if(t1*a1<t1*b1 && t1*a1+t2*a2<t1*b1+t2*b2){
        cout << 0 << endl;
        return 0;
    }

    ll init = abs(t1*(a1-b1));
    ll diff = abs(t1*(a1-b1)+t2*(a2-b2));
    ll ans = (init/diff)*2;
    if(init%diff != 0){ans++;}
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}

long long gcd(ll a, ll b){
  if(b == 0) return a;
  else return gcd(b, a%b);
}

template<typename T> void change(T &a, T &b){
    T tmp = a;
    a = b;
    b = tmp;
}

long long lcm(ll a, ll b){
  if(b > a) change(a, b);
  ll g = gcd(a, b);
  return a / g * b;
}

void solve(){
  int n; cin >> n;
  ll ans = 1;
  for(int i = 0; i < n; ++i){
    ll tmp; cin >> tmp;
    ans = lcm(ans, tmp);
    // cout << ans << endl;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3552
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    if(a!=1)cout<<1<<endl;
    else if(b!=2)cout<<2<<endl;
    else cout<<3<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); ++i) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

using namespace std;

//arc065 Day Dream
//Sを逆さにする
//Tを逆さにする
//比較する

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

  //末尾にgmを追加

  string T[4] = {"dream", "dreamer", "erase", "eraser"};

  reverse(S.begin(),S.end());
  REP(i,4)
  {
    reverse(T[i].begin(),T[i].end());
  }

  bool isOK = true;
  //++しない
  for(ll i = 0; i < S.size();)
  {
    bool flg2 = false;
    REP(j,4)
    {
      if(T[j] == S.substr(i, T[j].size()))
      {
        flg2 = true;
        i += T[j].size();
        break;
      }
    }
    if(flg2 != true)
    {
      isOK = false;
      break;
    }
  }

  if(isOK)cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

template <int p>
struct Modint
{
	int value;

	Modint() : value(0) {}
	Modint(long x) : value(x >= 0 ? x % p : (p + x % p) % p) {}

	inline Modint &operator+=(const Modint &b)
	{
		if ((this->value += b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator-=(const Modint &b)
	{
		if ((this->value += p - b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator*=(const Modint &b)
	{
		this->value = (int)((1LL * this->value * b.value) % p);
		return (*this);
	}
	inline Modint &operator/=(const Modint &b)
	{
		(*this) *= b.inverse();
		return (*this);
	}

	Modint operator+(const Modint &b) const { return Modint(*this) += b; }
	Modint operator-(const Modint &b) const { return Modint(*this) -= b; }
	Modint operator*(const Modint &b) const { return Modint(*this) *= b; }
	Modint operator/(const Modint &b) const { return Modint(*this) /= b; }

	inline Modint &operator++(int) { return (*this) += 1; }
	inline Modint &operator--(int) { return (*this) -= 1; }

	inline bool operator==(const Modint &b) const { return this->value == b.value; }
	inline bool operator!=(const Modint &b) const { return this->value != b.value; }
	inline bool operator<(const Modint &b) const { return this->value < b.value; }
	inline bool operator<=(const Modint &b) const { return this->value <= b.value; }
	inline bool operator>(const Modint &b) const { return this->value > b.value; }
	inline bool operator>=(const Modint &b) const { return this->value >= b.value; }

	//requires that "this->value and p are co-prime"
	// a_i * v + a_(i+1) * p = r_i
	// r_i = r_(i+1) * q_(i+1) * r_(i+2)
	// q == 1 (i > 1)
	// reference: https://atcoder.jp/contests/agc026/submissions/2845729 (line:93)
	inline Modint inverse() const
	{
		assert(this->value != 0);
		int r0 = p, r1 = this->value, a0 = 0, a1 = 1;
		while (r1)
		{
			int q = r0 / r1;
			r0 -= q * r1;
			swap(r0, r1);
			a0 -= q * a1;
			swap(a0, a1);
		}
		return Modint(a0);
	}

	friend istream &operator>>(istream &is, Modint<p> &a)
	{
		long t;
		is >> t;
		a = Modint<p>(t);
		return is;
	}
	friend ostream &operator<<(ostream &os, const Modint<p> &a)
	{
		return os << a.value;
	}
};

const int MOD = 1e6+3;

using Int = Modint<MOD>;

Int pow(Int e, int64_t x)
{
	if (x == 0)
		return 1;
	Int res = (x & 1 ? e : 1), tmp = pow(e, x >> 1);
	res *= tmp * tmp;
	return res;
}

void solve(void)
{
	int q;
	cin >> q;
	vector<Int> acc(MOD);
	acc[1] = 1;
	for (int i = 1; i < MOD-1; i++)
	{
		acc[i + 1] = acc[i] * Int(i + 1);
	}
	while(q--)
	{
		Int x, d;
		int n;
		scanf("%d%d%d", &x.value, &d.value, &n);
		if (d == 0)
		{
			cout << pow(x, n) << endl;
			continue;
		}
		x /= d;
		if (x.value+n-1 >= MOD)
		{
			cout << 0 << endl;
			continue;
		}
		Int ans = acc[x.value+n-1] / acc[x.value-1] * pow(d, n);
		printf("%d\n", ans.value);
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N,T; cin >> N >> T;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	vector<int> MAX(N);
	int M = 0;
	for(int i = N-1; i >= 0; i--){
		M = max(M,A[i]);
		MAX[i] = M;
	}
	map<int,int> P;
	rep(i,N-1){
		P[MAX[i+1]-A[i]]++;
	}
	int ans = 0;
	for(auto u : P){
		ans = u.second;
	}
	cout << ans << endl;
}



Measured memory_bytes: 5760
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| add(a)}
  end
  
  def add(element)
    @data.push(element)
    bottom_up
  end
  
  # @return Integer
  def peek
    @data[0]
  end

  # @return Integer
  def poll
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      max = @data[0]
      @data[0] = @data.pop
      top_down
      return max
    end
  end
  
  # @return Integer
  def size
    @data.size
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  
  def bottom_up
    idx = size - 1
    while(has_parent?(idx))
      parent_idx = parent_idx(idx)
      if @data[parent_idx] < @data[idx]
        swap(parent_idx, idx)
        idx = parent_idx
      else
        return
      end
    end
  end
  
  def top_down
    idx = 0
    while (has_child?(idx))
      a = left_child_idx(idx)
      b = right_child_idx(idx)
      if @data[b].nil?
        c = a
      else
        c = @data[a] >= @data[b] ? a : b
      end
      if @data[idx] < @data[c]
        swap(idx, c)
        idx = c
      else
        return
      end
    end
  end
  

  # @param Integer
  # @return Integer
  def parent_idx(idx)
    (idx - (idx.even? ? 2 : 1)) / 2
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end

  def has_parent?(idx)
    idx > 0
  end
end

n,m=gets.split(' ').map(&:to_i)
x=(1..n).map{gets.split.map(&:to_i)}.group_by{|a|a.first}
t=0
q=PriorityQueue.new
(1..m).each{|i| x[i].map{|j|q.add(j.last)}if x[i];(z=q.poll)? t+=z:nil}
puts t

Measured memory_bytes: 21628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        System.out.println(a * b > c * d ? a * b : c * d);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=998244353;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
ll f[300010],fi[300010];
ll mod_pow(ll x,ll n,ll mod){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret=ret*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return ret;
}

void fact(ll n){
	f[0]=1;
	for(ll i=1;i<=n;i++){
		f[i]=f[i-1]*i%MOD;
	}
	fi[n]=mod_pow(f[n],MOD-2,MOD);
	for(ll i=n-1;i>=0;i--){		
		fi[i]=fi[i+1]*(i+1)%MOD;
	}
}


ll ncr(ll n,ll r){
	if(r==0){
		return 1;
	}else{
		return ((f[n]*fi[r])%MOD*fi[n-r])%MOD;
	}
}

int main(){
	ll n,a,b,k;cin>>n>>a>>b>>k;
	fact(n);
	ll ans=0;
	for(ll i=0;i<=n;i++){
		if((k-(a*i))%b)continue;
		ll p=(k-(a*i))/b;
		if(p<0||a*i+p*b!=k||p>n)continue;
		(ans+=(ncr(n,i)*ncr(n,p)))%=MOD;
	}
	cout<<ans%MOD<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

vector<ll> ed(ll n)//nの約数を列挙
{
	vector<ll> ret;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i*i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> a = ed(M);
	ll ans = INF;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] >= N && a[i] < ans)ans = a[i];
	}
	if (ans == INF) {
		cout << 1 << endl;
		return 0;
	}
	cout << M / ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int M, N, a, data, max_ = 0;

	cin >> M >> N;

	for (int i = 0; i < M; i++)
	{
		data = 0;

		for (int j = 0; j < N; j++)
		{
			cin >> a;

			data += a;
		}

		max_ = max(max_, data);
	}

	cout << max_ << endl;

	return 0;
}

Measured memory_bytes: 1160
// Mode Value

#include <iostream>
using namespace std;

int main() {
    int counter[100] = {};
    int val;
    int freq;
    // count
    while (cin >> val) {
        counter[val-1]++;
    }

    // find mode
    freq = 0;
    for (int idx = 0; idx < 100; idx++) {
        if (counter[idx] > freq)
            freq = counter[idx];
    }

    // print mode(s)
    for (int idx = 0; idx < 100; idx++) {
        if (counter[idx] == freq)
            cout << idx+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3084
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b] <- getIntList
    print $ solve a b

solve a b | a >= 13 = b
          | a >= 6 = b `div` 2
          | otherwise = 0

Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;
    vector<int>A(M);
    cin >> A;
    N--;
    SORT(A);
    vector<int> dis(M - 1);
    REP(i, M - 1) {
        dis[i] = abs(A[i + 1] - A[i]);
    }

    SORT(dis);
    int ans = 0;
    REP(i, M - 1 - N) {
        ans += dis[i];
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 1024
import sys
#import unittest
#import collections

def plan_vacation(activity, n):
	dp = [[0] * 3 for i in xrange(n)]
	for i in xrange(3):
		dp[0][i] = activity[0][i]
	
	for i in xrange(1, n):
		for j in xrange(3):
			for k in xrange(3):
				if j != k:
					dp[i][j] = max(dp[i][j], dp[i-1][k] + activity[i][j])
	return max(dp[n-1])
	
	
def read_input():
	#Read the input N
	n = int(sys.stdin.readline())
	activity = [[0]* 3 for i in xrange(n)]
	for i in xrange(n):
		a = sys.stdin.readline().split()
		for j in xrange(3):
			activity[i][j] = int(a[j])
	
	result = plan_vacation(activity, n)
	print result
		
if __name__ == '__main__':
	 read_input()


Measured memory_bytes: 39044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    ll x[51], y[51];

    cin >> n;
    REP(i, n)
    cin >> x[i] >> y[i];

    if (n == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    int res = 1000;

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            ll p = (x[i] - x[j]);
            ll q = (y[i] - y[j]);

            int r = n;

            for (int k = 0; k < n; k++)
            {
                for (int l = k + 1; l < n; l++)
                {
                    if ((p == (x[k] - x[l]) && q == (y[k] - y[l])) ||
                        (p == -(x[k] - x[l]) && q == -(y[k] - y[l])))
                        r--;
                }
            }

            res = min(res, r);
        }
    }

    cout << res << endl;

    return 0;
}

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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

vector<bool> sosu(100010, true);
void eratosthenes(int n){
	sosu[1]=false;
	for(int i=2; i<=sqrt(n); i++){
		if(sosu[i]){
			for(int j=2; i*j<=n; j++){
				sosu[i*j]=false;
			}
		}
	}
}

int main(){
    eratosthenes(100005);
    
    vector<int> ans_sum(100005, 0);
    ans_sum[1]=0;
    for(int i=3; i<100000; i+=2){
        if(sosu[i] && sosu[(i+1)/2]){
            ans_sum[i]=ans_sum[i-2]+1;
        }
        else{
            ans_sum[i]=ans_sum[i-2];
        }
    }

    int q; cin>>q;
    for(int i=0; i<q; i++){
        int l, r; cin>>l>>r;
        if(l == 1){
            cout << ans_sum[r] << endl;
        }
        else{
            cout << ans_sum[r] - ans_sum[l-2] << endl;
        }
    }
}

Measured memory_bytes: 1024
for _ in range(int(input())):
    pipe = [0, 0]
    a = list(map(int, input().split()))
    for i in a:
        if i > max(pipe):
            pipe[pipe.index(max(pipe))] = i
        elif i > min(pipe):
            pipe[pipe.index(min(pipe))] = i
        else:
            print('NO')
            break
    else:
        print('YES')

Measured memory_bytes: 7560
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

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

int mod = 1000000007;
ll dp[100005];
const ll INF = 1e18;

ll gcd(long long a,long long b){
  if(b == 0)
    return a;
  else return gcd(b,a%b);
}

bool sortbyval(const pair<string, int> &a,
               const pair<string, int> &b){
    return (a.second < b.second);
}

int main(){

string s;
 cin>>s;

 int start=0,ends=-2;

 for(int i=0;i<s.length();i++){

    if(s[i] == 'A'){
        start = i;
        break; }
 }

 for(int i=0;i<s.length();i++){

    if(s[i] == 'Z'){
        if(i>ends)
            ends = i; }
 }

 //cout<<start<<"  "<<ends<<endl;

 ends = ends+1;

 cout<<ends-start<<endl;

return 0;
}


Measured memory_bytes: 3720
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)

using namespace std;
int a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a+b+c<=21){
        puts("win");
    }else{
        puts("bust");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, (b)<(e)?1:-1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define FOR(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)(__VA_ARGS__)
#ifdef LOCAL
#define dbg(x) cerr << '[' << #x << ":" << (x) << "]\n"
#else
#define dbg(x)
#endif
int dp[100001],v[100];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,k;cin>>n>>k;
	FOR(n)cin>>v[i];
	FOR(i,1,k+1){
		FOR(j,n){
			if(i-v[j]<0)continue;
			dp[i]|=!dp[i-v[j]];
		}
	}
	cout<<(dp[k]?"First":"Second")<<'\n';
}

Measured memory_bytes: 4056
#include <iostream>
#include <string>
#include <cctype>
#include <array>
#include <algorithm>

int main ()
{
  std::string str, pattern;
  std::cin >> str >> pattern;

  str += str;
  auto pos = str.find(pattern);

  if (pos == std::string::npos)
    std::cout << "No" << std::endl;
  else
    std::cout << "Yes" << std::endl;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib> //abs(int)
using namespace std;
int main(void){
  int a /*, c, d*/;
  cin >> a /*>> c >> d*/;
  if(a == 3 || a == 5 || a == 7){
    cout << "YES";
  } else {
    cout << "NO";
  }
}

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	vector<ll> d(n+1);
	d[0] = a[0];
	rep(i,n-1) d[i+1] = a[i+1] - a[i];
	d[n] = 0 - a[n-1];
	ll dist_base = 0;
	rep(i,n+1) dist_base += abs(d[i]);
	rep(i,n) cout << dist_base - (abs(d[i]) + abs(d[i+1]) - abs(d[i] + d[i+1])) << endl;

	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n; cin >> n;
   vector<bool> dp(1e6+1,true);
   vector<int> A(n);
   rep(i,n)cin >> A[i];
   sort(A.begin(),A.end());
   map<int,bool> m;
   rep(i,n-1){
      if(A[i]==A[i+1])m[A[i]] = true;
   }
   int ans = 0;

   for (auto &&i : A)
   {
      if(dp[i]){
         if(!m[i])ans++;
         for (int j = i;j <= 1e6;j+=i){
            dp[j] = false;
         }
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 13380
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a, b = input_to_int_map()
    import itertools
    _a = "".join(itertools.repeat(str(a), b))
    _b = "".join(itertools.repeat(str(b), a))
    ret = _b
    if _a < _b:
        ret = _a

    return ret


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


Measured memory_bytes: 3064
h,w = map(int, input().split())
S = [["." for i in range(w+2)]]
S += [["."] + list(input()) + ["."] for i in range(h)]
S += [["." for i in range(w+2)]]

def solve(S):
    for i in range(1,h+1): #i = 1,2,..,hについて処理
        for j in range(1,w+1): #j = 1,2,...,wについて処理
            if S[i][j] == "#":
                if S[i-1][j] == ("#" or "a") or S[i+1][j] == ("#" or "a") or S[i][j-1] == ("#" or "a") or S[i][j+1] == ("#" or "a"):
                    S[i][j] == "a"
                else:
                    return False
    return True

if solve(S):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N,M;
    cin >> N >> M;
    vector<pii> ab(M);
    rep(i,M){
        cin >> ab[i].fi >> ab[i].se;
        ab[i].fi--;
        ab[i].se--;
    }
    sort(all(ab));

    int ans = 0;
    int last = -1;
    for(int i=M-1;i>=0;i--){
        int a = ab[i].fi , b = ab[i].se;

        if(a <= last and last < b) continue;

        last = a;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
#! /usr/bin/python
#from math import gcd
from fractions import gcd
from functools import reduce
#N, X = 3, 3
#CITY = [1, 7, 11]
#
#N, X = 3, 81
#CITY = [33, 105, 57]

N,X= map(int,input().split())
CITY = list(map(int,input().split()))

nanka = [abs(X - c) for c in CITY]
print(reduce(lambda x, y: gcd(x, y), nanka))


Measured memory_bytes: 16304
def solve():
    N = int(input())
    S = input()
    
    ans = 0
    memo1 = set()
    for i in range(N - 2):
        si = int(S[i])
        if si in memo1:
            continue
        memo1.add(si)
        memo2 = set()
        for j in range(i + 1, N - 1):
            sj = int(S[j])
            if sj in memo2:
                continue
            memo2.add(sj)
            ans += len(set(S[j + 1:]))
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int mod=10e8+7;

int getmax(int n,int ar[])
{
  
    int dp[n],i,j,res,ans1,ans2,ans3;
      dp[0]=0;
      dp[1]=abs(ar[1]-ar[0]);;
   
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    }
  
    return dp[n-1];

    

}
int main()
{
    int T,n,sum;
    
    
   
        cin>>n;
        int ar[n];
        for(int i=0;i<n;i++)
        cin>>ar[i];
        cout<<getmax(n,ar)<<"\n";
    
}

Measured memory_bytes: 4260
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let mut vec: Vec<i32> = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    let mut sunuke_balls = vec![0; vec.len()];
    let mut m = 0;
    let mut ans = vec![];
    for (i_1, _) in vec.iter().enumerate().rev() {
        let i = i_1 + 1;
        let mut sum = 0;
        for j in 1..((vec.len() / i) + 1) {
            sum += sunuke_balls[(i * j) - 1];
        }
        if sum % 2 == vec[i_1] {
            sunuke_balls[i_1] = 0;
        } else {
            sunuke_balls[i_1] = 1;
            ans.push(i);
            m += 1;
        }
    }
    println!("{}", m);
    println!(
        "{}",
        sunuke_balls.iter().enumerate()
            .filter(|&(_, i)| *i == 1)
            .map(|(i, _)| (i + 1).to_string())
            .collect::<Vec<String>>()
            .join(" ")
    );
}


Measured memory_bytes: 14708
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <cmath>

using namespace std;

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

	for (int i = n; i >= 0; i--) {
		int x = sqrt(i);
		if (x * x == i) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 632
# -*- coding: utf-8 -*-

# input
A, B, C, X, Y = map(int, input().split())

# solve & output
print(min(A * X + B * Y, A * max(0, (X - Y)) + C * 2 * Y, B * max(0, (Y - X)) + C * 2 * X, C * 2 * max(X, Y)))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r, b;
    r = b = 0;
    for (auto a : s) {
        if (a == 'R') r++;
        else b++;
    }
    Yes(r > b);
    return 0;
}



Measured memory_bytes: 256
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)

s = ''.join(s)
t = ''.join(t)
check = [s, t]
check.sort()
if check[0] == s and check[0] != check[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064