akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
using namespace std;
#pragma warning(disable:4996)
int n, m, q, dist[110000], mark[110000], u[210000], v[210000];
vector<pair<int, int>>x[110000], y[110000], z[110000]; bool used[210000];
bool isgood(int f) {
	for (int i = 0; i < z[f].size(); i++) {
		if (mark[z[f][i].first] == 0 && used[z[f][i].second] == false)return true;
	}
	return false;
}
int main() {
	scanf("%d%d%d", &n, &m, &q); queue<int>Q;
	for (int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b); u[i + 1] = a; v[i + 1] = b;
		x[a].push_back(make_pair(b, i + 1)); x[b].push_back(make_pair(a, i + 1));
	}
	Q.push(1); for (int i = 1; i <= n; i++)dist[i] = 999999; dist[1] = 0;
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop();
		for (int i = 0; i < x[a1].size(); i++) {
			if (dist[x[a1][i].first] > dist[a1] + 1) { dist[x[a1][i].first] = dist[a1] + 1; Q.push(x[a1][i].first); }
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < x[i].size(); j++) {
			if (dist[i] < dist[x[i][j].first]) { y[i].push_back(x[i][j]); }
			if (dist[i] > dist[x[i][j].first]) { z[i].push_back(x[i][j]); }
		}
	}
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		int a; scanf("%d", &a); used[a] = true;
		int E1 = u[a], E2 = v[a];
		if (dist[E1] == dist[E2]) { cnt += 0; }
		else {
			int a1 = 0; if (dist[E1] < dist[E2])a1 = E2; else a1 = E1;
			if (isgood(a1) == false && mark[a1] == 0) {
				queue<int>Q; Q.push(a1); cnt++; mark[a1] = 1;
				while (!Q.empty()) {
					int a2 = Q.front(); Q.pop();
					for (int j = 0; j < y[a2].size(); j++) {
						if (mark[y[a2][j].first] == 0 && isgood(y[a2][j].first) == false) {
							mark[y[a2][j].first] = 1; Q.push(y[a2][j].first); cnt++;
						}
					}
				}
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 25636
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/scc>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>N>>M;
	scc_graph G(N);
    rep(i,M){
        int a, b;
        scanf("%d%d", &a, &b);
		G.add_edge(a, b);
    }
	auto scc_list = G.scc();
    printf("%d\n", (int)scc_list.size());
    for(vector<int> v : scc_list){
        int n = v.size();
        printf("%d ", n);
        rep(i, n) printf("%d%c", v[i], " \n"[i == n - 1]);
    }
}


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

int main() {
    int ilosc = 0;
    string s;
    cin >> s;
    int a = s.length();
    for(int i=0; i<a/2;) {
        for(int j=a-1; j>=a/2; j--) {
            if(s[i] != s[j]) {
                ilosc++;
            }
            i++;
        }
    }
    cout << ilosc;
    return 0;
}


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

// from iostream
#include<iostream>
using std::cout;
using std::cin;
using std::cerr;
using std::flush;
using std::endl;
// from vector
#include<vector>
using std::vector;
// from queue
#include<queue>
using std::deque;
using std::priority_queue;
// from tuple
using std::tuple;
using std::get;
using std::tie;
using std::make_tuple;
using std::forward_as_tuple;
// from string
#include<string>
using std::string;


// type definitions
typedef signed long long INT;
typedef tuple<INT,INT> TII;
typedef tuple<INT,INT,INT> TIII;
typedef tuple<double,double> TDD;
typedef tuple<double,double,double> TDDD;
typedef vector<INT>  VI;
typedef vector<TII>  VII;
typedef vector<TIII> VIII;
typedef vector<double> VD;
typedef vector<TDD>    VDD;
typedef vector<TDDD>   VDDD;

// macros
#define rep(i,n) for( INT i = 0 ; i <  n ; ++i )
#define REP(i,n) for( INT i = 1 ; i <= n ; ++i )
#define ALL(a) (a).begin(),(a).end()


// main

// begin global variables
// end global varieble;

int main(){
  std::ios::sync_with_stdio(false);
  // begin main
  INT N;
  cin >> N;

  VI a(N);
  rep(i,N) cin  >> a[i];
  rep(i,N) a[i]/=400;
  rep(i,N) a[i] = std::min<INT>(8,a[i]);
  bool flag[9] = {};
  INT count_free=0;
  rep(i,N) flag[a[i]] = true;
  rep(i,N) if(a[i]==8) ++count_free;
  INT count_color = 0;
  rep(i,8) if(flag[i]) ++count_color;

  cout << std::max<INT>(1,count_color) << " " << count_free+count_color << endl;
  // end main
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re          return
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define fill(c,val) memset(c,val,sizeof(c))
#define sz(x)       (int)x.size()
#define LB lower_bound
#define UB upper_bound
using namespace std;
typedef long long ll;
ll const NMAX=1e5+20;
const ll INF=(1LL<<60)-1;
const ll inf=1e9;
ll max(ll a,ll b){
	if(a>b)
	 return a;
	 return b;
}
ll min(ll a,ll b){
	if(a>b)
	 return b;
	 return a;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		   ll a,b,c,x,y;
		   cin>>a>>b>>c>>x>>y;
		   ll ans=inf;
		   for(int i=0;i<=100000;i++){
		   	  ans=min(ans,i*2*c+max(0,x-i)*1LL*a+max(0,y-i)*1LL*b);
		   }
		    cout<<ans;
		   cout<<endl;
   }
    return 0;
}

Measured memory_bytes: 256
S = [i for i in input()]
mae = S[0]+S[1]
ushiro = S[2]+S[3]
mmyy = True if int(mae)>0 and int(mae)<=12 else False
yymm = True if int(ushiro)>0 and int(ushiro)<=12 else False

if mmyy==True and yymm==True:
    print("AMBIGUOUS")
elif mmyy==True and yymm==False:
    print("MMYY")
elif mmyy==False and yymm==True:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	int a, b, n, i;
	while(scanf("%d %d", &a, &b) != EOF){
		n = a+b;
		for(i=0;n;i++){
			n/=10;
		}
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;

long long mod_pow(long long x, long long n) {
  long long res = 1;
  while(n > 0) {
    if(n & 1) (res *= x) %= MOD;
    (x *= x) %= MOD;
    n >>= 1;
  }
  return res;
}

long long n;
vector<int> x;

long long solve();

int main() {
  cin >> n;
  x.resize(n);
  for(int i = 0; i < n; i++) cin >> x[i];

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(int i = 0; i < n; i++) {
    ans += mod_pow(2, n - i - 1) * x[i] % MOD *
           mod_pow(x[i] + 1, i) % MOD;
    ans %= MOD;
  }
  return ans;
}


Measured memory_bytes: 6664
#include <stdio.h>
#include <stdlib.h>
#define int long long

int min(int a, int b){
	return a <= b ? a : b;
}

signed main(){
	int N, i, ans = 0;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	int *B = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
		B[i] = A[i] + N - 1 - i;
	}
	if(A[0] > 0){
		printf("-1\n");
		return 0;
	}
	int Bmin = (int)(1e18);
	for(i = 0; i < N; i++){
		Bmin = min(Bmin, B[i]);
		if(Bmin != B[i]){
			printf("-1\n");
			return 0;
		}
	}
	for(i = N - 1; i > 0; i--){
		ans += A[i];
		while(A[i - 1] == A[i] - 1 && i > 0){
			i--;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  string S, T;
  cin >> S >> T;

  for (int i = 0; i < (int)S.size(); ++i)
  {
    char chara_keeper = S[0];
    for (int j = 0; j < (int)S.size(); ++j)
    {
      char s = S[(j + 1) % (int)S.size()];
      S[(j + 1) % (int)S.size()] = chara_keeper;
      chara_keeper = s;
    }

    if (S == T)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        s[i] = (s[i] - 65 + n)%26 + 65;
    }
    cout<<s;
}

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

int rcount[2001][2001], d[2001][2001], u[2001][2001], r[2001][2001], l[2001][2001];

int main() {
    int n, m, q; cin >> n >> m >> q;
    string s[n];
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int x = 1; x <= n; x++)
        for (int y = 1; y <= m; y++) {
            if (s[x-1][y-1] != '1') continue;
            rcount[x][y] = 1;
            queue<pair<int, int> > q;
            q.push({x, y});
            while (!q.empty()) {
                int i = q.front().first, j = q.front().second;
                q.pop();
                s[i-1][j-1] = '2';
                const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
                for (int k = 0; k < 4; k++) {
                    int i1 = i + dx[k], j1 = j + dy[k];
                    if (0 < i1 && 0 < j1 && i1 <= n && j1 <= m && s[i1-1][j1-1] == '1') {
                        q.push({i1, j1});
                        if (i1 < i) u[i1][j] = 1;
                        else if (i1 > i) d[i1][j] = 1;
                        else if (j1 < j) l[i][j1] = 1;
                        else /* j1 > j */ r[i][j1] = 1;
                    }
                }
            }
        }
    for (int x = 1; x <= n; x++)
        for (int y = 1; y <= m; y++) {
            rcount[x][y] += rcount[x-1][y] + rcount[x][y-1] - rcount[x-1][y-1];
            d[x][y] += d[x][y-1];
            u[x][y] += u[x][y-1];
            r[x][y] += r[x-1][y];
            l[x][y] += l[x-1][y];
        }

    while (q--) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        int ans = rcount[x2][y2] - rcount[x1-1][y2] - rcount[x2][y1-1] + rcount[x1-1][y1-1];
        ans += r[x2][y1] - r[x1-1][y1];
        ans += l[x2][y2] - l[x1-1][y2];
        ans += d[x1][y2] - d[x1][y1-1];
        ans += u[x2][y2] - u[x2][y1-1];
        cout << ans << endl;
    }
}


Measured memory_bytes: 84096
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//----------------ここからだよ-------------------

int main(){
    int A,B; cin>>A>>B;
    int ans=0;
    bool can = false;
    rep(i,3000){
        if(floor(i*0.08)==A && floor(i*0.1)==B){
            ans=i;
            can=true;
            break;
        }
    }
    cout<<(can==true ? ans : -1)<<endl;
}

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

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    for(int i=sx;i<tx;++i)ans.push_back('R');
    for(int i=sy;i<ty;++i)ans.push_back('U');
    for(int i=tx;i>sx;--i)ans.push_back('L');
    for(int i=ty;i>sy;--i)ans.push_back('D');
    ans.push_back('D');
    for(int i=sx;i<=tx;++i)ans.push_back('R');
    for(int i=sy-1;i<ty;++i)ans.push_back('U');
    ans.push_back('L');
    ans.push_back('U');
    for(int i=tx;i>=sx;--i)ans.push_back('L');
    for(int i=ty+1;i>sy;--i)ans.push_back('D');
    ans.push_back('R');

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);I++) cin >> x[i];

int main(){
  int a,b,c ;
  cin >> a >> b >> c ;
  if(b-a == c-b)
    cout <<"YES" << endl;
  else
    cout <<"NO"<< endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=100005;
typedef long long ll;

int n,v[N];
ll C,x[N],s[N],qz[N],hz[N];


int main()
{
	scanf("%d%lld",&n,&C);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld%d",&x[i],&v[i]);
		s[i]=s[i-1]+v[i];
	}
	ll ans=0;
	for (int i=1;i<=n;i++) qz[i]=max(qz[i-1],s[i]-x[i]);//,printf("qz[%d]=%lld\n",i,qz[i]);
	for (int i=n;i>=1;i--) hz[i]=max(hz[i+1],s[n]-s[i-1]-(C-x[i]));//,printf("hz[%d]=%lld\n",i,hz[i]);
	ans=max(qz[n],hz[1]);
	
	for (int i=1;i<=n;i++)
	{
		ans=max(ans,s[i]-x[i]*2+hz[i+1]);
		ans=max(ans,(s[n]-s[i-1])-(C-x[i])*2+qz[i-1]);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3712
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


      cin>>n>>a>>b;

      n*=a;

      cout<<min(n,b)<<endl;













}



Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


signed main()
{
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++)
	{
		if (i % d == 0) ans++;
	}
	cout << ans << endl;
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




int n;
map<string, int> mp;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;
    while (n--) {
	string s;
	cin>>s;
	mp[s]++;
    }

    vector<string> v;
    v.push_back("AC");
    v.push_back("WA");
    v.push_back("TLE");
    v.push_back("RE");

    for (auto s: v) {
	cout<<s<<" x "<<mp[s]<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3684
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,s

    read*, n
    print'(i0)', (n*(n-1))/2 - n/2
    s = 2*(n/2)+1
    do i=1,n
        do j=i+1,n
            if (j == s-i) cycle
            print'(*(i0,1x))', i,j
        end do
    end do
end program main

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

typedef pair<long long, long long> p;

int main(void){
  int N;
  cin >> N;
  vector<long long> x(N), l(N);
  vector<p> vs(N);
  for(int i = 0; i < N; i++){
    cin >> x.at(i) >> l.at(i);
    vs.at(i).first = x.at(i) + l.at(i); // 右腕の端
    vs.at(i).second = x.at(i) - l.at(i); // 左腕の端
  }
  sort(vs.begin(), vs.end());

  int ans = 1;
  long long edge = vs.at(0).first;
  for(int i = 1; i < N; i++){
    if(edge <= vs.at(i).second){
      ans++;
      edge = vs.at(i).first;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
 
char txt[100001];
int dp[100001];
int main(){
	int N,Q;
	cin >> N >> Q;
	cin >> txt;
	for(int i=1;i<N;i++){
		if(txt[i]=='C'&&txt[i-1]=='A') dp[i]++;
		dp[i]+=dp[i-1];
	}
	while(Q--){
		int l,r;
		cin >> r >> l;
		cout << dp[l-1]-dp[r-1] << "\n";
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b,c; cin >> a>>b>>c;
	//string s; cin >> s;
	int num = a * 100 + b * 10+ c;
	if (num % 4 == 0)cout << "YES";
	else cout << "NO";
	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

 
int main(){  
  int n,k;
  cin >> n >> k;
  vector<int> h(mx,inf);
  vector<int> dp(mx,inf);
  rep(i,n){
    cin >> h[i];
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=0; i<n; i++){
    for(int j=1; j<=k; j++){
      dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;
const double PI = acos(-1);

#ifndef tejasp
#define trace(...) {}
#define cotra(...) {}
#define end_routine() {}
#define localsys 0
#define endl '\n'
#endif

#define MAXN 100010
vvi adj(MAXN);
vl val(MAXN,mod);
vll lim(MAXN,{-INF,INF});

pll dfs1(int v, int p)
{
    forr(x,adj[v])
    {
        if(x!=p)
        {
            auto cur=dfs1(x,v);
            lim[v].ff=max(lim[v].ff,cur.ff);
            lim[v].ss=min(lim[v].ss,cur.ss);
        }
    }
    return make_pair(lim[v].ff-1,lim[v].ss+1);
}

bool flag=0;

void dfs2(int v, int p)
{
    if(lim[v].ff>lim[v].ss) { flag=1; return; }
    if(v!=1)
    {
        if(val[p]+1>=lim[v].ff&&val[p]+1<=lim[v].ss)
            val[v]=val[p]+1;
        else if(val[p]-1>=lim[v].ff&&val[p]-1<=lim[v].ss) val[v]=val[p]-1;
        else flag=1;
    }
    forr(x,adj[v]) if(x!=p) dfs2(x,v);
}

int tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0, ans=0;
    cin>>n;
    fol(i,1,n)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    cin>>k;
    fol(i,0,k)
    {
        cin>>u>>v;
        lim[u]={v,v};
        val[u]=v;
    }
    dfs1(1,0);
    val[1]=lim[1].ff;
    dfs2(1,0);
    if(flag) return cout<<"No"<<endl, 0;
    cout<<"Yes"<<endl;
    fol(i,1,n+1) cout<<val[i]<<endl;
    return 0;
}

signed main()
{
    #ifdef tejasp
            freopen("input.txt", "rt", stdin);
            freopen("output.txt", "wt", stdout);
    #endif
    if(!localsys) { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
    end_routine();
    if(localsys) system("pause");
}

Measured memory_bytes: 13440
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
BC = []
for _ in range(M):
    B, C = map(int, input().split())
    BC.append((B, C))
BC.sort(key=lambda bc: (bc[1], bc[0]), reverse=True)

ai = 0
bci = bcj = 0
while ai < N and bci < M:
    if A[ai] < BC[bci][1]:
        A[ai] = BC[bci][1]
        ai += 1
        bcj += 1
        if BC[bci][0] <= bcj:
            bci += 1
            bcj = 0
    else:
        ai += 1
print(sum(A))

Measured memory_bytes: 75672
#include <stdio.h>

int main(){
  int n,s=0;
  scanf("%d",&n);
  while(n>=500){
    n-=500;
    s+=1000;  
  }
  while(n>=5){
    n-=5;
    s+=5;
  }
  printf("%d",s);
  return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "First" : "Second") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string S;
  cin >> S;
  if(S[0] == S[S.size()-1]) {
    yes(S.size()%2 == 0);
  } else {
    yes(S.size()%2 == 1);
  }
}

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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int check(int a, int b, int c){
    if(a < b + c && b < c + a && c < a + b) return 1;
    else return 0;
}
int main(){
    int n; cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());

    int ans = 0;

    rep(b,n)rep(a,b){
        int ab = l[a] + l[b];
        int right = lower_bound(l.begin(), l.end(), ab) - l.begin();
        int left = b+1;
        ans += max(0, right-left);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
cnt = 0
i = 0
while i < n:
    # まず同じ値を処理する
    if i+1 < n:
        while A[i+1] == A[i]:
            i += 1
    # その次の者が大きい?
    if i+1 < n:
        if A[i] <= A[i+1]:
            while A[i] <= A[i+1]:
                i += 1
                if i+1 < n:
                    pass
                else:
                    break
        else:
            while A[i] >= A[i+1]:
                i += 1
                if i + 1 < n:
                    pass
                else:
                    break
    cnt += 1
    i += 1
print(cnt)


Measured memory_bytes: 16328
#include<bits/stdc++.h>
using namespace std;
struct Union_find{
  vector<int> par;
  vector<int> rank;
  //初期化
  Union_find(int n):par(n),rank(n){
    for(int i=0;i<n;i++){
      par[i]=i;
      rank[i]=0;
    }
  }
  //根を探す
  int root(int x){
    return par[x]==x?x:par[x]=root(par[x]);
  }
  //xとyが連結かどうかしらべる
  int same(int x,int y){
    return root(x)==root(y);
  }

  //xとyを連結する
  void unit(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(rank[x]<rank[y]){
      par[x]=y;
    }else{
      par[y]=x;
      if(rank[x]==rank[y])rank[x]++;
    }
  }
};
int main(){
 int N,M;
 cin>>N>>M;
 vector<int>p(N);
 for(int i=0;i<N;i++){
   int x;
   cin>>x;
   x--;
   p[i]=x;
 }
 Union_find uf(N);
 for(int i=0;i<M;i++){
   int x,y;
   cin>>x>>y;
   x--,y--;
   uf.unit(x,y);
 }
 int ans=0;
 for(int i=0;i<N;i++){
   if(uf.same(i,p[i]))ans++;
 }
 cout<<ans<<endl;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007;
vector<vector<int>>dp; // dp(i,j) probablity of coming j heads when i coins
vector<int>v;

int winner(int stones,int player){

        //cout<<stones<<" "<<player<<"\n";
        if(dp[player][stones]!=-1){
            return dp[player][stones];
        }
        int sz = v.size();
        for(int i=0;i<sz;i++){
            if(stones>=v[i] &&(winner(stones-v[i],1-player)==player)){
                return dp[player][stones] =player;
            }
        }
        return dp[player][stones] = 1-player;
}

void solve(){
    int n,k;cin>>n>>k;
    v.resize(n);
    dp.resize(2,vector<int>(k+1,-1));
    dp[0][0] = 1;
    dp[1][0]=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    string x = winner(k,0)==0 ? "First" : "Second";
    cout<<x<<"\n";
}

int main(){
    //cin.tie(0);
    //cout.tie(0);
    //cin.sync_with_stdio(0);
    //cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


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

#define int long long
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; }

const int MOD = 2019;

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

	map<int, int> mp;
	int n = s.size();
	int now = 0;
	mp[now]++;
	int ten = 1;
	int ans = 0;
	for(int i = n-1;i >= 0;i--){
		now = (now + (s[i]-'0')*ten) % MOD; 
		ten = (ten * 10) % MOD;
		ans += mp[now];
		mp[now]++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3688
//
//  AAAAAB.cpp
//  my_programs
//
//  Created by Jiatuo Zou on 7/22/20.
//  Copyright © 2020 Jiatuo Zou. All rights reserved.
//

#include <iostream>
#include <string>

int main()
{
    using namespace std;
    
    int n;
    long long int sum = 0, prefix_sum[4001][3] = {{0}};
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            prefix_sum[i + 1][0]++;
        } else if(s[i] == 'G'){
            prefix_sum[i + 1][1]++;
        } else{
            prefix_sum[i + 1][2]++;
        }
        prefix_sum[i + 1][0] += prefix_sum[i][0];
        prefix_sum[i + 1][1] += prefix_sum[i][1];
        prefix_sum[i + 1][2] += prefix_sum[i][2];
    }
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(s[j] != s[i]){
                if(s[j] == 'R' && s[i] == 'G' || s[j] == 'G' && s[i] == 'R'){
                    sum += (prefix_sum[n][2] - prefix_sum[j][2]);
                } else if(s[j] == 'R' && s[i] == 'B' || s[j] == 'B' && s[i] == 'R'){
                    sum += (prefix_sum[n][1] - prefix_sum[j][1]);
                } else{
                    sum += (prefix_sum[n][0] - prefix_sum[j][0]);
                }
                if(j + j - i < n && s[j + j - i] != s[j] && s[i] != s[j + j - i]){
                    sum--;
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,nn) for(int i=0;i<nn;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  string s;
  cin >> s;
  ll ans=0,num;
  FOR(i,pow(2,(s.size()-1))){
    num=s[0]-'0';
    FOR(j,s.size()-1){
      if(i & (1<<j)){
        ans+=num;
        num=s[j+1]-'0';
      }else{
        num*=10;
        num+=s[j+1]-'0';
      }
      
    }
    ans+=num;
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(){
    ll ans=0;
    ll a,b,c,d;
    cin >> a >> b;
    cin >> c >> d;
    ans = (a-c)*(b-d);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    string a, b;cin >> a >> b;
    a += b;
    int k = stoi(a);
    rep(i, 1, 1000){
        if(k == i * i){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from itertools import accumulate
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def solve():
    n,q = LI()
    a = LI()
    X = LI()
    for x in X:
        ans = 0
        l = 0
        s = 0
        for r in range(n+1):
            while s > x:
                s -= a[l]
                l += 1
            ans += r-l
            if r < n:
                s += a[r]
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 16896
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int u = Integer.parseInt(sc.next())-1;
        int v = Integer.parseInt(sc.next())-1;
        ArrayList<ArrayList<Integer>> edge = new ArrayList<ArrayList<Integer>>();
        for (int i=0;i<N;i++) {
            ArrayList<Integer> add = new ArrayList<Integer>();
            edge.add(add);
        }
        for (int i=0;i<N-1;i++) {
            int A = Integer.parseInt(sc.next())-1;
            int B = Integer.parseInt(sc.next())-1;
            edge.get(A).add(B);
            edge.get(B).add(A);
        }
        int[] takahashi = new int[N];
        int[] aoki = new int[N];
        Arrays.fill(takahashi, -1);
        Arrays.fill(aoki, -1);

        ArrayDeque<int[]> q = new ArrayDeque<int[]>();
        // takahashi
        int[] f_1 = {u, 0};
        q.add(f_1);
        while (!q.isEmpty()) {
            int[] rem = q.poll();
            if (takahashi[rem[0]]!=-1) continue;
            takahashi[rem[0]]=rem[1];
            for (Integer i : edge.get(rem[0])) {
                int[] add = {i, rem[1]+1};
                q.add(add);
            }
        }

        // aoki
        int[] f_2 = {v, 0};
        q.add(f_2);
        while (!q.isEmpty()) {
            int[] rem = q.poll();
            if (aoki[rem[0]]!=-1) continue;
            aoki[rem[0]]=rem[1];
            for (Integer i : edge.get(rem[0])) {
                int[] add = {i, rem[1]+1};
                q.add(add);
            }
        }

        int ans = 0;
        for (int i=0;i<N;i++) {
            if (takahashi[i]<aoki[i]) {
                ans = Math.max(ans, aoki[i]-1);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 76776
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n;
ll a[MAX<<1],h[MAX<<1];

ll ST[MAX<<3],A[MAX<<1];

void build(ll node,ll lo,ll hi){
  if(lo == hi){
    ST[node] = A[lo];
    return;
  }
  ll mid = (lo+hi)>>1;
  build(node<<1,lo,mid);
  build(node<<1|1,mid+1,hi);
  ST[node]=ST[node<<1]+ST[node<<1|1];
}

void update(ll node,ll lo,ll hi,ll x,ll y){
  if(lo == hi){
    ST[node]=y;
    A[lo]=y;
    return;
  }
  ll mid = (lo+hi)>>1;
  if(lo<=x and mid>=x){
    update(node<<1,lo,mid,x,y);
  }
  else{
    update(node<<1|1,mid+1,hi,x,y);
  }
  ST[node]=max(ST[node<<1],ST[node<<1|1]);
}

ll query(ll node,ll lo,ll hi,ll l,ll r){
  if(lo>r or hi<l){
    return 0;
  }
  else if(l<=lo and hi<=r){
    return ST[node];
  }
  ll mid = (lo+hi)>>1LL;
  ll p1 = query(node<<1,lo,mid,l,r);
  ll p2 = query(node<<1|1,mid+1,hi,l,r);
  return max(p1,p2);
}

int main(){FAST;
cin>>n;
for(ll i=1;i<=n;++i){
  cin>>h[i];
}
for(ll i=1;i<=n;++i){
  cin>>a[i];
}
vll v;
for(ll i=1;i<=n;++i){
  v.pb(mp(h[i],i));
}
sort(all(v));
ll ans = a[1];
for(auto it:v){
  ll idx = it.second;
  ll mx = query(1,1,n,1,idx);;
  update(1,1,n,idx,mx+a[idx]);
  ans = max(ans,mx+a[idx]);
}
cout<<ans;
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 15372
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

ll modpow(ll a, ll n) {
    a %= MOD;
    if (n == 0)
        return 1;
    if (n == 1)
        return a % MOD;
    if (n % 2)
        return a * modpow(a, n - 1) % MOD;
    else
        return (modpow(a, n / 2) * modpow(a, n / 2)) % MOD;
}

ll culc(ll a, ll n) {
    ll up = 1;
    ll down = 1;
    for (ll i = n - a + 1; i <= n; i++) {
        up *= i % MOD;
        up %= MOD;
    }
    for (ll i = 1; i <= a; i++) {
        down *= i % MOD;
        down %= MOD;
    }
    down = modpow(down, MOD - 2);
    return up * down % MOD;
}

void ch(int &n) {
    n += 10 - n % 10;
    // n /= 10;
}

int main() {
    string s;
    cin >> s;
    int maxi = 0;
    int keep = 0;
    int n = s.size();

    rep(j, n) {
        if (s[j] == 'A' || s[j] == 'T' || s[j] == 'G' || s[j] == 'C') {
            keep++;
            maxi = max(maxi, keep);
        }
        else {
            
            keep = 0;
        }
    }
    cout << maxi << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int A[N] = {};
    
  for(int i =0 ;i<N-1;i++){
    int B = 0;
    cin >> B;
    
    if(i==0){
      A[i]=B;
      A[i+1]=B; 
    }else{
      if(A[i] > B) A[i]=B;  
      A[i+1]=B;
    }
  }
  
  int sum = 0;
  for(int i=0;i<N;i++){
    sum += A[i];
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;

int main(void){
    int n;
    cin>>n;
    vector<int> P(n),Q(n);
    rep(i,n) cin>>P[i];
    rep(i,n) cin>>Q[i];
    bool biggerp;
    rep(i,n){
        if(P[i]>Q[i]){
            biggerp=true;
            break;
        }
        else if(P[i]<Q[i]){
            biggerp=false;
            break;
        }
    }
    long long count=0;
    if(biggerp){
        do{
            /*rep(i,n) cout<<Q[i]<<" ";
            cout<<endl;*/
            bool temp=true;
            rep(i,n) if(P[i]!=Q[i]) temp=false;
            if(temp) break;
            count++;
        } while(next_permutation(Q.begin(),Q.end()));
    }
    else{
        do{
            /*rep(i,n) cout<<P[i]<<" ";
            cout<<endl;*/
            bool temp=true;
            rep(i,n) if(P[i]!=Q[i]) temp=false;
            if(temp) break;
            count++;
        } while(next_permutation(P.begin(),P.end()));
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3600
n,m=map(int,input().split())
height = list(map(int,input().split()))
lst = [0] * n
for j in range(m):
  a,b=map(int,input().split())
  if height[a-1]<height[b-1]:
    if lst[b-1] == -1:
      lst[a-1]=-1
    else:
      lst[a-1]=-1
      lst[b-1]+=1
  elif height[a-1]>height[b-1]:
    if lst[a-1]==-1:
      lst[b-1]=-1
    else:
      lst[a-1]+=1
      lst[b-1]=-1
  elif height[a-1]==height[b-1]:
    lst[a-1] = -1
    lst[b-1] = -1
cnt = 0
for k in range(n):
  if lst[k]>=0:
    cnt+=1
print(cnt)

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a;
    string s;
    cin >> a >> s;
    if (a < 3200)
        cout << "red\n";
    else
        cout << s << endl;
    return 0;
}

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

int main(void) {

	int n, m, cnt = 1, max = 0;
	string s[100], t[100];

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	cin >> m;
	for (int i = 0; i < m; i++)
		cin >> t[i];

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j])
				cnt++;
		}
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j])
				cnt--;
		}
		if (cnt > max)
			max = cnt;
		cnt = 1;
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll a,b;
    char op;
    cin>>a>>op>>b;
    if(op == '+') {
        cout << a + b << endl;
    }
    else {
        cout << a - b << endl;
    }
    return 0;
}


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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

ll mod=1e9+7;

int main(){
  int A,B,M;
  cin >> A>>B>>M;
  vector<int>a(A);
  vector<int>b(B);
  rep(i,A){
    cin >> a[i];
  }
  rep(i,B){
    cin >> b[i];
  }
  int ans=1e9;
  rep(i,M){
    int x,y,c;
    cin>> x>>y>>c;
    int num=a[x-1]+b[y-1]-c;
    ans=min(ans,num);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ans=min(ans,a[0]+b[0]);
  cout << ans << endl;
  
}
      
  
  
  

Measured memory_bytes: 1024
n, m = map(int, input().split())
a = list()
b = list()
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    ans = 0
    for n in range(m):
        ans += a[i][n] * b[n]
    print(ans)


Measured memory_bytes: 6012
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;

/// Info.
///****************************************************************************************************************************************///
/// author                : BAHAA El-DEEN OSAMA .
/// Problem name          : A - Choose Two Numbers
/// Method                : brute force
/// Online judge          : vjudge(Contest)
/// Date                  : 8/6/2020
///****************************************************************************************************************************************///

string str;
int n,AC=0,WA=0,TLE=0,RE=0;

int main()
{

cin>>n;
for(int i=0 ; i<n ;i++)
{
    cin>>str;
    if(str == "AC"){++AC;}
    else if(str == "WA"){++WA;}
    else if(str == "TLE"){++TLE;}
    else if (str == "RE"){++RE;}
}






cout << "AC" << " x " << AC <<endl;
cout << "WA" << " x " << WA <<endl;
cout << "TLE" << " x " << TLE <<endl;
cout << "RE" << " x " << RE <<endl;



return 0;
}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    std::string N;
    cin >> N;
    bool sev = false;
    for(int i = 0; i < 3; i++){
        if(N[i]=='7'){
            sev = true;
            break;
        }
    }
    if(sev){
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int h[n];
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int br[m][2];
	int a, b;
	for(int i = 0; i < m; i++) {
		cin >> br[i][0] >> br[i][1];
	}
	bool flag[n] = {true};
	for(int i = 0; i < n; i++) {
		flag[i] = true;
	}
	for(int i = 0; i < m; i++) {
		// printf("%d %d\n",h[br[i][0]-1], h[br[i][1]-1]);
		if(h[br[i][0]-1] > h[br[i][1]-1]) flag[br[i][1] -1] = false;
		else if(h[br[i][0]-1] < h[br[i][1]-1]) flag[br[i][0] -1] = false;
		else {
			flag[br[i][0] -1] = false;
			flag[br[i][1] -1] = false;
		}
	}
	int count = 0;
	for(int i = 0; i < n; i++) {
		if(flag[i]) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 4904