akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Card
{
    public string s;
    public long val;
    public Card(string s, long val)
    {
        this.s = s;
        this.val = val;
    }
}

class Program
{
    static long INF = 1000000001;
    static void Merge(Card[] A, int left, int mid, int right)
    {
        int n1 = mid - left;
        int n2 = right - mid;
        Card[] B = new Card[n1 + 1];
        Card[] C = new Card[n2 + 1];
        for (int i = 0; i < n1; i++) B[i] = A[left + i];
        for (int i = 0; i < n2; i++) C[i] = A[mid + i];
        B[n1] = new Card("H", INF);
        C[n2] = new Card("H", INF);
        int f1 = 0, f2 = 0;
        for (int k = left; k < right; k++)
        {
            if (B[f1].val <= C[f2].val)
            {
                A[k] = B[f1];
                f1++;
            }
            else
            {
                A[k] = C[f2];
                f2++;
            }
        }
    }

    static void MergeSort(Card[] A, int left, int right)
    {
        if (left + 1 < right)
        {
            int mid = (left + right) / 2;
            MergeSort(A, left, mid);
            MergeSort(A, mid, right);
            Merge(A, left, mid, right);
        }
    }

    static int Partition(Card[] A, int p, int r)
    {
        Card x = A[r];
        int i = p - 1;
        Card temp = new Card("H", 0);
        for (int j = p; j < r; j++)
        {
            if (A[j].val <= x.val)
            {
                i++;
                temp = A[i];
                A[i] = A[j];
                A[j] = temp;
            }
        }
        i++;
        temp = A[i];
        A[i] = A[r];
        A[r] = temp;
        return i;
    }

    static void QuickSort(Card[] A, int p, int r)
    {
        if (p < r)
        {
            int q = Partition(A, p, r);
            QuickSort(A, p, q - 1);
            QuickSort(A, q + 1, r);
        }
    }

    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        Card[] A = new Card[n];
        Card[] B = new Card[n];
        for (int i = 0; i < n; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            A[i] = new Card(s[0], long.Parse(s[1]));
            B[i] = new Card(s[0], long.Parse(s[1]));
        }
        MergeSort(A, 0, n);
        QuickSort(B, 0, n - 1);
        bool flag = true;
        for (int i = 0; i < n; i++) flag = flag && (A[i].s == B[i].s && A[i].val == B[i].val);
        Console.WriteLine((flag)? "Stable": "Not stable");
        for (int i = 0; i < n; i++) Console.WriteLine("{0} {1}", B[i].s, B[i].val);
    }
}


Measured memory_bytes: 38124
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
for i in range(len(s) - 1):
    if s[i] == s[i+1]:
        print('Bad')
        quit()
print('Good')

Measured memory_bytes: 65072
import bisect
def find_le_index(a, x):
    i = bisect.bisect_right(a, x)
    if i:
        return i-1
    raise ValueError


def q3():
    n, m, k = [int(i) for i in input().split(" ")]
    A = [int(i) for i in input().split(" ")]
    B = [int(i) for i in input().split(" ")]

    asum = [0]
    s = 0
    for a in A:
        s += a
        asum.append(s)
    bsum = [0]
    s = 0
    for b in B:
        s += b
        bsum.append(s)

    maxbooks = 0
    for i in range(len(asum)):
        if k < asum[i]:
            break
        abooknum = i
        bbooknum = find_le_index(bsum, k - asum[i])
        booknum = abooknum + bbooknum
        if maxbooks < booknum:
            maxbooks = booknum

    print(maxbooks)


q3()


Measured memory_bytes: 47200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int a, b;
  cin >> a >> b;
  for (int i = 1; i <= 1010; i++) {
    if (((int)(0.08 * i)) == a && ((int)(0.10 * i)) == b) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

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

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

int main() {
	int n;
	cin >> n;
	unordered_map<ll, int> cnt;
	ll ans = 0, sum = 0;
	cnt[0] = 1;
	while (n--) {
		int temp;
		cin >> temp;
		sum += temp;
		ans += cnt[sum];
		cnt[sum]++;
	}
	cout << ans << endl; 
	return 0;
}

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

int main(){
	int n;
	int i,j,k;
	int d[15];
	int s=12;
	memset(d,0,sizeof(d));
	cin>>n;
	for(i=0;i<n;i++){
		cin>>k;
		d[k]++;
	}
	int a=0,b=0;
	for(i=0,j=0;i<=12;i++){
		if(d[i]==0)continue;
		if(d[i]>2)s=0;
		else if(d[i]==2){
			if(s>i-b)s=i-b;
			b=i;
			if(s>a+i)s=a+i;
			a=-i;
		}else if(j%2==0){
			if(s>i-b)s=i-b;
			b=i;
		}else{
			if(s>a+i)s=a+i;
			a=-i;
		}
		j++;
	}
	a+=24;
	if(s>a-b)s=a-b;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  int a,b,c,d;cin>>a>>b>>c>>d;
  string s;cin>>s;

  s = '#'+s+'#';
  int m = 0;
  for(int i = a;i+1 <= c;i++){
    if(s[i] == '#' && s[i+1] == '#'){
      print("No");
      return 0;
    }
  }
  for(int i = b;i+1 <= d;++i){
    if(s[i] == '#' && s[i+1] == '#'){
      print("No");
      return 0;
    }
  }

  if(c>d){
    bool ok = false;
    for(int i = b;i <= d;++i){
      if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
        ok = true;
      }
    }
    if(!ok){
      print("No");
      return 0;
    }
  }
  print("Yes");
  return 0;
}

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

int main() {
  int N;
  cin >>N;
  vector<int> card(N);
  for(int i=0;i<N;i++){
    cin >> card.at(i);
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  int Alice=0;
  int Bob=0;
  for(int i=0;i<(N+1)/2;i++){
    Alice+=card.at(2*i);
  }
  for(int i=0;i<N/2;i++){
    Bob+=card.at(2*i+1);
  }
  cout <<Alice-Bob<<endl;
}
 

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



const int N = 4050, M = 2010, S = 2e5+10;
int n, a[S], b[S], dp[N][N], fac[S], ifac[S];
void add(int &a, int b) {a+=b;if (a>=P) a-=P;}
int C(int n, int m) {
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}
int main() {
	fac[0]=1;
	REP(i,1,S-1) fac[i]=(ll)fac[i-1]*i%P;
	ifac[S-1]=inv(fac[S-1]);
	PER(i,0,S-2) ifac[i]=(ll)ifac[i+1]*(i+1)%P;
	scanf("%d", &n);
	REP(i,1,n) scanf("%d%d",a+i,b+i),++dp[-a[i]+M][-b[i]+M];
	REP(i,-M,M) REP(j,-M,M) if (dp[i+M][j+M]) {
		add(dp[i+M+1][j+M],dp[i+M][j+M]);
		add(dp[i+M][j+M+1],dp[i+M][j+M]);
	}
	int ans = 0;
	REP(i,1,n) ans = (ans+dp[a[i]+M][b[i]+M])%P;
	REP(i,1,n) ans = (ans-C(2*a[i]+2*b[i],2*a[i]))%P;
	if (ans<0) ans += P;
	ans = (ll)ans*inv(2)%P;
	printf("%d\n", ans);
}









Measured memory_bytes: 67200
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<stack>

using namespace std;

int main(){
  stack<int> st;
  int n,i,get;

  cin>>n;

  for(i=0;i<n;i++){
    cin>>get;
    st.push(get);
  }

  for(i=0;i<n;i++){
    cout<<st.top();
    st.pop();
    if(i<n-1){
      cout<<" ";
    }
  }

  cout<<endl;

  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
//#pragma GCC optimize(2)

using namespace std;
#define LL long long
#define Rint register int
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define pii pair<int ,int>
#define MS0(X) memset(X,0,sizeof(X))
#define MSf(X) memset(X,false,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define BR printf("--------------------\n")
#define pb push_back
#define rep(i,a,b) for(Rint i=a;i<=b;++i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dirx[8]={1,0,-1,0,1,-1,-1,1};
int diry[8]={0,1,0,-1,1,1,-1,-1};
int n;
int a[maxn];
LL cnt[maxn],sum[maxn],ans[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
        sum[cnt[a[i]]]++;
    }
    for(int i=0;i<=n;i++)
    {
        sum[i]+=sum[i-1];
    }
    int now=0;
    for(int k=n;k>=1;k--)
    {
        while(now<n&&(sum[now+1]>=1ll*k*(now+1)))now++;
        ans[k]=now;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
#pragma GCC optimize ("Ofast")
int main()
{
    start;
    ll n,m,j,i;
    cin>>n; string s;
    ll ac=0,re=0,tle=0,wa=0;
    for(i=0;i<n;i++)
        {cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="RE")
            re++;
        else if(s=="TLE")
            tle++;
        else wa++;
        }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for (llong i = 0; i < times; i++)
#define rloop(i, times) for (llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl << msec << " msec " << endl;
}

#endif


int main(void)
{
	llong a; cin >> a;
	llong b; cin >> b;

	llong ans = 0;

	ans += max(a, b);
	if (a < b)
		b -= 1;
	else
		a -= 1;
	ans += max(a, b);

	cout << ans;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("hard1.txt","r",stdin)
#define OUT freopen("hard1.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 1000005
#define FastIO  ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii ;

#define maxn 1000005
#define mod 1000000007LL
#define lim 1000000000
#define INF 4500000000000000000LL

vector <int> out[805] , in[805] ;
int par[805] , edge[805] ;

void NO(int fl=0)
{
    printf("%d\n",fl) ;
    printf("NO\n") ;
    exit(0) ;
}

vector <int> cur ;
int vis[maxn] ;

void dfs(int u )
{
    vis[u] = 1 ;
    cur.pb(u) ;
    for(int v:out[u])
    {
        if( !vis[v] ) dfs(v) ;
    }
    for(int v : in[u])
    {
        if( !vis[v] ) dfs(v) ;
    }
}
int main()
{
    int n , h ;
    scanf("%d %d",&n,&h) ;

    for(int i=1 ; i<=n ; i++)
    {
        int a , b , c , d ;
        scanf("%d %d %d %d",&a,&b,&c,&d) ;

//        A[i] = a; B[i] = b ; C[i] = c ; D[i] = d ;

        int u , v ;

        if( c==0 ) u = a ;
        else u = h+c ;

        if(d==0) v = h+b ;
        else v = d ;

 //       printf("%d %d\n",u,v) ;

        out[u].pb(v) ; in[v].pb(u) ;
    }
//    backtrack(n) ;
    int fl = 1 ;
    for(int i=1; i<=h ; i++)
    {
        if( out[i].size() < in[i].size() ) fl = 0 ;
        if( out[i+h].size() > in[i+h].size() ) fl = 0 ;
    }

    for(int i=1; i<=2*h ; i++)
    {
        if( (in[i].size() > 0 || out[i].size() > 0) && !vis[i] )
        {
            int ca =0 ,cb = 0 ;
            cur.clear() ;
            dfs(i) ;
            for(int u:cur)
            {
                if( u <= h && out[u].size() > in[u].size() ) ca++ ;
                if( u > h && out[u].size() < in[u].size() ) cb++ ;
            }
            if(ca==0 || cb==0) fl = 0 ;
        }
    }

    if(fl) printf("YES\n") ;
    else printf("NO\n") ;

    return 0 ;
}


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

ll MAX = 1LL << 60;
ll h[100010];
ll dps[100010];

// n番目のジャンプ台まで到達するための最小コストを返す
ll dp(int n) {
  if (n == 0) {
     return 0;
  }
  if (dps[n] < MAX) {
    return dps[n];
  }
  
  ll n1 = dp(n-1) + abs(h[n] - h[n-1]);
  ll n2 = MAX;
  if (n > 1) {
    n2 = dp(n-2) + abs(h[n] - h[n-2]);
  }
  
  dps[n] = min(n1, n2);
  return dps[n];
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  for (int i = 0; i < 100010; i++){
    dps[i] = MAX;
  }
  cout << dp(N-1) << endl;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()





int main(){
  string S, C;
  cin >> S;
  // reverse(all(S));

  int Q, T, F;
  bool f = true;
  cin >> Q;

  rep(i, 0, Q){
    cin >> T;
    if(T == 1){
      f = !f;
    }else{
      cin >> F >> C;
      if(F == 1){
        if(f){
          S.insert(0,C);
        }else{
          S += C;
        }
      }else{
        if(f){
          S += C;
        }else{
          S.insert(0,C);
        }
      }
    }
  }

  if(!f){
    reverse(all(S));
  }

  cout << S << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


void solve(long long X, long long A){
    if (X < A) {
        cout << "0" << endl;
    } else {
        cout << "10" << endl;
    }
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
int power(int a,int n){
	int res=1;
	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}	
	return res;
}
int solve(int i, int j,string &a,string &b,vvi &dp)
{
	if (i == a.size() || j == b.size()) return 0;
	if (~dp[i][j]) return dp[i][j];
	if (a[i] == b[j]) return dp[i][j] = solve(i + 1, j + 1,a,b,dp) + 1;
	return dp[i][j] = max(solve(i + 1, j,a,b,dp), solve(i, j + 1,a,b,dp));
}
 
void build(int i, int j,string &a,string &b,string &ans,vvi &dp)
{
	if (i == a.size() || j == b.size()) return;
	if (a[i] == b[j]) {
		ans += a[i];
		build(i + 1, j + 1,a,b,ans,dp);
	}
	else {
		if (solve(i, j,a,b,dp) == solve(i + 1, j,a,b,dp)) build(i + 1, j,a,b,ans,dp);
		else build(i, j + 1,a,b,ans,dp);
	}
}
void reverse(string str) 
{ 
   for (int i=str.length()-1; i>=0; i--) 
      cout << str[i];  
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    vvi dp(s.size(),vi(t.size(),-1));
    int n=s.size(),m=t.size();
    solve(0,0,s,t,dp);
    int i=n-1,j=m-1;
    string s1="";
    build(0,0,s,t,s1,dp);
    cout<<s1<<endl;
    return 0;
}


Measured memory_bytes: 71168
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int N, X,min,i=0;
	cin >> N >> X;
	vector <int> m(N);
	rep(i, N) {
		cin >> m[i];
		X -= m[i];
	}
	min = *min_element(ALL(m));
	cout << N + (X / min);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
//using ll=long long;

int main(){
    string S, T;
    cin >> S >> T;
    if(S == T){
        cout << "Yes" << endl;
        return 0;
    }
    int len = S.size();
    for(int i = len; i > 0; --i){
        string tmp = S.back() + S.substr(0, len - 1);
        S = tmp;
        if(S == T){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}

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

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

  int P = 0, W = 0, G = 0, Y = 0;
  for(int i = 0; i < N; i++) {
    string x;
    cin >> x;
    if (x == "P")
      P++;
    else if (x == "W")
      W++;
    else if (x == "G")
      G++;
    else if (x == "Y") {
      Y++;
    }
  }
  if (Y > 0) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 3616
import collections

n = int(input())
#a,b = map(int,input().split())
a_L = list(map(int,input().split()))

counter = collections.Counter(a_L)

ans = 0
for k,v in counter.items():
    if k == v:
        continue
    elif k < v:
        ans += v - k
    else:
        ans += v

print(ans)


Measured memory_bytes: 68264
#include <stdio.h>
#include <iostream>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
typedef long long Int;
#define M (1000001)

int pt[M];
void build_pt() {
    for(int i=2; i<M; i++) if(pt[i]==0) {
        for(int j=i+i; j<M; j+=i) pt[j] = i;
    }
}

Int tot[M];
void build_tot() {
    for(int i=2; i<M; i++) {
        tot[i] = i;
        for(int p=i; p>1; ) {
            const int b = pt[p] ? pt[p] : p;
            tot[i] -= tot[i]/b;
            while(p%b==0) p/=b;
        }
    }
}

Int sum[M];

int main() {
    build_pt();
    build_tot();
    sum[1] = 2;
    for(int i=2; i<M; i++) sum[i] = sum[i-1]+tot[i];
    int T;
    scanf("%d", &T);
    while(T--) {
        int n;
        scanf("%d", &n);
        cout << sum[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int A,B,C,D,E,F;

signed main(){
  cin>>A>>B>>C>>D>>E>>F;

  double mx=0;
  int ans_w=100*A,ans_s=0;
  for(int a=0;a*A*100<=F;a++){
    for(int b=0;b*B*100<=F;b++){
      if(a==0&&b==0)break;
      for(int c=0;c*C<=F;c++){
        for(int d=0;d*D<=F;d++){
          if(100*A*a+100*B*b+C*c+D*d>F)  break;
          if((A*a+B*b)*E<C*c+D*d)break;
          if((c*C+d*D)>mx*(A*a+B*b)){
            mx=(double)(c*C+d*D)/(A*a+B*b);
            ans_s=c*C+d*D;
            ans_w=100*A*a+100*B*b;
          }
        }
      }
    }
  }

  cout<<ans_s+ans_w<<" "<<ans_s<<"\n";
  return 0;
}


Measured memory_bytes: 256
require 'pp'

# n件読み込んだ結果を文字列の配列で返却する
def gets_n_s_list
  n = gets.chomp.to_i
  array = []
  n.times do
    array.push(gets.chomp)
  end
  return n, array
end

N, s_list = gets_n_s_list
puts s_list.uniq.size

Measured memory_bytes: 35220
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
	int n;
	cin>>n;
	vector<vector<int> > A(n);//????????????????????????-1?????\???????????????
	//??\???
	REP(i,n){
		int u,k;
		cin>>u>>k;
		A[i]=vector<int>(k,0);
		REP(j,k){
			int l;
			cin>>l;
			A[i][j] = l-1;
		}
	}
	//??¢?´¢
	vector<int> s;//??????????????????????????\???
	vector<int> dis(n,0);//??????????????????????????????
	vector<int> fin(n,0);//???????????????????????????
	int time=0;
	while(find(dis.begin(),dis.end(), 0) != dis.end()){
		int saisyo = find(dis.begin(),dis.end(), 0) -  dis.begin();
		//cout<<saisyo<<endl;
		s.push_back(saisyo);//?????????0???????????????
		while(!s.empty()){
		//REP(ss,3){
			int k = s.back();//??????????????????????????????
			if(dis[k]==0){
				time++;
				dis[k]=time;
				//cout<<"dis "<<k<<" / time "<<time<<endl;
			}
			bool isfinish=true;
			for(int i: A[k]){
				//cout<<"?????????"<<i<<endl;
				bool nai = find(s.begin(),s.end(), i) == s.end();
				if(fin[i]==0 && i!=k && nai){
					s.push_back(i);
					isfinish=false;
					break;
				}
			}
			if(isfinish){
				time++;
				fin[k]=time;
				s.pop_back();
				//cout<<"fin "<<k<<" / time "<<time<<endl;
			}
		}
	}
	REP(i,n){
		cout<<i+1<<" "<<dis[i]<<" "<<fin[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    int n;cin>>n;
    int sum=0;
    rep(i,0,n){
        int a;cin>>a;sum+=a;
    }
    if(!(sum%2))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  string ans = "Yes";

  for (int i = n - 1; i > 0; i--) {
    if (h[i-1] > h[i]) h[i-1]--;
    if (h[i-1] > h[i]) {
      ans = "No";
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;
#define LL long long
#define dprintf printf

int main() {
	LL a[3];
	scanf("%lld %lld %lld", &a[0], &a[1], &a[2]);

	for (int i = 0; i < 3; ++i) {
		if (a[i] % 2 == 0) {
			printf("0\n");
			return 0;
		}
	}
	LL d[3];
	d[0] = a[2] * a[1];
	d[1] = a[0] * a[2];
	d[2] = a[0] * a[1];
	printf("%lld\n", min(d[0], min(d[1], d[2])));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int ans, n, rest, itr;
    const int coin[] = {500, 100, 50, 10, 5, 1};
    while(true){
        cin >> n;
        if(n == 0){
            break;
        }
        else {
            itr = 0;
            ans = 0;
            rest = 1000 - n;
            while(rest > 0){
                if(itr >= 6){
                    break;
                }
                else if(rest - coin[itr] >= 0){
                    ans++;
                    rest -= coin[itr];
                }
                else {
                    itr++;
                }
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3040
N,M=map(int,input().split())
big=10**13
data=[-1*float('inf')]*(N+1)
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b,c=map(int,input().split())
    branch[a]|={(b,c),}
from collections import deque
check=deque()
check.append((1,0,set()))
data[1]=0
while len(check)>0:
    now=check.popleft()
    for b,c in branch[now[0]]:
        if now[1]+c>data[b]:
            if data[b]>big:continue
            if b in now[2]:
                data[b]=float('inf')
                check.append((now[0],float('inf'),now[2]|{now[0],b}))
                check.append((b,float('inf'),now[2]|{now[0],b}))
            else:
                data[b]=now[1]+c
                check.append((b,now[1]+c,now[2]|{now[0],}))
if data[N]>big:print('inf')
else:print(data[N])

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define mod 1000000007
int ans[10005][10005];
int main()
{
  //ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int x, y;
  cin >> x >> y;
  char arr[x][y];
  for(int i =0 ;i<x;i++)
  {
    for(int j = 0; j < y ;j++)
    {
      cin >> arr[i][j];
    }
  }
  ans[0][0]=1;
  for(int i =0 ;i<x;i++)
  {
    for(int j = 0; j < y ;j++)
    {if(arr[i][j]=='#')
      continue;

      if(i)
      {
        ans[i][j]=(ans[i][j]%mod+ans[i-1][j]%mod)%mod;
      }
      if(j)
      {
        ans[i][j]=(ans[i][j]%mod+ans[i][j-1]%mod)%mod;
      }

    }
  }
  cout<<ans[x-1][y-1];


  return 0;
}


Measured memory_bytes: 40576
#!/usr/bin/env python3
import numpy as np
n = int(input()) 
t, a = map(int, input().split())
h = list(map(int, input().split()))
a_t = []
for i in h:
    a_t.append(t - i * 0.006)
print(np.abs(np.asarray(a_t) - a).argmin() + 1)

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

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

int main() {
    string S;

    cin >> S;

    if(S=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

}




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

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    string S;
    cin >> S;
    long long int now=0,ans=0,ten=1;
    vector<int> amari(2019,0);

    for(int i=0;i<S.size();i++){
        now += ten*(S[S.size()-1-i]-'0');
        now %= 2019;
        amari[now]++;
        ten *= 10;
        ten %= 2019;
    }

    COMinit();

    for(int i=0;i<2019;i++){
        ans += COM(amari[i],2);
    }

    ans += amari[0];

    cout << ans << endl;
}

Measured memory_bytes: 15636
#include<iostream>
#include<cstdio>
#include<cstring>
#define abs(a) (a>0?(a):-(a))
using namespace std;
int sums[2][100005],sumt[2][100005],q,lens,lent,ls,rs,lt,rt;
char s[100005],t[100005];
int main(){
    int numas,numbs,numat,numbt;
    scanf("%s%s",s,t);
    lens=strlen(s);
    lent=strlen(t);
    scanf("%d",&q);
    //cout<<s[3];
    for(int i=0;i<lens;i++){sums[0][i+1]=sums[0][i];sums[0][i+1]+=s[i]-'A'+1;}
    for(int i=0;i<lent;i++){sumt[0][i+1]=sumt[0][i];sumt[0][i+1]+=t[i]-'A'+1;}
    for(int i=1;i<=q;i++){
        scanf("%d%d%d%d",&ls,&rs,&lt,&rt);
        numas=sums[0][rs]-sums[0][ls-1];
        numat=sumt[0][rt]-sumt[0][lt-1];
        if((abs(numat-numas))%3!=0) puts("NO");
        else puts("YES");
    }
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	Int x;
	Int xmax = -INF;
	for (Int i = 0; i < N; i++) {
		cin >> x;
		xmax = max(xmax, x);
	}

	Int y;
	Int ymin = INF;
	for (Int i = 0; i < M; i++) {
		cin >> y;
		ymin = min(ymin, y);
	}

	//if (xmax<=ymin) cout << "No War" << "\n";
	//else cout << "War" << "\n";

	if (xmax>=ymin) {
		cout << "War" << "\n";
		return 0;
	}
	else if (ymin>Y) {
		cout << "War" << "\n";
		return 0;
	}
	else if (xmax<=X) {
		cout << "War" << "\n";
		return 0;
	}
	else {
		cout << "No War" << "\n";
		return 0;
	}
}


Measured memory_bytes: 256
def solve_b(c):
    res = "No"
    for a in range(1, 10):
        if c % a == 0 and c // a < 10:
            res = "Yes"
    return res


def main():
    # input
    c = int(input())
    res = solve_b(c)
    print(res)


def test():
    assert solve_b(10) == "Yes"
    assert solve_b(50) == "No"
    assert solve_b(81) == "Yes"


if __name__ == "__main__":
    test()
    main()


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

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

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

    // start
    string s;
    cin >> s;
    rep(i, s.size() - 1)
    {
        if (s[i] == 'A' && s[i + 1] == 'C')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    // end

    return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 1e5+5;
const ll oo = 1e18;
const ll mod = 1e9+7;
const int INF = 1 << 30;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
    
    int n, m;
    cin >> n >> m;
    int a[n];
    int total = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        total += a[i];
    }
    
    sort(a, a + n);
    bool flag = 0;
    int mm = m;
    for (int i = n - 1; i >= 0; i--) {
        if (mm == 0)
            break;
        //cout << a[i] << " " << (1/(4.0*m)) * total << endl;
        if (a[i] < (1/(4.0*m)) * total) flag = 1;
        mm--;
    }
    if (flag == false) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int dp[100005];


int main()
{
    int n;
    cin >> n;
    int arr[n];

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

    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);

    for(i=2;i<n;i++)
    {

        int a = abs(arr[i]-arr[i-1]) + dp[i-1];
        int b = abs(arr[i]-arr[i-2]) + dp[i-2];

        dp[i]=min(a,b);
    }

    cout << dp[n-1] << '\n';
}

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


int main()
{
 char s[200001];  cin>>s;
    int s1=strlen(s);
    int sum=0;
      for(int i=0;i<s1; i++)
      
       sum+=s[i]-'0';
	
	if(sum%9==0){
		cout<<"Yes"<<endl;
	}
	
	else {
	   cout<<"No"<<endl;
	}
	 return 0;

}



Measured memory_bytes: 3748
package main

import (
	"fmt"
	"os"
)

func main() {
	var a int
	var sum int

	for i := 0; i < 3; i++ {
		fmt.Scan(&a)
		if a != 5 && a != 7 {
			fmt.Println("NO")
			os.Exit(0)
		}
		sum += a
	}
	if sum == 17 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    string table[h];
    for(int i = 0; i < h; i++){
        cin >> table[i];
    }
    int h_check[h], w_check[w];
    for(int i = 0; i < h; i++){
        h_check[i] = 0;
    }
    for(int i = 0; i < w; i++){
        w_check[i] = 0;
    }
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if( table[i][j] == '#'){
                h_check[i] = 1;
                w_check[j] = 1;
            }
        }
    }
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(h_check[i] == 1 && w_check[j] == 1){
                cout << table[i][j];
            }
        }
        if(h_check[i]){
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
using namespace std;
//using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX 500003
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=998244353;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a);
        }
        a=(a*a);
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    fast;
    
    int t;
    t=1;
    while(t--)
    {
        int n,k,val;
        vi v;

        cin>>n>>k;

        rep(i,n)
        {
            cin>>val;
            v.pb(val);
        }
        sort(all(v));
        int sum=0;
        rep(i,k) sum+=v[i];
        cout<<sum<<endl;
    }
}


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



int main()
{
	int N,P;
	while(cin >> N >> P, (N||P))
	{
		int n[100]={0}, p=0,cnt=0,np=P;

		while(1)
		{
			if(P==0)
			{
				P=n[p];
				n[p]=0;
			}
			else
			{
				P--;
				n[p]++;
			}

			cnt++;
			
			if(n[p]==np) break;
			p=(cnt%N);

		}

		cout << p << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

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

}

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

// ダイクストラ法を適用し、dを更新する関数
#define MAX 10000
#define INFTY 1<<22
#define WHITE 0
#define GRAY 1
#define BLACK 2

// 重み付き有向グラフの隣接リスト
vector<pair<int,int> > adj[MAX];
int k[2000];

void dijkstra(int n,int start){
    priority_queue<pair<int,int>>pq;
    // weight[v]に始点sからvまでの最短コストを保存する.v,weight
    int weight[MAX];
    // 訪問状態を記録
    int color[MAX];
    // 1.初期化
    for(int i = 1;i <= n;++i){
        weight[i] = INFTY;
        color[i] = WHITE;
    }
    
    // 始点
    weight[start] = 0;
    color[start] = GRAY;
    pq.push(make_pair(0,start));
    // 2
    while(!pq.empty()){
        // 2.1最小である頂点の決定
        pair<int,int> first = pq.top();
        pq.pop();
        // 頂点
        int u = first.second;
        color[u] = BLACK;
        
        // 最短値を取りだして、最短でなければ飛ばす
        if(weight[u] < first.first * -1) continue;
        // uに隣接する頂点vが存在する限り最短店を更新する
        for(int i = 0;i < adj[u].size();++i){
            int v = adj[u][i].first;
            if(color[v] == BLACK)continue;
            // 2.2最短点の更新
            if(weight[v] > weight[u] + adj[u][i].second){
                weight[v] = weight[u] + adj[u][i].second;
                // priority_queueはデフォルトで大きい値を優先するので-にする
                pq.push(make_pair(weight[v] * -1, v));
                color[v] = GRAY;
            }
        }
    }
    
    // 出力
    for(int i = 1;i <= n;++i){
       k[weight[i]]++;
    }
    
}

int main() {
  
int n,x,y;cin >> n >> x >> y;
for (int i = 1; i <= n; ++i)
{
  k[i]=0;
}
adj[x].push_back(make_pair(y,1));
adj[y].push_back(make_pair(x,1));
for (int i = 1; i < n; ++i)
{
  adj[i].push_back(make_pair(i+1,1));
  adj[i+1].push_back(make_pair(i,1));
}

for (int i = 1; i <= n; ++i)
{
  dijkstra(n,i);
}
for(int i = 1;i < n;++i){
       cout << k[i]/2 << "\n";
    }
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int L = scanner.nextInt();

        int absMinTaste = 1000;
        int pieTaste = 0;
        for (int i = 1 ; i <= N ; i++) {
            int taste = L + i - 1;
            pieTaste += taste;
            if (Math.abs(absMinTaste) > Math.abs(taste)) {
                absMinTaste = taste;
            }
        }

        System.out.println(pieTaste - absMinTaste);
    }
}


Measured memory_bytes: 35700
#include <iostream>

#define REP(i, x, n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

using namespace std;

int w[1000007];
int n, k;

bool check(int p){

    ll sum = 0;
    ll idx = 0;
    rep(i,k){
        ll sum = 0;
        while(sum + w[idx] <= p){
            sum += w[idx];
            idx++;
            if(idx == n) return true;
        }
    }
    return  false;
}


int main(){

    cin >> n >> k;
    rep(i,n) cin >> w[i];

    ll r = 100000 * 10000;
    ll l = 0;
    ll mid;
    while(r - l > 1){
       mid = (l+r) / 2;
       if(check(mid)) r = mid;
       else l = mid; 
    }
    
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3460
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

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

    if((a*b)%2 != 0 ){
        cout << "Odd" << endl;
    }else{
          cout << "Even" << endl;
    };
    




    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(N):
    if p[i] == i + 1:
        if i == N - 1:
            tmp = p[i]
            p[i] = p[0]
            p[0] = tmp
            cnt += 1
        else:
            tmp = p[i]
            p[i] = p[i + 1]
            p[i + 1] = tmp
            cnt += 1

print(cnt)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = acos(-1) ;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"


int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0;
	ll c;
	cin>>n>>m>>c;
	int b[m];
	for(ll i=0;i<m;i++)cin>>b[i];
	while(n--)
	{
		ans=c;
		for(ll i=0;i<m;i++){
			cin>>x;
			ans+=x*b[i];
		}
		sum+=ans>0;
		//cout<<ans<<nw;
	}
	cout<<sum;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> odd;
    map<int, int> even;

    int max_odd = 0, max_even = 0;
    int second_odd = 0, second_even = 0;
    int sum_odd = 0, sum_even = 0;
    int odd_v, even_v;
    for(int i = 0; i < n; i++){
        int v;
        cin >> v;
        if(i % 2 == 0){
            odd[v]++;
            if(max_odd < odd[v]){
                max_odd = odd[v];
                odd_v = v;
            }
            else if(second_odd < odd[v]){
                second_odd = odd[v];
            }
            sum_odd++;
        }
        else{
            even[v]++;
            if(max_even < even[v]){
                max_even = even[v];
                even_v = v;
            }
            else if(second_even < even[v]){
                second_even = even[v];
            }
            sum_even++;
        }
    }

    if(odd_v != even_v){
        sum_odd -= max_odd;
        sum_even -= max_even;
        cout << sum_odd + sum_even << endl;
    }
    else{
        int t1 = sum_odd - max_odd + sum_even - second_even;
        int t2 = sum_odd - second_odd + sum_even - max_odd;
        cout << min(t1, t2) << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>
#include<chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 5e5 + 5;

ll fact[maxn];

ll C(ll n, ll k) {
    return mul(fact[n], inv(mul(fact[n - k], fact[k])));
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    fact[0] = 1;
    for (ll i = 1; i < maxn; i++) fact[i] = mul(fact[i - 1], i);

    ll n, m; cin >> n >> m;
    ll ans = 0;
    for (ll x = 0; x <= n; x++) {
        ll kek = 1;
        kek = mul(kek, fact[x]);
        kek = mul(kek, C(m, x));
        kek = mul(kek, C(n, x));
        kek = mul(kek, C(m - x, n - x));
        kek = mul(kek, C(m - x, n - x));
        kek = mul(kek, fact[n - x]);
        kek = mul(kek, fact[n - x]);
        if (x % 2) {
            ans -= kek;
        } else {
            ans += kek;
        }
        ans %= mod;
        if (ans < 0) ans += mod;
    }
    cout << ans << endl;

    return 0;
}

/*

*/

Measured memory_bytes: 7500