akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    ll ans = 0;

    for (int b = 1; b <= n; b++) {
        if (b <= k) continue;

        ll ac1 = n / b * (b - k);
        ll nokori = n - (n / b * b);
        ll keshi = k == 0 ? 0 : k - 1;
        ll ac2 = max(nokori - keshi, 0ll);

        ll now = ac1 + ac2;
        ans += now;
    }
    cout << ans << endl;
}


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

int main(){
  int A, B;
  cin>>A>>B;
  bool arimasen=true;
  for(int i=1; i<1010; i++){
    if(floor(i*0.08)==A && floor(i*0.1)==B){
      cout<<i<<endl;
      arimasen=false;
      break;
    }
  }
  if(arimasen) cout<<-1<<endl;
}


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

using namespace std;

int integral(int l, int r, const vector<int> &potential) {
  return potential[r] - potential[l - 1];
}

int main(int argc, char* argv[]) {
  string s, t;
  int q;
  cin >> s >> t >> q;
  vector<int> sa, sb, ta, tb;
  sa.push_back(0);
  ta.push_back(0);
  sb.push_back(0);
  tb.push_back(0);
  int a = 0, b = 0;
  for (int i = 0; i < s.size(); ++i) {
    char c = s[i];
    if (c == 'A') {
      sa.push_back(++a);
      sb.push_back(b);
    } else {
      sa.push_back(a);
      sb.push_back(++b);
    }
  }
  a = 0, b = 0;
  for (int i = 0; i < t.size(); ++i) {
    char c = t[i];
    if (c == 'A') {
      ta.push_back(++a);
      tb.push_back(b);
    } else {
      ta.push_back(a);
      tb.push_back(++b);
    }
  }
  vector<int> aaa, bbb, c, d;
  for (int i = 0; i < q; ++i) {
    int aa, bb, cc, dd;
    cin >> aa >> bb >> cc >> dd;
    aaa.push_back(aa);
    bbb.push_back(bb);
    c.push_back(cc);
    d.push_back(dd);
  }
  for (int i = 0; i < q; ++i) {
    int aa = aaa[i], bb = bbb[i], cc = c[i], dd = d[i];
    int sp = (integral(aa, bb, sa) - integral(aa, bb, sb)) % 3;
    int tp = (integral(cc, dd, ta) - integral(cc, dd, tb)) % 3;
    sp += (sp > 0) ? 0 : 3;
    tp += (tp > 0) ? 0 : 3;
    if (sp == tp) 
      cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 4884
<>=~$";
@HW=($`+1,$'+1);
@p=map[<>+0,0],1..$`;
@q=map[<>+0,1],1..$';
for(sort{@$a[0]-@$b[0]}@p,@q){
	$x+=@$_[0]*$HW[!@$_[1]];
	if($HW[@$_[1]]){
		--$HW[@$_[1]]
	}
}
print$x


Measured memory_bytes: 44672
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    printf("%d\n", r / d - (l-1) / d);

    return;
}

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


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long
#define rp(a,b,c) for(long long a=b;a<=c;++a)
#define pr(a,b,c) for(long long a=c;a>=b;--a)
using namespace std;

ll a[100000+5];
ll pre[100000+5];
ll erp[100000+5];


int main()
{
	ll ans=0;
	ll n;
	cin>>n;
	rp(i,1,n)
		cin>>a[i];
	pre[1]=a[1];
	pre[0]=1;
	rp(i,2,n)
		pre[i]=__gcd(pre[i-1],a[i]);
	erp[n]=a[n];
	pr(i,1,n-1)
		erp[i]=__gcd(erp[i+1],a[i]);
	
	ans=max(erp[2],pre[n-1]);
	rp(i,2,n-1)
		ans=max(ans,__gcd(pre[i-1],erp[i+1]));

		

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

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


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

    int N;
    cin >> N;
    std::map<pair<int, int>, int> A;
    for(int i=0; i<N; i++){
      int tmp;
      cin >> tmp;
      tmp--;
      A[make_pair(i, tmp)]++;
      A[make_pair(tmp, i)]++;
    }
    int ans;
    for(auto it=A.begin(); it!=A.end(); it++){
      if(it->second == 2) ans++;
    }
    cout << ans/2 << endl;
}


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

const int listmax=1000000;

int main(){
	bool nprime[listmax]={};
	for(int i=2;i<listmax;i++){
		if(nprime[i])continue;
		for(int j=i+i;j<listmax;j+=i){
			nprime[j]=true;
		}
	}
	int n;
	while(cin>>n){
		int sum=0;
		for(int i=2;i<=n;i++){
			if(!nprime[i])sum++;
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

using lint = long long;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	lint n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;

	lint mn = min({a, b, c, d, e});

	cout << 4  + (n / mn) + (n % mn == 0 ? 0 : 1) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin>>n;
    ll a[100010];
    ll x[100][100],y[100][100];
    rep(i,100)rep(j,100){
        x[i][j]=0;y[i][j]=0;
    }
    rep(i,n){
        cin>>a[i];
        rep(j,a[i]){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    ll ans=0;
    rep(bit,(1<<n)){
        ll cnt=0;
        ll s[20];
        rep(i,20) s[i]=0;
        bool ok=true;
        rep(i,n){
            if(bit&(1<<i)){
                s[i]=1;
                cnt++;
            }
        }
        rep(i,n){
            if(bit&(1<<i)){
                rep(j,a[i]){
                    ll p=x[i][j],q=y[i][j];
                    if(s[p]==0&&q==1){
                        ok =false;break;
                    }
                    else if(s[p]==1&&q==0){
                        ok =false;break;
                    }
                }
            }
            if(!ok) break;
        }
        if(!ok) continue;
        // cout<<bit<<" "<<cnt<<endl;
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N;
string S;

int main() {
	cin >> N >> S;
	int res = 0;
	for (int i = 0; i <= 999; i++) {
		int t = 0;
		string T;
		T.push_back(i / 100 + '0');
		T.push_back(i % 100 / 10 + '0');
		T.push_back(i % 10 + '0');
		for (char c : S) {
			if (c == T[t]) {
				t++;
				if (t == 3) {
					res++;
					break;
				}
			}
		}
	}
	cout << res << endl;
}

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

int cal=0;

int counter(int x){

    int result;
    if(x==0){
        result = cal;
        cal=0;
        return result;
    }
    else{
        if(x&1) cal++;
        counter(x>>1);
    }

    //if(x==0) return 0;
    //return counter(x>>1)+(x&1);

}

int main(){
    int n;
    cin>>n;
    int a[n];
    int x[n][n],y[n][n];

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

    int ans=0;

    for(int bits=1;bits<(1<<n);bits++){
        bool ok=true;
        for(int i=0;i<n;i++){
            if(bits&(1<<i)){
            for(int j=0;j<a[i];j++){
                if(((bits>>(x[i][j]-1))&1)^y[i][j]) ok=false;
            }
            }
        }
        if(ok) ans=max(ans,counter(bits));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc139/submissions/7298310

#include <iostream>
#include <vector>

using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int a[1010][1010] = {};
    int head[1010] = {};
    rep(i,n){
        rep(j,n-1){
            int x;
            cin >> x;
            x--;
            a[i][j] = x;
        }
    }
    int turn = 0;
    vector<int> used(n, -1);
    while(true){
        bool ng = true;
        int empty_cnt = 0;
        rep(i,n){
            if (head[i] == n-1) {
                empty_cnt++;
                continue;
            }
            int j = a[i][head[i]];
            if (used[i] == turn || used[j] == turn) continue;
            if (a[j][head[j]] == i) {
                head[i]++;
                head[j]++;
                used[i] = used[j] = turn;
                ng = false;
            }
        }
        if (empty_cnt == n) break;
        if (ng) {
            cout << -1 << endl;
            return 0;
        }
        turn++;
    }
    cout << turn << endl;

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
string h(const string& a, const string& b, unsigned p) {
	for (unsigned i = 0; i < b.length() && p+i < a.length(); ++ i) {
		if (!(a[p+i] == '?' || b[i] == '?' || a[p+i] == b[i])) return "";
	}
	string r = a;
	for (unsigned i = 0; i < b.length() && p+i < a.length(); ++ i) {
		if (b[i] != '?' && a[p+i] == '?') r[p+i] = b[i];
	}
	for (unsigned i = 0; i < b.length(); ++ i) {
		if (p+i >= a.length()) r += b[i];
	}
	return r;
}
int h2(const string& a, const string& b, unsigned p) {
	for (unsigned i = 0; i < b.length() && p+i < a.length(); ++ i) {
		if (!(a[p+i] == '?' || b[i] == '?' || a[p+i] == b[i])) return 0;
	}
	int r = a.length();
	for (unsigned i = 0; i < b.length(); ++ i) if (p+i >= a.length()) ++ r;
	return r;
}
int g(const string& a, const string& b) {
	for (unsigned i = 0; i <= a.length(); ++ i) {
		int x = h2(a, b, i);
		if (x) return x;
	}
	throw 1;
}
int f(const string& a, const string& b, const string& c) {
	int r = 1<<30;
	for (unsigned i = 0; i <= a.length(); ++ i) {
		string x = h(a, b, i);
		if (x.length()) {
			if ((int)x.length() >= r) break;
			r = min(r, g(x, c));
		}
	}
	return r;
}
int main() {
	string A, B, C;
	cin >> A >> B >> C;
	int r = f(A,B,C);
	r = min(r, f(A,C,B));
	r = min(r, f(B,A,C));
	r = min(r, f(B,C,A));
	r = min(r, f(C,A,B));
	r = min(r, f(C,B,A));
	cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<map>
using namespace std;
int main(){  
   int n;
   cin>>n;
   int a[n];
   int b[n];
   for (int i = 0; i < n; i++)
   {
       cin>>a[i];
   }
   for (int i = 0; i < n; i++)
   {
       cin>>b[i];
   }
   int ans=0;
   for (int i = 0; i < n; i++)
   {
       if(a[i]-b[i]>0) ans+=(a[i]-b[i]);
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;
int ans=mod;
vi ex;
vii dp;

int main(){
	int n;
    cin>>n;
    vi a(n);
    vi b(n);
    dp=vii(51,vi(1<<n,mod));
    ex=vi(51,0);
    FOR(i,0,n){
        cin>>a[i];
        ex[a[i]]=1;
    }
    FOR(i,0,n){
        cin>>b[i];
        ex[b[i]]=1;
    }
    queue<pii> q;
    dp[0][0]=0;
    FOR(i,0,n){
        int f=0,t;
        if((i&1)==f){
            dp[a[i]][1<<i]=i;
            t=a[i];
        }else{
            dp[b[i]][1<<i]=i;
            t=b[i];
        }
        q.push(MP(t,1<<i));
    }
    while(q.size()){
        auto pr=q.front();
        q.pop();
        auto mx=pr.ST;
        auto st=pr.ND;
        //cerr<<mx<<" "<<bitset<20>(st)<<" "<<dp[mx][st]<<endl;
        int sc=dp[mx][st];
        if(st==(1<<n)-1){
            ans=min(ans,dp[mx][st]);
            continue;
        }
        int c=0;
        FOR(i,0,n){
            if(st&(1<<i)){
                c++;
            }
        }
        int ex_c=0;
        FOR(i,0,n){
            if(st&(1<<i)){
                continue;
            }
            int f=c&1,t;
            if((i&1)==f){
                t=a[i];
            }else{
                t=b[i];
            }
            if(mx<=t){
                int nst=st|(1<<i);
                int nsc=sc+ex_c;
                
                if(dp[t][nst]==mod){
                    dp[t][nst]=nsc;
                    q.push(MP(t,nst));
                }else{
                    dp[t][nst]=min(dp[t][nst],nsc);
                }
                }
            
            ex_c++;
        }
    }

    if(ans==mod){
        cout<<-1<<endl;
    }else{
        cout<<ans;
    }

}


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

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

    int n, m;
    cin >> n >> m;
    map<int, int> cnt;
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;

        ++cnt[a];
        ++cnt[b];
    }

    for(auto elem: cnt){
        if(elem.second % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 7716
#include <iostream>
using ll = long long;
using namespace std;

/* initialize */

/* main */
int main() {
    char a, b;
    cin >> a >> b;
    auto f = [](char x){return (x=='H'?1:0);};
    int c = f(a)^f(b);
    if(c==0) cout << 'H'; else cout << 'D';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int dp[45] = {};

int fib(int n){
  int u, v;
  if(dp[n] != 0) return dp[n];
  else{ 
    if(n == 0 || n == 1) dp[n] = 1;
    else{
      u = fib(n - 1);
      v = fib(n - 2);
      dp[n] = u + v;
    }
  }
  return dp[n];
}

int main(){
  int n;
  scanf("%d", &n);
  printf("%d\n", fib(n));  
  return 0;
}

Measured memory_bytes: 596
from itertools import combinations
import math
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007

def add(a, b):
    return (a + b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(add(result[-1], x))
    return result

#N = int(input())
#C = input()
#D, T, S=map(int,input().split())
#C = []
#for i in range(N):
#    C.append(list(map(int,input().split())))

inv = cumsum(list(reversed(A)))
c = 0
for i in range(0,N-1):
    c = add(c,mul(A[i],inv[N-i-2]))

print(c)


Measured memory_bytes: 32144
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	string s, t;
	cin >> s >> t;
	t += s;
	co(t);

	return 0;
}


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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    i64 n, t;
    cin >> n >> t;
    vector<i64> a(n);
    for(auto& x : a)
        cin >> x;
    i64 min_v = a[0];
    i64 gain = 0;
    vector<i64> idx{0};
    i64 def = 0;
    for(i64 i = 1; i < n; ++i){
        if(a[i] < min_v)
            min_v = a[i];
        i64 nex_gain = a[i] - min_v;
        if(nex_gain > gain){
            gain = nex_gain;
            idx = {i};
        }else if(nex_gain == gain){
            idx.emplace_back(i);
        }
    }
    cout << idx.size() << endl;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll dp[256][110];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, K;
	cin >> n >> K;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = i; j >= 0; j--) {
			for (int k = 0; k <= 255; k++) {
				(dp[k ^ a[i]][j + 1] += dp[k][j]) %= MOD;
			}
		}
	}

	ll ans = 0, tmp = 1;
	for (int i = 1; i <= n; i++) {
		(tmp *= i) %= MOD;
		(ans += dp[K][i] * tmp % MOD) %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
l = list(map(int, input().split()))

print(' '.join(map(str, l)))
for i in range(1, n):
    v = l[i]
    j = i - 1
    while l[j] > v and j >= 0:
        l[j+1] = l[j]
        j -= 1
    l[j+1] = v
    print(' '.join(map(str, l)))



Measured memory_bytes: 5596
N = int(input())
z = []
w = []
for i in range(N):
    x,y = map(int,input().split())
    z.append(x+y)
    w.append(x-y)

z_max = max(z)
z_min = min(z)
w_max = max(w)
w_min = min(w)

print(max(z_max-z_min,w_max-w_min))

Measured memory_bytes: 24812
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a, b;
  cin >> a >> b;
  string ans ;
  if(a.size() > b.size()){
    cout <<"GREATER" <<endl;
    return 0;
  }
  else if(a.size() < b.size()){
    cout <<"LESS" << endl;
    return 0;
  }
  else{
    for(int i = 0; i < a.size(); i++){
      if(a[i] > b[i]){
        cout << "GREATER" << endl;
        return 0;
      }
      else if(a[i] < b[i]){
        cout << "LESS" << endl;
        return 0;
      }
    }
  }
  cout << "EQUAL" << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a+1];
    b[a] = 0;
    int tmp = 0;
    int max = 0;
    for(int i = 0;i < a;i++){
      b[i] = sc.nextInt();
    }
//    System.out.println(Arrays.toString(b));
    for(int j = 0;j < a;j++){
      if(b[j] >= b[j+1] && b[j+1] != 0){
        tmp++; 
      }else{
        max = Math.max(max,tmp);
        tmp = 0;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 50056
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  int N, K, ans = 0;
  cin >> N >> K;
  vector<int> l(N);
  for(int i = 0; i < N; i++){
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  for(int i = 0; i < K; i++){
    ans += l.at(N-1 - i);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from math import radians
from cmath import rect

p = 0+0j
prev_angle = radians(-90)
for line in stdin:
    m, next_angle = (int(i) for i in line.split(','))
    if not (m or next_angle):
        break
    p += rect(m, -prev_angle)
    prev_angle += radians(next_angle)
print('{}\n{}'.format(int(p.real), int(p.imag)))

Measured memory_bytes: 4488
#!/usr/bin/env python3
import sys
 
def find_array(N: int, Y: int):
    for a in range(N + 1):
        for b in range(N - a + 1):
            c = N - a - b
            if a * 10000 + b * 5000 + c * 1000 == Y:
                return [a, b, c]
    return [-1, -1, -1]
 
def solve(N: int, Y: int):
    array = find_array(N, Y)
    print(' '.join(map(str,array)))
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 38972
from collections import Counter

(N,) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
(Q,) = [int(x) for x in input().split()]
BC = [[int(x) for x in input().split()] for i in range(Q)]

freq = Counter(A)
total = sum(A)
for B, C in BC:
    total += (C - B) * freq[B]
    freq[C] += freq[B]
    del freq[B]
    print(total)


Measured memory_bytes: 105532
n=int(input())
a=list(map(int,input().split()))

ans=1
for i in range(n):
    if a[i]%2==0:
        if a[i]%3!=0 and a[i]%5!=0:
            ans=0
            break
if ans==1:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 9148
/*
	watch me go
*/

#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;*/
#define int long long
//#define d long double
#define pii pair<int,int>
#define bitcount(a) __builtin_popcountll(a)
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
 /*typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
                os; */

int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}

signed main() 
{ 
    haha
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    
    int dp[n];
    init(dp,0);
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        int x=dp[i-2]+abs(arr[i]-arr[i-2]);
        int y=dp[i-1]+abs(arr[i]-arr[i-1]);
        dp[i]=min(x,y);
    }
  
    cout<<dp[n-1];
    
   
   
} 


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 200010, M = 1010, mod = 998244353;

int n, m, k;
int fact[N], infact[N];

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

int C(int a, int b)
{
	int res = (LL)fact[a] * infact[a - b] % mod * infact[b] % mod;
	return res;
}

int main()
{
	fact[0] = infact[0] = 1;
	for (int i = 1; i < N; i ++ )
	{
		fact[i] = (LL)fact[i - 1] * i % mod;
		infact[i] = (LL)infact[i - 1] * qp(i, mod - 2) % mod;
	}
	
	cin >> n >> m >> k;
	
	int res = 0;
	for (int i = 0; i <= k; i ++ )
		res = (res + (LL)m * C(n - 1, i) % mod * qp(m - 1, n - 1 - i)) % mod;

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 5156
#include <iostream>

using namespace std;
string s[3] ={"Sunny","Cloudy","Rainy"};
int main()
{
    string m;
    cin>>m;
        if(m[0]==s[0][0]){
            cout<<s[1];}

        else if(m[0]==s[1][0]){
            cout<<s[2];

        }
        else{
            cout<<s[0];
        }












    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll fun(ll x, ll y) {
    if(y==0) return x;
    else return fun(y, x%y);
}

int main(void) {
    ll N, K;
    cin >> N >> K;
    ll g=0;
    ll a[100000], i, max=0;
    for(i=0; i<N; i++) {
        cin >> a[i];
        max=max(max, a[i]);
        g=fun(g, a[i]);
    }
    
    cout << ((K%g!=0 || K>max) ? "IMPOSSIBLE" : "POSSIBLE") << endl;
    
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;
const int N=1005,M=20000005;
int h,w,ch,cw,dh,dw,tot,cnt,bel[N][N],dis[N*N];
bool vis[N*N];
char s[N][N];
set<int> st[N*N];
queue<int> q;
void paint(int x,int y,int z){
	if(x<1||x>h||y<1||y>w||s[x][y]=='#'||bel[x][y]){
		return;
	}
	bel[x][y]=z;
	paint(x+1,y,z);
	paint(x,y+1,z);
	paint(x,y-1,z);
	paint(x-1,y,z);
}
int main(){
	scanf("%d%d%d%d%d%d",&h,&w,&ch,&cw,&dh,&dw);
	for(int i=1;i<=h;i++){
		scanf("%s",s[i]+1);
	}
	if(s[ch][cw]=='#'||s[dh][dw]=='#'){
		puts("-1");
		return 0;
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(s[i][j]=='.'&&!bel[i][j]){
				tot++;
				paint(i,j,tot);
			}
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(bel[i][j]){
				int lx=max(1,i-2),rx=min(h,i+2);
				int ly=max(1,j-2),ry=min(w,j+2);
				for(int x=lx;x<=rx;x++){
					for(int y=ly;y<=ry;y++){
						if(bel[x][y]&&bel[i][j]!=bel[x][y]){
							st[bel[i][j]].insert(bel[x][y]);
						}
					}
				}
			}
		}
	}
	vis[bel[ch][cw]]=true;
	q.push(bel[ch][cw]);
	while(!q.empty()){
		int u=q.front();
		q.pop();
		if(u==bel[dh][dw]){
			printf("%d\n",dis[u]);
			return 0;
		}
		for(auto v:st[u]){
			if(!vis[v]){
				dis[v]=dis[u]+1;
				vis[v]=true;
				q.push(v);
			}
		}
	}
	puts("-1");
	return 0;
}

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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll s,w;
	cin >> s >> w;
	if(w>=s)
	{
		cout << "unsafe" << endl;
	}
	else 
	{
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>

int abc(long long n)
{
    int  c,b;
    c = ((int)(log10(n)));
    b = (int) (n/(int)(pow(10,c)));
    return b;
}

using namespace std;
int main()
{
    long long n,i,j,total=0;
    cin >> n;
    int a[10][10]={0};
    for(i=1;i<=n;i++)
    {
         if(i%10==0)
            continue;
         else
         {
             j = abc(i);
             a[j][i%10]++;
         }
    }
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
           total = total + a[i][j]*a[j][i];
        }
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3960
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]=' ';
}
const int N=505;
int n,k,c,p,mp[N][N];
void solve(int p,int c){
	for(R int i=0,j=(n+p-i)%n;i<n;++i,j=(n+p-i)%n)
		mp[i][j]=c+(i&1);
}
void dd(int p,int c){
	for(R int i=0,j=(n+p-i)%n;i<n;++i,j=(n+p-i)%n)
		mp[i][j]=c;
}
int main(){
	scanf("%d",&k),n=(k+1)>>1,n+=(n&1);
	if(k==1)return puts("1\n1\n"),0;
//	if(k==2)return puts("2\n1 2\n2 1\n"),0;
//	fp(i,0,n-2)solve(i,(i<<1)+1);
//	(k&1)?dd():solve(n-1,k-1);
	p=0,c=1;
	while(n-p<k-c+1)solve(p,c),++p,++c,++c;
	while(p<n&&c<=k)dd(p,c),++p,++c;
	print(n),sr[C]='\n';
	fp(i,0,n-1){
		fp(j,0,n-1)print(mp[i][j]);
		sr[C]='\n';
	}
	return Ot(),0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef ONLINE_JUDGE
const int N = 1e6+50;
#else
const int N = 1e2+10;
#endif




int main() {
	set<int> s;
	REP(i,1,9) REP(j,1,9) s.insert(i*j);
	puts(s.count(rd())?"Yes":"No");
}









Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int h , w;
  scanf("%d %d",&h,&w);
  
  char  a[h][w];
  int cuth[100] = {0}, cutw[100] = {0};
 
  for(int i = 0;i < h;i ++){
    scanf("%s",a[i]);
  }
  
  for(int i = 0;i < h;i ++){
    int j = 0;
    while(j < w){
      if(a[i][j]=='.'){
        cuth[i] ++;
      }
      j ++;
    }
    cuth[i+1] = 0;
  }
  for(int i = 0;i < w;i ++){
    int j = 0;
    while(j < h){
      if(a[j][i]=='.'){
        cutw[i]++;
      }
      j ++;
    }
   cutw[i+1] = 0;
  }
  
  for(int i = 0;i < h;i ++){
    for(int j = 0;j < w;j ++){
      if(cuth[i]!=w&&cutw[j]!=h){
        printf("%c",a[i][j]);
      }
    }
    if(cuth[i]!=w){
     putchar('\n');
    }
  }

  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  string s, t;
  cin >> s >> t;
  int sl = s.length();
  int tl = t.length();
  int min = MAX;
  rep(i, sl - tl+1) {
    int cnt = 0;
    rep(j,tl) {
      if (s[i+j] != t[j]) cnt++;
    }
    if (cnt < min) min = cnt;
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a+b == c {
		fmt.Println("Yes")
		return
	}
	if a+c == b {
		fmt.Println("Yes")
		return
	}
	if c+b == a {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[40005][205]={0};
ll max_v[40005]={0};
ll ts[205]={0};
const ll inf=174417441744;
int main(){
  ll n;
  cin>>n;
  ll all_time=0;
  for(int i=0;i<n;i++) cin>>ts[i];
  for(int i=0;i<n;i++){
    ll v,t=ts[i];
    cin>>v;
    v*=2;
    for(int j=all_time+1;j<=all_time+t*2;j++) max_v[j]=v;
    all_time+=t*2;
  }
  for(int i=0;i<=all_time;i++){
    for(int j=0;j<205;j++) dp[i][j]=-inf;
  }
  dp[0][0]=0;
  for(int i=0;i<all_time;i++){
    for(int j=0;j<=max_v[i+1];j++){
      if(j>0) dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+j+j-1);
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]+2*j);
      if(j+1<=max_v[i+1]) dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+j+j+1);
    }
  }
  cout<<fixed;
  cout<<setprecision(5)<<(double)dp[all_time][0]/8<<endl;
}


Measured memory_bytes: 64640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define emp emplace
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN = 200100;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll N,Q,a,b,c,d,e,M;
ll A[MAXN];
ll B[MAXN];
map<ll,ll> p;
ll ans;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>N;for(int i=1;i<=N;++i)cin>>A[i];
	for(int i=1;i<=N;++i){
		ll tar=i-A[i];
		ans+=p[tar];
		p[A[i]+i]++;
	}
	cout<<ans;
}

Measured memory_bytes: 27860
#include <stdio.h>
int main(void){
    int i,j,k,n,v;
    int a[100]={0};
    
    scanf("%d",&n);
    
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    
    for(i=0; i<n; i++){
        if(i!=n-1) printf("%d ",a[i]);
        if(i==n-1) printf("%d\n",a[i]);
    }
    
    for(i=1; i<n; i++){
        v = a[i];
        j=i-1;
        
        while(j>=0 && a[j]>v){
            a[j+1]=a[j];
            j--;
            a[j+1]=v;
        }
        
        for(k=0; k<n; k++){
        if(k!=n-1) printf("%d ",a[k]);
        if(k==n-1) printf("%d\n",a[k]);
    }
    }
    
    return 0;
    
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void)
{

	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a == b) {
		if (a != c)
			printf("Yes");
		else
			printf("No");
	}
	else
	{
		if (b == c)
			printf("Yes");
		else {
			if (a == c)
				printf("Yes");
			else
				printf("No");
		}
	}
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!

def Bellman_Ford(g,start):
    n = len(g)    
    dist = [float("inf")]*n
    dist[start] = 0
    a0 = float("inf")
    
    for i in range(n<<1):
        updated = False
        for v in range(n):
            for to, cost in g[v]:
                if dist[to] <= dist[v] + cost: continue
                dist[to] = dist[v] + cost
                updated = True
        if not updated: break
        if i <= n: a0 = dist[-1]
    if a0 != dist[-1]: return None, False
    return dist, True


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,m = [int(i) for i in readline().split()]
g = [[] for _ in range(n)]
for i in range(m):
    a,b,c = [int(i) for i in readline().split()]
    g[a-1].append((b-1,-c))
#    g[b-1].append((a-1,c))

dist, TF = Bellman_Ford(g, 0)

if TF: print(-dist[-1])
else: print("inf")




Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  int H, N;cin >> H >> N;
  int A = 0;
  rep(i,N){
    int a; cin >> a;
    A += a;
  }
  bool ans = false;
  if(H <= A) ans = true;

  cout << (ans ? "Yes" : "No")  << endl;

	return 0;
}



Measured memory_bytes: 3632
function Main(input: string) {

    let input1 = input.split('\n')[0];
    let sLength: number = input1.length;

    let forward: Array<string> = []
    let back: Array<string> = []

    if (sLength % 2 === 0) {
        forward = input1.split('').slice(0, sLength / 2)
        back = input1.split('').slice(sLength / 2).reverse();
    } else {
        forward = input1.split('').slice(0, Math.floor(sLength / 2))
        back = input1.split('').slice(Math.floor(sLength / 2) + 1).reverse();
    }


    let count: number = forward.filter((v, i) => {
        return back[i] !== v;
    }).length

    console.log(count)

}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll imos[100010];
ll sum = 0;
ll A[100010];
int n, m;

void add_range(int l, int r, int x){
    imos[l] += x;
    imos[r + 1] -= x;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    for(int i = 1; i < n; i++){
        if(A[i - 1] < A[i]){
            sum += A[i] - A[i - 1];
            add_range(A[i - 1] + 2, A[i], 1);
            add_range(A[i] + 1, A[i] + 1, - A[i] + A[i - 1] + 1);
        }else{
            sum += m - A[i - 1] + A[i];
            add_range(A[i - 1] + 2, m, 1);
            add_range(1, 1, m - A[i - 1]);
            add_range(2, A[i], 1);
            add_range(A[i] + 1, A[i] + 1, - m + A[i - 1] - A[i] + 1);
        }
    }
    ll mx = 0;
    ll s = 0;
    for(int i = 1; i <= m; i++){
        s += imos[i];
        imos[i + 1] += imos[i];
        chmax(mx, s);
    }
    cout << sum - mx << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n,m;
	cin>>n>>m;
	ll a[n];
	float sum=0;
	for(i=0;i<n;i++)
	{
	cin>>a[i];
	sum+=a[i];
    }
	sum/=4;
	sum/=m;
	ll ans=0;
	for(i=0;i<n;i++)
	{
	if(a[i]<sum)
	{
	}
	else
	ans++;
    }
	if(ans>=m)
	cout<<"Yes";
	else
	cout<<"No";
 cout<<"\n"; 
 } 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll v1 = max(a*c, a*d);
  ll v2 = max(b*c, b*d);
  cout << max(v1, v2) <<endl;
}

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

//using namespace __gnu_pbds;
using namespace std;

typedef  long long ll;
typedef long double ld;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define endl "\n"
#define ioss ios::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define eb emplace_back



double startTime;
double gct()//get_current_time
{
    return ((double)clock()-startTime)/CLOCKS_PER_SEC;
}

void suraj();

int main()
{
    startTime=(double)clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt,"w",stdout);
    //ioss
    //int t;cin>>t;while(t--)
    suraj();
    //suraj2();
    //suraj3();
    //suraj4();
    return 0;
}

































const int nax=3005;
const int aax=1e9;

ll dp[nax][nax];//dp[i][j] is equal to the optimal value of (x-y) if the remaining array has index from i to j
void suraj(){
int n;scanf("%d",&n);
vector<ll>a(n);for(ll &i:a)scanf("%lld",&i);
for(int l=n-1;l>=0;l--){
    for(int r=l;r<n;r++){
        if(l==r)
            dp[l][r]=a[l];
        else{
            dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
        }
    }
}


cout<<dp[0][n-1]<<endl;



}//













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

typedef long long ll;
const ll INF = 1LL << 60;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int n, k;
int main() {
    cin >> n >> k;
    combination c(n);
    mint ans;
    for (int i = 0; i <= k; i++) {
        ans += c(n, i) * c(n - i - 1 + i, i);
    }
    cout << ans.x << endl;
}

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

int main() {
  
  vector<int> x(5);
  
  for(int i=0;i<5;i++)
    cin>>x.at(i);
  
  for(int i=0;i<5;i++){
    if(x.at(i)==0)
      cout<<i+1<<endl;
  }
}


Measured memory_bytes: 3588
/*
  author:   Ziel
  created:  13.09.2020 17:59:24
*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
struct chash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + RANDOM);
  }
};

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int32_t main() {
  fre("");
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  
  cout << max({a * c, b * d, a * d, b * c});
  
  return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation
// gp_hash_table<T, U, chash> -> fast unordered_map
// m.count(x) <-> (m.find(x) != m.end())


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

int main(){
  string s,t;
  int n,c=0;
  cin>>s>>n;
  for(int i=0;i<n;i++){
    cin>>t;
    if((t+t).find(s)!=string::npos)c++;
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 3144