akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int a, b;
    int sum = 0;
    scanf("%d", &a);
    scanf("%d", &b);

    for (int B = b-a; B > 0; B -= (a-1)){
        sum++;
    }

    if (b == 1) {
        printf("%d\n", 0);
    }
    else{
        printf("%d\n", sum+1);
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
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);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

typedef complex<double> P;
typedef pair<P, P> L;

signed main() {
    int N; cin >> N;
    queue<L> q;
    q.push(make_pair(P(0, 0), P(100, 0)));
    double theta = M_PI / 3.0;
    rep(k,0,N) {
        int cnt = 1LL << (2*k);
        while(cnt--) {
            L t = q.front(); q.pop();
            P vec = t.second - t.first;

            double x = vec.real() * cos(theta) - vec.imag() * sin(theta);
            double y = vec.real() * sin(theta) + vec.imag() * cos(theta);
            P rot(x, y);

            P ps[5];
            rep(i,0,5) {
                if(i <  2) ps[i] = t.first + i / 3.0 * vec;
                if(i == 2) ps[i] = t.first + 1.0 / 3.0 * vec + rot / 3.0;
                if(i >  2) ps[i] = t.first + (i-1) / 3.0 * vec;
            }
            rep(i,0,4) {
                q.push(make_pair(ps[i], ps[i+1]));
            }
        }
    }

    bool init = true;
    while(!q.empty()) {
        L t = q.front(); q.pop();
        if(init) printf("%.12f %.12f\n", t.first.real(), t.first.imag());
        printf("%.12f %.12f\n", t.second.real(), t.second.imag());
        init = false;
    }
    return 0;
}

Measured memory_bytes: 3332
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int x;
    cin>>x;
    int d=x;
    int ii=0;
    vector<int> abcd(4);
    vector<int> abcdcopy(4);
    while(d>0){
        abcd[ii]=d%10;
        d/=10;
        ii++;
    }
    reverse(abcd.begin(),abcd.end());
    int sum=0;
    vector<char> op(3);
    abcdcopy[0]=abcd[0];
    for(int bit=0;bit<(1<<3);bit++){
        sum=0;
        for(int i=0;i<3;i++){
            if(bit&(1<<i)){
                abcdcopy[i+1]=abcd[i+1];
                op[i]='+';
            }else{
                abcdcopy[i+1]=-abcd[i+1];
                op[i]='-';
            }
        }
        for(int i=0;i<4;i++){
            sum+=abcdcopy[i];
        }
        if(sum==7){
            cout<<abcd[0]<<op[0]<<abcd[1]<<op[1]<<abcd[2]<<op[2]<<abcd[3]<<"=7";
            return 0;
        }
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    vector<pi> from, to;
    vector<vi> table(h, vi(w));
    rep(i,h)rep(j,w){
        cin>>table[i][j];
    }
    rep(i,h)rep(j,w){
        if (i==h-1 && j==w-1) break;
        if (table[i][j]&1){
            from.emplace_back(i+1,j+1);
            if (j==w-1){
                table[i+1][j]++;
                to.emplace_back(i+2,j+1);
            }else{
                table[i][j+1]++;
                to.emplace_back(i+1,j+2);
            }
        }
    }
    cout<<from.size()<<endl;
    rep(i,from.size()){
        cout<<from[i].fi<<" "<<from[i].se<<" ";
        cout<<to[i].fi<<" "<<to[i].se<<endl;
    }
    return 0;
}


Measured memory_bytes: 5356
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

using namespace std;

vector<int> L;
int N;

int binary_serch(int n) {
	int ok = 0;
	int ng = N;
	int mid = (ok + ng) / 2;
	while (ng - ok > 1) {
		mid = (ok + ng) / 2;
		if (L[mid] < n) ok = mid;
		else ng = mid;
	}
	return ok;
}

signed main() {
	cin >> N;

	L = vector<int>(N+1);
	REP(i, N) cin >> L[i];
	L[N] = 1e9;

	sort(ALL(L));

	long long ans = 0;
	REP(i, N-1) FOR(j, i + 1, N) {
		int k = binary_serch(L[i] + L[j]);
		ans += max(k - j, 0);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  static int p = 1000000007;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    long ans = 0;
    long n = inv(2, N);
    if(n != 0) n -= 1;
    long c = 1;
    long n1 = 1;
    for(int i = 0; i < a; i++){
      n1 *= N-i;
      n1 %= p;
      c *= a-i;
      c %= p;
    }
    
    long d = 1;
    long n2 = 1;
    for(int i = 0; i < b; i++){
      n2 *= N-i;
      n2 %= p;
      d *= b-i;
      d %= p;
    }
    
    
    n -= (n1 * inv(c,p-2) % p);
    n -= (n2 * inv(d,p-2) % p);
    while(n < 0){
      n += p;
    }
    System.out.println(n);
  }
  
  public static long inv(long n, int k){
    if(k == 0){
      return 1;
    }
    
    if(k%2 == 0){
      long l = inv(n, k/2);
      return l * l % p;
    }else{
      return n * inv(n, k-1) % p;
    }
  }
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    string t = s;
    reverse(t.begin(), t.end());
    s += t;
    int l = 0;
    for(int i = 1; i <= n; i++){
        if(s.substr(i, n) < s.substr(l, n)) l = i;
    }
    int c, r = 0;
    for(c = 1; c < n; c++){
        if(s[l + c] != s[l]){
            r = l + c;
            break;
        }
    }
    for(int i = 0; i < k - 1; i++){
        c <<= 1;
        if(c >= n){
            c = n;
            break;
        }
    }
    for(int i = 0; i < c; i++) cout << s[l];
    for(int i = 0; i < n - c; i++) cout << s[r + i];
    cout << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

class UnionFind {
public:
  vector<int> par, rank; // parent(negative := its root and abs-value is its size), depth
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;  // already belong to same tree
    if(rank[x] < rank[y]){  // y becomes parent node
      par[y] += par[x];
      par[x] = y;
    } else {  // x becomes parent node
      par[x] += par[y];
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int size(int x){ return -par[find(x)]; }
};

vector<int> x[100005];
vector<int> y[100005];

int main(){
  int n,w,h;
  cin>>n>>w>>h;
  rep(i,n){
    int p,q;
    cin>>p>>q;
    p--;q--;
    x[p].pb(i);
    y[q].pb(i);
  }

  UnionFind uf(n);

  rep(i,100005){
    rep(j,x[i].size()-1) uf.unite(x[i][j], x[i][j+1]);
  }
  rep(i,100005){
    rep(j,y[i].size()-1) uf.unite(y[i][j], y[i][j+1]);
  }

  if(uf.size(0)==n){ cout << n-1 << endl; }
  else {
    vector<bool> checked(n, false);
    int cnt = 0;
    rep(i,n){
      int p = uf.find(i);
      if(!checked[p]){
        checked[p] = true;
        cnt++;
      }
    }
    int hoge = 0;
    if(x[0].size()>0 || x[w-1].size()>0 || y[0].size()>0 || y[h-1].size()>0) hoge++;

    cout << (n-cnt) + cnt + cnt-1-hoge << endl;
  }

  return 0;
}

Measured memory_bytes: 9900
#include<iostream>
  
int const MAXN = 21;
int const MOD = 1000000007;

int N;
int a[MAXN][MAXN];
int dp[2][1<<MAXN];

inline int next(int comb) {
  int x = comb&-comb, y = comb + x;
  comb = ((comb&~y)/x >> 1) | y;
  return comb;
}

int main() {
  std::cin >> N;
  for(int i = 0; i < N; ++i) for(int j = 0; j < N; ++j) std::cin >> a[i][j];

  dp[0][0] = 1;
  for(int n = 1; n <= N; ++n) {
    for(int comb = (1<<n)-1; comb < 1<<N; comb = next(comb)) {
      int tmp = 0;
      for(int k = 0; k < N; ++k) if((1<<k)&comb) if(a[n-1][k]) {
        tmp = (tmp + dp[(n-1)%2][comb&~(1<<k)]) % MOD;
      }
      dp[n%2][comb] = tmp;
    }
  }
  std::cout << dp[N%2][(1<<N)-1] << std::endl;

  return 0;
}


Measured memory_bytes: 16640
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX 25
#define NIL -1
struct Node{
  int parent,left,right;
};

struct Node T[MAX];

int getSib(int id){
  if(T[id].parent==NIL) return -1;
  int p=T[id].parent;
  if(T[p].left != id) return T[p].left;
  else return T[p].right;
}

int getDegree(int id){
  int cnt=0;
  if(T[id].left != NIL) cnt++;
  if(T[id].right != NIL) cnt++;
  return cnt;
}

int getDepth(int id){
  int p=id;
  int dep=0;
  while(T[p].parent != NIL){
    dep++;
    p=T[p].parent;
  }
  return dep;
}

int getHeight(int id){
  if(T[id].left==NIL && T[id].right==NIL){
    return 0;
  }else if(T[id].left==NIL){
    return getHeight(T[id].right)+1;
  }else if(T[id].right==NIL){
    return getHeight(T[id].left)+1;
  }else{
    return max(getHeight(T[id].left),getHeight(T[id].right))+1;
  }
}

string getType(int id){
  if(T[id].parent==NIL) return "root";
  else if(T[id].left==NIL && T[id].right==NIL) return "leaf";
  else return "internal node";
}

int main(){
  int n; scanf("%d",&n);
  for(int i=0;i<n;i++){
    T[i].left=NIL;
    T[i].right=NIL;
    T[i].parent=NIL;
  }
  for(int i=0;i<n;i++){
    int id,l,r;
    scanf("%d %d %d",&id,&l,&r);
    if(l!=NIL){
      T[id].left=l; T[l].parent=id;
    }
    if(r!=NIL){
      T[id].right=r; T[r].parent=id;
    }
  }
  for(int id=0;id<n;id++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
    ,id,T[id].parent,getSib(id),getDegree(id),getDepth(id),getHeight(id));
    cout << getType(id) << endl;
  }
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<ll> A(N+1);
    rep(i,N){
        ll a;
        cin >> a;
        A[i+1] = A[i] + a;
    }
    ll ans = INF;
    for(int i=1;i<N;i++){
        ans = min(ans,abs(A[N] - 2*A[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
N,M=map(int,input().split())
s=[0]*M
c=[0]*M

for i in range(M):
  s[i],c[i]= map(int,input().split())

if M==0:
  for j in range(1000):
    k=str(j)
    if len(k)==N:
      ans=j
      break
else:
  max_s=max(s)
  ans=-1
  for j in range(1000):
    flag=True
    k=str(j)
    if len(k)!=N:
      pass
    else:
      for l in range(M):
        if int(k[s[l]-1])!=c[l]:
          flag=False
          break
      if flag==True:
        ans=j
        break
      
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#define maxn 100005

using namespace std;

int a[maxn];
int n;

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if (n==1) {	
		printf("%d\n",n);
		return 0;
	}
	int cur=a[1];
	int app=1;
	int ans=0;
	for (int i=2;i<=n;i++) {
		if (a[i]==cur) app++;
			else {
				if (app % 2==1) {
					ans++;
				}
				app=1;
				cur=a[i];
			}
	} 
	if (app % 2==1) ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,int> P;

long long  lcm(long long x,long long y){
  long long mindata,maxdata;
  mindata=min(x,y);
  maxdata=max(x,y);
  while(maxdata%mindata!=0){
    long long temp;
    temp=maxdata%mindata;
    maxdata=mindata;
    mindata=temp;
  }
  return x*y/mindata;
}



int main(){
  ll A,B,C,D,ansL,ansS;
  cin>>A>>B>>C>>D;
  ansL=B/C+B/D-B/lcm(C,D);
  ansS=(A-1)/C+(A-1)/D-(A-1)/lcm(C,D);
  cout<<(B-A+1)-ansL+ansS<<endl;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;

    auto dp = new long[][](N+1, 2);
    dp[0][1] = 1;

    auto imos = new long[](3*N);
    long INV = powmod(N-1, MOD-2, MOD);
    long ans = 0;

    foreach (i; 0..N) {
        (dp[i+1][0] += dp[i][1] * (N - 1) % MOD) %= MOD; // 1のあとに2〜N
        (dp[i+1][1] += dp[i][1]) %= MOD; // 1のあとに1
        (dp[N][0] += dp[i][0] * (N - 1) % MOD) %= MOD; // 2〜Nのあとに2〜N (無限ループ)

        // 2〜Nのあとに1
        (imos[i+2] += dp[i][0] * INV % MOD) %= MOD;
        (imos[i+N+1] -= dp[i][0] * INV % MOD) %= MOD;

        (imos[i+1] += imos[i]) %= MOD;
        (dp[i+1][1] += imos[i+1]) %= MOD;
    }

    foreach (i; N..3*N-1) {
        (imos[i+1] += imos[i]) %= MOD;
        (ans += imos[i+1]) %= MOD;
    }

    ans = (ans + dp[N].sum % MOD + MOD) % MOD;
    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}


Measured memory_bytes: 74108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    char tmp = S[0];
    int ans = 1;
    for(int i=1;i<N;i++){
        if(S[i]!=tmp){
            ans++;
            tmp = S[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
fn input_line() -> Vec<i64> {
    use std::str::FromStr;
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|n| i64::from_str(n).unwrap())
        .collect()
}

fn main() {
    let it = input_line();
    let (n, k) = (it[0], it[1]);
    let mut vec: Vec<i64> = input_line();

    let mut sum: i64 = 0;

    for _ in 0..k {
        let mut m = 0;
        for i in 0..n {
            m = if vec[m] < vec[i as usize] { 
                i as usize
            } else {
                m
            }
        }
        sum = sum + vec[m];
        vec[m] = 0
    }
    println!("{}", sum);
}


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

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

    long long int redNum, greenNum, blueNum, tot;
    cin >> redNum >> greenNum >> blueNum >> tot;

    long long int ans = 0;
    for (int i = 0; i * redNum <= tot; i++) {
        for (int j = 0; i * redNum + j * greenNum <= tot; j++) {
            if ((tot - (i * redNum + j * greenNum)) % blueNum == 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

    int a[3][3];
    rep(i,3){
        rep(j,3){
            cin>>a[i][j];
        }
    }

    int n;
    cin>>n;
    rep(_,n){
        int b;
        cin>>b;
        rep(i,3){
            rep(j,3){
                if(a[i][j]==b) a[i][j]=-1;
            }
        }
    }

    bool flag=false;

    rep(i,3){
        flag|=(a[i][0]==a[i][1]&&a[i][1]==a[i][2]);
    }

    rep(j,3){
        flag|=(a[0][j]==a[1][j]&&a[1][j]==a[2][j]);
    }

    flag|=(a[0][0]==a[1][1]&&a[1][1]==a[2][2]);
    flag|=(a[0][2]==a[1][1]&&a[1][1]==a[2][0]);

    Yes(flag);


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int h,w;
  cin >> h >> w;
  vector<vector<int>> da(h,vector<int>(w,0));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> da[i][j];
    }
  }
  int co=0;
  vector<vector<int>> ans(0);
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      if(da[i][j]%2==1){
        da[i][j]--;
        da[i][j+1]++;
        ans.push_back({i+1,j+1,i+1,j+2});
        co++;
      }
    }
  }
  for(int i=0;i<h-1;i++){
    if(da[i][w-1]%2==1){
      da[i][w-1]--;
      da[i+1][w-1]++;
      ans.push_back({i+1,w,i+2,w});
      co++;
    }
  }
  cout << co << endl;
  for(int i=0;i<co;i++){
    for(int j=0;j<3;j++){
      cout << ans[i][j] << ' ';
    }
    cout << ans[i][3] << endl;
  }
  /*for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      cout << da[i][j] << ' ';
    cout << endl;
  }*/
}

Measured memory_bytes: 10032
#include <bits/stdc++.h>
using namespace std;
long MOD = 1e9+7;
int main(){
    long n,a[26]={},cnt=1;
    string s;
    cin >> n >> s;
    for(int i=0;i<n;i++) a[s[i]-97]++;
    for(int i=0;i<26;i++) cnt =  (cnt * (a[i]+1))%MOD;
    cout << cnt-1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N; cin >> N;
	char S[100][1];
	rep(i, 0, N) {
		cin >> S[i];
		if (S[i][0] == 'Y') {
			cout << "Four" << endl;;
			return 0;
		}
	}
	cout << "Three" << endl;;

	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a%b
	return a

def lcm(a, b):
	return a*b // gcd(a, b)

def lcm_list(A):
	ans = A[0]
	for i in range(1, len(A)):
		ans = lcm(ans, A[i])
	return ans


N = int(input())
T = [int(input()) for i in range(N)]

if N==1:
	print(T[0])
else:
	print(lcm_list(T))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
const ll INF = 1LL<<60;
 
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
 
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
   	
   	ll A, B;
  	int K;
   	
   	cin >> A >> B >> K;
   	
   	if(A+K < B-K+1){
   		for(int i = A; i < A + K; i++){
   			cout << i << endl;
   		}
   		for(int i = B-K+1; i <= B; i++){
   			cout << i << endl;
   		}
   	}else{
   		for(int i = A; i <= B; i++){
   			cout << i << endl;
   		}
   	}
   	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int H,W;
  cin>>H>>W;
  vector<string> line(H);
  for(int i=0;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;
  for(int i=0;i<H;i++){
    cin>>line.at(i);
    cout<<"#"+line.at(i)<<"#"<<endl;
  }
  for(int i=0;i<W+2;i++){
  cout<<"#";
  }  
}


Measured memory_bytes: 3568
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
ans = 0
MAX = 0
for i in range(N):
    if i == 0:
        kari = A1[0]+sum(A2)
    elif i == N-1:
        kari = sum(A1)+A2[-1]
    else:
        kari = sum(A1[0:i+1])+sum(A2[i:])
    if MAX <= kari:
        MAX = kari
print(MAX)

Measured memory_bytes: 3064
n=int(input())
#a,b,x=map(int,input().split())
bl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

al=[0 for i in range(n)]

al[n-1]=bl[-1]

for i in range(n-2,-1,-1):
    al[i]=bl[i]
    if al[i+1]>bl[i]:
        al[i+1]=bl[i]

print(sum(al))


Measured memory_bytes: 3060
N = int(input())
v_list = list(map(int, input().split()))

v_list_sorted = sorted(v_list)

sum = 0
tmp_min = 0

if N == 1:
    print(v_list[0])
    exit(0)

for i in range(0, N - 1):
    if i == 0:
        merged = (v_list_sorted[i] + v_list_sorted[i + 1]) / 2.0
        tmp_min = merged
        sum = merged
    else:
        tmp_min = (tmp_min + v_list_sorted[i + 1]) / 2.0
print(tmp_min)



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

using namespace std;

int main()
{
    int a[5], c = 0;

    for (int i = 0; i < 5; i++)
    {
        c++;
        scanf("%d", &a[i]);
        if (a[i] == 0)
        {
            printf("%d", c);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////

int main(){
    
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll sum=0;rep(i,0,n-2)sum+=a[i];
    if(sum>a[n-1])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int a; cin >> a;
  cout << a + a * a + a * a * a << "\n";
  return 0;
}

Measured memory_bytes: 3592
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define ff first
#define ss second

int n,m;
int val[maxn];
ll all,dis[maxn],sum1[maxn],sum2[maxn],mx1[maxn],mx2[maxn];

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

inline ll read_ll(){
	ll x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read(),all=read_ll();
	for (int i=1;i<=n;i++) dis[i]=read_ll(),val[i]=read();
	for (int i=1;i<=n;i++) sum1[i]=sum1[i-1]+val[i];
	for (int i=n;i;i--) sum2[i]=sum2[i+1]+val[i];
	ll ans=0;
	for (int i=1;i<=n;i++) mx1[i]=max(mx1[i-1],sum1[i]-dis[i]),ans=max(ans,mx1[i]);
	for (int i=n;i;i--) mx2[i]=max(mx2[i+1],sum2[i]-(all-dis[i])),ans=max(ans,mx2[i]);
	for (int i=1;i<n;i++) ans=max(ans,sum1[i]-2*dis[i]+mx2[i+1]);
	for (int i=n;i>1;i--) ans=max(ans,sum2[i]-2*(all-dis[i])+mx1[i-1]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int h; cin >> h;
  int ans = 1;
  while(h) {
    h /= 2;
    ans *= 2;
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanLines)
	s := read()
	rv := ""
	cols := strings.Split(s, "")
	for i := 0; i < len(cols); i++ {
		rv += cols[len(cols)-1-i]
	}
	fmt.Println(rv)
}



Measured memory_bytes: 1068
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define max(l,r) ((l)>(r)?(l):(r))
#define min(l,r) ((l)<(r)?(l):(r))

ll x[202020],y[202020];
ll wa[202020], wai[202020];
ll sa[202020], sai[202020];

/////merge sort(ll)
ll tllar[202020];
void msortll(ll *ar, int l, int r){ // [l,r)
    if(r-l<=1) return;
    int mid=(l+r)/2;
    if(r-mid>1) msortll(ar,mid,r);
    if(mid-l>1) msortll(ar,l,mid);
    for(int li=l,ri=mid,afi=l;afi<r;afi++){
        if(ri>=r||(li<mid&&ri<r&&ar[li]<=ar[ri])) tllar[afi]=ar[li++]; //cmp
        else tllar[afi]=ar[ri++];
    }
    for(int i=l;i<r;i++) ar[i]=tllar[i];
}
/////

int main(){
    int n; scanf("%d", &n);
    rep(i,n){
        scanf("%lld%lld", &x[i], &y[i]);
        wa[i] = x[i] + y[i];
        wai[i] = -wa[i];
        sa[i] = x[i] - y[i];
        sai[i] = -sa[i];
    }
    msortll(wa,0,n);
    msortll(wai,0,n);
    msortll(sa,0,n);
    msortll(sai,0,n);

    ll ans = max(max(wa[n-1]-wa[0],sa[n-1]-sa[0]),max(wai[n-1]-wai[0],sai[n-1]-sai[0]));
    printf("%lld\n", ans);
    //rep(i, n) scanf("%lld", ans+i);
    //if(ans){ puts("YES"); rep(i,n) printf("%lld ", a[i]);}else puts("NO");
}


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

typedef long long ll;
const ll MOD = 1000000007;

int N, M;
vector<vector<int>> G, rG;
vector<bool> vis;
vector<int> vs;
vector<int> S;
vector<vector<int>> s;

void dfs(int v){
    vis[v] = true;
    for(int i=0; i<G[v].size(); i++)
        if(!vis[G[v][i]]) dfs(G[v][i]);
    vs.push_back(v);
}

void rdfs(int v, int k){
    vis[v] = 1;
    S[v] = k; s[k].push_back(v);
    for(int i=0; i<rG[v].size(); i++)
        if(!vis[rG[v][i]]) rdfs(rG[v][i],k);
}

void scc(){
    for(int i=0; i<N; i++)if(!vis[i]) dfs(i);
    for(int i=0; i<N; i++)
        vis[i] = false;
    
    reverse(vs.begin(), vs.end());
    
    s.clear();
    for(int i=0; i<N; i++) if(!vis[vs[i]]){
        s.push_back(vector<int>());
        rdfs(vs[i],s.size()-1);
    }
    vector<int> rs(N);
    N = s.size();
    for(int i=0; i<N; i++)
        for(int v: s[i])
            rs[v] = i;
    
    
    vector<vector<int>> tG(N);
    vector<vector<int>> trG(N);
    for(int i=0; i<N; i++){
        vector<bool> done(N);
        for(int u: s[i]){
            for(int v: G[u]) if(rs[v]!=i && !done[rs[v]]){
                done[rs[v]] = true;
                tG[i].push_back(rs[v]);
            }
            for(int v: rG[u]) if(rs[v]!=i && !done[rs[v]]){
                done[rs[v]] = true;
                trG[i].push_back(rs[v]);
            }
        }
    }
    G = tG;
    rG = trG;
}

ll tree(int u){
    if(rG[u].size() == 0) //leaf
        return 2;
    
    ll res = 1;
    for(int v: rG[u])
        res = (res * tree(v)) % MOD;
    return res + 1;
}

int main(){
    cin >> N >> M;
    G.resize(N); rG.resize(N);
    vis.resize(N); S.resize(N);

    for(int i=0; i<M; i++){
        int s, d; cin >> s >> d; s--; d--;
        G[s].push_back(d);
        rG[d].push_back(s);
    }
    
    scc();
    
    ll ans = 1;
    for(int i=0; i<N; i++){
        if(G[i].size() == 0) //root
            ans = (ans * tree(i)) % MOD;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3436
#include<iostream>
#include<stdio.h>   
#include<math.h>
#include<string> 
#include<set>  
using namespace std;    
bool ok(int a)
{
int b[5];
b[0]=a/10000;
b[1]=(a/1000)%10;
b[2]=(a/100)%10;
b[3]=(a/10)%10;
b[4]=a%10;
 for(int i=0;i<2;i++)
 {if(b[i]!=b[4-i])
  return false;}
 return true;}
int main()   
{   
int a,b,cnt=0;
cin>>a>>b;
for(int i=a;i<=b;i++)
if(ok(i)==true)
cnt++;
cout<<cnt;
system("pause");
return 0;  
}

Measured memory_bytes: 504
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int t = a % b;
  while(1){
    if(t == c){
      cout << "YES" << endl;
      return 0;
    }

    t = (t + a) % b;

    if(t == a % b){
      cout << "NO" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b = f()
    c = a * 10**len(str(b)) + b

    d = int(c**0.5)
    if d**2 == c:
        print('Yes')
    else:
        print('No')

solve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll i,j,k,m,n,t;
	string s1,s2;
	cin>>s1>>s2;
	ll l1=s1.length();
	ll l2=s2.length();
	ll ans=INT_MAX;
	for(i=0;i+l2-1<l1;i++)
	{
		ll ctr=0;
		j=i;
		for(auto x:s2)
		{
			if(x!=s1[j]) ctr++;
			j++;
		}
		ans=min(ans,ctr);
	}
	cout<<ans;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	inputs := scanNums(N)

	maxValue := 0
	secondValue := 0
	maxValueCols := []int{}
	for i, v := range inputs {
		if maxValue == v {
			maxValueCols = append(maxValueCols, i)
		} else if v > maxValue {
			secondValue = maxValue
			maxValue = v
			maxValueCols = []int{i}
		} else if v > secondValue {
			secondValue = v
		} else {
			continue
		}
	}
	res := createRes(N, maxValue, secondValue, maxValueCols)

	for _, v := range res {
		fmt.Println(v)
	}

}

func createRes(N, maxValue, secondValue int, maxValueCols []int) (res []int) {
	for i := 0; i < N; i++ {
		res = append(res, maxValue)
	}
	if len(maxValueCols) == 1 {
		res[maxValueCols[0]] = secondValue
	}
	return
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 12544
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int result1 = A + B;
    int result2 = A - B;
    int result3 = A * B;
    
    int values [] = {result1,result2,result3};
    int max = values[0];
    
    for(int i = 1; i < values.length;i++){
      max = Math.max(max, values[i]);
    }
    
    System.out.println(max);
    


 
  }
}

Measured memory_bytes: 23124
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n,sum;
bool P,W,G,Y;
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		if (s=="P")
		   if (!P)
		   {
		   	  P=true;
		   	  sum++;
		   }
		if (s=="W")
		   if (!W)
		   {
		   	  W=true;
		   	  sum++;
		   }
		if (s=="G")
		   if (!G)
		   {
		   	  G=true;
		   	  sum++;
		   }
		if (s=="Y")
		   if (!Y)
		   {
		   	  Y=true;
		   	  sum++;
		   }
	}
	if (sum==3)
	   cout<<"Three";
	else
	   cout<<"Four";
    return 0;
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int N = s.length();
    long ans = 0;
    long dp[N + 1][2];
    dp[0][0] = 1;
    dp[0][1] = 0; //ぴったり払うときにフラグ１
    for(int i=1; i<=N; i++){
        int n = s[i-1] - '0';
        dp[i][0] = min(dp[i-1][0] + (9 - n), dp[i-1][1] + n + 1);
        dp[i][1] = min(dp[i-1][0] + (10 - n), dp[i-1][1] + n);
    }
    ans = dp[N][1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17028
/*
 * Contents   : AOJ DPL 1 B
 * Author     : KitauraHiromi
 * LastUpdate : 20180610
 * Since      : 20180610
 */
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int N, W;
int dp[101][10001]; // valueを保持
int value[101], weight[101];
int main(void){
    cin >> N >> W;
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<N; ++i) cin >> value[i] >> weight[i];
    for(int i=0; i<N; ++i){
        for(int w=0; w<=W; ++w){
            (w >= weight[i]) ? dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]) : dp[i+1][w] = dp[i][w];
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7056
#include<bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define fread           freopen("input.txt","r",stdin)
#define fwrite          freopen("output.txt","w",stdout)
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define memo(ara,val)   memset(ara,val,sizeof(ara))
#define II              ( { int a ; read(a) ; a; } )
#define LL              ( { ll a ; read(a) ; a; } )
#define DD              ({double a; scanf("%lf", &a); a;})
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              printf("\n")
#define sc(x)           scanf("%lld",&x)
#define scw(x)          scanf("%I64d",&x)
#define sci(x)          scanf("%d",&x)
#define sc2(x,y)        scanf("%lld %lld",&x,&y)
#define sc3(x,y,z)      scanf("%lld %lld %lld",&x,&y,&z)
#define Found(a, b)     a.find(b) != a.end()
// bool operator< (const node& sx) const { return sx.val < val; }
//set<ll,greater<ll> >st;
//priority_queue<ll , vector<ll> , greater<ll> >
template<class T>inline bool read(T &x){ int c=getchar();int sgn=1;
  while(~c&&c<'0'|c>'9'){if(c=='-')sgn=-1;c=getchar();}
  for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())x=x*10+c-'0';x*=sgn;return ~c;
}
const ll N = 1005;
const ll MOD = 1e9+7;
ll dp[N][N];
char ara[N][N];
ll h, w;
ll solve(ll i, ll j){
   if(dp[i][j]!=-1) return dp[i][j];
   if(i==h-1 && j==w-1) return 1;
   if(i >=h || j>=w) return 0;
   ll s = 0;
   if(ara[i][j+1]=='.') s += solve(i, j+1);
   if(ara[i+1][j]=='.') s += solve(i+1, j);
   s %= MOD;
   return dp[i][j] = s;
}
int main(){
   //fread;
     h = LL, w = LL;
    rep(i,h) rep(j,w) cin >> ara[i][j];
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << endl;
}











Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  double ret = 0;
  for (int i = 0; i < n; i++) {
    double x;
    cin >> x;
    string u;
    cin >> u;
    if (u == "JPY") {
      ret += x;
    } else {
      ret += x * 380000.0;
    }
  }
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 256
from string import*;from itertools import*;b=ascii_lowercase;s=r=input();t=s[::-1];d=0
if len(s)>25:d=-[p*len(list(k))for p,k in groupby([i<j for i,j in zip(t,t[1:])])][0]-2;s,b,r=s[:d],s[d+1:],b[:ord((s*2)[d])-97]
print(-(d<-26)or s+sorted(set(b)-set(r))[0])

Measured memory_bytes: 3772
#include<cstdio>
#include<algorithm>
#define N 2200
#define mod 1000000007
using namespace std;
int f[N][N],s[N],n,k,ans;
int main(){
	//freopen("arc.in","r",stdin);
	scanf("%d%d",&n,&k);f[0][n+1]=1;s[n+1]=1;
	for (int i=n;i>=1;--i) s[i]=s[i+1]+f[0][i];
	for (int i=1;i<=k-1;++i){
		for (int j=1;j<=n-i+1;++j) f[i][j]=s[j];
		s[n+1]=f[i][n+1];for (int j=n;j>=1;--j) s[j]=(s[j+1]+f[i][j])%mod;
	}for (int i=2;i<=n+1;++i) (ans+=f[k-1][i])%=mod;
	for (int i=1;i<=n-k-1;++i) (ans*=2)%=mod;printf("%d",ans);
	return 0;
}

Measured memory_bytes: 18560
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
ll dp[100005][66],n;
int compute(int pos,int rem){
	if(rem<0){
		return 1;
	}
	if(pos==0){
		if(rem==0){
			return 1;
		}
		return 0;
	}
	if(dp[pos][rem]!=-1){
		return dp[pos][rem];
	}
	int i;
	dp[pos][rem]=0;
	rep(i,rem+1){
		dp[pos][rem]+=compute(pos-1,i);
		dp[pos][rem]%=mod;
	}
	return dp[pos][rem];
}
int main(){
	std::ios::sync_with_stdio(false);
	ll m,i,ans=1,j;
	vi v;
	int cnt[100005]={0};
	cin>>n>>m;
	rep(i,n+2){
		rep(j,65){
			dp[i][j]=-1;
		}
	}
	for(i=2;i*i<=m;i++){
		while(m%i==0){
			m/=i;
			cnt[i]++;
		}
		if(cnt[i]!=0){
			v.pb(cnt[i]);
		}
	}
	if(m!=1){
		v.pb(1);
	}
	rep(i,65){
		compute(n,i);
	}
	rep(i,v.size()){
		//cout<<v[i]<<endl;
		ans*=dp[n][v[i]];
		ans%=mod;
	}	
	cout<<ans<<endl;
} 
	

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

typedef long long ll;
 
const int N=2e5+7;
ll n,k,a[N],b[N],c[N],po,ne;
 
bool check(ll x) {
	int p=ne;ll ret=0;
	for (int i=1;i<=ne;i++) {
		while (p>=1&&b[i]*b[p]<x) p--;
		ret+=p;
	}
	p=1;
	for (int i=po;i>=1;i--) {
		while (p<=po&&c[i]*c[p]<x) p++;
		ret+=po-p+1;
	}
	p=po;
	for (int i=1;i<=n;i++) if (a[i]*a[i]>=x) ret--;
	ret/=2;
	for (int i=ne;i>=1;i--) {
		while (p>=1&&b[i]*c[p]<x) p--;
		ret+=p;
	}
	return n*(n-1)/2-ret>=k;
}
 
int main()
{
	scanf("%lld%lld",&n,&k);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++) if (a[i]<0) b[++ne]=a[i];else c[++po]=a[i];
	ll l=-1e18,r=1e18;
	while (l<r) {
		ll mid=(l+r) >> 1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",l-1);
	return 0;
}
//老天，AC吧，再不AC，要被打脸的~~(>_<)~~

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p;
  cin >> n >> p;
  string s;cin>>s;
  long ans=0;
  if(10%p>0){
  	vector<long> vec(p+1,0);
  	int sum=0;
  	vec[0]++;
  	int Pow=1;
  	for(int i=n-1;i>-1;i--){
  	  sum=(sum+(s[i]-'0')*Pow)%p;
 	   vec[sum]++;
 	   Pow=(10*Pow)%p;
  	}
  	for(int i=0;i<p;i++) ans+=vec[i]*(vec[i]-1)/2;
  }
  else{
  	for(int i=n-1;i>-1;i--){
      if((s[i]-'0')%p==0){
        ans+=(i+1);
      }
  	}  
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
let rec f i x a=let w=truncate(2.**(float i))in if w=x then w::a else if w<x then f(i-1)(x-w)(w::a)else f(i-1) x a and q()=q(List.iteri(fun i e->Printf.printf(if i=0then"%d"else" %d")e)(f 9(read_int())[]);print_newline());;try q()with _->()

Measured memory_bytes: 2444
input_num=int(input())
jugy_num=0
slash_num=input_num
while slash_num > 1:
	parcent_num=int(slash_num%10)
	slash_num=int(slash_num/10)
	if parcent_num == 7:
		jugy_num=1
if jugy_num == 1:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 61836
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const int mod=1e9+7;

ll cnt[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    for(int i=1;i<maxn;i++)
    {
        cnt[i]=cnt[i-1]+i;//
        cnt[i]%=mod;
    }
    ll ans=0;
    for(int i=k;i<=n+1;i++)
    {
        ans=ans+1ll*i*n%mod-cnt[i-1]*2+1;
        ans=(ans+mod)%mod;
    }
    cout<<ans<<'\n';

}


Measured memory_bytes: 5188
#include<stdio.h>
int main(void)
{
	int n, m, l, i, j, k, A[100][100] = { 0 }, B[100][100] = { 0 };
	long C[100][100] = { 0 };
	scanf("%d %d %d",&n, &m, &l);

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d", &A[i][j]);
		}
	}

	for (i = 0; i < m; i++)
	{
		for (j = 0; j < l; j++)
		{
			scanf("%d", &B[i][j]);
		}
	}

	for (k = 0; k < n; k++)
	{
		for (i = 0; i < l; i++)
		{
			for (j = 0; j < m; j++)
			{
				C[k][i] += A[k][j] * B[j][i];
			}
		}
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			printf("%ld", C[i][j]);
			if (j+1<l)
			{
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2104
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  temp=0
  x=i
  while i>0:
    temp=int(i%10)+temp
    i=int(i/10)
  i=x
  if temp>=a and temp<=b:
    ans+=i
  
print(ans)

Measured memory_bytes: 3060
N = int(input())
h = list(map(int, input().split()))

a = [0]*N
lst = [0]*(N+1)
cnt = 0

while h != a:
    for i in range(N):
        if h[i] > a[i]:
            h[i] -= 1
            lst[i] = 1
        else:
            h[i] -= 0
            lst[i] = 0
    for j in range(N):
        if lst[j]*lst[j+1] == 0 and lst[j] == 1:
            cnt += 1
        else:
            cnt += 0

print(cnt)

Measured memory_bytes: 3064
N = int(input())
a = list(map(int, input().split()))

answer = 0
t = 0
cursor = 0
while cursor != N:
    # print("X {} {}".format(t, a[cursor]))
    if t == a[cursor]:
        answer += 1
        t = 0
    else:
        t = a[cursor]
    cursor += 1
    # print(t)

print(answer)

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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "] size: " << vec.size() << endl;
}

int main()
{
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if (x - r < 0 || x + r > W || y - r < 0 || y + r > H)
  {
    printf("No\n");
  }
  else
  {
    printf("Yes\n");
  }
}



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

using namespace __gnu_pbds;  
using namespace std;

typedef long long ll;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  ll x; cin >> x;
  ll cur = (x / 500) * 1000;
  x %= 500;
  cur += (x / 5) * 5;
  cout << cur << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

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

int main(){
    int h, w; cin >> h >> w;
    vector<string> data(h); rep(i,h) cin >> data[i];
    vector<vector<int>> ans(h,vector<int>(w,0));

    if(data[0][0] == '#') ans[0][0] = 1;
    rep(i,w-1){
        if(data[0][i+1] == '#' && data[0][i] == '.') ans[0][i+1] = ans[0][i] + 1;
        else ans[0][i+1] = ans[0][i];
    }
    rep(i,h-1){
        if(data[i+1][0] == '#' && data[i][0] == '.') ans[i+1][0] = ans[i][0] + 1;
        else ans[i+1][0] = ans[i][0];
    }
    rep(i,h-1) rep(j,w-1){
        if(data[i+1][j+1] == '#' && data[i][j+1] == '.' && data[i+1][j] == '.')
            ans[i+1][j+1] = min(ans[i][j+1], ans[i+1][j]) + 1;
        else if(data[i+1][j+1] == '#' && data[i][j+1] == '#' && data[i+1][j] == '.')
            ans[i+1][j+1] = min(ans[i][j+1], ans[i+1][j]+1);
        else if(data[i+1][j+1] == '#' && data[i][j+1] == '.' && data[i+1][j] == '#')
            ans[i+1][j+1] = min(ans[i][j+1]+1, ans[i+1][j]);
        else ans[i+1][j+1] = min(ans[i][j+1], ans[i+1][j]);
    }
    cout << ans[h-1][w-1] << endl;
}

Measured memory_bytes: 3664