akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 200011;

int n, i;
ll x, s;
map<ll, int> M;
ll ans;

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d", &n);
    M[0]++;
    for (i = 1; i <= n; i++) {
        scanf("%lld", &x);
        s += x;
        ans += M[s];
        M[s]++;
    }

    printf("%lld", ans);


    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll INF=1e18+5;

int main(){
  ll N, K;
  cin >> N >> K;
  double p = 1.0/(double)(N);
  double ans = 0.0;
  rep(i,0,N){
    ll s = i+1;
    ll cnt = 0;
    while(s < K){
      s *= 2;
      cnt++;
    }
    ans += p/(double)(pow(2,cnt));
  }
  cout << std::fixed << std::setprecision(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


 

Measured memory_bytes: 3640
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
// #include <fstream>//ifstream/ofstream
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>

#define PRIME_SHORT 10007
#define PRIME 1000000007

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;

int main(void) {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    ui diffx = tx - sx;
    ui diffy = ty - sy;

    char* vert = new char[diffy + 2];
    char* horz = new char[diffx + 2];
    for (size_t i = 0; i < diffy; ++i) vert[i] = 'U';
        vert[diffy] = '\0';
    for (size_t i = 0; i < diffx; ++i) horz[i] = 'R';
        horz[diffx] = '\0';
    cout << vert << horz;
    for (size_t i = 0; i < diffy; ++i) vert[i] = 'D';
        vert[diffy] = '\0';
    for (size_t i = 0; i <= diffx; ++i) horz[i] = 'L';
        horz[diffx+1] = '\0';
    cout << vert << horz;
    for (size_t i = 0; i <= diffy; ++i) vert[i] = 'U';
        vert[diffy+1] = '\0';
    for (size_t i = 0; i <= diffx; ++i) horz[i] = 'R';
        horz[diffx+1] = '\0';
    cout << vert << horz << "DR";
    for (size_t i = 0; i <= diffy; ++i) vert[i] = 'D';
        vert[diffy+1] = '\0';
    for (size_t i = 0; i <= diffx; ++i) horz[i] = 'L';
        horz[diffx+1] = '\0';
    cout << vert << horz << 'U' << endl;

    delete[] vert;
    delete[] horz;

    return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

D = i()
c = l()
C = sorted(c)
rank = [0]*26
ans = [0]*D
for i in range(D):
    s = l()
    ans[i] = s.index(max(s))+1
for i in range(26):
    rank[i] = C.index(c[i])+1
for i in range(26):
    d = D//rank[i]
    for j in range(i,D,d):
        ans[j] = i+1
for i in ans:
    print(i)

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

using namespace std;



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

    if(a == b){
        cout << c << "\n";
    }else if(b == c){
        cout << a << "\n";
    }else{
        cout << b << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n, sum;
  bool flg = false;
  cin >> n;
  vector<ll> t(n+1,0), x(n+1,0), y(n+1,0);
  for (int i = 1; i <= n;i++){
    cin >> t[i] >> x[i] >> y[i];
    sum = t[i] - t[i - 1];
    sum -= abs(x[i - 1] - x[i]) + abs(y[i - 1] - y[i]);
    if(sum<0||sum%2!=0){
      flg = true;
    }
  }
  if(flg){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 5468
import java.util.*;

public class Main {
	static class Tuple {
		int x, y, z, id;
		long value;

		public Tuple(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
			this.id = (x * 1024 + y) * 1024 + z;
			this.value = A[x] + B[y] + C[z];
		}

		public static Tuple build(int x, int y, int z) {
			if (x >= 0 && y >= 0 && z >= 0) {
				return new Tuple(x, y, z);
			}
			return null;
		}
	}

	static int X, Y, Z, K;
	static long[] A, B, C;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		X = sc.nextInt();
		Y = sc.nextInt();
		Z = sc.nextInt();
		K = sc.nextInt();
		A = new long[X];
		for (int i = 0; i < X; i++) {
			A[i] = sc.nextLong();
		}
		B = new long[Y];
		for (int i = 0; i < Y; i++) {
			B[i] = sc.nextLong();
		}
		C = new long[Z];
		for (int i = 0; i < Z; i++) {
			C[i] = sc.nextLong();
		}

		Arrays.sort(A);
		Arrays.sort(B);
		Arrays.sort(C);

		Set<Integer> visited = new HashSet<Integer>();
		PriorityQueue<Tuple> q = new PriorityQueue<Tuple>(Comparator.comparingLong((Tuple t) -> t.value).reversed());
		{
			Tuple t = new Tuple(A.length - 1, B.length - 1, C.length - 1);
			visited.add(t.id);
			q.add(t);
		}
		Tuple[] ts = new Tuple[3];
		for (int i = 0; i < K; i++) {
			Tuple t = q.poll();
			System.out.println(t.value);
			ts[0] = Tuple.build(t.x - 1, t.y, t.z);
			ts[1] = Tuple.build(t.x, t.y - 1, t.z);
			ts[2] = Tuple.build(t.x, t.y, t.z - 1);
			for (Tuple newT : ts) {
				if (newT != null) {
					if (!visited.contains(newT.id)) {
						visited.add(newT.id);
						q.add(newT);
					}
				}
			}
		}
	}
}


Measured memory_bytes: 32164
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0;i<3;++i) if(s[i] == t[i]) ++ans;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
#define pu push_back
#define po pop_back
#define EPS (1e-7)
#define INF (1e9)
#define pi (acos(-1))
#define fast ios::sync_with_stdio(false); cin.tie(0)
//#define pii pair<int,int>
//#define pll pair<ll,ll>
#define vec vector
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> P;
//const int INF = 1001001001;

//gcd & lcm
ll gcd (ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}
ll lcm (ll a, ll b) {
  return a/gcd(a,b)*b;
}

int main(void) {
  int N, Y;
  cin >> N >> Y;
  int x,y;
  for (int x=0; x<=N; x++) {
    for (int y=0; y<=N-x; y++) {
      int z = N - x - y;
      if (x*10000 + y*5000 + z*1000 == Y) {
        cout << x << ' ' << y << ' ' << z << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define s(l) scanf("%lld",&l)
#define ss(lc) scanf("%s",lc)

#define ppp push_back
#define p(x) printf("%lld\n",x)
#define sr string
#define vr vector
/*int ff(int w)
{
    if(w==1){return 1;}
    else if(w==0){return 1;}
    else{return w*ff(w-1);}
}*/
/*int pr(int ww)
{
    int xs=ww/2;
    int sx=1;
    for(int i=2;i<=xs;i++)
    {
        if(ww%i==0){sx=0;break;}

    }
    return sx;
}*/
ll a[200005],b[200005];
using namespace std;
int main()
{
    vr<ll> mn;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
  ll x=0,y,z=0,zz,i,j,k=0,l,m,n,o,p,q,r,ss;
  s(n);
vr<ll>dp(n,0);
for(i=0;i<n;i++)
{
    s(a[i]);
}
dp[1]=abs(a[1]-a[0]);
for(i=2;i<n;i++)
{
    dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);//cout<<dp[i]<<" "<<abs(a[i]-a[i-1])<<dp[i-1]<<abs(a[i]-a[i-2])<<dp[i-2]<<endl;
}
cout<<dp[n-1]<<endl;
}





Measured memory_bytes: 7240
#include<cstdio>

using int64=long long;
using uchar=unsigned char;

constexpr int maxn(3000);

inline int io(){
	static int _;
	return scanf("%d",&_),_;
}

int inv[maxn+1],
	C[maxn+1],
	S[maxn+1][maxn+1];

int main(){
	const int n=io(),p=io();

	const auto inc=[p](auto&x,const auto&y){x+=y;(p<=x)&&(x-=p);};
	const auto pls=[p](const auto&x,const auto&y){return x+y<p?x+y:(x+y-p);};

	inv[1]=1;
	for(int i=2;i!=n;++i)
		inv[i]=(int64)inv[p%i]*(p-p/i)%p;

	C[0]=C[n]=1;
	for(int i=1;i!=n;++i)
		C[i]=(int64)C[i-1]*inv[i]%p*(n-i+1)%p;

	S[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=(S[i][0]=1);j<=i;++j)
			S[i][j]=(S[i-1][j-1]+(int64)S[i-1][j]*(j+1))%p;

	int64 ans=0;
	for(int i=n,pw=1,pw2=2;~i;--i,inc(pw,pw),pw2=(int64)pw2*pw2%p){
		int64 t=0;
		for(int j=0,pw3=1;j<=i;++j,pw3=(int64)pw3*pw%p)
			t+=(int64)pw3*S[i][j]%p;
		(i&1)?(ans-=t%p*pw2%p*C[i]%p):(ans+=t%p*pw2%p*C[i]%p);
	}

	printf("%d",pls(ans%p,p));

	return 0;
}


Measured memory_bytes: 34048
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
// const int k_mod = 1e9 + 7;
const int k_mod = 998244353;

template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	bool is_visited = false;
} node;
typedef struct {
	int to;
	int cost;
	P <int, int> change;
} edge;
double win_ratio( int a, int b ){
	return 1 / ( 1 + pow( 10, ( double )( b - a ) / 400 ));
}
int main( void ){
	string S; cin >> S;
	reverse(S.begin(), S.end());
	pair <int, string> arr[ 4 ] = {pair <int, string>( 5, "maerd" ),
		                           pair <int, string>( 7, "remaerd" ),
		                           pair <int, string>( 5, "esare" ),
		                           pair <int, string>( 6, "resare" )};
	while(S.size() != 0){
		bool can = false;
		rep( i, 0, 4 ){
			if (S.substr(0, arr[i].first) == arr[i].second){
				S = S.substr(arr[i].first);
				can = true;
				break;
			}
		}
		if(!can){
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	string s;
	cin>>s;
	int n = s.size();
	for(int i = 0;i<n;i++)
	{
		if(s[i]=='?')
			s[i]='D';
	}
	cout<<s<<'\n';
}
int main()
{
	int t= 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int>point(N);
  for(int i; i<N; i++){
    cin >> point.at(i);
  }
  
  sort(point.begin(), point.end());
  reverse(point.begin(), point.end());
  
  int a_score=0;
  int b_score=0;
  
  for(int i; i<N; i++){
    if(i%2==0){
      a_score = a_score + point[i];
    } else {
      b_score = b_score + point[i];
    }
  } 
  
  cout << a_score - b_score << endl;
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool chkmax(int &x,int y){return x<y?x=y,true:false;}
bool chkmin(int &x,int y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n;
ll d[45][45][45];
char a[45][45];

ll dp(int L,int R,int x){
	if(L==R) return 1;
	if(d[L][R][x]>-1) return d[L][R][x];
	d[L][R][x]=0;
	for(int i=L;i<x;i++){
		for(int j=x+1;j<=R;j++){
			if(a[i][j]=='0') continue;
			for(int k=i;k<x;k++)
				for(int l=x+1;l<=j;l++)
					d[L][R][x]+=dp(L,k,i)*dp(k+1,l-1,x)*dp(l,R,j);
		}
	}
	return d[L][R][x];
}

int main(){
	n=readint();
	for(int i=1;i<=n+n;i++) scanf("%s",a[i]+1);
	memset(d,-1,sizeof(d));
	ll ans=0;
	for(int i=2;i<=n+n;i++) if(a[1][i]=='1') ans+=dp(2,n+n,i);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 896
import fractions

A, B = map(int,input().split())

for i in range(1, 2000):
        #if fractions.floor(i * 0.08)==A:
        if (i*0.08)//1 == float(A) and (i*0.1)//1 == float(B):
                print(i)
                exit()
print('-1')

Measured memory_bytes: 5688
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int a = scanner.nextInt();
		    int b = scanner.nextInt();
		    int c = scanner.nextInt();
		    int d = scanner.nextInt();
		    
		    if( a * b > c *d ) 
		    {
		    	System.out.println(a * b);
		    }
		    else 
		    {
		    	System.out.println(c * d);
		    }
		    
		    scanner.close(); }
		  }

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

typedef long long ll;

ll gca (ll  a, ll b) {
	ll c = a % b;
	if (c==0) 
		return b;
	else
		return gca (b,c);
}

int main () {
	ll a, b;
	cin >> a >> b;
	ll g = gca (a, b);
	cout << a * b / g << endl;
	return 0;
}

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

ans, best = 0, float('inf')
for i in range(N):
    x = H[i]
    temp = (T - x * 0.006)
    diff = abs(A - temp)
    if best > diff:
        ans = i
        best = diff
print(ans + 1)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int h,w;
    
    for(;;){
        cin >> h >> w;
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 0;i < h;i++){
            if(i % 2 == 0){
            for(int j = 0;j < w;j++){
                if(j % 2 == 0) cout << "#";
                else cout << ".";
            }
            }
            if(i % 2 == 1){
            for(int j = 0;j < w;j++){
                if(j % 2 == 0) cout << ".";
                else cout << "#";
            }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-6;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a,b;
main() {
    file("snakes");
    ios;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b});
    return 0;
}
/**

*/


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


int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin >> l[i];
    }

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

    int ans=0;
    if(n<=2){
      cout << 0 << endl;
      return 0;
    }
    for(int i=0;i<l.size()-2;i++){
        for(int j=i+1;j<l.size()-1;j++){
            for(int k=j+1;k<l.size();k++){
                if(l[i]==l[j] || l[j]==l[k]){
                    continue;
                }
                if(l[i]+l[j]>l[k]){
                    ans ++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
a,b=map(int,input().split())
print(100,100)
ans=[list("#"*100)for _ in range(50)]+[list("."*100)for _ in range(50)]
for i in range(a-1):
  h=(i//50)*2
  w=(i%50)*2
  ans[h][w]="."
for i in range(b-1):
  h=(i//50)*2+51
  w=(i%50)*2
  ans[h][w]="#"
for i in ans:print("".join(i))

Measured memory_bytes: 3064
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = [int(input()) for _ in range(d)]

last = [[0] * d for _ in range(26)]  # 26xd

ans = 0
for i in range(d):
    type = t[i]  # 1~26
    contest = c[type-1]
    satisfy = s[i][type-1]
    ans += satisfy
    last[type-1][i:] = [i+1] * (d-i)

    for j in range(26):
        ans -= c[j] * ((i+1)-last[j][i])
    print(ans)

Measured memory_bytes: 74432
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll max_n = 1e5+5;

int main() {
    // your code goes here
    ll n, h[max_n], dp[max_n];
    cin >> n;
    rep(i,1,n) cin >> h[i];
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    rep(i,3,n) dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)

using namespace std;

int main(void) {	
	string str;
	while (cin >> str) {
		int ans = 0;
		int ans2 = 0;
		REP(i, str.length() - 2) {
			if (str.substr(i, 3) == "JOI")
				ans++;
			else if (str.substr(i, 3) == "IOI")
				ans2++;
		}			   	
		
		cout << ans << endl << ans2 << endl;
		
	}
	
				  
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector <int> p(n);
    vector <int> ps(n);
    int flag = 0;
    for(int i = 0 ; i < n ; i++){
        cin >> p[i];
        ps[i] = p[i];
    }
    sort(ps.begin(),ps.end());

    for(int i = 0 ; i < n ; i++){
        if(ps[i] != p[i]){
            flag++;
        }    
    }

    if(flag <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int size = scan.nextInt(), queries = scan.nextInt();
        RangeMinQuery rmq = new RangeMinQuery(size);
        for(int i = 0; i < queries; i++){
            int c = scan.nextInt(); int x = scan.nextInt(); int y = scan.nextInt();
            if(c == 0) rmq.update(x, y);
            else System.out.println(rmq.rangemin(x, y));
        }
    }
}

class RangeMinQuery{
    int height;
    int tree[];
    RangeMinQuery(int size){
        for(height = 0; 1 << height < size; height++);
        tree = new int[1 << (height + 1)];
        for(int i = 0; i < tree.length; i++) tree[i] = (1 << 31) - 1;
        //System.out.println("height: " + height);
    }

    private int sibling(int i){
        if(i == 0) throw new IllegalArgumentException("RangeMinQuery.sibling(0)");
        return ((i - 1) ^ 1) + 1;
    }

    void update(int i, int x){
        i += (1 << height) - 1;
        tree[i] = x;
        for(; i != 0; i = (i - 1) / 2){
            int min = Math.min(tree[i], tree[sibling(i)]);
            if(min == tree[(i - 1) / 2]) break;
            tree[(i - 1) / 2] = min;
        }
        //dump();
    }

    int rangemin(int from, int to){
        if(!(0 <= from && from <= to && to < (1 << height)))
            throw new IllegalArgumentException("from < to");
        int depth = height, size = (to - from) + 1;
        from += (1 << height) - 1;
        int r = tree[from];
        while(0 < size){
            for(; from % 2 == 1 && 2 << (height - depth) <= size; depth--, from /= 2);
            for(; size < 1 << (height - depth); depth++, from = from * 2 + 1);
            r = Math.min(r, tree[from]);
            from++;
            size -= 1 << (height - depth);
        }
        return r;
    }

    void dump(){
        int subarr[];
        for(int i = 0; i <= height; i++){
            subarr = Arrays.copyOfRange(tree, (1 << i) - 1, (1 << i + 1) - 1);
            System.out.println(Arrays.toString(subarr));
        }
    }
}

Measured memory_bytes: 103464
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;
int main() {
	int n; cin >> n;
	for (int i = 0; i < 3; i++) {
		if (n % 10 == 7) {
			cout << "Yes" << endl;
			return 0;
		}
		n = n / 10;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3600
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    vector<bool> ok(N);
    vector<int> OUTPUT;
    
    for(int i = 0;i<N;i++){
        int removeIndex = -1;
        int cnt = 1;
        for(int j = 0;j<N;j++){
            if(retu.at(j) == cnt && !ok.at(j)){
                removeIndex = j;
            }
            if(!ok.at(j)){
                cnt++;
            }
        }
        if(removeIndex == -1){
            cout << -1 << endl;
            return 0;
        }
        else{
            OUTPUT.push_back(retu.at(removeIndex));
            ok.at(removeIndex) = true;
        }
    }
    reverse(OUTPUT.begin(),OUTPUT.end());
    for(int V : OUTPUT) cout << V << endl;
}

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

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100;
    B *= 100;

    vector<int> water(0);
    for (int i = 0; i * A <= F; i++) {
        for (int j = 0; i * A + j * B <= F; j++) {
            water.push_back(i * A + j * B);
        }
    }

    vector<int> sugar(0);
    for (int i = 0; i * C <= F; i++) {
        for (int j = 0; i * C + j * D <= F; j++) {
            sugar.push_back(i * C + j * D);
        }
    }

    int max_w = 0;
    int max_s = 0;
    for (int w : water) {
        for (int s : sugar) {
            int ws = w + s;
            if (ws == 0 || ws > F || s > w * E / 100) {
                continue;
            }
            if (max_w == 0 || (double) s / ws > (double) max_s / (max_w + max_s)) {
                max_w = w;
                max_s = s;
            }
        }
    }

    printf("%d %d\n", (max_w + max_s), max_s);
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
 
using namespace std;
int main() {
    long long n;
    cin >> n;
    
    vector<string> s(n);
    
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]==s[i+1]){
            ans++;
        }
    }
    cout << n-ans << endl;
    
    
    return 0;
}




Measured memory_bytes: 9596
import copy
import random
import math
d = int(input())
c = list(map(int,input().split()))
s = []
t = [0 for _ in range(d)]
for i in range(d):
  si = list(map(int,input().split()))
  s.append(si)
lastd = [-1 for _ in range(26)]
for i in range(d):
  mx = 0
  mj = 0
  for j in range(26):
    if s[i][j] + (i-lastd[j])*c[j] > mx:
      mx = s[i][j] + (i-lastd[j])*c[j]
      mj = j
  lastd[mj] = i
  t[i] = mj
lastd = [-1 for _ in range(26)]
ans = 0
for i in range(d):
  di = t[i]
  lastd[di-1] = i
  ans += s[i][di-1]
  for j in range(26):
    ans -= (i-lastd[j])*c[j]
mxans = ans
mxt = copy.deepcopy(t)
for time in range(1000000):
  da = random.randint(0, d-1)
  qb = t[da]
  if random.random() < 0.7:
    bord = c[qb]*(0.6)
    qac = []
    cap = qac.append
    for i in range(0,qb):
      if s[da][i] > bord:
        cap(i)
      continue
    for i in range(qb+1,26):
      if s[da][i] > bord:
        cap(i)
      continue
    if len(qac) == 0:
      continue
    qa = random.choice(qac)
  else:
    bord = c[qb]//2
    qac = []
    cap = qac.append 
    for i in range(0,qb):
      if c[i] > bord:
        cap(i)
    for i in range(qb+1,26):
      if c[i] > bord:
        cap(i)
    if len(qac) == 0:
      continue
    qa = random.choice(qac) 
  #print(da,qb,qa,t)
  qb1 = -1
  qa1 = -1
  for i in range(da-1,-1,-1):
    if t[i] == qb:
      qb1 = i
      break
  for i in range(da-1,-1,-1):
    if t[i] == qa:
      qa1 = i
      break
  qb2 = d
  qa2 = d
  for i in range(da+1,d):
    if t[i] == qb:
      qb2 = i
      break
  for i in range(da+1,d):
    if t[i] == qa:
      qa2 = i
      break
  delta = -s[da][qb]+s[da][qa]-c[qb]*(qb2-da)*(da-qb1)+c[qa]*(qa2-da)*(da-qa1)
  if delta > 0:
    t[da] = qa
    ans += delta
    if ans > mxans:
      mxans = ans
      mxt = copy.deepcopy(t)
  else:
    if random.random() < math.exp((delta*time)/1000000):
      t[da] = qa
  #print(mxans)
for ansd in mxt:
  print(ansd+1)

Measured memory_bytes: 84636
n = int(input())
l = []

for i in range(n):
  l.append(list(map(int,input().split())))

dp = [[-1 for _ in range(3)] for _ in range(n+1)]

dp[0][0] = dp[0][1] = dp[0][2] = 0
dp[1][0] = l[0][0] 
dp[1][1] = l[0][1]
dp[1][2] = l[0][2]

for j in range(2,n+1):
  for k in range(3):
    dp[j][k] = max(dp[j-1][(k+1)%3] + l[j-1][k],dp[j-1][(k+2)%3] + l[j-1][k])

print(max(dp[n][0],dp[n][1],dp[n][2]))



Measured memory_bytes: 47396
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << endl; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  
  vector<Pll> a;
  rep(i, n) {
    int x; cin >> x;
    a.emplace_back(x, i);
  }
  sort(all(a));
  drep(i, n-1) chmin(a[i].second, a[i+1].second);

  Vll ans(n);
  ans[0] = a[0].first * n;
  rep(i, n-1) ans[a[i+1].second] += (a[i+1].first - a[i].first) * (n-i-1);

  cout << ans;
  return 0;
}


Measured memory_bytes: 3440
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int dp[110][10010]={}; //[v][w]

int main() {
    int a,p;
    cin>>a>>p;
    int sum=a*3+p;
    cout<<sum/2<<endl;
}



Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10**9 + 7
 
def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return pow(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * pow(n, r-1, mod) % mod
 
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
 
ans = pow(2, n, mod) - 1
ans -=  combination(n, a, mod)
ans -=  combination(n, b, mod)
ans += 3*mod
ans %= mod
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


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

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


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n, m;
    cin >> n >> m;
    cout << n * m << endl;
}



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

using namespace std;

int main() {
	int n, k;
	cin>>n>>k;
	vector<int> arr(n);
	for(int& c: arr) 
		cin>>c;
	sort(arr.begin(), arr.end());
	int ans = 0;
	for(int i = 0; i < k; i++) {
		ans += arr[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<int,int> P;


int main(){
  string s;
  cin >> s;
  string s2="CODEFESTIVAL2016";
  int ans=0;
  for(int i=0;i<16;i++){
    if(s[i] != s2[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, k, q; cin >> n >> k >> q;
    vector<int> a(n, k - q);
    for (int i = 0; i < q; i++) {
        int x; cin >> x;
        x--;
        a[x]++;
    }
    for (int i = 0; i < n; i++) {
        cout << (a[i] <= 0 ? "No" : "Yes") << "\n";
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll p[N] , a[N] ;
vector<ll> k [N] ;
ll f(ll v) {
	if (p[v] == v) return v ;
	return p[v] = f(p[v]) ;
}
void m(ll v , ll u) {
	v = f(v) ;
	u = f(u) ;
	if (v == u) return ;
	p[v] = u ;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n , q; 
    cin >> n >> q ;
    for (int i = 1 ; i <= n ; i ++) cin >> a[i] ;
    for (int i = 1 ; i <= n ;  i++) p[i] = i ;
    for (; q ; q --) {

    	ll v , u ;
    	cin >> v >> u ;
    	m(v , u) ;
    	
	}
	for (int i = 1 ; i <= n ; i ++) {
		k[f(i)].pb(i) ;
	}
    ll ans  = 0 ;
    for (int i = 1 ; i <= n ; i ++) {
    	set<ll> s1 , s2 ;
    	for (auto u : k[i]) s1.insert(u) , s2.insert(a[u]) ;
    	for (auto u  : s1) {
    		if (s2.find(u) != s2.end()) ans ++ ;
		}
	}
	cout << ans ;
    
    return (0) ;
}

Measured memory_bytes: 17396
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
const int MAX = 500050;
typedef pair<int, int>P;
struct P2 {
	int x1, x2, y1, y2;
};
bool operator==(const P2& p1, const P2& p2) {
	if (p1.x1 == p2.x1 && p1.y1 == p2.y1 && p1.x2 == p2.x2 && p1.y2 == p2.y2) {
		return true;
	}
	else return false;
}

int R, C, N;
vector<P>v;

bool safe(int x,int y) {
	if (0 < x && x < R) {
		if (0 < y && y < C) {
			return true;
		}
	}
	return false;
}

signed main() {
	cin >> R >> C >> N;
	REP(i, N) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if (!safe(x1, y1) && !safe(x2, y2)) {
			int res1;
			if (x1 == 0) {
				res1 = 2 * R + 2 * C - y1;
			}
			else if (y1 == C) {
				res1 = 2 * R + C - x1;
			}
			else {
				res1 = x1 + y1;
			}

			int res2;
			if (x2 == 0) {
				res2 = 2 * R + 2 * C - y2;
			}
			else if (y2 == C) {
				res2 = 2 * R + C - x2;
			}
			else {
				res2 = x2 + y2;
			}
			v.pb(P(res1, i));
			v.pb(P(res2, i));
			//pe(i)pe(res1)print(res2);
		}
	}
	if (v.size() == 0) {
		print("YES"); return 0;
	}
	VSORT(v);
	stack<int>stk;
	
	stk.push(v[0].second);
	FOR(i,1, v.size()) {
		if (stk.empty()) {
			stk.push(v[i].second);
		}
		else if (v[i].second == stk.top())stk.pop();
		else {
			stk.push(v[i].second);
		}
	}
	if (stk.empty())print("YES") else print("NO");
}


Measured memory_bytes: 6384
import java.util.Scanner;
 
public class Main {
	static final long MOD = 1_000_000_007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		
		boolean[] broken = new boolean[n + 1];
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			broken[a] = true;
		}
		
		long[] dp = new long[n + 1];
		dp[0] = 1;
		dp[1] = broken[1] ? 0 : 1;
		for (int i = 2 ; i < dp.length; i++) {
			dp[i] = broken[i] ? 0 : (dp[i - 2] + dp[i - 1]) % MOD;
		}
		
//		System.out.println(Arrays.toString(dp));
		
		System.out.println(dp[n]);
		
		sc.close();
	}
}



Measured memory_bytes: 48664
var lines: string[] = [];
var reader: any = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on("line", function(line: string) {
  lines.push(line);
});
reader.on("close", function() {
  var valueN: number = Number(lines[0].split(" ")[0]);
  var valueM: number = Number(lines[0].split(" ")[1]);
  var valueX: number = Number(lines[0].split(" ")[2]);
  var listA: number[] = lines[1]
    .split(" ")
    .map(function(value: string): number {
      return Number(value);
    });

  var counterA: number = 0;
  var costList: number[] = new Array<number>(valueN + 1).fill(0);
  for (var idx in listA) {
    costList[listA[idx]] = 1;
  }

  var sumPrime = costList
    .slice(0, valueX)
    .reduce(function(accumulator, currentValue): number {
      return accumulator + currentValue;
    }, 0);
  var sumSecond = costList
    .slice(valueX, valueN + 1)
    .reduce(function(accumulator, currentValue): number {
      return accumulator + currentValue;
    }, 0);
  if (sumPrime > sumSecond) {
    console.log(sumSecond);
  } else {
    console.log(sumPrime);
  }
});


Measured memory_bytes: 7628
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int n;
	cin >> n;
        if(n <= 999) cout << "ABC" << endl;
        else cout << "ABD" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using lint = long long;

void solve() {
    lint x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    --x1, --y1, --x2, --y2;

    lint ans = std::abs(x2 - x1) + std::abs(y2 - y1);
    lint three = 1;

    for (int i = 0; i < 30; ++i) {
        for (int j = 0; j < 2; ++j) {
            std::swap(x1, y1);
            std::swap(x2, y2);

            if (x1 / three != x2 / three ||
                (x1 / three) % 3 != 1 ||
                std::abs(y1 / three - y2 / three) <= 1) continue;

            lint d1 = x1 % three, d2 = x2 % three;
            lint d = std::min(d1 + d2 + 2, three - d1 + three - d2);
            ans = std::max(ans, d + std::abs(y2 - y1));
        }
        three *= 3;
    }

    std::cout << ans << std::endl;
}

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

    int q;
    std::cin >> q;
    while (q--) solve();

    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    string s; cin >> s;
    
    if (s.back() == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    return 0;
}

Measured memory_bytes: 3680
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	ans := 0
	if x == 1 {
		ans += 300000
	} else if x == 2 {
		ans += 200000
	} else if x == 3 {
		ans += 100000
	}
	if y == 1 {
		ans += 300000
	} else if y == 2 {
		ans += 200000
	} else if y == 3 {
		ans += 100000
	}
	if x == 1 && y == 1 {
		ans += 400000
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[0] - h[1])

for i in range(2, n):
    dp[i] = min(abs(h[i-1] - h[i]) + dp[i-1], abs(h[i-2] - h[i]) + dp[i-2])

print(dp[n-1])

Measured memory_bytes: 52208
from collections import defaultdict, Counter
N, M = map(int, input().split())
C = Counter(map(int, input().split()))
D = [0]*M
E = [0]*M
for k, v in C.items():
    D[k%M] += v
    E[k%M] += v//2

ans = D[0] // 2

for i in range(1, M):
    j = M - i
    if i < j:
        if D[i] < D[j]:
            i,j = j,i
        ans += D[j]
        ans += min((D[i]-D[j])//2, E[i])
#        x = min(D[i], D[j])
#        y = min((D[i] - x)//2, E[i]) + min((D[j] - x)//2, E[j])
        #ans += x + y
    elif i == j:
        ans += D[i] //2
    else:
        break

print(ans)

Measured memory_bytes: 22636
N, K = [int(_) for _ in input().split()]
cnt = []
for i in range(1, N+2):
    mini = (i - 1) * i // 2
    maxi = (N - i + 1 + N) * i // 2
    cnt.append((maxi - mini + 1))
print(sum(cnt[K-1:]) % (10**9 + 7))


Measured memory_bytes: 21200
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b /2 << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b;
    cin >> a >> b;
    
    if(a < b) {
        for(int i=0; i<b; i++) {
            cout << a;
        }
        cout << endl;
    }
    else {
        for(int i=0; i<a; i++) {
            cout << b;
        }
        cout << endl;

    }
    

    return 0;
}


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

#define MAX 1000
#define MD 1000000007

using namespace std;

typedef long long ll;


int main(){
  ll ans=1;
  int n; cin >> n;
  vector<int> pn;
  for(int i=2;i<=n;i++){
    bool flag=1;
    for(int j=2;j*j<=i;j++){
      if(i%j == 0){
        flag=0;
        break;
      }
    }
    if(flag) pn.push_back(i);
  }
  //for(int i=0;i<pn.size();i++) cout << pn[i] << endl;
  ll cnt[pn.size()];
  for(int i=0;i<pn.size();i++) cnt[i]=0;
  for(int i=2;i<=n;i++){
    int x=i;
    int j=0;
    while(j<pn.size() && x>=2){
      if(x%pn[j] == 0){
        cnt[j]++;
        x=x/pn[j];
      }else{
        j++;
      }
    }
  }
  for(int i=0;i<pn.size();i++){
    //cout << cnt[i] << " ";
    ans=(ans*(cnt[i]+1))%MD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    char a[200001];
    char b[200001];
    int i, j, count=0;

    (void)scanf("%s %s", a, b);

    j = (int)strlen(a);

    for(i=0; i<j; i++){
        if(a[i] != b[i]){
            count++;
        }
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 2100
using System;
using System.Linq;
using System.Text;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int h = arr[0];
    int w = arr[1];
    var sb = new StringBuilder();
    var s = new string('#', w + 2);
    sb.AppendLine(s);
    while (h-- > 0) {
      sb.Append("#");
      sb.Append(Console.ReadLine());
      sb.AppendLine("#");
    }
    sb.AppendLine(s);
    Console.Write(sb);
  }
}

Measured memory_bytes: 13268
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e6+10;
int n,cnt[N],sum[N],tmp=2,ans;
char a[N];
int main() {
	scanf("%d",&n); n--;scanf("%s",a);
	for(int i=0;i<=n;i++) {
		a[i]-='1';
		if(a[i]==1) tmp=1;
	}
	for(int i=1;i<=n;i++) 
		sum[i]=sum[i-1]+(cnt[i]=(i&1?0:cnt[i>>1]+1));
	for(int i=0;i<=n;i++)
		if(sum[n]==sum[i]+sum[n-i])
			(ans+=a[i]/tmp)&=1;
	printf("%d\n",ans*tmp); return 0;
}



Measured memory_bytes: 8960
#include <iostream>
#include <algorithm>

using namespace std;

using ll =  long long;

int main() {
    ll n, u, v;
    cin >> n;
    ll ans = (n * (n+1) * (2*n+1) / 6 + n * (n+1) / 2) / 2;
    for(int i=0;i<n-1;++i) {
        cin >> u >> v;
        ans -= min(u, v) * (n - max(u, v) + 1);
    }
    cout << ans << endl;
}

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

signed main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> d;
  rep(i,n){
    auto p=lower_bound(d.rbegin(),d.rend(),a[i]);
    if(p==d.rbegin()){
      d.push_back(a[i]);
    } else{
      p--;
      *p= a[i];
    }
  }
  int ans=d.size();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168