akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = [0] * n
    ans = 0
    for i in range(n):
        ai = a[i]
        l, r = i + ai, i - ai
        if 0 <= l < n:
            d[l] += 1
        if 0 <= r < n:
            ans += d[r]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 92768
N = gets.to_i
Rs = N.times.map{gets.split.map(&:to_i)}
Bs = N.times.map{gets.split.map(&:to_i)}

cnt = 0
Bs.sort_by{|b| b[0]}.each do |b|
  if r = Rs.select{|r| r[0] < b[0] && r[1] < b[1]}.max_by{|r| r[1]}
    cnt += 1
    Rs.delete(r)
  end
end
puts cnt

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int mod=1000000007 ;

void solve(){
	
	int n ;
	cin>> n ;

	int a,b ;
	cin>>a>>b ;

	bool flag=false ;

	for(int i=a;i<=b;i++){
		if(i%n==0)
		{
			flag=true ;
			//cout<<i<<"\n" ;
			break ;
		}
	}

	if(flag==true)
		cout<<"OK";
	else
		cout<<"NG" ;
 

}


int main(){


	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int maxl = 1, minr = n;
    for (int i = 0; i < m; i++){
        int lhs, rhs;
        cin >> lhs >> rhs;
        maxl = max(maxl, lhs);
        minr = min(minr, rhs);
        if (lhs > minr or rhs < maxl){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << minr - maxl + 1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>    


int main(void)
 {
   int foo, bar;
   int hoge;
   int x;


 scanf("%d", &foo);scanf("%d", &bar);

  x = 0;
  hoge = 0;
  while (x < bar) {
    hoge += foo;
    x++;
  }
  printf("%d %d", hoge, foo + bar + foo + bar);

  printf("\n");

  
  return (0);
}





Measured memory_bytes: 2048
#include <stdio.h>
#include <math.h>
#define LL long long int
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b!=c||a==c&&a!=b||b==c&&a!=b)
    printf("Yes");
    else printf("No");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  string s;
  int n = 0;
  cin >> s >> n;
  for(int i = 0;i < s.size();i++){
    if((int)('z' - s[i]) + 1 <= n && s[i] != 'a'){
      n -= (int)('z' - s[i]) + 1;
      s[i] = 'a';
      //cout << s[i] << endl;
    }
    //cout << i << " " << n << endl;
  }
  n %= 26;
  if(n > 0){
    for(int i = s.size() - 1;i >= 0;i--){
      if(s[i] != 'a'){
        s[i] += n;
        n = 0;
        break;
      }
    }
  }
  if(n > 0)s[s.size() - 1] += n;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>


using namespace std;

int main() {
    int A, B, C, ans=0;
    cin >> A >> B >> C;

    for (int i = A; i <= B; i += A) {
        if (ans < C) {
            ans++;
        }
        else {
            break;
        }
    }
    cout << ans;
    return 0;
} 


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

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

  ll n, a, b, c, d, e; 
  cin >> n >> a >> b >> c >> d >> e;

  ll min_elem = min({a, b, c, d, e});
  cout << (n + min_elem - 1)/min_elem + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

class Edge{
public:
	long long from;
	long long to;
	long long w;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	bool N=false;
	bool W=false;
	bool S=false;
	bool E=false;
	
	for(int i=0;i<s.length();i++){
		if(s[i]=='N')N=true;
		if(s[i]=='S')S=true;
		if(s[i]=='E')E=true;
		if(s[i]=='W')W=true;
	
	}if(S!=N || W!=E){
		cout<<"No"<<endl;
		return 0;
		}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;


template<typename T, typename S>
struct LazySegmentTree{
private:
    int n;
    vector<T> node;
    vector<S> lazy;
    T E0;
    S E1;

    inline void updatef(S& lazy,S& value){
        lazy += value;
        lazy%=mod;
    }
    inline void calculatef(T& node,S& lazy,int len){
        node += lazy * len % mod;
        node%=mod; //区間sumはこっち
    }
    inline T queryf(T& x,T& y){
        return (x + y)%mod;
    }
public:
    LazySegmentTree(int sz,T nodeE,S lazyE ):E0(nodeE), E1(lazyE){
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E0);
        lazy.resize(2*n-1,E1);
    }

    LazySegmentTree(vector<T>& v,T E0,S E1 ):E0(E0),E1(E1){
        n=1;
        int sz=v.size();
        while(n<sz)n<<=1;
        node.resize(2*n-1,E0);
        lazy.resize(2*n-1,E1);
        rep(i,sz)node[i+n-1] = v[i];
        for(int i=n-2; i>=0; --i){
            node[i] = queryf(node[2*i+1],node[2*i+2]);
        }
    }

    void eval(int k,int l,int r){
        if(lazy[k]==E1)return ;
        calculatef(node[k], lazy[k], r-l);
        if(r-l>1){
            updatef(lazy[2*k+1], lazy[k]);
            updatef(lazy[2*k+2], lazy[k]);
        }
        lazy[k]=E1;
    }

    void update(int a, int b, S x,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        eval(k,l,r);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            updatef(lazy[k], x);
            eval(k,l,r);
        }
        else {
            update(a,b,x,2*k+1,l,(l+r)/2);
            update(a,b,x,2*k+2,(l+r)/2,r);
            node[k]=queryf(node[2*k+1], node[2*k+2]);
        }
    }

    T query(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        eval(k,l,r);
        if(r<=a||b<=l)return E0;
        if(a<=l&&r<=b)return node[k];
        T xl=query(a,b,2*k+1,l,(l+r)/2);
        T xr=query(a,b,2*k+2,(l+r)/2,r);
        return queryf(xl, xr);
    }
};


ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    ll n,k,a;
    cin>>n>>k>>a;
    LazySegmentTree<ll,ll> sg(n+k+2,0,0);
    ll p = powmod(n,mod-2);
    a*=powmod(100,mod-2);
    a%=mod;
    sg.update(1,n+1,p);
    REP(i,1,k){
        auto ret = sg.query(i,i+1);
        sg.update(i+1,i+n+1,ret*a%mod*p%mod);
    }
    cout<<sg.query(k,k+n)<<endl;
    return 0;
}


Measured memory_bytes: 11024
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

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

 int main(){
    int64_t a, b, p; cin >> a >> b;
    p = gcd(a,b);
      
    int64_t c = 1;
    if (p % 2 == 0){
        c++;
        while(p % 2 == 0) p /= 2;
    }
  
    for (int64_t i = 3; i*i <= p; i+=2) {
        if(p % i == 0){
            c++;
            while (p%i == 0) p /= i;
        }
      	if(p == 1) break;
	}
  	if(p != 1) c++;
 
    cout << c << endl;
}


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

using namespace std;
#define int long long
int arr[152052];
signed  main(){
     int ans=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        scanf("%lld",&arr[i]);
    int temp=arr[1];
    for(int i=1;i<=n;i++){
        if(i==n){  // 特判一下
            ans+=max(arr[i],temp);
        }else{
            if(arr[i]>=temp){
                temp=arr[i]; 
                //cout<<1<<" "<<temp<<endl;
            }else{
                ans+=abs(arr[i]-temp);// 需要减去多加的数
                temp=arr[i];//cout<<2<<" "<<temp<<endl;
            }
        }
    } 
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> g(N);
    vector<ll> cost(N);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        g[a - 1].emplace_back(b - 1);
    }
    REP(i, Q) {
        int p, q;
        cin >> p >> q;
        cost[p - 1] += q;
    }
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int now = que.front();
        que.pop();
        ll c = cost[now];
        REP(i, g[now].size()) {
            int nxt = g[now][i];
            cost[nxt] += c;
            que.push(nxt);
        }
    }
    print(cost);

    return 0;
}

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

int main(){
  int N;
  cin>>N;
  map<string, int> poll;
  for(int i=0; i<N; i++){
    string S;
    cin>>S;
    if(!poll.count(S)) poll[S]=1;
    else poll[S]++;
  }
  int max=0;
  for (auto p : poll) {
  auto v = p.second;
  if(v>max) max=v; 
}
  priority_queue<string, vector<string>, greater<string>> kouho;
  for (auto p : poll) {
  auto k = p.first;
  auto v = p.second;
  if(v==max) kouho.push(k);
}
  while(!kouho.empty()){
    cout<<kouho.top()<<endl;
    kouho.pop();
  }
}
 

Measured memory_bytes: 26868
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

    left = right = 0
    for s in S:
        if s == '(':
            left += 1
        elif left > 0:
            left -= 1
        else:
            right += 1

    ans = '(' * right + S + ')' * left
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61932
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep_r(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define RESIZE(x, n) x.resize(n)
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MAX = 100000;
struct edge {
    ll from, to, weight;
    edge(ll f, ll t, ll w) : from(f), to(t), weight(w) { }
};
vector<vector<edge>> edges;
vector<vector<ll>> graph;
vector<bool> visited;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll n, k;

// ll dp[2001][2001];
vvl dp;
ll ncr(ll n, ll r) { // nCrの組み合わせ
    if (n < r) return 0;
    if (dp[n][r] != -1) return dp[n][r];
    for (ll i = 0; i <= n; i++) {
        for (ll j = 0; j <= i; j++) {
            if (j == 0 || i == j) dp[i][j] = 1;
            else dp[i][j] = dp[i-1][j-1] % mod + dp[i-1][j] % mod;
        }
    }
    return dp[n][r] % mod;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // memset(dp, -1, sizeof(dp));  
    cin >> n >> k;
    dp.resize(n+1, vl(n+1, -1));
    for (ll i = 1; i <= k; i++) {
        ll answer = ncr(n-k+1, i) * ncr(k-1, i-1) % mod;
        // printf("%lld回の場合 %lld\n", i, answer);
        cout << answer << "\n";
    }
}

Measured memory_bytes: 34560
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

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


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

#define LOG(FMT...) fprintf(stderr, FMT)

const int MAXN = 1e3 + 20;
const int INF = 1e9;

ll mod = 1e9 + 7;

ll ml(ll a, ll b){
    return(a * b) % mod;
}

ll add(ll a, ll b) {
    return (a + b) % mod;
}

void solve() {
    ll a;
    cin >> a;
    cout << a + a * a + a * a * a;
}

#else

void solve() {

}

#endif


void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Mission #" << (i++) << ": \n";

        solve();
//        cout << "\n";
    }
}



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

#ifdef multi
//    gen();

//    doo();

    multisolve();
#else
    solve();
    //    gen();
#endif

}


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

int main() {
	long long ans = 0;
	int n;
	cin >> n;
	vector<int> a(n);
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	ans += a[0] / 2;
	a[0] %= 2;
	
	for(int i = 1; i < n; i++){
		if((a[i-1] > 0) && (a[i] > 0)){
			ans++;
			a[i-1]--;
			a[i]--;
		}
		ans += a[i] / 2;
		a[i] %= 2;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin >> s;
    vector<int> a;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A' || s[i] =='C' || s[i] =='G' || s[i] =='T') {
            ans += 1;
        }
        else ans = 0;
        a.push_back(ans);
    }
    cout << *max_element(a.begin(), a.end());
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string a,b,c;
  cin>>a>>b>>c;
  a.push_back('x');
  b.push_back('x');
  c.push_back('x');
  reverse(ALL(a));
  reverse(ALL(b));
  reverse(ALL(c));
  char tmp='a';
  while(true){
    if(tmp=='a'){
      if(a.size()==1){
        cout<<'A'<<endl;
        return 0;
      }
      tmp=a[a.size()-1];
      a.pop_back();
    }else if(tmp=='b'){
      if(b.size()==1){
        cout<<'B'<<endl;
        return 0;
      }
      tmp=b[b.size()-1];
      b.pop_back();
    }else if(tmp=='c'){
      if(c.size()==1){
        cout<<'C'<<endl;
        return 0;
      }
      tmp=c[c.size()-1];
      c.pop_back();
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a ,b, c, d, e, X, Y ,r;
  long long  a, b, c, d, e, X, Y;
  //  double  c;
 long long  A[200003]={};
//  int  A[100003]={};
  int  B[100003]={};
  long long  C[100003][100001]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  long long min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld", &a);
  for(i=0;i<9;i++){
    scanf("%lld", &A[i]);
//    printf("%lld ", A[i]);
  }
  scanf("%lld", &a);
  for(i=0;i<a;i++){
    scanf("%lld", &b);
//    printf("%lld ", b);
    for(j=0;j<9;j++){
      if(A[j]==b) B[j]=1;
    }
  }
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
//       printf("%d ",B[i]);
    }
//    printf("\n");
  }
  if(B[0] && B[1] && B[2])   printf("Yes\n"); 
  else if(B[3] && B[4] && B[5])   printf("Yes\n"); 
  else if(B[6] && B[7] && B[8])   printf("Yes\n"); 
  else if(B[0] && B[3] && B[6])   printf("Yes\n"); 
  else if(B[0] && B[3] && B[6])   printf("Yes\n"); 
  else if(B[1] && B[4] && B[7])   printf("Yes\n"); 
  else if(B[2] && B[5] && B[8])   printf("Yes\n"); 
  else if(B[0] && B[4] && B[8])   printf("Yes\n"); 
  else if(B[2] && B[4] && B[6])   printf("Yes\n"); 
  else     printf("No\n"); 
  
return 0;
}


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

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

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



int main(){
  int N; cin >> N;
  int A,B; cin >> A >> B;
  int ans = min(A*N,B);
  cout << ans << endl;

}


Measured memory_bytes: 256
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    s=input()
    if s=='AC':
        ac+=1
    elif s=='WA':
        wa+=1
    elif s=='TLE':
        tle+=1
    elif s=='RE':
        re+=1

print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::string S;
int dp[5100][5100];

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

  std::cin >> N >> S;

  int res = 0;

  for(int i=1;i<=N;++i){
      for(int j=i+1;j<=N;++j){
          if(S[i-1] == S[j-1]){
              dp[i][j] = std::min(dp[i-1][j-1] + 1, j - i);
              res = std::max(res, dp[i][j]);
          }

          // std::cerr << dp[i][j] << " ";
      }
      // std::cerr << std::endl;
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 100608
#include <bits/stdc++.h>
using namespace std;
void Countingsort(const unsigned short *arrayA, unsigned short *arrayB, int n, unsigned short max)
{
    int arrayC[max + 1] = {};
    for (int j = 0; j < n; ++j)
        arrayC[arrayA[j]]++;
    for (int i = 1; i <= max; ++i)
        arrayC[i] += arrayC[i - 1];
    for (int j = n - 1; j >= 0; --j)
    {
        arrayB[arrayC[arrayA[j]]] = arrayA[j];
        arrayC[arrayA[j]]--;
    }
}
int main()
{
    int n;
    cin >> n;
    unsigned short A[n], B[n + 1] = {}, max(0);
    for (int i = 0; i < n; ++i)
    {
        scanf("%hu", &A[i]);
        if (max < A[i])
            max = A[i];
    }
    Countingsort(A, B, n, max);
    for (int i = 1; i < n; ++i)
        printf("%d ", B[i]);
    cout << B[n] << endl;
}


Measured memory_bytes: 11028
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
using ll = long long;

int h[200000];
int visit[200000];
int n, m;
vector<int> edge[200000];
int ans = 0;
int maxh;
int cnt;
bool bfs(int st)
{
    int maxh = -1;
    REP(i, edge[st].size())
    {
        int next = edge[st][i];
        maxh = max(h[next], maxh);
    }
    if (maxh == -1)
    {
        return true;
    }
    else
    {
        if (maxh < h[st])
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

int main(void)
{
    cin >> n >> m;
    fill(visit, visit + 200000, -1);
    REP(i, n)
    {
        cin >> h[i];
    }

    REP(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        edge[a].push_back(b);
        edge[b].push_back(a);
        /*
        if (!binary_search(edge[a].begin(), edge[a].end(), b))
        {
            edge[a].push_back(b);
        }
        if (!binary_search(edge[b].begin(), edge[b].end(), a))
        {
            edge[b].push_back(a);
        }
        */
    }

    REP(i, n)
    {
        if (bfs(i))
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12276
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
using namespace std;


int main()
{
   
   string w;
   cin>>w;
   size_t i;
	
   map<char,int>  count;
   
   for(char c:w)
   {
   	
   	count[c]++;
   	
   }
   
   
   	
    for(i=0;i<w.size();i++)
	{

	     if(count[w[i]]%2!=0)
		 {
		 	
		 	break;
		 	
		 }	
		
		
	}	
	
	
	
	if(i==w.size())
	{
		
		cout<<"Yes"<<endl;
		
	}
	
	
	else
	{
		
		
		cout<<"No"<<endl;
	}
	
	
	
	
	return 0;
	
}

Measured memory_bytes: 3572
import std.stdio, std.string, std.conv;
void main() {
	readln;
	int[10][3][4] d;
	foreach (string l; lines(stdin)) {
		auto r = l.chomp.split.to!(int[]);
		d[r[0]-1][r[1]-1][r[2]-1] += r[3];
	}
	foreach (j; 0..4) {
		foreach (i; d[j]) {
			" %s".writefln(i.to!(string[]).join(" "));
		}
		if (j != 3) "####################".writeln;
	}
}

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

int main(){

  int cnt, c[3], num[11];

  while(cin >> c[0] >> c[1] >> c[2]){
    cnt = 0;
    fill(num+1, num+11, 0);
    for(int i=0; i<3; i++){
      for(int j=1; j<11; j++){
        if(c[i] == j){
          num[j] = 1;
          break;
        }
      }
    }

    int m = 20 - (c[0] + c[1]);
    for(int i=1; i<11; i++){
      if(num[i] == 0 && i <= m) cnt++;
    }

    cout << ((cnt>=4)? "YES":"NO") << endl;

  }

  return 0;

}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		if(A == 1) {
			if(B == 1) {
				System.out.println("Draw");
			}else {
				System.out.println("Alice");
			}
		}else if(B == 1) {
			if(A == 1) {
				System.out.println("Draw");
			}else {
				System.out.println("Bob");
			}
		}else {
			if(A == B) {
				System.out.println("Draw");
			}else if(A > B) {
				System.out.println("Alice");
			}else {
				System.out.println("Bob");
			}
		}
	}
}


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

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

    string answer = "NO";
    for (int i = a; i <= b * a; i += a)
    {
        if (i % b == c)
        {
            answer = "YES";
            break;
        }
    }
    cout << answer << endl;
}

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

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	
	if(a>=13) printf("%d\n",b);
	if(5<a&&a<13) printf("%d\n",b/2);
	if(a<=5) printf("%d\n",0);
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<tuple>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	REP(i, n) cin>>a[i];
	vector<int> dp(n + 1);
	dp[0] = -1;
	FOR(i, 1, n + 1) {
		dp[i] = INF;
	}
	FOR(i, 1, n + 1) {
		vector<int>::iterator ite = lower_bound(ALL(dp), a[i - 1]);
		if(ite != a.end()) *ite = a[i - 1];
	}
	int res = 0;
	REP(i, n + 1) {
		if(dp[i] != INF) res = i;
	}
	cout<<res<<endl;
}

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

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

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        if (i % 2 == 1 && a % 2 == 1) ans++;
    }

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


Measured memory_bytes: 3620
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){  
  ll n,m;cin>>n>>m;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<ll>sum(n+1,0);
  rep(i,n)sum[i+1]=sum[i]+a[i];
  rep(i,n+1)sum[i]%=m;
  map<ll,ll>count;
  rep(i,n+1)count[sum[i]]++;
  ll ans=0;
  for(auto&&i:count)ans+=i.second*(i.second-1)/2;
  cout<<ans<<endl;
  
  
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
#define ll long long int
#define ld long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back

using namespace std;
typedef pair<int, int> pii;

#define MOD 1000000007;

int main() {
    fastIO;
    int n;
    cin >> n;
    ll ans = 1;
    ll no0 = 1;
    ll no1 = 1;
    ll no2 = 1;
    for (int i = 1; i <= n; i++) {
        ans *= 10;
        no0 *= 9;
        no1 *= 9;
        no2 *= 8;
        no2 %= MOD;
        no0 %= MOD;
        no1 %= MOD;
        ans %= MOD;
    }

    ans -= no0;
    ans -= no1;
    ans += no2;
    ans += (ll) 3 * MOD;
    ans %= MOD;
    cout << ans;
}


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

int main(){
  int n,k; cin>>n >>k;
  int ans=0;
  for(int i=0;i<n;i++){
    int x; cin>>x;
    ans+=min(2*abs(x-k),2*x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m,x=map(int,input().split())
info=[]
for i in range(n):
    z=list(map(int,input().split()))
    info.append(z)
ans=10**9
for i in range(2**n):
    skill=[x]*m
    total=0
    for j in range(n):
        if (i>>j)&1: #j番目の本を買う
            total+=info[j][0]
            for k in range(m):
                skill[k]-=info[j][1+k]
            flag=True
            for k in range(m):
                if 0<skill[k]:
                    flag=False
                    break
            if flag:
                if total<ans:
                    ans=total
print(ans if ans<10**9 else -1)

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

void func_A() {
    int A, B;
    cin >> A >> B;
    int res = A > 2 * B ? A - 2 * B : 0;
    cout << res << endl;
}

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

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

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    ll p = c - a - b;
    if(p > 0 && (4*a*b < p*p)) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
n = int(input())
stick = list(map(int, input().split()))
s_sum = [0 for _ in range(n)]
s_sum[0] = stick[0]
for i in range(1, n):
    s_sum[i] = s_sum[i-1]+stick[i]
ans = [abs(2*s_sum[i]-s_sum[-1]) for i in range(n)]
print(min(ans))


Measured memory_bytes: 30092
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] input =Console.ReadLine().Split(' ');
      int A=int.Parse(input[0]);
      int K=int.Parse(input[1]);
      int ans=1;
      while((A/K)>0){
        ans++;
        A=(A/K);
      }
	
      Console.WriteLine(ans);
  }

}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    // 青いカード
    int N;
    cin >> N;
    vector<string> blue( N );
    for( auto &&x : blue )
    {
        cin >> x;
    }
    // 赤いカード
    int M;
    cin >> M;
    vector<string> red( M );
    for( auto &&x : red )
    {
        cin >> x;
    }
    // 青いカードに書かれた文字列の重複数をカウントする
    map<string, int> mp;
    for( auto &&x : blue )
    {
        ++mp[ x ];
    }
    // 赤いカードに書かれた文字列の重複数カウントを削除する
    for( auto &&x : red )
    {
        --mp[ x ];
    }
    // 青いカードに書かれた文字列の MAX を取る
    int res{};
    for( auto && x : mp )
    {
        res = max( res, x.second );
    }
    cout << res << endl;
    return 0;
}

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

int main()
{
    int n, a, b;
    
    cin >> n;
    
    a = n / 10;
    b = n % 10;
    
    
    if((a == 9) || (b == 9)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main() {
    int n = 0;
    int t = 0, a = 0;
    scanf("%d\n%d %d\n", &n, &t, &a);
    int ans = 0;
    int buf = 0;
    double hoge = 0, min = 0;
    for (int i=0; i<n; i++) {
        scanf("%d", &buf);
        hoge = fabs(a - t + buf * 0.006);
        if (i == 0) {
            ans = 1;
            min = hoge;
        }
        else if (hoge < min) {
            ans = i+1;
            min = hoge;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main ()
{
  string S;cin>>S;
  if(S[0]!='A'){
    cout<<"WA"<<endl;
    return 0;
  }
  S[0]='a';
  int flag =0;
  for(int i =2;i<S.size()-1;i++){
    if(S[i]=='C'){
      flag++;
      S[i] = 'c';
    }
  }
  if(flag!=1){
    cout<<"WA"<<endl;
    return 0;
  }
  for(int i=0;i<S.size();i++){
    if(S[i]<97){
      cout<<"WA"<<endl;
      return 0;
    }
  }
  cout<<"AC"<<endl;
  return 0;
}

Measured memory_bytes: 256
/****************
 *		*
 *ALDS_1_5_D	*
 *The Number	*
 *Of Inversions	*
 *		*
 *2019/08/31	* 
 *		*
 ****************/

#include<iostream>
#include<cstdio>

using namespace std;

#define MAX_ARRAY 500000
#define MAX_LIMIT 1000000001

int S[MAX_ARRAY];

/*
 *整列済みの２つの配列を１つの配列にまとめる関数
 */
long long merge(int left,int mid,int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  int Left[MAX_ARRAY/2+1];
  int Right[MAX_ARRAY/2+1];
  long long  count_inversion = 0;
  
  for(i=0;i<n1;i++) Left[i] = S[left + i];
  Left[n1] = MAX_LIMIT;
  for(j=0;j<n2;j++) Right[j] = S[mid + j];
  Right[n2] = MAX_LIMIT;

  i=0;
  j=0;

  for(k=left;k<right;k++){
    if(Left[i] <= Right[j]){
      S[k] = Left[i];
      i++;
    }
    else {
      S[k] = Right[j];
      j++;
      count_inversion += (n1-i);
    }
  }

  return count_inversion;
}

/*
 *配列をマージソートする関数
 *
*/

long long mergeSort(int left,int right){
  if((left + 1) < right){
    long long inversion;
    long long inversion_left;
    long long inversion_right;
    int mid = (left + right)/2;
    
    inversion_left = mergeSort(left,mid);
    inversion_right = mergeSort(mid,right);
    inversion = merge(left,mid,right);

    return inversion_left + inversion + inversion_right;
  }
  else
    return 0;  
}

int main(void){
  int n=0;
  long long count_inversion=0;
  /*入力*/
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%d",&S[i]);

  /*処理*/
  count_inversion = mergeSort(0,n);

  /*出力*/
  printf("%lld\n",count_inversion);
  
  return 0;
}



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

// types - only for stuff used a lot 
using ll = long long;
#define vv vector
#define Pp pair

// IO
#define get(x) scanf("%d",&x)
#define getl(x) scanf("%lld",&x);

// Operations
#define pb push_back
#define pob pop_back
#define sz(a) int(a.size()) 
#define re(a,b) a=max(a,b) // relax
#define ri(a,b) a=min(a,b) // relaxi

// Debugging

#ifndef LOCAL
#define cerr if (0) cerr
#else
#define cerr cout
#endif

#define print(arr,n) {for (int _ = 0; _ < n; _++) cerr<<arr[_]<<" "; cerr << endl; }
#define printv(vec)  {for (int _ : vec) cerr<<_<<" "; cerr<<endl;}

const int mod = 1e9+7, oo = 1e9;
const ll loo = 1e18;

// Functions 
ll modpow(ll a, ll b) {
	ll ans = 1; // faster modpow than recursive
	for (; b; b/=2,a=a*a%mod)
		if (b&1) ans = (ans*a)%mod;
	return ans;
}
ll gcd(ll a, ll b) {
	while (a) b%=a,swap(a,b);
	return b;
}
#define bitcount __builtin_popcountll
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)


/* 

   ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS

 */

const bool DEBUG = 1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n;
	cin >> n;
	int t[2][3];
	cin>>t[0][0]>>t[0][1]>>t[0][2]>>t[1][0]>>t[1][1]>>t[1][2];	
	vector<ll> sack(n+1);
	f(i,0,n+1) sack[i]=i;	
	f(w,0,3) {
		f(i,0,n+1) {
			if (i+t[0][w]<=n)
				re(sack[i+t[0][w]],sack[i]+t[1][w]);	
		}
	}
	n = sack[n];
	sack = vector<ll>(n+1);
	f(i,0,n+1) sack[i]=i;
	f(w,0,3) {
		swap(t[0][w],t[1][w]);
		f(i,0,n+1) {
			if (i+t[0][w]<=n)
				re(sack[i+t[0][w]],sack[i]+t[1][w]);	
		}
	}
	cout << sack[n] << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}




Measured memory_bytes: 195584
n=int(input())
a=list(map(int,input().split()))
ans=0
j=False #i-1番目を変えたか
for i in range(1,n):
    if a[i]==a[i-1] and not j:
        ans+=1
        j=True
    elif a[i]==a[i-1]:
        j=False
    else:
        j=False
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

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

    vector<pair<int, int> > paths(n);

    for (int i = 0; i < n; i++) {
        int c,t;
        cin >> c >> t;
        paths[i] = make_pair(c, t);
    }

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

    int cost = 0;
    for (int i = 0; i < n; i++) {
        if (paths[i].second <= time) {
            cost = paths[i].first;
            break;
        }
    }

    if (cost == 0) cout << "TLE" << endl;
    else cout << cost << endl;
}


Measured memory_bytes: 888
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

A, B, C, X, Y = MAP()

ans = 0
if A+B > 2*C:
	ans += 2*C*min(X,Y)
	idx = (X, Y).index(max(X, Y))
	left = abs(X-Y)
	if 2 * C < (A, B)[idx]: #if 2 * C *left < (A, B)[idx] * left:
		ans += 2*C*left
	else:
		ans += (A, B)[idx] * left
else:
	ans = A*X + B*Y
print(ans)


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

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

    rep(i,s.size()) s[i] = 'x'; 

    cout << s << endl;


    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int X = scn.nextInt();
		int ans = 1;
		int now = 0;
		for (int i = 0; i < N; i++) {
			int L = scn.nextInt();
			now += L;
			if (now <= X) {
				ans++;
			}else {
				break;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23892
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def is_sym(S):
    N = len(S)
    for i in range(N):
        for j in range(N):
            if S[i][j] != S[j][i]:
                return False
    return True
def main():
    N=I()
    S=[ST() for _ in range(N)]
    ans = 0
    for A in range(N):
        S=S[1:] + S[:1]
        if(is_sym(S)):
            ans += N
    print(ans)
if __name__ == '__main__':
    main()

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

string s;
string dream = "dream";
string dreamer = "dreamer";
string erase = "erase";
string eraser = "eraser";

bool dfs(int st) {
	if (st == s.size())
		return true;

	string sub1 = s.substr(st, min(5, (int)s.size() - st));
	string sub2 = s.substr(st, min(6, (int)s.size() - st));
	string sub3 = s.substr(st, min(7, (int)s.size() - st));

	bool ret = false;
	if (sub3 == dreamer) {
		ret |= dfs(st + 7);
	}
	if (sub2 == eraser) {
		ret |= dfs(st + 6);
	}
	if (sub1 == dream) {
		ret |= dfs(st + 5);
	}
	if (sub1 == erase) {
		ret |= dfs(st + 5);
	}
	return ret;
}

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

	cin >> s;

	bool judge = dfs(0);

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

	return 0;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}

int c[1000010];

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> m;
    rep(i,n){
        cin>>a[i];
        c[a[i]]++;
    }

    bool ok2=true;
    for(int i=2;i<1000005;i++){
        int cnt=0;
        for(int j=i;j<1000005;j+=i) cnt+=c[j];
        if(cnt>1){
            ok2=false;
            break;
        }
    }

    int g=0;
    rep(i,n) g=gcd(g,a[i]);

    if(ok2){
        cout<<"pairwise coprime"<<endl;
    }
    else if(g==1){
        cout<<"setwise coprime"<<endl;
    }
    else{
        cout<<"not coprime"<<endl;
    }

}


Measured memory_bytes: 11132