akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;

class SegTree {
 private:
  const ll def_val_ = INF;
  vl val_;
  ll n_;

  ll comp(ll l, ll r) { return min(l, r); }
  ll getr(ll x, ll y, ll k, ll l, ll r) {
    if (y <= l || r <= x) return def_val_;
    if (x <= l && r <= y) return val_[k];
    auto vl = getr(x, y, 2 * k + 1, l, (l + r) / 2);
    auto vr = getr(x, y, 2 * k + 2, (l + r) / 2, r);
    return comp(vl, vr);
  }

 public:
  SegTree(ll size) {
    n_ = 1;
    while (n_ < size) n_ *= 2;
    val_ = vl(2 * n_, def_val_);
  }
  void update(ll i, ll v) {
    i += (n_ - 1);
    val_[i] = v;
    while (i > 0) {
      i = (i - 1) / 2;
      val_[i] = comp(val_[2 * i + 1], val_[2 * i + 2]);
    }
  }
  // get XXX value between [x,y)
  ll getRange(ll x, ll y) { return getr(x, y, 0, 0, n_); }
};

struct edge {
  ll to, cost;
  edge(ll t, ll c) : to(t), cost(c) {}
};

class Dijkstra {
 private:
  ll n_;
  vector<vector<edge> > G_;
  vl d_;

 public:
  Dijkstra(ll n) : n_(n), G_(n), d_(n, INF) {}
  void addEdge(ll v, ll to, ll cost) { G_[v].push_back(edge(to, cost)); }
  void exec(ll s) {
    priority_queue<pll, vector<pll>, greater<pll> > que;
    d_[s] = 0;
    que.push({0, s});
    while (!que.empty()) {
      pll p = que.top();
      que.pop();
      ll v = p.second;
      if (d_[v] < p.first) continue;
      for (auto& e : G_[v]) {
        if (d_[e.to] > d_[v] + e.cost) {
          d_[e.to] = d_[v] + e.cost;
          que.push({d_[e.to], e.to});
        }
      }
    }
  }
  ll dist(ll g) { return d_[g]; }
};

int main() {
  ll n,m,s,t;
  cin>>n>>m>>s>>t;
  s--,t--;
  Dijkstra gs(n), gt(n);
  rep(i,m) {
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    u--,v--;
    gs.addEdge(u,v,a);
    gs.addEdge(v,u,a);
    gt.addEdge(u,v,b);
    gt.addEdge(v,u,b);
  }
  gs.exec(s);
  gt.exec(t);
  SegTree st(n);
  rep(i,n) {
    st.update(i, gs.dist(i) + gt.dist(i));
  }
  rep(i,n) {
    ll ans = (ll)1e15 - st.getRange(0, n + 1);
    cout << ans << endl;
    st.update(i, INF);
  }
  return 0;
}


Measured memory_bytes: 20352
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
    int N, M;
    cin >> N >> M;
    vector<P> A(N);
    for(int i=0; i<N; ++i) {
        cin >> A[i].first >> A[i].second;
    }
    sort(begin(A), end(A));

    long long res = 0;
    priority_queue<int> Q;
    int cur = 0;
    for(int i=1; i<=M; ++i) {
        while(cur < N && A[cur].first <= i) {
            Q.push(A[cur].second);
            ++cur;
        }
        if(!Q.empty()) {
            res += Q.top();
            Q.pop();
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
using P = pair<ll,ll>;

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

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
signed main(){
    int N;
    cin>>N;
    int ans=0;
    for(int i=1;i<=N;i++){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
S,T=input(),input()
N=len(S)
M=len(T)
U=[]

ans="UNRESTORABLE"
if N>=M:
  for i in range(N-M+1):
    cnt=0
    for j in range(M):
      if S[i+j]==T[j] or S[i+j]=="?":
        cnt+=1
        #print(cnt)
    if cnt==M:
      U.append((S[:i]+T+S[i+M:]).replace("?","a"))
U.sort()
#print(U)

if len(U)>0:
  ans=U[0]
print(ans)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  VI a(n);
  map<int,int> mp;
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(all(a));

  if(a.back() - a[0] >= 2){
    cout << "No" << "\n";
    return 0;
  }


  // a[0] == mm + cnt1 - 1
  // a[0] + 1 == mm + cnt1;
  if(a[0] == a.back()){
    //もしも全て複数ケース存在する場合
    if( n >= 2*a[0]){
      cout << "Yes" << "\n";
      return 0;
    }

    // もしも全てユニークケース
    if(a[0] == (n -1) ){
      cout << "Yes" << "\n";
      return 0;
    }

    cout << "No" << "\n";
  }else{
    // 混在する場合
    ll uniqueCnt = mp[a[0]]; //少ない方の個数
    ll amari = (a[0] - uniqueCnt) + 1;
    // cout << amari << " " << uniqueCnt << endl;
    if(amari <= 0) {
      cout << "No" << "\n";
      return 0;
    }

    if(amari*2 <= mp[a[0]+1] && amari + uniqueCnt == (a[0]+1) ){
      cout << "Yes" << "\n";
      return 0;
    }
    cout << "No" << "\n";

  }

  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    cin >> N;
    vector<string> S(N);
    
    REP(i,N){
        cin >> S.at(i);
    }

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

    ll count = 1;
    for (ll i = 0; i < N - 1; i++)
    {
        if(!(S.at(i)==S.at(i+1))){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 9520
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define do(i,j,k) for(register int i=j;i>=k;i--) 
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
int n; 
ll sum;
int main()
{
	cin>>n;
	fo(i,1,n)
	{
		if(i>2&&(i%3==0||i%5==0)) continue;
		else sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3584
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    C=[tuple(map(int,input().split())) for i in range(n)]
    C.sort()
    honsu=m
    cost=0
    for i,c in enumerate(C):
        cost+=c[0]*min(honsu,c[1])
        honsu-=c[1]
        if honsu<=0:
            break
    print(cost)
if __name__=='__main__':
    main()

Measured memory_bytes: 16976
#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
    long long x,k,d;
    cin >> x >> k >> d;
    
    if(abs(x)/d >= k){
        cout << abs(abs(x)-d*k) << endl;
    } else {
        long long num = (abs(x)/d)*d;
        if((k-abs(x)/d) % 2 == 1){
            long long num2 = abs(x) - (abs(x)/d)*d;
            cout << min(abs(num2-d),abs(num2+d));
        } else {
            cout << abs(abs(x)-num);
        }
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    
    string str="";
    for(int i=0; i<n; i++){
        str.push_back(s[i]);
        str.push_back(t[i]);
    }
    cout<<str<<endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ_C++.cpp : アプリケーションのエントリ ポイントを定義します。
//
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

int main()
{
	double r;
	std::cin >> r;
	double s = r * r * M_PI;
	double cir = 2 * r * M_PI;
	std::cout << std::fixed;
	std::cout << s << " " << cir << std::endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree< ll, null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll mod;

ll pwr(ll a, ll b){
  ll res = 1;
  while(b > 0){
    if(b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

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

  ll n, p;
  cin >> n >> p;
  string s;
  cin >> s;

  mod = p;

  if(10 % p == 0){
    ll ans = 0;
    for(int i = 0; i < n; i++){
      if((s[i] - '0') % p == 0) ans += i + 1;
    }
    cout << ans << endl;
    return 0;
  }

  vector < ll > dp(p, 0);
  ll x = 0, ans = 0;
  dp[0] = 1;
  for(int i = 0; i < n; i++){
    ll num = s[i] - '0';
    x = (10 * x + num) % p;
    ll val = x * pwr(10, n - i - 1);
    val %= p;
    ans += dp[val];
    dp[val]++;
  }

  cout << ans << endl;
}


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

int main() {
int n, w;
scanf("%d %d", &n, &w);
vector<int >  val(n),wt(n);
for(int i=0; i<n; ++i){
	scanf("%d %d",&wt[i] , &val[i]);
}

vector< vector< long long> > dp(n+1, vector<long long> (w+1,0));

for(int i=1; i<=n; ++i){
	for(int j=1; j<=w; ++j){
		dp[i][j] = dp[i-1][j];
		if(wt[i-1]<=j)
		dp[i][j] = max(val[i-1] + dp[i-1][j-wt[i-1]]  , dp[i][j]);
	}
}

printf("%ld\n", dp[n][w]);
	
	

	return 0;
}


Measured memory_bytes: 83060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main() {
  ll n;
  cin >> n;
  if (n >= 400 && 599 >= n) {
    cout << "8\n";
  }else if (n >= 600 && 799 >= n) {
    cout << "7\n";
  }else if (n >= 800 && 999 >= n) {
    cout << "6\n";
  }else if (n >= 1000 && 1199 >= n) {
    cout << "5\n";
  }else if (n >= 1200 && 1399 >= n) {
    cout << "4\n";
  }else if (n >= 1400 && 1599 >= n) {
    cout << "3\n";
  }else if (n >= 1600 && 1799 >= n) {
    cout << "2\n";
  }else if (n >= 1800 && 1999 >= n) {
    cout << "1\n";
  }

  return 0;
}
 

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

vector<vector<int>> G;
vector<long long> cost;

void renew_cost(int i, int par = -1) {
    if (G[i].empty()) return;
    for (int j : G[i]) {
        if (j == par) continue;
        cost[j] += cost[i];
        renew_cost(j, i);
    }
}

int main() {
    int N, Q;  cin >> N >> Q;
    G.resize(N, vector<int>());  cost.resize(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;  cin >> a >> b;  --a;  --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 0; i < Q; ++i) {
        int p, x;  cin >> p >> x;  --p;
        cost[p] += x;
    }

    renew_cost(0);

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


Measured memory_bytes: 24320
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

bool dp[1005][1005][1005];

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

    ll x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());
    a.push_back(-1 * LINF);
    b.push_back(-1 * LINF);
    c.push_back(-1 * LINF);
    priority_queue<pair<ll, pair<ll, pair<ll, ll> > > > q;
    ll ma = a[0] + b[0] + c[0];
    q.push(make_pair(ma,make_pair(0, make_pair(0,0))));
    dp[0][0][0] = true;
    for(ll i = 0; i < k; i++){
        auto p = q.top();
        q.pop();
        ll res = p.first;
        cout << res << endl;
        ll ai = p.second.first;
        ll bi = p.second.second.first;
        ll ci = p.second.second.second;

        ll nexta = a[ai+1] + b[bi] + c[ci];
        if(!dp[ai+1][bi][ci]){
            q.push(make_pair(nexta, make_pair(ai+1, make_pair(bi, ci))));
            dp[ai+1][bi][ci] = true;
        }
        

        ll nextb = a[ai] + b[bi+1] + c[ci];
        if(!dp[ai][bi+1][ci]){
            q.push(make_pair(nextb, make_pair(ai, make_pair(bi+1, ci))));
            dp[ai][bi+1][ci] = true;
        }

        ll nextc = a[ai] + b[bi] + c[ci+1];
        if(!dp[ai][bi][ci+1]){
            q.push(make_pair(nextc, make_pair(ai, make_pair(bi, ci+1))));
            dp[ai][bi][ci+1] = true;
        }
    }
}


Measured memory_bytes: 985856
while true
    n=STDIN.gets.to_i
    exit 0 if n==0
    l=STDIN.gets.chomp.split
    for i in 0..n-1 do
        l[i]=l[i].to_i
    end

    num_op=0
    last_l=nil
    while true
        tmp=Array.new(n)
        for i in 0..n-1 do
            k = 0
            for j in 0..n-1 do
                k=k+1 if l[i]==l[j]
            end
            tmp[i] = k
        end
        last_l = l
        l = tmp
        break if last_l==l
        num_op = num_op+1
    end
    print num_op,"\n"
    for i in 0..n-1 do
        print last_l[i]
        print " " if i < n-1
    end
    print "\n"
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; i++)
    {
        cin >> grid[i];
    }
    vector<vector<bool>> check(h, vector<bool>(w, true));
    for (int i = 0; i < h; i++)
    {
        bool flg = true;
        for (int j = 0; j < w; j++)
        {
            if (grid[i][j] == '#')
            {
                flg = false;
            }
        }
        if (flg)
        {
            for (int j = 0; j < w; j++)
            {
                check[i][j] = false;
            }
        }
    }
    for (int i = 0; i < w; i++)
    {
        bool flg = true;
        for (int j = 0; j < h; j++)
        {
            if (grid[j][i] == '#')
            {
                flg = false;
            }
        }
        if (flg)
        {
            for (int j = 0; j < h; j++)
            {
                check[j][i] = false;
            }
        }
    }
    vector<string> ans;
    for (int i = 0; i < h; i++)
    {
        string tmp = "";
        for (int j = 0; j < w; j++)
        {
            if (check[i][j])
            {
                tmp += grid[i][j];
            }
        }
        if (tmp != "")
        {
            ans.push_back(tmp);
        }
    }
    for (auto a : ans)
    {
        cout << a << endl;
    }
}

Measured memory_bytes: 256
n = gets.to_i

h = Array.new(n){Hash.new(0)}

n.times do |i|
  
  s = gets.chomp
  
  s.each_char do |c|
    
    h[i][c] += 1
    
  end
  
end

ans = ""
(?a..?z).each do |c|
  
  m = 50
  n.times do |i|
    m = h[i][c] if m > h[i][c] 
  end
  
  ans += c * m
end

puts ans
  
  

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n,x; cin>>n>>x;
    vint a(n); rep(i,n) cin>>a[i];

    vvint minval(n, vint(n, LLONG_MAX)); // minval[i][j]
    rep(i,n){
        priority_queue<ll, vint, greater<ll>> pq;
        repf(j,i,n){
            pq.push(a[j]);
            minval[i][j] = pq.top();
        }
    }
    rep(i,n){
        rep(j,n){
            if(i<=j) continue;
            minval[i][j] = min(minval[0][j], minval[i][n-1]);
        }
    }
    // rep(i,n){
    //     rep(j,n){
    //         cout<<minval[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    ll ans = LLONG_MAX;

    rep(c,n){
        ll tmp = c*x;
        rep(i,n){
            tmp += minval[(i-c+n)%n][i];
        }
        chmin(ans,tmp);
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 31616
var
  s: array[0..100000] of char;
  alpha: array[0..26] of int64;
  i: int64;
  ok: boolean;
begin
  readln(s);
  for i := 0 to 100000 do
  begin
    alpha[ord(s[i]) - 96] := 1;
  end;
  
  ok := False;
  for i := 1 to 26 do
  begin
    if alpha[i] = 0 then
    begin
      writeln(chr(i + 96));
      ok := True;
      break;
    end;
  end;
  
  if ok = False then
  begin
    writeln('None');
  end;
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define pb push_back
#define mp make_pair
#define re return
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF=1e9;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef queue <int> qi;
int v,t,s;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>v>>t>>s;
	if(t*s>=v)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3636
<?php
$x = 0; $y = 0;
while(!feof(STDIN))
{
  fscanf(STDIN, "%d,%d,%d", $a, $b, $c);
  if($a * $a + $b * $b == $c * $c)
    $x++;
  if($a === $b)
    $y++;
}
echo $x . "\n" . $y . "\n";

Measured memory_bytes: 6572
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////


int main() {
	int n; cin >> n;
	if (n <= 3) {
		cout << 0 << endl;
		return 0;
	}
	string s; cin >> s;
	vector<int>cntr, cntg, cntb;
	cntr.push_back(0);
	cntg.push_back(0);
	cntb.push_back(0);
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'R') {
			cntr.push_back(cntr[i] + 1);
			cntg.push_back(cntg[i]);
			cntb.push_back(cntb[i]);
		}
		else if (s[i] == 'G') {
			cntr.push_back(cntr[i]);
			cntg.push_back(cntg[i] + 1);
			cntb.push_back(cntb[i]);
		}
		else {
			cntr.push_back(cntr[i]);
			cntg.push_back(cntg[i]);
			cntb.push_back(cntb[i] + 1);
		}
	}
	ll sum = 0;
	for (int i = 1; i <= n - 2; ++i) {
		if (s[i] == 'R') {
			sum += cntg[i] * (cntb[n] - cntb[i + 1]);
			sum += cntb[i] * (cntg[n] - cntg[i + 1]);
			for (int j = 1; i - j >= 0 && i + j < n; ++j) {
				if (s[i - j] != 'R'&&s[i + j] != 'R'&&s[i - j] != s[i + j]) {
					sum -= 1;
				}
			}
		}
		else if (s[i] == 'G') {
			sum += cntr[i] * (cntb[n] - cntb[i + 1]);
			sum += cntb[i] * (cntr[n] - cntr[i + 1]);
			for (int j = 1; i - j >= 0 && i + j < n; ++j) {
				if (s[i - j] != 'G'&&s[i + j] != 'G'&&s[i - j] != s[i + j]) {
					sum -= 1;
				}
			}
		}
		else {
			sum += cntr[i] * (cntg[n] - cntg[i + 1]);
			sum += cntg[i] * (cntr[n] - cntr[i + 1]);
			for (int j = 1; i - j >= 0 && i + j < n; ++j) {
				if (s[i - j] != 'B'&&s[i + j] != 'B'&&s[i - j] != s[i + j]) {
					sum -= 1;
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  cin >> N;
  int a[N];
  ll ans = 0;
  ll where[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    a[i]--;
    where[a[i]] = i;
  }
  set<ll> Set;
  Set.insert(-1LL);
  Set.insert(N);
  for (ll i = 0; i < N; i++) {
    auto itr = Set.lower_bound(where[i]);
    auto itr2 = prev(itr,1);
    ll res = (*itr - where[i]) * (where[i] - *itr2) * (i + 1); 
    ans += res;
    Set.insert(where[i]);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

#define vlll vector<vll>

int main() {
  int n, m;
  cin >> n >> m;
  if (n > m) {
    cout << 0 << endl;
    return 0;
  }

  vlll dp(m + 1, vll(n + 1, vl(n + 1)));
  dp[0][1][0] = 1;
  
  rep (i, m) {
    rep (j, n + 1) {
      rep (k, n + 1) {
        ll koritsu = n - j - k;
        if (koritsu < 0) continue;
        if (dp[i][j][k] == 0) continue;
        if (koritsu != 0) {
          (dp[i + 1][j][k + 1] += dp[i][j][k] * koritsu % MOD) %= MOD;
        }
        (dp[i + 1][j][k] += dp[i][j][k] * k % MOD) %= MOD;
        (dp[i + 1][j + k][0] += dp[i][j][k] * j % MOD) %= MOD;
      }
    }
  }
  cout << dp[m][n][0] % MOD << endl;
}


Measured memory_bytes: 216832
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,l;
  cin>>n;
  long long int a[100000];
  long long int count=0;
  l = sqrt(n);
  for(long long int i=1;i<=l;++i){
    if(n%i==0){
      a[count]= i;
      count++;
    }
  }
  int ans,m=30;
  string tem1,tem2;
  for(long long int i=0;i<count;++i){
    tem1 = to_string(a[i]);
    tem2 = to_string(n/a[i]);
    ans = max(tem1.length(),tem2.length());
    m = min(m,ans);
  }
  cout<<m;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;


void solve(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    Vl A(n);
    ll sum = 0;
    rep(i, 0, n){
        cin >> A[i];
        sum += A[i];
    }

    ll ans = 1001001001001;
    ll l = 0;
    rep(i, 0, n-1){
        l += A[i];
        ll r = sum - l;
        ans = min(ans, abs(l - r));
    }

    cout << ans << endl;
}


int main() {
    solve();
}


Measured memory_bytes: 1792
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=12010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int n;
struct EDGE { int v,w,c,nx; }lb[N<<3]; int tot=1,top[N];
void add (int u,int v,int w,int c)
{
	lb[++tot]=(EDGE){v,w, c,top[u]},top[u]=tot;
	lb[++tot]=(EDGE){u,0,-c,top[v]},top[v]=tot;
}
int s,t;
LL dis[N]; int flow[N],pre[N],las[N]; bool in[N];
bool spfa ()
{
	for (int i=1; i<=t; i++)
		dis[i]=-1e18,flow[i]=pre[i]=las[i]=0,in[i]=0;
	queue <int> q;
	flow[s]=oo; dis[s]=0,q.push (s),in[s]=1;
	while (q.size ())
	{
		int u=q.front (); q.pop (),in[u]=0;
		for (int kb=top[u]; kb; kb=lb[kb].nx)
		{
			int v=lb[kb].v,w=lb[kb].w,c=lb[kb].c;
			if (w&&dis[v]< dis[u]+c)
			{
				dis[v]=dis[u]+c;
				flow[v]=min (flow[u],w);
				pre[v]=u,las[v]=kb;
				if (!in[v]) q.push (v),in[v]=1;
			}
		}
	}
	return pre[t];
}
int maflow; LL macost;
void mcmf ()
{
	while (spfa ())
	{
		int u=t,fl=flow[t]; maflow+=fl,macost+=dis[t]*fl;
		while (u!=s) lb[las[u]].w-=fl,lb[las[u]^1].w+=fl,u=pre[u];
	}
}
struct LY { int x,y,w,id; }a[N],b[N];
const int dx[4]={1,-1,1,-1},dy[4]={1,1,-1,-1}; int id[4];
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n);
	for (int i=1; i<=n; i++)
		sc(a[i].x),sc(a[i].y),sc(a[i].w);
	for (int i=1; i<=n; i++)
		sc(b[i].x),sc(b[i].y),sc(b[i].w);
	s=n*2+4+1,t=s+1;
	for (int i=1; i<=n; i++)
		add (s,i,a[i].w,0),add (i+n,t,b[i].w,0);
	for (int i=1; i<=4; i++)
		id[i-1]=n*2+i;
	for (int i=1; i<=n; i++)
		for (int j=0; j<=3; j++)
			add (i,id[j],oo,dx[j]*a[i].x+dy[j]*a[i].y),add (id[j],i+n,oo,-(dx[j]*b[i].x+dy[j]*b[i].y));
	mcmf ();
	pr(macost);

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;

const int INF = 100000000;
typedef pair<int,int> P;
char maze[51][51];
int n,m;
int sx,sy;
int gx,gy;
int d[51][51];
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int i,j;

int bfs(){
queue<P> que;
for(i=0;i<n;i++){
  for(j=0;j<m;j++){
    d[i][j]=INF;
  }
}
que.push(P(sx,sy));
d[sx][sy]=0;

while(que.size()){
P p=que.front(); que.pop();

if(p.first==gx and p.second==gy) break;

for(i=0;i<4;i++){
  int nx=p.first + dx[i], ny=p.second + dy[i];

  if(0<=nx and nx<n and 0<=ny and ny<m and maze[nx][ny]!='#' and d[nx][ny]==INF){
    que.push(P(nx,ny));
    d[nx][ny]=d[p.first][p.second]+1;
  }
}
}
return d[gx][gy];
}

int main(){
cin>>n>>m;;
int count=0;
for(i=0;i<n;i++){
  for(j=0;j<m;j++){
    cin>>maze[i][j];
    if(maze[i][j]=='.') count++;
  }
}
sx=sy=0; gx=n-1;gy=m-1;
int ans = bfs(); //cout << ans << endl;
if(ans==INF) cout << -1 << endl;
else{
ans = count - ans -1;
cout << ans << endl;
}
}


Measured memory_bytes: 256
N = int(input())
# N <= X x 1.08 < N+1
# になる整数Xを求める

# min_xとmax_xの間に1つでも整数が存在していればいい
import math
min_x = math.ceil(N/1.08)
max_x = math.ceil((N+1)/1.08)
if max_x - min_x >= 1:
    print(min_x)
else:
    print(':(')


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int intTemp;
		while(scan.hasNext()){
			intTemp = scan.nextInt();
			if(intTemp == 0){
				scan.close();
				break;
			}else{
				list.add(intTemp);
			}
		}
		if(list.size() != 0){
			for(int i = 0; i < list.size(); i++){
				System.out.println("Case " + (i + 1) + ": " + list.get(i));
			}
		}
	}

}

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

int main(void)
{
    int a,b;
    cin >> a >> b;
    int d = 0;
    int c = b;
    while(b != 0){
        b = b / 10;
        d++;
    }
    int n = a * pow(10,d) + c;
    bool check = false;
    for(int i = 0; i < 340; i++){
        if(i * i == n) check = true;
    }
    if(check) printf("Yes");

    else printf("No");



}


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

int insertionSort(int a[],int n,int g,int cnt){
    int i,j,v;
    for(i=g;i<n;i++){
        v=a[i];
        j=i-g;
        while(j>=0&&a[j]>v){
            a[j+g]=a[j];
            j-=g;
            cnt++;
        }
        a[j+g]=v;
    }
    return cnt;
}

int shellSort(int a[],int g[],int m,int n){
    int cnt=0;
    int i;
    for(i=0;i<m;i++){
        cnt=insertionSort(a,n,g[i],cnt);
    }
    return cnt;
}

int main(void){
    int n,a[1000000];
    cin>>n;
    int i;
    for(i=0;i<n;i++)cin>>a[i];
    
    if(n==1){
        cout<<1<<endl<<1<<endl<<0<<endl<<a[0];
        return 0;
    }
    
    int m=0,tmp=n,g[20];
    while(tmp>1){
        tmp/=2;
        g[m]=tmp;
        m++;
    }
    int cnt=shellSort(a,g,m,n);
    
    cout<<m<<endl;
    for(i=0;i<m-1;i++)cout<<g[i]<<" ";
    cout<<g[m-1]<<endl;
    cout<<cnt<<endl;
    for(i=0;i<n;i++)cout<<a[i]<<endl;
    return 0;
}


Measured memory_bytes: 6988
n=int(input())
rest=[0]*n
for i in range(n):
  a,b=map(str,input().split())
  b=int(b)
  rest[i]=[i+1,a,b]


rest.sort(key=lambda x:x[2],reverse=True)
rest.sort(key=lambda x:x[1])



for i in range(n):
  print(rest[i][0])

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

using namespace std;

long long n, a[312345], sum[312345];
int cnt = 0;

int main() {
                                               

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

	long long ans = 1e18;
	for(int i = 1; i < n; i++) {
		long long f = sum[i];
		long long s = sum[n] - sum[i]; 
		long long mid = (f + s) / 2;

		ans = min(ans, abs(f - mid) + abs(s - mid));
	}
	cout << ans;
}




Measured memory_bytes: 3840
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int a[2000];
int n,m;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	for(int i=0;i<m;i++)sum+=a[i];
	cout<<sum;
	return 0;
}



Measured memory_bytes: 3660
n=int(input())
dp=[]
for i in range(n):
    a=[int(i) for i in input().split()]
    dp.append(a)
for i in range(1,n):
    for j in range(3):
        m=0
        for k in range(3):
            if k!=j:
                m=max(dp[i][j]+dp[i-1][k],m)
        dp[i][j]=m
print(max(dp[n-1]))


Measured memory_bytes: 61656
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	int sz = s.l_ength();
	vector<vector<int>> v(26);
	for( int i = 0; i < sz; ++i ){
		int n = s[i] - 'a';
		v.at(n).push_back(i);
	}
	for( int i = 0; i < 26; ++i ){
		int listsz = v.at(i).l_ength();
		if( listsz <= 1 ) continue;
		int x = v.at(i).at(0);
		for( int j = 1; j < listsz; ++j ){
			int y = v.at(i).at(j);
			if( t[x] != t[y] ){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	vector<vector<int>> w(26);
	for( int i = 0; i < sz; ++i ){
		int n = t[i] - 'a';
		w.at(n).push_back(i);
	}
	for( int i = 0; i < 26; ++i ){
		int listsz = w.at(i).l_ength();
		if( listsz <= 1 ) continue;
		int x = w.at(i).at(0);
		for( int j = 1; j < listsz; ++j ){
			int y = w.at(i).at(j);
			if( s[x] != s[y] ){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 2952
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 998244353
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=-10000000000,t=0,q=0,x,y,m;
        cin>>k;
        cin>>n;
        ll a[n];
        for(i=0;i<n;i++)
        cin>>a[i];
        for(i=0;i<n-1;i++)
        {
        	l=l+a[i+1]-a[i];t=max(t,a[i+1]-a[i]);
		}
		l=l+(k-a[n-1]+a[0]);
		t=max(t,k-a[n-1]+a[0]);
		cout<<l-t;
}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

Measured memory_bytes: 1792
n = int(input())
a = [int(x) for x in input().split()]
ans = "APPROVED"
for a_i in a:
    if a_i % 2 != 0: continue
    else:
        if a_i % 3 != 0 and a_i % 5 != 0:
            ans = "DENIED"
            break
print(ans)

Measured memory_bytes: 3064
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " " ;
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 

void Panda() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
}
  
int32_t main() {
 
    FAST;

   
    
    Panda();

    return 0; 
} 

Measured memory_bytes: 3664
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N, K = map(int, input().split())

print (N-K+1)





Measured memory_bytes: 38384
#include <cstring>
#include <iostream>

using namespace std;

const int N = 1e5 + 10;

typedef struct pp //* 存名字和时间
{
    char name[100];
    int t;
} p;

p Q[N];
int head, tail;
int n, q;

void enqueue(p x) //* 插入队列中
{
    Q[tail] = x;
    tail = (tail + 1) % N;
}

p dequeue() //*  从队列中取出
{
    p x = Q[head];
    head = (head + 1) % N;
    return x;
}

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

    int elaps = 0, c; // todo elaps 是累计已经过的时间
    p u;

    cin >> n >> q; //! 输入 数量和 一次的处理时间（速度）

    for(int i = 1; i <= n; i++) cin >> Q[i].name >> Q[i].t; //! 下标从 1 开始读入

    head = 1; //* head 指向 队列首元素
    tail = n + 1;

    while(head != tail) //* 只要 head 不等与 tail（不空）
    {
        u = dequeue(); //*从队头中取出元素
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0)
            enqueue(u);
        else
            cout << u.name << " " << elaps << endl;
    }
    return 0;
}


Measured memory_bytes: 13292
from collections import Counter

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
ex=1
for i in range(len(n)):
    a+=int(n[i])*ex
    x[i]=a%2019
    ex=ex*10%2019
c=Counter(x)
ans = c[0]
for i in c.keys():
    b=c[i]
    ans += b*(b-1)//2

print(ans)


Measured memory_bytes: 18008
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;



typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

ll n,f[100][10],p[100][11];

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			cin >> f[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 11; j++){
			cin >> p[i][j];
		}
	}

	ll ans = -(1<<30);

	for(int bit = 1; bit < (1<<10); bit++){
		ll x = 0;
		for(int i = 0; i < n; i++){
			int cnt = 0;
			for(int j = 0; j < 10; j++){
				if((bit>>j&1) && f[i][j]) cnt++;
			}
			x += p[i][cnt];
		}
      
      
		if(ans<x) ans = x;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

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

  vector<int> P;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    P.push_back(x);
  }

  vector<int> Q;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    Q.push_back(x);
  }

  int a, b;
  vector<int> v;

  for (int i = 1; i <= n; i++) {
    v.push_back(i);
  }

  int now = 1;
  do {
    if (P == v) {
      a = now;
    }
    if (Q == v) {
      b = now;
    }
    now++;
  } while(next_permutation(v.begin(), v.end()));

  cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
n = int(input())
E = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

mod = [3, 1, 2]
ans = [0 for i in range(n)]
count = [0, 0]

def bfs(cur, pre, c):
    stack = deque([[cur, pre, c]])
    while stack:
        cur, pre, c = stack.popleft()
        count[c % 2] += 1
        for e in E[cur]:
            if e != pre:
                stack.append([e, cur, c+1])

def case1(cur, pre, c, i):
    stack = deque([[cur, pre, c]])
    while stack:
        cur, pre, c = stack.popleft()
        t = c % 2
        if t == i:
            ans[cur] = mod[0]
            mod[0] += 3
        else:
            if mod[1] <= n:
                ans[cur] = mod[1]
                mod[1] += 3
            elif mod[2] <= n:
                ans[cur] = mod[2]
                mod[2] += 3
            else:
                ans[cur] = mod[0]
                mod[0] += 3
        for e in E[cur]:
            if e != pre:
                stack.append([e, cur, c+1])

def case2(cur, pre, c):
    stack = deque([[cur, pre, c]])
    while stack:
        cur, pre, c = stack.popleft()
        t = c % 2
        if mod[t+1] <= n:
            ans[cur] = mod[t+1]
            mod[t+1] += 3
        else:
            ans[cur] = mod[0]
            mod[0] += 3
        for e in E[cur]:
            if e != pre:
                stack.append([e, cur, c+1])

bfs(0, -1, 0)

if count[0] <= n // 3:
    case1(0, -1, 0, 0)
elif count[1] <= n  // 3:
    case1(0, -1, 0, 1)
else:
    case2(0, -1, 0)

print(" ".join([str(i) for i in ans]))


Measured memory_bytes: 63464
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
int q,a,b;
string s;
cin>>q;
map<string,int>m;
for(;q--;){
cin>>a;
if(a==0)cin>>s>>b,m[s]=b;
if(a==1)cin>>s,cout<<m.at(s)<<endl;
}
}


Measured memory_bytes: 27784
#include<stdio.h>
#include<stdlib.h>

typedef struct p{

    int key;

    struct p *prev, *next;

}node;

void delete(int);
void deletefirst(void);
void deletelast(void);
void insert(int);

node *nil;

int main(){

    int i, n, key;

    char s[20];

    nil=(node *)malloc(sizeof(node));
    nil->next=nil;
    nil->prev=nil;

    scanf("%d", &n);

    for(i=0;i<n;i++){

        scanf("%*c%s", s);

        if(s[0]=='i'){
            
            scanf("%d", &key);
            
            insert(key);

        }

        else if(s[6]=='F') deletefirst();

        else if(s[6]=='L') deletelast();

        else{
            
            scanf("%d", &key);
            
            delete(key);

        }

    }

    node *t=nil->next;

    while(1){

        if(t==nil) break;

        if(i==0) printf(" ");

        printf("%d", t->key);

        t=t->next;

        i=0;

    } 

    printf("\n");

    free(nil);

    return 0;

}

void insert(int key){

    node *x=(node *)malloc(sizeof(node));

    x->key=key;

    x->next=nil->next;

    nil->next->prev=x;

    nil->next=x;

    x->prev=nil;

}

void delete(int key){

    node *t=nil->next;
    
    while(1){

        if(t==nil || t->key==key) break;

        t=t->next;

    }

    if(t==nil) return;

    t->prev->next=t->next;

    t->next->prev=t->prev;

    free(t);

}

void deletefirst(){

    node *t=nil->next;

    if(t==nil) return;

    t->prev->next=t->next;

    t->next->prev=t->prev;

    free(t);

}

void deletelast(){

    node *t=nil->prev;

    if(t==nil) return;

    t->prev->next=t->next;

    t->next->prev=t->prev;

    free(t);

}


Measured memory_bytes: 33036