akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

vector<char> solve(string& s){
	vector<char> st;
	for(auto c : s){
		if(st.empty()) st.emplace_back(c);
		else{
			if(st.back() == '(' and c == ')'){
				st.pop_back();
			}else{
				st.emplace_back(c);
			}
		}
	}
	return st;
}

bool check(vector<bool>& b){
	for(auto i : b) if(not i) return false;
	return true;
}

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

	vector<string> s;
	rep(i,n){
		string t;
		cin >> t;

		vector<char> st = solve(t);
		if(st.empty()) continue;

		string tmp;
		for(auto c : st){
			tmp += c;
		}
		s.emplace_back(tmp);
	}


	vector<int> l, r;
	vector<pair<int, int>> m;
	rep(i,s.size()){
		map<char, int> ma;
		for(auto c : s[i]) ma[c]++;
		if(ma.size() == 1){
			if(ma.begin()->first == '(') l.emplace_back(ma.begin()->second);
			if(ma.begin()->first == ')') r.emplace_back(ma.begin()->second);
		}else{
			m.emplace_back(ma['('], ma[')']);
		}
	}

	//cout << l << endl;
	//cout << r << endl;
	//rep(i,m.size()){
	//	cout << m[i].first << ' ' << m[i].second << endl;
	//}

	int sum = accumulate(all(l), 0);
	vector<bool> used(m.size(), false);
	rep(i,m.size()){
		int maxi = -1e9, p = -1, mini = 1e9;;
		rep(j,m.size()){
			if(sum >= m[j].second and maxi < m[j].first - m[j].second and not used[j]){
				maxi = m[j].first - m[j].second;
				mini = m[j].second;
				p = j;
			}else if(sum >= m[j].second and maxi == m[j].first - m[j].second and not used[j] and m[j].first > m[j].second){
				mini = m[j].second;
				p = j;
			}
		}
		if(p == -1) continue;
		//cout << p << endl;
		used[p] = true;
		sum += m[p].first - m[p].second;
	}

	sum -= accumulate(all(r), 0);

	cout << (sum == 0 and check(used) ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3196
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
std::vector<int> g[100003];
int color[100003];
int cnt[2];
int n,m;
bool isbipartite = true;
void check()
{
    std::queue<int> q;
    int col = 0;
    q.push(1);
    color[1] = 0;
    while(!q.empty())
    {
        int siz = q.size();
        for(int i=0;i<siz;i++)
        {
            int x = q.front();
            q.pop();
            cnt[col]++;
            for(int next : g[x])
            {
                if(color[next] == -1)
                {
                    q.push(next);
                    color[next] = 1 - col;
                }
                else if(color[next] == col)
                {
                    isbipartite = false;
                    return;
                }
            }
        }
        col = 1 - col;
    }
}
int main()
{
    memset(color,-1,sizeof(color));
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    check();
    long long int ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(isbipartite)
            ans += cnt[1-color[i]] - g[i].size();
        else
            ans += (n - 1 - g[i].size());
    }
    printf("%lld", ans/2LL);
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define endl '\n';
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

vector<int> Zalgo(const string &S){
  int N = S.size();
  vector<int> res(N);
  res[0] = N;
  int i=1,j=0;
  while(i<N){
    while(i+j<N && S[j] == S[i+j]) j++;
    res[i] = j;
    if(j == 0){++i; continue;}
    int k=1;
    while(i+k<N && k+res[k]<j) res[k],k++;
    i += k;
    j -= k;
  }
  return res;
}

int main(){ 
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  string S;
  cin >> N >> S;
  int res = 0;
  for(int i=0; i<N; i++){
    string T = S.substr(i);
    auto lcp = Zalgo(T);
    for(int j=0; j<T.size(); j++){
      int l = min(lcp[j],j);
      chmax(res,l);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<set>
#include<cstdio>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main(){
    int n,m;
    cin>>n>>m;
    
    int P[100000],Y[100000];
    vector<int> v[100001];
    
   /* rep(i,m){
        cin>>P[i]>>Y[i];
        v[P[i]].push_back(Y[i]);
    }*/
    rep(i,m){
        scanf("%d%d",&P[i],&Y[i]);
    v[P[i]].push_back(Y[i]);
    }
    
    //rep(i,n) sort(v[i+1].begin(),v[i+1].end());
    
    rep(i,n)sort(v[i+1].begin(),v[i+1].end());
    
  /*  rep(i,m){
        printf("%06d",P[i]);
        for(int j=0;j<v[P[i]].size();j++){
            u++;
            if(v[P[i]][j]==Y[i]){
                break;
            }
        }
        int u=int(lower_bound(v[P[i]]. begin(),v[P[i]].end(),Y[i])-v[P[i]].begin())+1;
        printf("%06d",u);
        cout<<endl;
    }*/

    rep(i,m){
        printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(v[P[i]]. begin(),v[P[i]].end(),Y[i])-v[P[i]].begin())+1);}

return 0;
}


Measured memory_bytes: 7808
n,k = map(int,input().split())
cnt = 0
for i in range(k,n+2):
    cnt += n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - i * (i - 1) / 2 + 1
print(int(cnt % (10 ** 9 + 7)))

Measured memory_bytes: 9180
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] v1 = new int[100001];
        int[] v2 = new int[100001];
        int max1 = 0;
        int m1=0;
        int m2=0;
        int max2 = 0;
        for (int i=0;i<n/2;i++){
            v1[scanner.nextInt()]++;
            v2[scanner.nextInt()]++;
        }
        for (int i=1;i<100001;i++){
            max1 = Math.max(max1,v1[i]);
            if (v1[i]==max1)m1=i;
            max2 = Math.max(max2,v2[i]);
            if (v2[i]==max2)m2=i;
        }
        if (max1>max2){
            for (int i=1;i<100001;i++){
                if (i!=m1)max2 = Math.max(max2,v2[i]);
            }
        }else if (max1<max2){
            for (int i=1;i<100001;i++){
                if (i!=m2)max1 = Math.max(max1,v1[i]);
            }
        }else {
            int j=0;
            int k=0;
            for (int i=1;i<100001;i++){
                if (i!=m1)j = Math.max(j,v2[i]);
                if (i!=m2)k = Math.max(k,v1[i]);
            }
            max2 = Math.max(j,k);
        }
        if (max1==max2&&m1==m2&&max1+max2==n){
            System.out.println(n/2);
        }else {
            System.out.println(n-max1-max2);
        }
    }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

// Description: 素集合を管理するデータ構造
// TimeComplexity: 初期化$\mathcal{O}(n)$ 更新$\mathcal{O}(\log n)$
// Verifyed: AOJ DSL_1_A

struct Union_find {
	Union_find(int n) {data.assign(n, -1);}
	int find(int x) {return (data[x] < 0) ? x : data[x] = find(data[x]);}
	void unite(int a, int b) {
		a = find(a), b = find(b);
		if (a != b) {
			if (data[a] < data[b]) swap(a, b);
			data[a] += data[b], data[b] = a;
		}
	}
	bool same(int a, int b) {return find(a) == find(b);}
	int size(int x) {return -data[x];}
	vector<int> data;
};

const int limit = 100010;
int c[limit];
ll a[limit], b[limit], w[limit];


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

	rep(i, n) cin >> c[i];

	rep(i, m) {
		cin >> a[i] >> b[i] >> w[i];
		a[i]--, b[i]--;
	}


	int total = k;
	rep(i, n) if (c[i] == 0) c[i] = ++total;
	rep(i, n) c[i]--;

	Union_find uf(total);

	using edge = tuple<ll, int, int>;
	vector<edge> graph;

	rep(i, m) graph.push_back(edge(w[i], c[a[i]], c[b[i]]));
	sort(begin(graph), end(graph));

	int cnt = 0;
	ll ans = 0LL;

	for (auto &e : graph) {
		ll ww, aa, bb;
		tie(ww, aa, bb) = e;
		if (uf.same(aa, bb)) continue;
		uf.unite(aa, bb);
		ans += ww, cnt++;
		if (cnt == k - 1) break;
	}

	if (cnt < k - 1)
		cout << -1 << endl;
	else
		cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5876
#include <iostream>
#include <string>
#include <vector>

class TLongistCommons
{
	std::vector<std::vector<int> > FTable;
	const std::string& FSequenceX;
	const std::string& FSequenceY;
	
	int MeasureCommons(int PrefixX, int PrefixY);
public:
	TLongistCommons(const std::string& SequenceX, const std::string& SequenceY);
	
	int Length();
};

TLongistCommons::TLongistCommons(const std::string& SequenceX, const std::string& SequenceY)
: FSequenceX(SequenceX), FSequenceY(SequenceY), FTable(SequenceX.length() + 1, std::vector<int>(SequenceY.length() + 1, -1))
{
}

int TLongistCommons::MeasureCommons(int PrefixX, int PrefixY)
{
	if(FTable[PrefixX][PrefixY] < 0){
		int Longest;
		if(PrefixX == 0 || PrefixY == 0){
			Longest = 0;
		}else if(FSequenceX[PrefixX - 1] == FSequenceY[PrefixY - 1]){
			Longest = MeasureCommons(PrefixX - 1, PrefixY - 1) + 1;
		}else{
			Longest = std::max(MeasureCommons(PrefixX - 1, PrefixY), MeasureCommons(PrefixX, PrefixY - 1));
		}
		FTable[PrefixX][PrefixY] = Longest;
	}
	return FTable[PrefixX][PrefixY];
}

int TLongistCommons::Length()
{
	return MeasureCommons(FSequenceX.length(), FSequenceY.length());
}

int MeasureLcs(const std::string& SequenceX, const std::string& SequenceY)
{
	TLongistCommons Subsequence(SequenceX, SequenceY);
	return Subsequence.Length();
}

int main()
{
	int Count;
	std::cin >> Count;
	for(int i = 0; i < Count; ++i){
		std::string SequenceX, SequenceY;
		std::cin >> SequenceX;
		std::cin >> SequenceY;
		std::cout << MeasureLcs(SequenceX, SequenceY) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;
const int N=200500;
struct P{
	int x,y,id;
}p[N];
int n,fa[N],sum[N],out[N];
set<int> sp;

bool cmp(P a,P b){return a.x<b.x;}

inline int findfa(int x){
	if(x==fa[x]) return x;
	return x=findfa(fa[x]);
}

inline void hb(int x,int y){
	int u=findfa(x),v=findfa(y);
	if(u<v) swap(u,v);
	sum[v]+=sum[u];
	fa[u]=v;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&p[i].x,&p[i].y);
		p[i].id=i;
	}
	sort(p+1,p+1+n,cmp);
	for(int i=1;i<=n;i++) fa[i]=i,sum[i]=1;
	for(int i=1;i<=n;i++) {
		while(!sp.empty() && (*sp.begin())<p[i].y) {
			hb(p[i].y,(*sp.begin()));
			sp.erase(sp.begin());
		}
		sp.insert(findfa(p[i].y));
	}
	for(int i=1;i<=n;i++)
		out[p[i].id]=sum[findfa(p[i].y)];
	for(int i=1;i<=n;i++)
		printf("%d\n",out[i]);
	return 0;
}

Measured memory_bytes: 12816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string st;
    cin>>st;
    ll k;
    cin>>k;
    ll t=st.size();
    REP(i,min(t,k)){
        if(st[i]!='1'){
            cout<<st[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >


using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10,mod=1e9+7;

int main ()
{
    FASTIO
    ll a,b,n;
    cin >> a >> b >> n;
    ll x = min(n,b-1);
    cout << (a*x)/b - a*(x/b) << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 3560
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;

const int MNUM = 12, leapMNUM = 12;
const int ML[] = {31,28,31,30,31,30,31,31,30,31,30,31};      //day/month in usual year
const int leapML[] = {31,29,31,30,31,30,31,31,30,31,30,31};  //day/month in leap year
const string days[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

struct date{
  int y,m,d;

  date(void):y(0),m(1),d(1){}
  date(int a,int b,int c):y(a),m(b),d(c){}
  
  bool isLeap(void){
    if(y%400==0)return true;
    if(y%100==0)return false;
    if(y%4==0)return true;
    return false;
  }

  date next(void){
    d++;
    if(isLeap()){
      if(leapML[m-1]<d){ d=1; m++; }
      if(leapMNUM<m){ m=1; y++; }
    }else{
      if(ML[m-1]<d){ d=1; m++; }
      if(MNUM<m){ m=1; y++; }
    }
    return *this;
  }

  bool operator==(const date x)const{return (y==x.y && m==x.m && d==x.d);}

  bool operator<(const date x)const{
    if(y!=x.y)return y<x.y;
    if(m!=x.m)return m<x.m;
    return d<x.d;
  }

  bool operator<=(const date x)const{return (*this==x || *this<x); }
  bool operator>(const date x)const{return !(*this<=x);}
  bool operator>=(const date x)const{return !(*this<x);}

  ll dayCount(void)const{
    date tmp;
    for(ll res=0;;res++){
      if(tmp==*this)return res;
      tmp.next();
    }
    return 0;
  }

  ll operator-(const date x)const{
    return dayCount() - x.dayCount();
  }

  //calculate days from Julian Day(-4713/01/01) using Fliegel's formula.
  ll Fliegel(void){
    int a = (14-m)/12, Y = y+4800-a, M = m+12*a-3;
    return (ll)d + (153*M+2)/5 + 365*Y + Y/4 - Y/100 + Y/400 - 32045;
  }

  //calculate day of week using Zeller congruence.
  int Zeller(void){
    int Y = y, M = m;
    if(M<3){ Y--; M+=12; }
    return (Y + Y/4 - Y/100 + Y/400 + (13*M+8)/5 + d)%7;
  }
};

int main(){
  int y1,m1,d1,y2,m2,d2;
  while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2,y1>=0)
    cout << date(y2,m2,d2).Fliegel()-date(y1,m1,d1).Fliegel() << endl;
}

Measured memory_bytes: 1204
import math
import itertools
#n = int(input())
#n, d = list(input().split())
#n, l = list(map(int, input().split()))

A, B, C= list(map(int, input().split()))
if (A==B and A!=C) or (A==C and A!=B) or (B==C and B!=A):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N = gets.to_i
abc = N.times.map {gets.split.map &:to_i}

dp = Array.new(N + 1) {Array.new(3) {0}}
N.times do |i|
  3.times do |j|
    3.times do |k|
        dp[i + 1][k] = [dp[i + 1][k], dp[i][j] + abc[i][k]].max if j != k
    end
  end
end

puts dp[N].max

##　備忘録として他の方のコードを提出させていただきます

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

int main()
{
    
    int K;
    cin >> K;
    
    if(K == 1) {
        cout << 1 << endl;
    }

    if(K == 2) {
        cout << 1 << endl;
    }

    if(K == 3) {
        cout << 1 << endl;
    }
    
    if(K == 4) {
        cout << 2 << endl;
    }

    if(K == 5) {
        cout << 1 << endl;
    }
    
    if(K == 6) {
        cout << 2 << endl;
    }
    
    if(K == 7) {
        cout << 1 << endl;
    }
    
    if(K == 8) {
        cout << 5 << endl;
    }
    
    if(K == 9) {
        cout << 2 << endl;
    }
    
    if(K == 10) {
        cout << 2 << endl;
    }
    
    if(K == 11) {
        cout << 1 << endl;
    }

    if(K == 12) {
        cout << 5 << endl;
    }

    if(K == 13) {
        cout << 1 << endl;
    }
    
    if(K == 14) {
        cout << 2 << endl;
    }

    if(K == 15) {
        cout << 1 << endl;
    }
    
    if(K == 16) {
        cout << 14 << endl;
    }
    
    if(K == 17) {
        cout << 1 << endl;
    }
    
    if(K == 18) {
        cout << 5 << endl;
    }
    
    if(K == 19) {
        cout << 1 << endl;
    }
    
    if(K == 20) {
        cout << 5 << endl;
    }
    
    if(K == 21) {
        cout << 2 << endl;
    }

    if(K == 22) {
        cout << 2 << endl;
    }

    if(K == 23) {
        cout << 1 << endl;
    }
    
    if(K == 24) {
        cout << 15 << endl;
    }

    if(K == 25) {
        cout << 2 << endl;
    }
    
    if(K == 26) {
        cout << 2 << endl;
    }
    
    if(K == 27) {
        cout << 5 << endl;
    }
    
    if(K == 28) {
        cout << 4 << endl;
    }
    
    if(K == 29) {
        cout << 1 << endl;
    }
    
    if(K == 30) {
        cout << 4 << endl;
    }
    
    if(K == 31) {
        cout << 1 << endl;
    }

    if(K == 32) {
        cout << 51 << endl;
    }
    
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))

def get_res(a_list):
  if 0 in a_list:
    return 0
  res = 1  
  for a in a_list:
    res *= a
    if res>10**18:
      return -1

  return res
print(get_res(a_list))

Measured memory_bytes: 21480
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;


int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  int max = 0, max_i, next = 0;
  for(int j = 0; j < n; j++) {
    if(a[j] > max) {
      max = a[j];
      max_i = j;
    }else if(a[j] > next){
      next = a[j];
    }
  }
  for(int i = 0; i < n; i++) {
    if(i != max_i) cout << max << endl;
    else cout << next << endl;
  }
}


Measured memory_bytes: 2432
import java.util.Scanner;

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

	String s1 = scan.next();
	String s2 = scan.next();
	String s3 = scan.next();

	System.out.println(s1.charAt(0)+""+
			   s2.charAt(1)+""+
			   s3.charAt(2));
    }

}


Measured memory_bytes: 23636
# ~100
n = int(input())
# ~100
s = sorted(int(input()) for _ in range(n))
mask = list(map(lambda x: x % 10 != 0, s))
print([sum(s), sum(s)-s[mask.index(True)]
       if True in mask else 0][sum(s) % 10 == 0])

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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;

    int n = s.size();
    string ans = "AC";

    if(s[0] != 'A') {
        ans = "WA";
    }

    int cnt = 0;
    int ind = -1;
    repu(i, 2, n - 1, 1) {
        if(s[i] == 'C') {
            cnt++;
            ind = i;
        }
    }
    if(cnt != 1) {
        ans = "WA";
    } else {
        repu(i, 1, n, 1) {
            if(i == ind) {
                continue;
            }
            if(not islower(s[i])) {
                ans = "WA";
            }
        }
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int h[100005],n,dp[100005];
int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> h[i];
    }
    dp[1]=0;
    for(int i=2;i<=n;i++){
        if(i!=2)
            dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
        else
            dp[i]=abs(h[i]-h[i-1])+dp[i-1];
    }
    cout << dp[n] << '\n';
return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
        constexpr ll mod = 1e9 + 7;
        ll n, k;
        cin >> n >> k;

        ll ans = 0;
        for (ll i = k; i <= n + 1; i++) {
                ll a = (2 * n - i + 1) * i / 2;
                ll b = (i - 1) * i / 2;

                ll t = a - b + 1;

                ans += t;
                ans %= mod;
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 3592
/*
	Samrat De
	NIT Durgapur
	A Noob Coder
*/

/*#include<iostream>
#include<functional>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>*/
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define mpp(x,y) map<x,y>
#define qq(x) queue<x>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define pi(x,y) pair<x,y>
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rel(i,x,y) for(ll i=x-1;i>=y;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define pf push_front
#define vp(x,y) vec(pi(x,y) )
#define all(x) x.begin(),x.end()
#define indexof order_of_key
#define valueat find_by_order
#define myds tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dxx[8]={0,0,1,-1,-1,-1,1,1};
int dyy[8]={1,-1,0,0,-1,1,1,-1};

/*
unordered_map<ll,ll> um
um.reserve(1<<15);
um.max_load_factor(0.25);
*/

using namespace std;
//using namespace __gnu_pbds;

#define s second
#define f first

int32_t main()
{
	fastio;
// best of luck don't loose hope man	

    int n,m;
    cin>>n>>m;
    vec(pi(ll,ll) ) v;
    rep(i,0,n){
    	ll x,y;cin>>x>>y;
    	v.pb({x,y});
    }
    sort(all(v));
    ll ans=0;
    rep(i,0,n){
    	if(v[i].s<m){
    		ans+=v[i].s*v[i].f;
    		m-=v[i].s;
    	}
    	else{
    		ans+=m*v[i].f;
    		m=0;
    	}
    	if(m==0)
    		break;
    }	
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=1e4+5;

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n,m;cin>>n>>m;
    int x;
    for(int i=1;i<=m;i++){
        cin>>x;
        n-=x;
    }
    if(n>=0) cout<<n;
    else cout<<-1;
}


Measured memory_bytes: 3652
unittest
{
	assert( [ "3 14" ].parse.expand.solve == 2 );
	assert( [ "10 123" ].parse.expand.solve == 3 );
	assert( [ "100000 1000000000" ].parse.expand.solve == 10000 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	return tuple( nm[ 0 ], nm[ 1 ] );
}

auto solve( long n, long m )
{
	for( auto i = m / n; 0 < i; i-- )
	{
		if( m % i == 0 ) return i;
	}
	assert( false );
}


Measured memory_bytes: 256
<?php
list($n, $x) = ints();
$a = ints();
$cnt = 0;
for ($i = 1; $i < $n; ++$i) {
    if ($a[$i] + $a[$i - 1] > $x) {
        $d = $a[$i] + $a[$i - 1] - $x;
        $a[$i] = max(0, $a[$i] - $d);
        $cnt += $d;
    }
}
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

string f(int64_t n) {
    if (n == 0) return "";
    n--;
    return f(n/26) + (char)('a' + n%26);
}

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=505;
int ans[N][N];
int main()
{
	int n;
	scanf("%i",&n);
	int l;
	for(l=0;;l++)
	{
		vector<int> v[2];
		for(int i=0;i<n;i++) v[i>>l&1].pb(i+1);
		if(v[1].empty()) break;
		for(int i:v[0]) for(int j:v[1]) ans[min(i,j)][max(i,j)]=l+1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++) printf("%i ",ans[i][j]);
		printf("\n");
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  
  if(n%1111==0){
    cout<<"Yes"<<endl;
  }
  
  else if(n%1110<=9){
    cout<<"Yes"<<endl;
  }
  else if((n%1000)%111==0){
    cout <<"Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	bool a[26];
	fill(a, a + 26, 1);
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		a[(int)s[i] - 'a'] = 0;
	}
	for (int i = 0; i < 26; i++) {
		if (a[i]) {
			cout << (char)(i + 'a') << endl;
			goto loop;
		}
	}
	cout << "None\n";
loop:;
	getchar(); getchar();
}

Measured memory_bytes: 512
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
    
N = int(input())
    
print(sum(num_divisors_table(N)[:-1]))

Measured memory_bytes: 24664
W, H, x, y, r = map(int, input().split())
if 0 < x < W and 0 < y < H:
    if 0 <= x+r <= W and 0 <= x-r <= H:
        if 0 <= y+r <= W and 0 <= y-r <= H:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')



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

int main(){
    int n, d;
    cin >> n >> d;
    int cnt = 0;
    while(n > 0){
        n -= (d * 2 + 1);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

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 vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >>ty;
  vector <char>ans;
  rep(i, tx-sx) ans.push_back('R');
  rep(i, ty-sy) ans.push_back('U');
  rep(i, tx-sx) ans.push_back('L');
  rep(i, ty-sy) ans.push_back('D');
  ans.push_back('L');
  rep(i, ty-sy+1) ans.push_back('U');
  rep(i, tx-sx+1) ans.push_back('R');
  ans.push_back('D');
  ans.push_back('R');
  rep(i, ty-sy+1) ans.push_back('D');
  rep(i, tx-sx+1) ans.push_back('L');
  ans.push_back('U');
  rep(i, ans.size()){
    cout << ans[i] << "";
  }
}
  


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >>k;
    if(e - a > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!"<< endl;
    }
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
//#define TASK "z2prefix"
#define pb push_back
#define fi first
#define se second
#define double long double
using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) (void)42
#endif

// every true-boy doesn't read statement!

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < int > vi;
typedef vector < string > vs;

const int MAXF = 3001;

int A, B, C, D, E, F;

bool inline better(const pii &a, const pii &b) {
	return a.fi * b.se - a.se * b.fi > 0;
}

void solve() {
	cin >> A >> B >> C >> D >> E >> F;
	pii ans = { 0, 100 * A }, pp;
	for (int i = 0; i <= 32; i++) {
		for (int j = 0; j <= 32; j++) {
			int max_ss = (A * i + B * j) * E;
			int ww = (A * i + B * j) * 100;
			
			if (ww > F)
				continue;
			for (int u = 0; u <= 1501; u++) {
				for (int v = 0; v <= 1501; v++) {
					int ss = (C * u + D * v);
					if (ss + ww > F || ss > max_ss)
						continue;
					pp = { ss, ww + ss };
					if (better(pp, ans))
						ans = pp;
				}
			}
		}
	}
	cout << ans.se << " " << ans.fi;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	assert(freopen("xxx.in", "r", stdin));
	assert(freopen("xxx.out", "w", stdout));
#else
	//assert(freopen(TASK".in", "r", stdin));
	//assert(freopen(TASK".out", "w", stdout));
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
def solve(s):
    return max(int(s[:i]) * int(s[i:]) for i in range(1, len(s)))

for _ in range(int(input())):
    s = input()
    cnt = 0
    while len(s) > 1:
        cnt += 1
        s = str(solve(s))
    print(cnt)


Measured memory_bytes: 5608
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 10000000000000000
typedef long long ll;

struct edge { ll from, to, cost; };
edge es[2020];
ll d[1009];
bool negative[1009];
int N, M;

void bell(){
    
    fill(d,d+1009,INF);
    d[1]=0;
    
    rep(i,N-1){
        rep(j,M){
            edge e = es[j];
            //cout3(d[e.to], d[e.from], e.cost);
            if(d[e.from]==INF) continue;
            if(d[e.to] > d[e.from] + e.cost ){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
}

bool is_negative(){
    
    mem(negative,false);
    
    rep(i,N){
        rep(j,M){
            edge e = es[j];
            if(d[e.from]==INF) continue;
            if(d[e.to] > d[e.from] + e.cost ){
                d[e.to] = d[e.from] + e.cost;
                negative[e.to] = true;
            }
            if(negative[e.from]){
                negative[e.to] = true;
            }
        }
    }
    return negative[N];
}

int main() {
    
    cin>>N>>M;
    
    rep(i,M){
        ll a,b,c; cin3(a,b,c);
        es[i] = {a,b,-c};
    }
    
    bell();
    if(is_negative()){
        cout1("inf");
    }else{
        cout1(-d[N]);
    }
    
}

Measured memory_bytes: 256
/// sultanov_       
/// @bachaquer TOP
 
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define size(x) (int) x.size()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;                                   
 
const int INF32 = INT_MAX;
const ll INF64 = ((ll)INF32 << 29ll);

void reflex() {                   
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr); 
}   

signed main() {
    reflex();      
    int n, x;
    cin >> n >> x;
    int prev = 0, ans = 1;
    for (int i = 0, y; i < n; i++) {
        cin >> y, y += prev;
        ans += (y <= x);
        prev = y;
    }
    cout << ans;
    return false;                                                       
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
N=int(input())
A = [None]*N
for i in range(N):
    m = int(input())
    A[i] = [list(map(int,input().split())) for _ in [0]*m]

ans = 0
for i in range(2**N):
    done = [-1]*N
    for j in range(N):
        if (i>>j)&1==0:
            if done[j] == 1: break
            done[j] = 0
            continue
        if done[j] == 0 : break
        done[j] = 1
        breakFlg = False
        for x,y in A[j]:
            x -= 1
            if done[x] == -1:
                done[x] = y
            elif done[x] != y:
                breakFlg = True
                break
        if breakFlg: break
    else:
        tmp = sum(map(int,bin(i)[2:]))
        ans = max(ans,tmp)
print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define DEV_VAL (1000000000 + 7)

int main()
{
  ll n;
  cin >> n;
  vector<ll> val;
  ll sum = 0;

  repl(i, n)
  {
    ll tmp;
    cin >> tmp;
    val.push_back(tmp);
    sum ^= tmp;
  }

  repl(i, n)
  {
    ll a = sum ^ val[i];
    cout << a << ' ';
  }
  cout << endl;


  return 0;
}

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
int main() {
 int n , x;
 cin >> n >> x;
 int l[n];
 rep (i,n) cin >> l[i];
 int cnt = 0,d=0;
 rep (i,n+1){
   if (d>x){
     break;
   }
   cnt++;
   d+=l[i];
 }
 cout << cnt << endl;

}


Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

int readint()
{
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9')
	{
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}

const int maxn=200005;
int n,r,l;
int a[maxn],ans[maxn];

int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	r=n-1;
	for(int i=n-1;i>=0;i--){
		if((n-i)&1)ans[l++]=a[i];
		else ans[r--]=a[i];
	}
	rep(i,n)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

int main(){
    int k,n ;
    cin >> k >> n ;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    int M = 0 ;
    for (size_t i = 0; i < n-1; i++)
    {
        M = max(M,a.at(i+1) - a.at(i)) ;
    }
    M = max(M , k+a.at(0) - a.at(n-1) ) ;
    cout << k - M << endl ;
}

Measured memory_bytes: 1024
def is_acgt(s):
    for c in list(s):
        if c not in ["A", "C", "G", "T"]:
            return False
    return True


S = input()
N = len(S)
ans = 0
for l in range(N):
    for r in range(N, l, -1):
        ss = S[l:r]
        if is_acgt(ss):
            ans = max(ans, len(ss))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  string s;
  cin >> s;
  vector<string> h = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

  rep(i, 7) {
    if (h[i] == s) {
      cout << 7-i << endl;
    }
  }
}


Measured memory_bytes: 256
package main

import "fmt"

func printSlice(a []int) {
	for i, e := range a {
		if i > 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%d", e)
	}
	fmt.Printf("\n")
}

func sort(a []int) {
	for i, e := range a {
		j := i - 1
		for 0 <= j && e < a[j] {
			a[j+1] = a[j]
			j--
		}
		a[j+1] = e
		printSlice(a)
	}
}

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

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort(a)
}



Measured memory_bytes: 1204
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

typedef long long ll;
typedef long double ld;
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPR(i,a,b) for(int i = b; i >= a; i--)
#define all(a)              a.begin(), a.end()
#define alln(a, n)          (a, a+n)
#define sz(x) (int)(x).size()
#define MAX                 10000007
#define MIN                 -10000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mii             map<int,int>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf 1e18
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<vi> vvi; 
typedef vector<string> vs;
typedef set<int> si;
const int MOD=1e9+7;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b,ll MOD){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2,MOD) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2,MOD);}
ll fact[1],inv[1];
void factorial(ll n){
  fact[0]=1;
  for(ll i=1;i<=n;i++){
    fact[i]=fact[i-1]*i;
    if(fact[i]>=MOD)
      fact[i]%=MOD;
  }
}
ll ncr(ll n,ll r){
  if(n<r||n<0||r<0)
    return 0;
  ll b=inv[n-r];
  ll c=inv[r];
  ll a=fact[n]*b;
  if(a>=MOD)
    a%=MOD;
  a*=c;
  if(a>=MOD)
    a%=MOD;
  return a;
}
vector<char> is_prime(100001, true);
void sieve(ll n){
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i)
                  is_prime[j] = false;
        }
  }    
}     
 
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      
    int t;
    t=1;
    cout<<fixed<<setprecision(0);
     //  cin>>t;
    while(t--){
            int n,maxx=0,c=0;
            cin>>n;
            REP(i,0,n-1){
              int a,b;
              cin>>a>>b;
              if(a==b) c++;
              else {maxx=max(maxx,c);c=0;}
            }  
            maxx=max(maxx,c);
            maxx>=3?cout<<"Yes\n":cout<<"No\n";
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3904
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t X, Y;
	int asumisu = 1;
	uint64_t miyukiti;
	if (scanf("%" SCNu64 "%" SCNu64, &X, &Y) != 2) return 1;
	miyukiti = X;
	while (miyukiti * 2 <= Y) {
		miyukiti *= 2;
		asumisu++;
	}
	printf("%d\n", asumisu);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

const int MAX_N = 301;
int N;
vector<int> a;

double dp[MAX_N][MAX_N][MAX_N];
double solve(int i, int j, int k) {
  if (dp[i][j][k] != -1) return dp[i][j][k];
  if (i == 0 && j == 0 && k == 0) return 0.0;

  double res = N;
  if (i > 0) res += i * solve(i - 1, j, k);
  if (j > 0) res += j * solve(i + 1, j - 1, k);
  if (k > 0) res += k * solve(i, j + 1, k - 1);
  res /= (i + j + k);

  return dp[i][j][k] = res;
}

int main() {
  cin >> N;
  a.resize(N);

  map<int, int> c;
  rep(i, N) {
    cin >> a[i];
    c[a[i]]++;
  }
  rep(i, N + 1) rep(j, N + 1) rep(k, N + 1) dp[i][j][k] = -1;

  cout << setprecision(10) << solve(c[1], c[2], c[3]) << endl;

  return 0;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    VI jj{4,2,0,9,7};
    VI id{0,7,3,10,6,2,9,5,1,8,4};
    VI v{0,8,5,2,10,7,4,1,9,6,3,0,8,5,2,10,7,4,1,9,6,3};
    int n,k; cin >> n >> k;
    int ans = 0;
    REP(j,5){
        ans += (n-2)/11;
        int q = (n-2)%11;
        REP(i,q){
            if(v[id[jj[j]]+i] == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

struct dat{ string s; int i; };

int main(){
	string str;
	int a[8];
	dat d, d2;
	
	map<string, int> cost;
	map<string, bool> checked;
	
	queue<dat> que;
	
	cost["01234567"] = 0;
	checked["01234567"] = true;
	
	d.s = "01234567"; d.i = 0;
	que.push(d);
	while(!que.empty()){
		d = que.front(); que.pop();
		//cout << d.s << " " << d.i << endl;
		for(int i = 0; i < 8; i++){
			if(d.s[i] == '0'){
				if(i % 4 > 0){
					d2 = d;
					swap(d2.s[i], d2.s[i - 1]);
					if(!checked[d2.s]){
						checked[d2.s] = true;
						cost[d2.s] = d.i + 1;
						d2.i += 1;
						que.push(d2);
					}
				}
				if((i + 1) % 4 > 0){
					d2 = d;
					swap(d2.s[i], d2.s[i + 1]);
					if(!checked[d2.s]){
						checked[d2.s] = true;
						cost[d2.s] = d.i + 1;
						d2.i += 1;
						que.push(d2);
					}
				}
				
				break;
			}
		}
		for(int i = 0; i < 8; i++){
			if(d.s[i] == '0'){
				if(i < 4){
					d2 = d;
					swap(d2.s[i], d2.s[i + 4]);
					if(!checked[d2.s]){
						checked[d2.s] = true;
						cost[d2.s] = d.i + 1;
						d2.i += 1;
						que.push(d2);
					}
				}
				else{
					d2 = d;
					swap(d2.s[i], d2.s[i - 4]);
					if(!checked[d2.s]){
						checked[d2.s] = true;
						cost[d2.s] = d.i + 1;
						d2.i += 1;
						que.push(d2);
					}
				}
				
				break;
			}
		}
	}
	
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7]){
		for(int i = 0; i < 8; i++){
			str += a[i] + 48;
		}
		cout << cost[str] << endl;
		str.erase();
	}
	
	return 0;
}

Measured memory_bytes: 5664