akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define rep(...) _overload3(__VA_ARGS__,_repi,_rep)(__VA_ARGS__)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrep(i,n) _rrepi(i,0,n)
#define rrep(...) _overload3(__VA_ARGS__,_rrepi,_rrep)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload3(__VA_ARGS__,a,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}


int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    cin>>a;
    ll ans=LINF;
    rep(i,0,n-k+1){
        if(a[0+i]*a[k-1+i]<0){
            if(min(abs(a[0+i]),abs(a[k-1+i]))*2+max(abs(a[0+i]),abs(a[k-1+i]))<ans)ans=min(abs(a[0+i]),abs(a[k-1+i]))*2+max(abs(a[0+i]),abs(a[k-1+i]));
        }
        else if(max(abs(a[k-1+i]),abs(a[0+i]))<ans)ans=max(abs(a[k-1+i]),abs(a[0+i]));
    }
    out(ans);
}














Measured memory_bytes: 1024
def main():
    n = int(input())
    As = list(map(int, input().split()))
    nums = []
    rainbow = 0
    for A in As:
        num = A // 400
        if num < 8:
            if num not in nums:
                nums.append(num)
        else:
            rainbow += 1
    ans_max = len(nums)+rainbow
    ans_min = max(1, len(nums))
    print(ans_min, ans_max)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9056
#include<bits/stdc++.h>
const int N=101000;
using namespace std;
long long D[N];
int w[N], n;
int main() {
	cin>>n;
	for (int i=1;i<=n;i++) {
		cin>>w[i];
	}
	for(int i=2;i<=n;i++){
		D[i]=1e18;
		for(int j=i-1;j>=i-2&&j>=1;j--) {
			D[i]=min(D[i],D[j]+abs(w[j]-w[i]));
		}
	}
	cout<<D[n];
}

Measured memory_bytes: 1408
import math
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if r == 0:
  print(abs(a-b))
elif r == 180:
  print(a + b)
elif 180 < r:
  r1 = 360 - r
  cos = math.cos(math.radians(r1))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)
else:
  cos = math.cos(math.radians(r))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)

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

int main(){
  int a,b;
  cin >> a >> b;
  if( a == 1 ) a += 13;
  if( b == 1 ) b += 13;
  if( a > b ){
    cout << "Alice" << endl;
  }else if( a ==  b ){
 	cout << "Draw" << endl;
  }else{
    cout << "Bob" << 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=100010;
const ll mod=1e9+7;

int main(){
  int n,a;
  cin >> n >> a;
  ll dp[55][55][3000];
  vector<int> x(n);
  rep(i,n){ cin>>x[i]; }
  
  dp[0][0][0]=1; 
  for(int i=0; i<n; i++)for(int j=0; j<=n; j++)rep(k,2501){
    dp[i+1][j][k] += dp[i][j][k]; 
    dp[i+1][j+1][k+x[i]] = dp[i][j][k];
  }
  
  ll ans=0;
  for(int j=1; j<=n; j++){
    ans += dp[n][j][j*a];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 66560
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	int X = 0, S, D;
	vector<int> A;
	
	cin>>N;
	
	A.resize(N);
 	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	for(int i = 0; i < N; i++){
		if(i >= 2) X ^= A[i];
	}
	
	S = A[0] + A[1];
	D = (S - X)/2;
	
	if((S - X) % 2 || S < X || (D&X) || D > A[0]) {
		cout<<-1<<endl;
		return 0;
	}
	
	int Y = 0;
	
	for(int i = 50; i >= 0; i--){
		if(D&(1ll<<i)) continue;
		if(!(X&(1ll<<i))) continue;
		
		if((D^(Y|(1ll<<i))) < A[0]) {
			Y |= (1ll<<i);
		}
	}
	
	if((D^Y) == 0) {
		cout<<-1<<endl;
	} else {
		cout<<A[0] - (D^Y)<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3644
N, M = map(int, input().split())

if N>M:
    N, M = M, N

if N==1:
    if M==1:
        ans = 1
    else:
        ans = M - 2

elif N==2:
    ans = 0
else:
    ans = (N - 2)*(M - 2)

print(ans)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int x;cin>>x;
  cout<<(x>29?"Yes":"No");
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c,k,sum;
  cin>>a>>b>>c>>k;
  if(k<=a)
  {
      cout<<k<<'\n';
  }

  else{
    sum=min(k,a);
    long long t=abs(k-a);
    if(b>=t)
    {
        cout<<sum<<'\n';
    }
    else{
        long long l=abs(t-b);
        sum+=l*(-1);
        cout<<sum<<'\n';
    }
  }
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll X,ans;



int main() {
	cin >> X;
	ll M = X % 11;
	if (M >= 1 && M <= 6)ans++;
	else if (M != 0)ans += 2;
	ans += 2*(X / 11);
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

//sqrt
//-------------------------------------------
template<class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//repetition
//------------------------------------------
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  FOR(i,0,n)
#define REPR(i, n) for(int i = n;i >= 0;i--)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


int main() {

    int H; cin>>H;
    int W; cin>>W;

    VS map(H);
    REP(i, H){
        cin>>map[i];
    }

    vector<vector<int>> map2(H);
    REP(i, H){
        map2[i].resize(W);
    }
    REP(i, H){
        REP(j, W){
            map2[i][j] = 0;
        }
    }

    int xArray[] = {-1, 0, 1, -1, 1, -1, 0, 1};
    int yArray[] = {-1, -1, -1, 0, 0, 1, 1, 1};

    REP(i, H){
        REP(j, W){
            int count = 0;
            REP(k,8){
                int y = i + yArray[k];
                int x = j + xArray[k];
                if(x>=0 && x<W){
                    if(y>=0 && y<H){
                        if(map[y][x] == '#'){
                            count++;
                        }
                    }
                }
            }
            map2[i][j] = count;
        }
    }

    REP(i, H){
        REP(j, W){
            if(map[i][j] == '#'){
                printf("#");
            }else{
                printf("%d", map2[i][j]);
            }
        }
        printf("\n");
    }

    return 0;
}















































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

#define ll long long

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int arr[n];

    int p, q;
    int sum=0;
    for(int i=0; i<n; i++){
        cin >> arr[i];
        sum+=arr[i];
    }

    p=sum/n;
    q=p+1;

    int p1=0, q1=0;

    for(int i=0; i<n; i++){
        p1+=(arr[i]-p)*(arr[i]-p);
        q1+=(arr[i]-q)*(arr[i]-q);
    }

    cout << min(p1,q1) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // カードの枚数をsortして大きい数のものを減らしていく
    // 累積和
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
        int x;
        cin >> x;
        A[x-1]++;
    }
    sort(A.begin(), A.end());
    vector<int> Acum(N+1);
    rep(i, N) {
        Acum[i+1] = Acum[i] + A[i];
    }
    int cur = N, ans = N;
    for (int k = 1; k <= N; k++) {
        while (1) {
            auto ok = [&](int c) {
                while (cur > 0 && A[cur-1] >= c) cur--;
                int temp = Acum[cur] + c * (N - cur);
                return (temp >= c * k);
            }(ans);
            if (ok) break;
            ans--;
        }
        cout << ans << '\n';
    }    
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

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

int main() {
  ll x;
  cin >> x;
  for (int i = -118; i < 120; i++) {
    for (int j = -119; j < 119; j++)
      if (pow(i, 5) - pow(j, 5) == x) {
        printf("%d %d\n", i, j);
        return 0;
      }
  }
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int i=0;
  
  while(true){
    if(i*4==N){
      cout << "Yes" << endl;
      return 0;
    }
    int j=1;
    while(true){
      if((i*4+j*7)==N){
        cout << "Yes" << endl;
        return 0;
      }
      j++;
      if((i*4+j*7)>N) break;
    }
    i++;
    if(i*4>N) break;
  }
  cout << "No" << endl;
  return 0;
}


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

#define MAX_N 11

int main() {
	int N;
	double sum = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		double num;
		string t;
		cin >> num >> t;
		if (t == "JPY") {
			sum += num;
		} else {
			sum += num * 380000;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
//atcoder 101 b median of medians
#include <bits/stdc++.h>
using namespace std;

inline int read()
{
	int x=0,f=1,c=getchar();
	while(c<48) c=='-'&&(f=-1),c=getchar();
	while(c>47) x=x*10+c-'0',c=getchar();
	return x*f;
}

typedef long long ll;
const int MAXN = 100005;
int val[MAXN],ori[MAXN],sum[MAXN],t[MAXN<<1];
int n,m,lim;

inline void add(int x,int k)
{while(x<=lim) t[x]+=k,x+=x&-x;}

inline int query(int x)
{
	int res=0;
	while(x) res+=t[x],x-=x&-x;
	return res;
}

inline int check(int mid)
{
	ll res=0; memset(t,0,sizeof(t));
	function<ll()> calc=[]() {return 1ll*n*(n-1)/2+n;};
	for(int i=1; i<=n; ++i) sum[i]=(val[i]<mid ? -1 : 1);
	for(int i=1; i<=n; ++i) sum[i]+=sum[i-1],res+=sum[i]>=0;
	for(int i=1; i<=n; ++i) sum[i]+=n+1,lim=max(lim,sum[i]);
	for(int i=1; i<=n; ++i) res+=query(sum[i]),add(sum[i],1);
	return calc()-res<calc()/2+1;
}

int main(int argc, char const *argv[])
{
	n=read();
	for(int i=1; i<=n; ++i) ori[i]=val[i]=read();
	sort(ori+1,ori+n+1,[](int i,int j) {return i<j;});
	m=unique(ori+1,ori+n+1)-ori-1;
	for(int i=1; i<=n; ++i)
		val[i]=lower_bound(ori+1,ori+m+1,val[i])-ori;
	int l=1,r=m;
	while(l<r)
	{
		int mid=(l+r+1)>>1;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	printf("%d\n", ori[l]);
	return 0;
}

Measured memory_bytes: 5680
///ac
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define ll long long
#define ull long long unsigned
using namespace std;
#define foru(i,a,n) for (int i=(a); i<=(n); i++)
#define ford(i,n,a) for (int i=(n); i>=(a); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define bit1cnt(x) (__builtin_popcountll(x))
#define sqr(x) ((x) * (x))
#define sz(x) ((int)(x.size()))
#define Pi 3.14159265358979
#define ii pair<int,int>
#define LL pair<ll,ll>
#define vi vector<int>
string s;
int x, y, cntF, cntT;
vi dX, dY;
int cal(vi seg, int Dich, int type){
    map <int,int> ans;
    ans[0] = 1;
    rep(i, seg.size()){
        map <int,int> tmp;
        for(auto x : ans){
            tmp[x.first + seg[i]] = 1;
            if(i==0 && type==1) continue;
            tmp[x.first - seg[i]] = 1;
        }
        ans = tmp;
    }
    return ans[Dich];
}

int main(){
    cin >>s >>x >>y;
    ///Move with X and with Y
    int len = 0, dir = 1;
    s +='T';    ///Process last 'F' in S
    rep(i, s.size()){
        if(s[i]=='F') len++;
        else{
            if(dir) dX.push_back(len); else dY.push_back(len);
            dir = !dir;
            len = 0;
        }
    }

    if(cal(dX, x, 1) && cal(dY, y, 0))
        cout <<"Yes";
    else
        cout <<"No";
    return 0;
}


Measured memory_bytes: 640
n, c = map(int, input().split())
tv = [list(map(int, input().split())) for i in range(n)]

tv.sort(key=lambda x: x[1])
imos = [0 for i in range(10**5+2)]
mark = [[] for i in range(10**5+2)]
for i in range(n):
    flag = 0
    for j in mark[tv[i][0]]:
        if j == tv[i][2]:
            flag = 1
    if flag:
        imos[tv[i][0]+1] += 1
    else:
        imos[tv[i][0]] += 1
    imos[tv[i][1]+1] -= 1
    mark[tv[i][1]].append(tv[i][2])

for i in range(10**5+1):
    imos[i+1] += imos[i]

print(max(imos[:-1]))

Measured memory_bytes: 36428
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val d = (1..n).map { sc.nextInt() }
  val m = sc.nextInt()
  val t = (1..m).map { sc.nextInt() }


  val dmap = mutableMapOf<Int, Int>()
  for (di in d) {
    val tmp = dmap.getOrElse(di) { 0 }
    dmap.put(di, tmp+1)
  }
  val tmap = mutableMapOf<Int, Int>()
  for (ti in t) {
    val tmp = tmap.getOrElse(ti) { 0 }
    tmap.put(ti, tmp+1)
  }

  for (key in tmap.keys) {
    val di = dmap.getOrElse(key) { 0 }
    val ti = tmap.getOrElse(key) { 0 }

    if (di < ti) {
      println("NO")
      return
    }
  }
  println("YES")

}

Measured memory_bytes: 88928
//coded by not_surrender

#pragma GCC optimize( "Ofast" )

#include <bits/stdc++.h>

#define MAXN 55
#define oo (1<<30)
#define MOD 1000000007
#define mid ((a+b)/2)
#define L (nod*2)
#define R (nod*2+1)
#define pb push_back

using namespace std;

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

ll N, K, ans;

struct Matrix{
	ll M[MAXN][MAXN];
	Matrix(){
		memset( M, 0, sizeof M );
	}
	
	Matrix operator * ( const Matrix other ) const {
		Matrix ret;
		for ( int k = 1; k <= N; ++k )
			for ( int j = 1; j <= N; ++j )
				for ( int i = 1; i <= N; ++i )
					ret.M[k][j] += (M[k][i]*other.M[i][j])%MOD, ret.M[k][j] %= MOD;
		return ret;
	}
	
	static Matrix ident(){
		Matrix ret;
		for ( int i = 1; i <= N; ++i )
			ret.M[i][i] = 1;
		return ret;
	}
		
}A, B;

Matrix mpow( ll exp ){
	//~ if ( exp == 1 )
		//~ return A;
	//~ Matrix tmp = mpow( exp/2 );
	//~ return tmp*tmp;
	Matrix ret = Matrix::ident();
	for ( ; exp; A = A*A, exp /= 2 )
		if ( exp&1 )
			ret = ret*A;
	return ret;
}

int main(){

    #ifndef ONLINE_JUDGE
        //~ freopen( "a.txt", "r", stdin );
    #endif // ONLINE_JUDGE

    ios_base::sync_with_stdio( false );
    cin.tie( NULL ), cout.tie( NULL );
    
    cin >> N >> K;
    
    for ( int i = 1; i <= N; ++i )
		for ( int j = 1; j <= N; ++j )
			cin >> A.M[i][j];
	
	B = mpow( K );
			
	for ( int i = 1; i <= N; ++i )
		for ( int j = 1; j <= N; ++j )
			ans += B.M[i][j], ans %= MOD;
	
	cout << ans << '\n';
      
return 0;
}


Measured memory_bytes: 384
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (L, R, D): (Vec<usize>, Vec<usize>, Vec<i64>) = {
        let (mut L, mut R, mut D) = (vec![], vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            L.push(iter.next().unwrap().parse().unwrap());
            R.push(iter.next().unwrap().parse().unwrap());
            D.push(iter.next().unwrap().parse().unwrap());
        }
        (L, R, D)
    };

    let G = {
        let mut G = vec![std::collections::HashMap::new(); N + 1];
        for i in 0..M {
            G[L[i]].insert(R[i], D[i]);
            G[R[i]].insert(L[i], -D[i]);
        }
        G
    };
    const INF: i64 = 1_000_000_000_000_000;
    let mut x = vec![INF; N + 1];
    fn validate(i: usize, G: &Vec<std::collections::HashMap<usize, i64>>, x: &mut Vec<i64>) -> bool {
        let mut res = true;
        for (&j, &d) in &G[i] {
            if x[j] == INF {
                x[j] = x[i] + d;
                res &= validate(j, G, x);
            }
            else { res &= x[j] == x[i] + d }
        }
        res
    }

    let mut is_consistent = true;
    for i in 1..(N + 1) {
        if x[i] == INF {
            x[i] = 0;
            is_consistent &= validate(i, &G, &mut x);
        }
    }
    let ans = if is_consistent { "Yes" } else { "No" };

    println!("{}", ans);
}

Measured memory_bytes: 98492
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;

const int mod=1000000007;
const int N=2005;


long long A,B;

int main() {
    scanf("%lld%lld",&A,&B);

    if(A==B) {
        puts("1"); return 0;
    }

    int k=-1;
    for(int i=59;i>=0;--i) {
        int x0=(A>>i)&1;
        int x1=(B>>i)&1;
        if(x0+x1==1) {
            k=i; break;
        }
        else if(x0+x1==2) {
            A^=1ll<<i,B^=1ll<<i;
        }
    }
    long long T=1ll<<k;
    long long ans=T-A;
    for(k=59;k>=0;--k) {
        if(T+(1ll<<k)<=B) {
            break;
        }
    }
    long long ll0=T,rr0=T+(1ll<<(k+1))-1;
    long long ll1=T+A,rr1=T+T-1;
    if(ll0==ll1) {
        ans+=max(rr0,rr1)-ll0+1;
    }
    else {
        if(ll1<=rr0) {
            if(rr0>=rr1) ans+=rr0-ll0+1;
            else {
                ans+=rr1-ll0+1;
            }
        }
        else {
            ans+=rr0-ll0+1;
            ans+=rr1-ll1+1;
        }

    }
    printf("%lld\n",ans);

}


Measured memory_bytes: 256
def solve():

    N = int(input())

    ans = 0
    for i in range(N+1):
        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            ans += i

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 67464
while True:
  m,f,r = map(int,input().split())
  if m==-1 and f==-1 and r==-1:
    break
  elif m==-1 or f==-1:
    print("F")
  elif (m+f) >= 80:
    print("A")
  elif 65 <= (m+f) < 80:
    print("B")
  elif 50 <= (m+f) < 65:
    print("C")
  elif 30 <= (m+f) < 50:
    if r >= 50:
      print("C")
    else :
      print("D")
  elif (m+f) < 30:
    print("F")


Measured memory_bytes: 5592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	vector<int> v;
	inputVector(v, n);
	
	map<int, int> m[2];
	rep(i, n) m[i % 2][v[i]]++;

	int num1, num2;
	int val1 = n, val2 = n;
	itrep(it, m[0]) {
		int val = abs(n / 2 - it->second);
		if (val < val1) {
			val1 = val;
			num1 = it->first;
		}
	}
	itrep(it, m[1]) {
		int val = abs(n / 2 - it->second);
		if (val < val2) {
			val2 = val;
			num2 = it->first;
		}
	}

	cerr << "num1:" << num1 << " val1:" << val1 << endl;
	cerr << "num2:" << num2 << " val2:" << val2 << endl;
	if (num1 != num2) {
		cout << val1 + val2 << endl;
		return 0;
	}

	int ret = min(val1, val2) + n / 2;
	itrep(it, m[0]) {
		if (it->first == num1) continue;
		ret = min(ret, val2 + abs(n / 2 - it->second));
	}
	itrep(it, m[1]) {
		if (it->first == num1) continue;
		ret = min(ret, val1 + abs(n / 2 - it->second));
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 7296
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
int dp[101][(int)1e5+10] = {};
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n,w;
	cin>>n>>w;
	vector<pii> val(n+1);
	for(int i=1;i<=n;i++){
		cin>>val[i]._1>>val[i]._2;
	}
	for(int i=1;i<(int)1e5+10;i++){
		dp[0][i] = 1e13+10;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=(1e5+5);j++){
			int ans = dp[i-1][j];
			if((j - val[i]._2) >= 0){
				ans = min(ans,dp[i-1][j-val[i]._2]+val[i]._1);
			}
			dp[i][j] = ans;
		}
	}
	int ans = 0;
	for(int i=1;i<=(1e5+5);i++){
		if(dp[n][i] <= w){
			ans = i;
		}
	}
	cout<<ans;
    return 0;
}
//.........

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

int main()
{
  int H, W, N;
  cin >> H >> W >> N;
  int ans = N / max(H, W);
  if (N % max(H, W) != 0)
    ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    N, K = list(map(int, input().split()))
    field = list(map(int, input().split()))

    dpList = [0] * N
    dpList[1] = abs(field[0] - field[1])

    for i in range(2, N):
        tmpList = []
        minCost = -1

        minS = max(0, i - K)

        for dpJ, fJ in zip(dpList[minS:i], field[minS:i]):
            cost = dpJ + abs(field[i] - fJ)

            if(minCost == -1):
                minCost = cost
            elif minCost > cost:
                minCost = cost

        dpList[i] = minCost

    print(dpList[-1])

if __name__ == "__main__":
    main()

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	vector<vector<int>> dp(N + 1, vector<int>(3));
	int res = 0;
	dp[1][0] = 1;
	for (int i = 1; i < N; i++) {
		dp[i + 1][0] = a[i - 1] != a[i] ? dp[i][0] + 1 : 1;
		dp[i + 1][1] = a[i - 1] != a[i] ? dp[i][1] + 1 : dp[i][0] + 1;
		dp[i + 1][2] = a[i - 1] != a[i] ? dp[i][2] + 1 : dp[i][1] + 1;
		res = max(res, max({ dp[i + 1][0], dp[i + 1][1], dp[i + 1][2] }));
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 8692
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define brep1(i,n) for(int i=n;i>=1;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long

unsigned const int MOD = 1e9+7;



int main(void){
    ll a,b;
    cin >> a >> b;
    ll ans = 0;
    for(int i = b;i < b+a;i++)ans+=i;
    ll max = b+a-1;
    if(b >= 1)ans -= b;
    else if(max < 0)ans -= max;
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
  long long n;
  cin >> n;
  string ans = "";
  long long m = 26, c;
  
    c = n % m;
    if(c == 0)
      c = 26;
    ans += (c + 'a' - 1);
    n -= c;
 	n /= 26;
   
  while(n)
  {
    c = n % 26;
    if(c == 0)
      c = 26;
    ans += (c + 'a' - 1);
    n -= c;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3624
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    n = int(input())
    path = list(itertools.permutations(list(range(n))))
    path_len = len(path)
    place = [list(map(int, input().split())) for i in range(n)]
    ans = 0
    for i in path:
        q = 0
        for k in range(n-1):
            q += ( (place[i[k+1]][0] - place[i[k]][0])**2 + (place[i[k+1]][1] - place[i[k]][1])**2 )**(1/2)
        ans += q
    print(ans/path_len)


if __name__=="__main__":
    main()


Measured memory_bytes: 80748
n=int(input())
t,a=map(float,input().split())
h=input().split()
i=0
min_dis=1000000
p=0
while i<len(h):
    p_w=t-float(h[i])*0.006
    w=a-p_w
    if a-p_w<0:
        w=p_w-a
    if w<min_dis:
        min_dis=w
        p=i+1
    i+=1
print(p)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int n, b, f, r, v;
  int i ,j, k; //カウンタ変数
  int hotel[4][3][10];
  for(i = 0 ; i < 4 ; i++){
    for(j = 0 ; j < 3 ; j++){
      for(k = 0 ; k < 10 ; k++){
	hotel[i][j][k] = 0;
      }
    }
  }
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    hotel[b-1][f-1][r-1] += v;
    if(hotel[b-1][f-1][r-1] > 9){
      hotel[b-1][f-1][r-1] = 9;
    }
    if(hotel[b-1][f-1][r-1] < 0){
      hotel[b-1][f-1][r-1] = 0;
    }
  }
  for(i = 0 ; i < 4 ; i++){
    for(j = 0 ; j < 3 ; j++){
      for(k = 0 ; k < 10 ;k++){
	printf(" %d", hotel[i][j][k]);
      }
      printf("\n");
    }
    if(i == 3)break;
    printf("####################\n");
  }
  return 0;
}




Measured memory_bytes: 2112
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

struct Edge {
  ll a, b, c;
};

int main() {
  int N, M;
  get(N, M);
  vector<Edge> E;
  FOR(i, M) {
    int a, b, c;
    get(a, b, c);
    a--;
    b--;
    E.push_back(Edge({a, b, -c}));
  }
  vector<ll> d(N, 1LL << 60);
  d[0] = 0;
  FOR(i, N) {
    FOR(j, M) {
      Edge e = E[j];
      if (d[e.b] > d[e.a] + e.c) {
        d[e.b] = d[e.a] + e.c;
      }
    }
  }
  ll ans1 = d[N - 1];
  FOR(i, N) {
    FOR(j, M) {
      Edge e = E[j];
      if (d[e.b] > d[e.a] + e.c) {
        d[e.b] = d[e.a] + e.c;
      }
    }
  }
  if (ans1 != d[N - 1]) {
    print("inf");
  } else {
    print(-d[N - 1]);
  }
  return 0;
}
#include <algorithm>


Measured memory_bytes: 384
N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)] )

P = [-1] * (N+1)
P[0] = 1
P[1] = 1
flg=False
MOD = 10**9 + 7
for i in range(2, N+1):
    if i-1 not in a:
        P[i] = P[i-1]
    if i-2 not in a:
        if P[i] != -1:
            P[i] += P[i-2] % MOD
        else:
            P[i] = P[i-2] % MOD
    if P[i]==-1:
        flg=True
        break
if flg:
    print(0)
else:
    print(P[N] % MOD)

Measured memory_bytes: 13212
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    return buf
}

fn main() {
  let line = gets();
  let mut ans = String::new();
  for (i, c) in line.chars().enumerate() {
    if (i + 1) % 2 == 1 {
      ans.push_str(&c.to_string());
    }
  }
  println!("{}", ans);
}


Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

struct BM {
  int V;
  vector<vector<int > > G;
  vector<int> match;
  vector<bool> used;
  BM(int n=0) : V(n), G(n), match(n, -1), used(n) {}
  inline void add(int u, int v) {
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  bool dfs(int v) {
    used[v] = true;
    for(int u:G[v]) {
      int w = match[u];
      if(w < 0 or (!used[w] and dfs(w))) {
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }
  int bipartite_matching() {
    int res = 0;
    rep(v, V) {
      if(match[v] < 0) {
        rep(i, v) used[i] = 0;
        if(dfs(v)) res++;
      }
    }
    return res;
  }
};

//head

int x, y, e;
BM bpm(200);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> x >> y >> e;
  rep(i, e) {
    cin >> x >> y;
    bpm.add(x, 100+y);
  }
  cout << bpm.bipartite_matching() << endl;
}


Measured memory_bytes: 3248
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main()
{
    int N, L[10];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> L[i];
    sort(L, L+N);

    int sum = 0;
    for(int i = 0; i < N - 1; i++) sum += L[i];
    if(sum > L[N-1]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = CInt(NextString())
        Dim ans As Integer

        For i As Integer = 1 To N Step 2
            ans += B2I(Calc(i) = 8)
        Next
        WriteLine(ans)
    End Sub

    Function Calc(n As Integer) As Integer
        Dim result As Integer
        Dim i As Integer = 1
        Do While i ^ 2 < n
            If n Mod i = 0 Then result += 2
            i += 1
        Loop
        If i ^ 2 = n Then result += 1
        Return result
    End Function

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 20432
import numpy as np
from numba import jit

@jit('i2[:](i2,i2,i2[:])',cache = True)
def solve(n,k,A):
    l,r=0,0
    for i in range(k):
        B=np.zeros(n+1,dtype=np.int64)
        for x,y in enumerate(list(A)):
            l=max(0,x-y)
            r=min(n,x+y+1)
            B[l]+=1
            B[r]-=1
        A=np.cumsum(B[:-1])
        if A[A==n].size==n:
            break
    return A
n,k=map(int,input().split())
a=list(map(int,input().split()))
A=np.array(a)
X=solve(n,k,A)
print(*X,sep=' ')

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> p;
  for (int i = 1; i <= min(a, b); ++i) {
    if (a % i == 0 && b % i == 0)
      p.push_back(i);
  }
  reverse(p.begin(), p.end());
  cout << p[k - 1] << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int arr[100100];
int main()
{
    int n;
    cin>>n;
    for(int i = 1 ; i<=n ; ++i)
    {
        int x;
        scanf("%d" , &arr[i]);
    }
    int ans = 0;
    for(int i = 1 ; i<=n ; ++i)
    {
        if(arr[i] == i)
        {
            ans++;
            swap(arr[i] , arr[i+1]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
a = []
b = []
n, m, l = [int(n) for n in input().split()]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    a.append([int(n) for n in input().split()])
for i in range(m):
    b.append([int(n) for n in input().split()])
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for num in c:
    print(' '.join(str(n) for n in num))

Measured memory_bytes: 8932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    ll d,s,t;
    cin >> d >> s >> t;
    if(s * t >= d)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
N=int(input())
_t = 0
_x = 0
_y = 0
flag = True
for i in range(N):
    t,x,y = map(int,input().split())
    if abs(x - _x) + abs(y - _y) > t - _t or (t - _t - (x - _x + y - _y))%2 !=0 :
        flag = False
        break
    _t, _x, _y = t, x, y
if flag:
    print("Yes")
else:
    print("No")


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

int main(){
int n,m,temp;
  cin>>n>>m;
  vector<int> cities(n);
  for(int i=0;i<m*2;i++){
    cin>>temp;
    cities.at(temp-1)++;
  }
  for(int i=0;i<n;i++){
    cout<<cities.at(i)<<endl;
  }
}



Measured memory_bytes: 256
#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>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    cout << (a+b-3)/(a-1) << endl;
}

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

int main() {
    string str, acgt = "ACGT";
    int s = 0, t = 0;
    cin >> str;

    for(size_t i = 0; i < str.size(); i++) {
        if(acgt.find(str[i]) == string::npos) {
            t = 0;
        } else {
            t++;
        }
        if(t > s) s = t;
    }
    
    cout << s << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
f = True

for a in A:
  if a%2==0:
    if a%3==0 or a%5==0:
      f = True
    else:
      f = False
      break

if f:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;
struct edge {
  int to, idx;
};
typedef std::vector<std::vector<edge>> graph;

bool dfs(int cur, int target, bitset<49> &set, graph &g,
         vector<bool> &visited) {
  if (cur == target)
    return true;
  if (visited[cur]) {
    return false;
  }
  visited[cur] = true;
  for (const auto u : g[cur]) {
    if (dfs(u.to, target, set, g, visited)) {
      set[u.idx] = true;
      return true;
    }
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  graph g(n);
  REP(i, n - 1) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  int m;
  cin >> m;
  vector<bitset<49>> set(m, bitset<49>());

  REP(i, m) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    vector<bool> visited(n, false);
    dfs(u, v, set[i], g, visited);
  }

  ll comp = 0LL;
  FOR(bit, 1, (1 << m)) {
    int c = __builtin_popcount(bit);
    bitset<49> tmp;
    REP(i, m) {
      if (bit & (1 << i)) {
        tmp |= set[i];
      }
    }
    int size = n - 1 - (int)tmp.count();
    if (c % 2 == 1) {
      comp += (1LL << size);
    } else {
      comp -= (1LL << size);
    }
  }

  cout << (1LL << (n - 1)) - comp << endl;

  return 0;
}


Measured memory_bytes: 384
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    map<int,int> m;
    int pre[n+1];
    pre[0] = 0;
    for(int i=1;i<=n;i++){
    	pre[i] = pre[i-1]+arr[i-1];
    }
    for(int i=1;i<=n;i++)
    	pre[i] = (pre[i]-i+k)%k;
    int ans = 0;
    cerr<<endl;
    for(int i=0;i<=n;i++){
    	if(i-k>=0){
    		m[pre[i-k]]--;
    	}
    	ans+=m[pre[i]];
    	m[pre[i]]++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 15872
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include "bitset"
#include "cmath"
#include "list"
#include "complex"
#include <cassert>
#include "deque"
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
//#define mp make_pair
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vc visit(sze, false);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

int dp[3050][3050];

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

	string s, t;
	cin >> s >> t;

	for (int i = 0; i < s.size(); i++)
	{
		for (int j = 0; j < t.size(); j++)
		{
			if (s[i] == t[j])
			{
				maxi(dp[i + 1][j + 1], dp[i][j] + 1);
			}
			maxi(dp[i + 1][j + 1], dp[i][j + 1]);
			maxi(dp[i + 1][j + 1], dp[i + 1][j]);
		}
	}

	cnt = dp[s.size()][t.size()];
	n = s.size();
	m = t.size();

	string ans = "";
	while (cnt)
	{
		if (dp[n][m] == dp[n - 1][m - 1] + 1 && s[n-1] == t[m-1])
		{
			ans += s[n - 1];
			n--;
			m--;
			cnt--;
		}
		else
		{
			if (dp[n][m] == dp[n - 1][m])
			{
				n--;
			}
			else
			{
				m--;
			}
		}
	}

	reverse(all(ans));
	cout << ans;
	return 0;
}

Measured memory_bytes: 82944