akhauriyash/Code-Regression huggingface dataset:
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    for i in 0..n - 1 {
        a[i + 1] += a[i];
    }

    let mut ans1 = 0;
    let mut ans2 = 0;
    let mut diff = 0i64;
    for i in 0..n {
        if i % 2 == 0 && a[i] + diff <= 0 {
            // sei
            ans1 += 1 - (a[i] + diff);
            diff += 1 - (a[i] + diff);
        }
        if i % 2 == 1 && a[i] + diff >= 0 {
            // hu
            ans1 += a[i] + diff + 1;
            diff -= a[i] + diff + 1;
        }
    }
    diff = 0;
    for i in 0..n {
        if i % 2 == 0 && a[i] + diff >= 0 {
            // sei
            ans2 += a[i] + diff + 1;
            diff -= a[i] + diff + 1;
        }
        if i % 2 == 1 && a[i] + diff <= 0 {
            // hu
            ans2 += 1 - (a[i] + diff);
            diff += 1 - (a[i] + diff);
        }
    }
    println!("{}", min(ans1, ans2));
}


Measured memory_bytes: 6396
n,m = map(int,input().split())
city = list(enumerate([list(map(int,input().split())) for _ in range(m)]))
city.sort(key = lambda x:(x[1][0],x[1][1]))
city_dict = {}
for c in city:
  if c[1][0] in city_dict:
    city_dict[c[1][0]] += 1
    c[1][1] = city_dict[c[1][0]]
  else:
    city_dict[c[1][0]] =1
    c[1][1] = city_dict[c[1][0]]

city.sort(key = lambda x:x[0])
for c in city:
  num = str(c[1][0]*10**6+c[1][1])
  print("0"*(12-len(num))+num)

Measured memory_bytes: 52512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	int n;
	cin >> n;
	cout << n*n << endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <vector>
# include <string>
# include <stack>

using namespace std;

int main()
{
    string s;
    cin >> s;
    
        if(s.size() == 1) {
            cout << -1 << " " << -1;
            return 0;
        } else if(s.size() == 2) {
            if(s[0] == s[1])
                cout << 1 << " " << 2;
            else 
                cout << "-1 -1";
            return 0;
        }

    for(int i = 0; i < s.size() - 1; i++) {
        if(s[i] == s[i + 1]) {
            if(i != 0) {
                cout << i << " " << i + 2;
            } else {
                cout << "1 3";
            }
            return 0;
        } else if((i < s.size() - 2) && s[i] == s[i + 2]) {
            if(i != 0) {
                cout << i + 1 << " " << i + 3;
            } else {
                cout << "1 3";
            }
            return 0;
        }
    }


    cout << "-1 -1";
    return 0;
}

Measured memory_bytes: 512
n = int(input())

d = [[0]*10 for i in range(10)]

for i in range(1, n+1):
  i_ = str(i)
  x = int(i_[0])
  y = int(i_[-1])
  d[x][y] += 1

ans = 0
for i in range(10):
  for j in range(10):
    ans += d[i][j]*d[j][i]
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void){
    int list_x[7][3]={{1,0,1},{0,0,0},{1,2,3},{0,-1,-1},{1,1,2},{0,1,1},{1,0,-1}};
    int list_y[7][3]={{0,1,1},{1,2,3},{0,0,0},{1,1,2},{0,1,1},{1,1,2},{0,1,1}};
    int i,j;
    int k,l;
    int fig_i;
    char fig[8]={"ABCDEFG"};
    char s[8][9];
    bool judge;
    
    while(true){
        judge=false;
        for(i=0;i<8;i++){
            if(!(cin>>s[i]))return(0);
            cin.get();
        }
        for(i=0;i<8;i++){
            for(j=0;j<8;j++){
                if(s[i][j]=='1'){
                    for(k=0;k<7;k++){
                        judge=true;
                        for(l=0;l<3;l++){
                            if(s[i+list_y[k][l]][j+list_x[k][l]]!='1'){
                                judge=false;
                            }
                        }
                        if(judge){
                            fig_i=k;
                            break;
                        }
                    }
                }
                if(judge)break;
            }
            if(judge)break;
        }
        cout<<fig[fig_i]<<endl;
    }
}

Measured memory_bytes: 1132
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define ll long long
#define int long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> p;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    string t;
    if(s.size()==3){
        t.push_back(s[2]);
        t.push_back(s[1]);
        t.push_back(s[0]);
        cout<<t;
    }
    else{
        cout<<s;
    }
    return 0;
}

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

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;

// namespace utils
namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    rep (i, mat.size()) {
      rep (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    rep (i, v.size()) cout << v[i] << ' ';
    cout << endl;
  }
// end namespace utils
}

class Heap {

  public:
    Heap(int H) {
      W.resize(H+1);
    }

    vector<int> W;
    bool check(int i);
};


bool Heap::check(int i) {
  if (1 <= i && i < (int)W.size()) return true;
  else return false;
}


int main() {
  int H;
  vector<int> W;

  cin >> H;
  Heap heap = Heap(H);

  rep (i, H) cin >> heap.W[i+1];
  for (int i=1; i<=H; i++) {
    cout << "node " << i << ": ";
    cout << "key = " << heap.W[i] << ", ";
    if (heap.check(i/2)) cout << "parent key = " << heap.W[i/2] << ", ";
    if (heap.check(i*2)) cout << "left key = " << heap.W[i*2] << ", ";
    if (heap.check(i*2+1)) cout << "right key = " << heap.W[i*2+1] << ", ";
    cout << endl;
  }
}

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

using namespace std;

long long N, M, K;
vector <long long> A, B;
vector <long long> SumA, SumB;
int main(){
    cin >> N >> M >> K;
    cin.ignore();

    long long tmp;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        A.push_back(tmp);
    }
    cin.ignore();
    
    for(int i = 0; i < M; i++){
        cin >> tmp;
        B.push_back(tmp);
    }
    
    long long cur = 0;
    int a_ptr = 0;
    int b_ptr = 0;

    long long cnt = 0;

    // まずはAでどれだけ読めるか
    long long SumA = 0;
    for(a_ptr = 0;a_ptr < N; a_ptr++){
        if(A[a_ptr]<= K){
            K -= A[a_ptr];
            ++cnt;
        } else {
            break;
        }
    }
    --a_ptr; // Aから何も出せないときは-1になる

    //cout << "a_ptr = " << a_ptr << endl;
    //cout << "SumA = " << SumA << endl;

    // B たりなかったらAの最後尾から間借りし、cntが増えればOK
    for(b_ptr = 0; b_ptr < M; b_ptr++){
        if(B[b_ptr] <= K){
            ++cnt;
            K -= B[b_ptr];
        } else {
            break;
        }
    }

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

    long long max_cnt = cnt;

    // Aからの補充フェーズ
    while(b_ptr < M && a_ptr >= 0){
        long long tmp_K = K + A[a_ptr];
        long long tmp_cnt = cnt - 1;
        int tmp_b_ptr = 0;
        for(tmp_b_ptr = b_ptr; tmp_b_ptr < M; tmp_b_ptr++){
            if(B[tmp_b_ptr] <= tmp_K){
                ++tmp_cnt;
                tmp_K -= B[tmp_b_ptr];
            } else {
                break;
            }
        }
        --a_ptr;
        b_ptr = tmp_b_ptr;
        K = tmp_K;
        cnt = tmp_cnt;
        if(tmp_cnt > max_cnt) max_cnt = tmp_cnt;
    }
    cout << max_cnt << endl;

    return 0;
}

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

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

	int ans = 0;
	for (auto i = L.begin(); i != L.end() - 2; i++) for (auto j = i + 1; j != L.end() - 1; j++) ans += lower_bound(j + 1, L.end(), *i + *j) - j - 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
program main
        implicit none
        integer :: n, i
        integer, allocatable :: a(:)

        read *, n
        allocate( a(n) )
        read *, a

        do i = 1, n
          if ( mod(a(i),2) == 0 ) then
            if ( (mod(a(i),3) == 0) .or. (mod(a(i),5) == 0) ) then
            else
              print *, 'DENIED'
              stop
            end if
          end if
        end do

        print *, 'APPROVED'
end program main


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

long long a,b,c,d;
long long ans=-9e18;
long long cmp=0;

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


Measured memory_bytes: 3632
// atcoder/keyence2019/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  str s;
  while (cin >> s) {
    bool f = false;
    str t = "keyence";
    for (int i = 0; i < s.size(); ++i) {
      for (int j = i; j <= s.size(); ++j) {
        str u;
        for (int k = 0; k < s.size(); ++k) {
          unless (i <= k && k < j) u += s[k];
        }
        f = f || (t == u);
      }
    }
    cout << (f ? "YES" : "NO") << endl;
  }

  return 0;
}


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

int main() {
  int n, m; cin >> n >> m;
  vector<P> p(m);
  rep(i,m) cin >> p[i].first >> p[i].second;
  rep(x,1000) {
    int digit = 1;
    int nx = x/10;
    vector<int> d(1,x%10);
    while (nx) {
      digit++;
      d.push_back(nx%10);
      nx /= 10;
    }
    if (digit != n) continue;
    bool flag = true;
    reverse(d.begin(), d.end());
    rep(i,m) {
      if (d[p[i].first-1] != p[i].second) flag = false;
    }
    if (flag) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{

    class Program
    {

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            int length = s.Length;
            int res = 0;

            for (int i = 0; i < length; i++)
                if (s[i] != t[i])
                    res++;

            Console.WriteLine(res);

        }

    }
}



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

int main() {
  int N; //入力値
  int sum = 0; //各桁の和
  int len = 1;  //Nの桁数
  int n;  //N保管
  int A; //N保管
  int i;
  int j;

  cin >> N;

  n = N;
  A = N;

  //Nの桁数の取り出し

  while(n / 10 > 0){
    n = n / 10;
    len++;
    if(len == 9){
      break;
    }
  }

  //cout << "len: " << len << endl; //Nの桁数の表示

  //各桁の取り出し

  int m = 1;

  for(i = 1; i < len; i++){
    m *= 10;
  }

  //cout << "m: " << m << endl << endl;

  for(i = 0; i < len; i++){
    int n;
      n = N / m; //最上位ビット
      N = N - n * m; //最上位ビットの削除
      sum = sum + n;
      m /= 10;
      //cout << N << endl << m << endl << sum << endl << endl;
  }

  //cout << sum << endl;

  int ans;
  ans = A % sum;

  if(ans == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  

  return 0;
} 

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

// Macros
#define F  first
#define S  second
#define PB push_back
#define MP make_pair
#define ALL(container)   container.begin(),container.end()
#define RALL(container)  container.rbegin(),container.rend()
#define MAKE_UNIQUE(vec) vec.erase(unique(ALL(vec)),vec.end())

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = std::pair <int,int>;

// Random
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/* [a,b] */ template<class T> T rnd_IntType(T a, T b){ return uniform_int_distribution<T>(a, b)(rng); }
/* [a,b) */ template<class T> T rnd_RealType(T a, T b){ return uniform_real_distribution<T>(a,b)(rng); }

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// Helpers
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
// vec.assign() GOOD; vec.resize() BAD
// comparator, <

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef VOID_d1097589d5c8e3676b0fd9e08281f3d4
	#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); d__f(_it, args); }
	void d__f(__attribute__((unused)) istream_iterator<string> it) {}
	template<typename Head, typename... Tail> void d__f(istream_iterator<string> it, Head H, Tail... T) { cerr << *it << " <=> [" << H << "]\n"; d__f(++it, T...); }
#else
	#define trace(args...)
#endif


void solve(){
	vector<int> arr(5);
	for(auto &i: arr) cin >> i;

	for(int i = 0; i < 5; ++i){
		if(arr[i] == 0){
			cout << i + 1 << "\n";
			return;
		}
	}
}

signed main (void){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	int a, b, x; cin >> a >> b >> x;
	if(a>x || a+b<x){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<cstdio>

int main(){
	long long k,s;
	scanf("%lld %lld",&k,&s);
	long long cnt=0;
	for(int i=0;i<=k;i++){
		for(int m=0;m<=s-i&&m<=k;m++){
			int n=s-i-m;
			if(n>=0&&n<=k){
				cnt++;
			}
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		int high,low,sa;
        
        for(int i=0;i<7;i++){
			high=sc.nextInt();
			low=sc.nextInt();
            sa=high-low;
		    System.out.println(sa);
		
        }
	}

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

Measured memory_bytes: 17168
//jinhaonan
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void read(T &x){
	x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	x=f?-x:x;
}
template<class T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
template<class T>inline bool chkmax(T &a,T const &b){
	return a<b?a=b,1:0;
}
template<class T>inline bool chkmin(T &a,T const &b){
	return a>b?a=b,1:0;
}
const int mo=1e9+7;
const int N=5000+10;
vector<int> e[N];
int c[N],size[N],f[N][N];
void addedge(int u,int v){
	e[u].push_back(v);
	e[v].push_back(u);
}
void add(int &x,int y){
	if((x+=y)>=mo)
		x-=mo;
}
void dfs(int u,int fa){
	size[u]=1;
	f[u][1]=1;
	static int tmp[N];
	for(int v:e[u])
		if(v!=fa){
			dfs(v,u);
			for(int i=0;i<=size[u];++i)
				for(int j=0;j<=size[v];++j)
					add(tmp[i+j],(long long)f[u][i]*f[v][j]%mo);
			size[u]+=size[v];
			for(int i=0;i<=size[u];++i){
				f[u][i]=tmp[i];
				tmp[i]=0;
			}
		}
	f[u][0]=0;
	for(int i=1;i<=size[u];++i)
		add(f[u][0],mo-(long long)f[u][i]*c[i]%mo);
}
int main(){
	// freopen("in.txt","r",stdin);
	int n;read(n);
	c[0]=1;
	for(int i=2;i<=n;i+=2){
		c[i]=c[i-2]*(i-1ll)%mo;
	}
	
	for(int i=1;i<n;++i){
		int u,v;read(u),read(v);
		addedge(u,v);
	}
	dfs(1,0);
	write(mo-f[1][0]),putchar('\n');
	return 0;
}

Measured memory_bytes: 97408
def main():
    import sys
    input = sys.stdin.readline

    p = int(input())
    A = list(map(int, input().split()))

    ans = [0] * p
    for i, a in enumerate(A):
        if not a:
            continue
        ans[-1] += 1
        ij = 1
        ans[0] = (ans[0] - ij)%p
        for j in range(1, p):
            ij = (ij * i)%p
            ans[j] = (ans[j] - ij)%p
    ans.reverse()
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), v(1000010);
    rep(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    rep(i,N){
        ll t = A[i];
        if(v[t] != 0){
            v[t]++;
            continue;
        }
        while(t<1000010){
            v[t]++;
            t += A[i];
        }
    }
    rep(i,N){
        if(v[A[i]] == 1)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12672
#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	int n;
  	cin >> n;
  	int p[n];
  	for(int i = 0; i < n; i++){
    	cin >> p[i];
    }
  	int count = 0;
	for(int i = 1; i < n-1; i++){
    	int s[3];
      	s[0] = p[i-1];
        s[1] = p[i];
      	s[2] = p[i+1];
      	sort(s, s+3);
      	if(s[1] == p[i]) count++;
    }
  	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  cout << min(a*n, b) << endl;

  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    while(cin >> n >> m, n){
        vector<ll> v(n);
        for (auto &&i : v) scanf("%lld", &i);
        ll S = 0;
        set<ll> s;
        s.emplace(0);
        ll ans = 0;
        for (int i = 0; i < n; ++i) {
            (S += v[i]) %= m;
            auto a = s.upper_bound(S);
            if(a != s.end()){
                ans = max(ans, (S-*a+m)%m);
            }else {
                ans = max(ans, S-*s.begin());
            }
            s.emplace(S);
        }
        cout << ans << "\n";
    }
    return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define Fix( x ) setprecision( x ) << fixed
#define mem( a , x ) memset( a , x , sizeof( a ) )
#define bug( a , b ) cerr<< #a <<" = "<<a<<" , "<< #b <<" = "<<b<<"\n";
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define FOR( i , a , b ) for( int i = a; i <= b; i++ )
#define ROF( i , a , b ) for( int i = a; i >= b; i-- )
#define sz( V ) (int)V.size( )
#define all( V ) V.begin( ),V.end( )
#define Found( S , val ) S.find( val ) != S.end( )
#define Unique( V ) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
typedef pair < int , int > ii;
typedef pair < int , ii > iii;
typedef long long int LL;
typedef unsigned long long uLL;
const int inf = (int)1e9;
const LL INF = (LL)1e18;
const int N = 100005;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );


int main( int argc, char const *argv[] ) {
        fast_io;
        int a , b;
        cin >> a >> b;
        if( a+b == 15 ) cout << "+";
        else if( a*b == 15 ) cout << "*";
        else cout << "x" ;
        cout << endl;
        return 0;
}








Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int k;
	cin >> k;

	vector<bool> v(k, false);
	if(k == 1 or k == 7) {
		cout << 1 << '\n';
		return 0;
	}

	int r = 7, res = 1;
	while(r) {
		if(v[r % k]) {
			res = -1;
			break;
		}
		v[r % k] = true;
		r = ((r * 10) + 7) % k;
		res++;
	}

	cout << res << '\n';
}

Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	bool ok = true;
	if (a >= 10) { ok = false; }
	if (b >= 10) { ok = false; }

	int ans = ok ? a * b : -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
while 1:
    H , W = map( int,input().split() )
    if H == 0 and W == 0:
        break
    print( "#" * W )
    for i in range( H-2 ):
        print( "#" + ( "." * ( W-2 ) ) + "#" )
    print( '#' * W )
    print()


Measured memory_bytes: 5612
import itertools
import math


def read():
    a, b, x = list(map(int, input().split()))

    return a, b, x


def solve(a, b, x):
    tan = 0
    if a * a * b / 2 >= x:
        tan = a * b * b / (2 * x)
    else:
        tan = (2 * b * a * a - 2 * x) / (a ** 3)
    return math.degrees(math.atan(tan))


if __name__ == '__main__':
    input = read()
    print(solve(*input))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
struct edge{ll to,cost;};
int main(){
    ll n,x,y; cin >> n >> x >> y;
    v<> m(n+1,0);
    for(ll i=1;i<=n;i++){
        for(ll j=i+1;j<=n;j++){
            m[min(j-i,abs(x-i)+1+abs(y-j))]++;
        }
    }

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

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
string str;
int cntw[255][255],cnth[255][255],cnta[255][255],cntb[255][255];
int n;
int t[255][255],ans;
int main(){
  while(cin>>n&&n){
    ans=0;
    for(int i=0;i<n;i++){
      cin>>str;
      for(int j=0;j<n;j++){
	t[i][j]=str[j]-'0';
	cntw[i][j]=cnth[i][j]=cnta[i][j]=cntb[i][j]=t[i][j];
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(t[i][j]==0)continue;
	if(i>0){
	  cnth[i][j]+=cnth[i-1][j];
	}
	if(j>0){
	  cntw[i][j]+=cntw[i][j-1];
	}
	if(i>0&&j>0){
	  cnta[i][j]+=cnta[i-1][j-1];
	}
	if(i>0&&j<n-1){
	  cntb[i][j]+=cntb[i-1][j+1];
	}
	ans=max(ans,cnth[i][j]);
	ans=max(ans,cntw[i][j]);
	ans=max(ans,cnta[i][j]);
	ans=max(ans,cntb[i][j]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2472
#include <iostream>
#include <string>   
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N, Q, l, r;
    string S;
    cin >> N >> Q >> S;
    vector<int> L(Q), R(Q);
    for(int i = 0; i < Q; ++i){
        cin >> l >> r;
        L[i] = l-1;
        R[i] = r-1;
    }
    vector<int> table(N, 0);
    int j = 0;
    bool isfirst = true;
    while(true){
        if(j == S.size()-1){
            table[j] = table[j-1];
            break;
        }else if(j > S.size()){
            break;
        }
        if(S[j] == 'A' && S[j+1] == 'C'){
            if(isfirst == true){
                isfirst = false;
                table[j+1] = 1;
            }else{
                table[j] = table[j-1];
                table[j+1] = table[j]+1;
            }
            j += 2;
        }else if(S[j+1] == 'A'){
            table[j] = table[j-1];
            table[j+1] = table[j];
            j++;
        }else{
            table[j] = table[j-1];
            table[j+1] = table[j];
            j += 2;
        }
    }
    // for(int i = 0; i < N; i++){
    //     cout << table[i];
    // }
    // cout << "\n" ;
    // cout << S << endl;

    for(int i = 0; i < Q; ++i){
        cout << table[R[i]]-table[L[i]] << "\n";
    }





    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int nums[n];
    for(int i = 0; i < n; i++){
        cin >> nums[i];
    }
    int ch_k = k - 1;
    int ch_cnt = n - 1;
    if(ch_cnt % ch_k  == 0){
        cout << ch_cnt / ch_k;
    }else{
        cout << ch_cnt / ch_k + 1;
    }
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int n, x[1000], y[1000];
    cin >> n;
    for(int i=0; i<n; i++) cin >> x[i];
    for(int i=0; i<n; i++) cin >> y[i];

    double d1=0, d2=0, d3=0, dinf=0;
    for(int i=0; i<n; i++){
        d1 += fabs(x[i] - y[i]);
        d2 += pow(fabs(x[i] - y[i]), 2);
        d3 += pow(fabs(x[i] - y[i]), 3);
        if(dinf < fabs(x[i] - y[i])) dinf = fabs(x[i] - y[i]);
    }
    d2 = sqrt(d2);
    d3 = pow(d3, 1.0/3.0);

    printf("%lf\n%lf\n%lf\n%lf\n", d1, d2, d3, dinf);

    return 0;
}


Measured memory_bytes: 3364
use std::str::FromStr;

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

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

fn main() {
    let n : usize = get_one();
    let v : Vec<usize> = get_vec();
    let mut ans = 0;
    let mut w = vec!(0;100005);
    for x in v {
        w[x] += 1;
    }
    for i in 1..w.len()-1 {
        let tmp = w[i-1] + w[i] + w[i+1];
        ans = std::cmp::max(tmp, ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <stdio.h>
typedef long long int lld;

int check(char *s, int len) {
  for (int i = 0; i < len / 2; i++) {
    if (s[i] != s[len - i - 1]) {
      return 0;
    }
  }
  return 1;
}

int main(void) {
  char s[99];
  int l = 0;
  for (l = 0; l < 99; l++) {
    scanf("%c", &s[l]);
    if (s[l] == '\n') {
      break;
    }
  }
  puts(check(s, l) && check(s, (l - 1) / 2) && check(&s[(l + 1) / 2], (l - 1) / 2) ? "Yes" : "No");
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

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


void solve()
{
    int a, b; cin >> a >> b;
    int ans = a;
    if(b < a) ans--;
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

using namespace std;



int main(){
  int N, L;
  cin >> N >> L;
  vector<string> strs(N);
  for(int i = 0; i < N; i++)
    cin >> strs[i];
  sort(strs.begin(), strs.end());

  for(int i = 0; i < N; i++)
    cout << strs[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <set>
#include <string>
#include <math.h>
#include <map>
#include <climits>
#include <iomanip>


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

#define ll long long

using namespace std;

void A();
void B();
void C();
void D();
void E();
void F();

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	A();


}

void A() {

	int K, A, B;
	cin >> K >> A >> B;

	double qA = (double)A / (double)K;
	double qB = (double)B / (double)K;

	cout << (qA <= (int)qB ? "OK" : "NG");


}

void B() {

}

void C() {

}

void D() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void E() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void F() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}



Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int dp[3005][3005];
string getLCS(string str1, string str2, int len) {
	string ans = "";
	int i = str1.length(), j = str2.length();
	while (len > 0) {
		if (str1[i - 1] == str2[j - 1]) {
			ans.push_back(str1[i - 1]);
			i--;
			j--;
			len--;
		}
		else {
			if (dp[i][j - 1] > dp[i - 1][j]) j--;
			else i--;
		}
	}
	reverse(ans.begin(), ans.end());
	return ans;
}

int lcs(string str1, string str2) {
	int s1 = str1.length();
	int s2 = str2.length();
	for (int i = 0; i <= max(s1, s2); i++) {
		if (i <= s1 )dp[i][0] = 0;
		if (i <= s2 )dp[0][i] = 0;
	}
	for (int i = 1; i <= s1; i++) {
		for (int j = 1; j <= s2; j++) {
			if (str1[i - 1] == str2[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	return dp[s1][s2];
}

int main() {
	string str1, str2;
	cin >> str1 >> str2;
	int len = lcs(str1, str2);
	cout << getLCS(str1, str2, len) << endl;

	return 0;
}

Measured memory_bytes: 38236
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,int> pli;
#define fir first
#define sec second
#define Mp make_pair
const int MAXN = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;

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

ll a[MAXN];

int main(void)
{
	int n;	
	ll d;
	scanf("%d%lld",&n,&d);
	for(int i=1; i<=n; ++i) scanf("%lld",&a[i]);
	
	ll ans=0;
	for(int i=1; i<=n; ++i) ans += a[i];
	
	for(int i=2; i<=n; ++i) chk_min(a[i], a[i-1]+d);
	for(int i=n-1; i>=1; --i) chk_min(a[i], a[i+1]+d);
	
	for(int i=1; i<=n; ++i) ans += a[i];
	printf("%lld",ans + d*(n-1) - a[1] - a[n]);
	return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n;
int l[maxn],r[maxn];
int a[maxn];

int32_t main()
{
    IOS
    cin>>n;
    for (int i=1;i<=n;i++) cin>>l[i]>>r[i];

    int L,R;

    for (int i=1;i<=n;i++) a[i]=l[i];
    sort(a+1,a+n+1);
    if (n&1) L=a[(n+1)/2];
    else L=a[n/2]+a[n/2+1];

    for (int i=1;i<=n;i++) a[i]=r[i];
    sort(a+1,a+n+1);
    if (n&1) R=a[(n+1)/2];
    else R=a[n/2]+a[n/2+1];

    cout<<R-L+1<<endl;
}



Measured memory_bytes: 6016
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
LL n;
int main()
{
    bool tf=true;
    LL ans=0,lalal=(1<<30);
    scanf("%lld",&n);
    for (LL u=1;u<=n;u++)
    {
        LL a,b;
        scanf("%lld%lld",&a,&b);
        if (a!=b) tf=false;
        ans=ans+a;
        if (a>b) lalal=min(lalal,b);
    }
    if (tf) printf("0");
    else printf("%lld\n",ans-lalal);
    return 0;
}

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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

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

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll ans=0;
    rep(i,1,n+1){
    	ll cnt=0;
    	ll t=i;
    	while(t){
    		cnt++;t=t/10;
    	}
    	if(cnt&1)	ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip>    // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <map>
#include <bits/stdc++.h>
#define MOD (1e+9)+7
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cerr << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(){

    long long int N,x;
    cin >> N >> x;
    long long int a[N];
    long long int sum = 0;
    REP(i,N){
        cin >> a[i];
        sum += a[i];
    }
    if(x == 0){
        cout << sum << endl;
        return 0;
    }
    long long int ans = 0;
    REP(i,N-1){
        if(a[0] > x){
            ans += a[0] - x;
            a[0] -= a[0] - x;
        }

        if(a[i]+a[i+1] > x){
            ans += a[i]+a[i+1] - x;
            a[i+1] -= a[i]+a[i+1] - x;
        }
        
    }
    
    // REP(i,N){
    //     cout << a[i] << " ";
    // }
    // cout << endl;
    

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


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>

using namespace std;


int main() {

    int N, M;
    cin >> N >> M;

    int leftMax = 0;
    int rightMin = 100000 + 1;

    for (int i = 0; i < M; i++) {
        int L, R;
        cin >> L >> R;

        leftMax = max(leftMax, L);
        rightMin = min(rightMin, R);
    }

    int result = 0;

    for(int i =1; i<= N; i++) {

        if((leftMax <= i) and (i <= rightMin)) {
            result += 1;
        }

    }

    cout << result << "\n";

    return 0;
}

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

		string s;
		cin>>s;
		int cnt = 0;
		for(int i=0;i<s.size();i++){
			if(s[i] == s[s.size() -1 -i]){}
				else{s[i] = s[s.size()-1-i];cnt++;}
		}
		cout << cnt<<endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, N2, c, K=0;

    cin >> N;

    N2 = N;

    while(N2>0){
        N2 /= 10;
        K++;
    }

    c = N / pow(10,K-1);

    if(N+1 == (c+1)*pow(10,K-1)){
        cout << c+9*(K-1) << endl;
    }
    else cout << c+9*(K-1)-1 << endl;

    return 0;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }

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

    int a, b, c; cin >> a >> b >> c;
    if(a <= c && c <= b) Yes;
    else No;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	bool N[4] = { 0 };

	for (int i = 0; i < 4; i++)
	{
		int X;
		cin >> X;
		if (X == 1) {
			N[0] = true;
		}
		else if (X == 9) {
			N[1] = true;
		}
		else if (X == 7) {
			N[2] = true;
		}
		else if (X == 4) {
			N[3] = true;
		}
	}

	if (N[0] && N[1] && N[2] && N[3]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

int main()
{
	int a[3][3];
	int b[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
			b[i][j] = 0;
		}
	}

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x = 0;
		cin >> x;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (x == a[i][j]) {
					b[i][j] = 1;
				}
			}
		}
	}
	

	if (b[0][0] == 1 && b[0][1] == 1 && b[0][2] == 1) {
		cout << "Yes" << endl;
	}
	else if (b[1][0] == 1 && b[1][1] == 1 && b[1][2] == 1) {
		cout << "Yes" << endl;
	}
	else if (b[2][0] == 1 && b[2][1] == 1 && b[2][2] == 1) {
		cout << "Yes" << endl;
	}
	else if (b[0][0] == 1 && b[1][0] == 1 && b[2][0] == 1) {
		cout << "Yes" << endl;
	}
	else if (b[0][1] == 1 && b[1][1] == 1 && b[2][1] == 1) {
		cout << "Yes" << endl;
	}
	else if (b[0][2] == 1 && b[1][2] == 1 && b[2][2] == 1) {
		cout << "Yes" << endl;
	}
	else if (b[0][0] == 1 && b[1][1] == 1 && b[2][2] == 1) {
		cout << "Yes" << endl;
	}
	else if (b[0][2] == 1 && b[1][1] == 1 && b[2][0] == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
ll n,a;
ll calc(ll k){
    ll r=pow(n,1/(double)k);
    ll cur=pow(r,k),sum=k*r;
    while(cur<n)cur=cur*(r+1)/r,sum++;
    return a*(k-1)+sum;
}
int main(){
  cin>>n>>a; //if(n>1e6)return 0;
  ll ans=3e18;
  for(ll i=1;i<60;i++)ans=min(ans,calc(i));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
if s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()
ns = [ord(c) - 97 for c in s]
ns_ = [i for i in range(26) if i not in ns]
if len(ns) == 26:
    ms = [0]
    while True:
        ms.append(ns.pop())
        if ms[-1] < ms[-2]:
            min_m = 27
            for m in ms:
                if m < min_m and m > ms[-1]:
                    min_m = m
            ns.append(min_m)
            break
else:
    ns.append(min(ns_))
cs = [chr(n + 97) for n in ns]
print(''.join(cs))


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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int main() {
    string S;
    cin >> S;
    int ans = 0;

    for (int i = 0; i <= S.length(); i++) {
        int cnt = 0;
        for (int j = i; j <= S.length(); j++) {
            if (S[j] == 'A' or S[j] == 'T' or S[j] == 'G' or S[j] == 'C') {
                cnt++;
            } else {
                ans = max(ans, cnt);
                break;
            }
        }
    }

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


Measured memory_bytes: 256
# ABC118b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [list(map(int, input().split()))[1:] for _ in range(n)]
ans = set(a[0])
for i in a:
    ans = ans.intersection(set(i))
print(len(ans))


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, T;
    cin >> A >> B >> T;
    cout << (T / A) * B << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  set<string> memo;
  bool flg = true;

  char bef = '_';
  rep(i, n) {
    string w;
    cin >> w;
    if (!flg) continue;

    if (memo.find(w) != memo.end()) flg = false;
    memo.insert(w);

    if (i != 0 && bef != w[0]) flg = false;
    bef = w.back();
  }

  cout << (flg ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7

N = int(readline())

x = pow(10, N, MOD)
x -= pow(9, N, MOD) * 2
x += pow(8, N, MOD)
print(x % MOD)

Measured memory_bytes: 9236