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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nmk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (n, m, k) = (nmk[0], nmk[1], nmk[2]);
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var seqB = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var sumB = new long[seqB.Length + 1];
        for (int i = 1; i < sumB.Length; ++i)
        {
            sumB[i] = sumB[i - 1] + seqB[i - 1];
        }

        var max = BinarySearch(0, sumB.Length, x => sumB[x] <= k);
        var t = 0L;
        for (int i = 0; i < seqA.Length; ++i)
        {
            t += seqA[i];
            if (t > k)
            {
                break;
            }

            var readable = i + 1 + BinarySearch(0, sumB.Length, x => t + sumB[x] <= k);
            max = Math.Max(max, readable);
        }

        Console.WriteLine(max);
    }

    private static int BinarySearch(int ok, int ng, Func<int, bool> predicate)
    {
        while (Math.Abs(ng - ok) > 1)
        {
            var mid = (ng - ok) / 2 + ok;
            if (predicate(mid))
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        return ok;
    }
}


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

int main() {
	// your code goes here
	int tc=1;
	//cin>>tc;
	while(tc--)
	{
		int n;
		cin>>n;
		int h[n];
		for(int i=0;i<n;i++)
			cin>>h[i];
		long long cnt=0;
		for(int i=1;i<n;i++)
		{
			if(h[i]<h[i-1])
			{
				cnt+=h[i-1]-h[i];
				h[i]=h[i-1];
			}
		}
		cout<<cnt;
	}
	return 0;
}

Measured memory_bytes: 4416
n=int(input())
S=[int(i) for i in input().split()]

q=int(input())
T=[int(i) for i in input().split()]

count=0

for i in range(q):
    left=0
    right=n
    while left <= right:
        center=int((left+right)/2)
        if S[center] > T[i]:
            right=center-1
        elif S[center] < T[i]:
            left=center+1
        elif S[center]==T[i]:
            count+=1
            break

print(count)


Measured memory_bytes: 16896
n = int(input())

p = [0 for i in range(n+1)]
for i in range(n):
    p[i],p[i+1] = map(int,input().split())
    
m = [[0 for i in range(n)] for j in range(n)]

for l in range(1,n):
    for i in range(0,n-l):
        j = i + l
        m[i][j]= float("inf")
        for k in range(i,j):
            m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i]*p[k+1]*p[j+1])


print(m[0][n-1])

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

int main(){
  int n;

  while(1) {
  cin >> n;
  if(n == 0) break;
  vector <int> v,lo;

  string str[10];
  v.resize(n);
  lo.resize(n);
  for(int i=0;i<n;i++) v[i] = lo[i] = 0;
  
  int a;
  for(int i=0;i<n;i++) {
    cin >> str[i];
    for(int j=0;j<n-1;j++) {
      cin >> a;
      if(a ==0) v[i]++;
      else if(a == 1) lo[i]++;
      
    }
  }
  
  string t;

  for(int i=0;i<n-1;i++) {
    for(int j=n-1;j>i;j--) {
      if(v[j] > v[j-1]) {
	t = str[j];
	str[j] = str[j-1];
	str[j-1]  = t;
	
	a = v[j];
	v[j] = v[j-1];
	v[j-1] = a;
	
	a = lo[j];
	lo[j] = lo[j-1];
	lo[j-1] = a;
	
      } else if(v[j] == v[j-1] && lo[j] < lo[j-1]) {
	t = str[j];
	str[j] = str[j-1];
	str[j-1] = t;

	a = lo[j];
	lo[j] = lo[j-1];
	lo[j-1] = a;
      }
    }
  }
      for(int i=0;i<n;i++) cout << str[i] << endl;

  } 


  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main()
{
    int x, y;
    cin >> x >> y;
    rep(i, 100)
    {
        rep(j, 100)
        {
            if (2 * i + 4 * j == y && i + j == x)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;

/**
 * Fenwick Tree 
 *
 * 0-indexed
 */
template <int N>
struct FenwickTree {
    using D = ll; /// ????´???????
    D seg[N+1];
    
    /// ????´???????????????????
    void init() {
        for (int i = 0; i <= N; i++) {
            seg[i] = 0;
        }
    }

    /// i?????????????´????x???????????????
    void add(int i, D x) {
        i++;
        while (i <= N) {
            seg[i] += x;
            i += i & -i;
        }
    }

    /// [0, i)???sum
    D sum(int i) {
        D s = 0;
        while (i > 0) {
            s += seg[i];
            i -= i & -i;
        }
        return s;
    }

    /// [a, b)???sum
    D sum(int a, int b) {
        return sum(b) - sum(a);
    }
};

using P = pair<ll, ll>;
const int MN = 100100;
P p[MN];
FenwickTree<MN> fw;

int main() {
    fw.init();
    int n;
    cin >> n;
    ll sm = 0;
    p[0] = P(0, 0);
    for (int i = 1; i <= n; i++) {
        int d;
        cin >> d;
        sm += d;
        if (sm <= 0) {
            cout << -1 << endl;
            return 0;
        }
        p[i] = P(sm, i);
    }
    sort(p, p+n+1, [&](const P &l, const P &r){
        return l.first < r.first;
    });
    // for (int i = 0; i <= n; i++) {
    //     printf("%d %lld %lld\n", i, p[i].first, p[i].second);
    // }
    ll u = 0;
    for (int i = 1; i <= n; i++) {
        int l;
        cin >> l;
        ll re = p[i].first - p[i-1].first;
        if (re < l) {
            cout << -1 << endl;
            return 0;
        }
        u += fw.sum(p[i].second, MN);
        fw.add(p[i].second, 1);
    }
    cout << u << endl;
    return 0;
}

Measured memory_bytes: 5444
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
int main()
{
	FAST
	#ifdef ayk_16
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	string s;
	cin>>s;
	ll n=s.length();
	n/=2;
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		if(s[i]!=s[s.length()-i-1])
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CINS(int, a, N);

    int ave = 0;
    for (int i = 0; i < N; i++) {
        ave += a[i];
    }
    ave /= N;

    int cost1 = 0, cost2 = 0;

    for (int i = 0; i < N; i++) {
        cost1 += (a[i] - ave) * (a[i] - ave);
        cost2 += (a[i] - ave - 1) * (a[i] - ave - 1);
    }

    cout << min(cost1,cost2) << "\n";

    return 0;
}

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

using namespace std;

int main()
{
    string st;



    cin >> st;

    if(st[2]==st[3] && st[4]==st[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3552
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------

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

const long double EPS = 1e-12;
const int INF = 10000;


int main(){
	int N,Q,M;
	int cnt[101];
	while(cin>>N>>Q){
		if(N==0&&Q==0)break;
		CLR(cnt);
		REP(i,N){
			cin>>M;
			REP(j,M){
				int temp;cin>>temp;
				cnt[temp]++;
			}
		}
		int ma=0,date=0;
		REP(i,101){
			if(cnt[i]>ma){
				ma=cnt[i];
				date=i;
			}
		}
		if(ma<Q)cout<<0<<endl;
		else cout<<date<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
    }


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, count;
    for(;;out.println(count)){
      n = sc.nextInt(); if(n == 0)break;
      for(count = 0;n != 1;count++){
        if(n % 2 == 0)n /= 2;
        else n = n * 3 + 1;
      }
    }
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 26072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

ll l(ll a) {return pow(a, 5);};

ll r(ll b, ll x) {return pow(b, 5) + x;};

map<vll, bool> mp;
void solve(ll a, ll b, ll x) {
	mp[{a, b}] = true;
	queue<vll> task;
	task.push({a, b});
	while (task.size()) {
		ll sz = task.size();
		while (sz--) {
			vll v = task.front();
			task.pop();
			if (l(v[0]) == r(v[1], x)) {
				cout << v[0] << " " << v[1] << endl;
				return;
			}
			else if (l(v[0]) < r(v[1], x)) {
				if (!mp[{v[0] + 1, v[1]}]) {
					task.push({v[0] + 1, v[1]});
					mp[{v[0] + 1, v[1]}] = true;
				}
				if (!mp[{v[0], v[1] - 1}]) {
					task.push({v[0], v[1] - 1});
					mp[{v[0], v[1] - 1}] = true;
				}
			}
			else {
				if (!mp[{v[0] - 1, v[1]}]) {
					task.push({v[0] - 1, v[1]});
					mp[{v[0] - 1, v[1]}] = true;
				}
				if (!mp[{v[0], v[1] + 1}]) {
					task.push({v[0], v[1] + 1});
					mp[{v[0], v[1] + 1}] = true;
				}
			}
		}
	}
}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll x;
	cin >> x;
	ll a = 0, b = 0;
	solve(a, b, x);
}

Measured memory_bytes: 4392
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n,fixedcost;
int x[MAXN];
ll xsum[MAXN+1];

ll safemlt(ll a,ll b) { assert(a>=0&&b>=0); if(b==0) return 0; if(a>LLONG_MAX/b) return LLONG_MAX; return a*b; }
ll safeadd(ll a,ll b) { assert(a>=0&&b>=0); if(a>=LLONG_MAX-b) return LLONG_MAX; return a+b; }


void run() {
	scanf("%d%d",&n,&fixedcost); REP(i,n) scanf("%d",&x[i]);
	xsum[0]=0; REP(i,n) xsum[i+1]=xsum[i]+x[i];

	ll ret=LLONG_MAX;
	FORE(i,1,n) {
		ll cur=(ll)(n+i)*fixedcost;
		int lim=(n+i-1)/i;
		REP(j,lim) {
			int a=j*i,b=min(n,(j+1)*i);
			ll now=safemlt(j==0?5:2*j+3,xsum[n-a]-xsum[n-b]);
			cur=safeadd(cur,now);
		}
		/*REP(j,n) {
			int t=j/i+1;
			cur+=(ll)(t==1?5:(ll)2*t+1)*x[n-j-1];
		}*/
		//printf("%d: %lld\n",i,cur);
		ret=min(ret,cur);
	}
	printf("%lld\n",ret);
}

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


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int gcd(int a, int b) {
    if(a < b) swap(a, b);
    if(a%b == 0) return b;
    else return gcd(b, a%b);
}

int main(void)
{
    int k;
    cin >> k;

    int sum = 0;

    for(int i = 1; i <= k; i++) {
        for(int j = 1; j <= k; j++) {
            for(int l = 1; l <= k; l++) {
                int tmp = gcd(i,j);
                sum += gcd(tmp, l);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    if(n==2){
        if(m){
            cout<<-1<<endl;
            return 0;
        }
        cout<<1<<endl<<1<<" "<<2<<endl;
        return 0;
    }else if(n==3){
        if(m==0){
            cout<<3<<endl<<1<<" "<<2<<endl<<2<<" "<<3<<endl<<3<<" "<<1<<endl;
        }else if(m==1){
            cout<<2<<endl<<1<<" "<<2<<endl<<2<<" "<<3<<endl;
        }else{
            cout<<-1<<endl;
        }
        return 0;
    }
    vp ans;
    REP(i,n-1){
        ans.pb({1,i+2});
    }
    int k=(n-1)*(n-2)/2;
    if(k<m){
        cout<<-1<<endl;
        return 0;
    }
    REP(i,n-1){
        REP(j,i){
            ans.pb({i+2,j+2});
            k--;
            if(k==m){
                break;
            }
        }
        if(k==m){
            break;
        }
    }
    if(k>m){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans.size()<<endl;
    REP(i,ans.size()){
        cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#define MX 35
#define MOD 1'000'000'007
#define set(N,pos) (N = (1LL<<(pos)))
#define clear(N,pos) (N = (~(1LL<<(pos))))
#define is_set(N,pos) (N & (1LL<<(pos)))
#define all(v) (v).begin(),(v).end()

ll bigMod(ll base, ll pw)
{
    ll ret = 1, mul = base;
    while(pw)
    {
        if(pw&1)
            ret = (ret*mul)%MOD;
        mul = (mul*mul)%MOD;
        pw >>= 1;
    }
    return ret;
}

vi prime;
vector<bool> mark(MX,0);
void sieve()
{
    int limit = sqrt(MX+1);
    prime.push_back(2);
    for(int i=3; i<MX; i+=2)
    {
        if(!mark[i])
        {
            prime.push_back(i);
            if(i < limit)
            {
                for(int j=i*i; j<MX; j+=2*i)
                    mark[j] = 1;
            }
        }
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
    #endif // ONLINE_JUDGE

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

	int a, b, c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b << endl;

    return 0;
}

















Measured memory_bytes: 256
N ,A, B, C, D = map(int, input().split())

rock = "#"
S = list()
three_empty = []
two_rocks = []
rock_cnt, empty_cnt = 0, 0

# 通れない２連続岩の場所とABが交差できる３emptyの場所取得
left, right = min(A, B), max(C, D)
for i, s in enumerate(input().strip()[left-1:right], start=left):
  is_rock = s == rock
  if is_rock:
    if empty_cnt >= 3:
      three_empty.append((i - 1, empty_cnt))
    rock_cnt += 1
    empty_cnt = 0
  else:
    if rock_cnt >= 2:
      two_rocks.append(i - 1)
    rock_cnt = 0
    empty_cnt += 1
if rock_cnt >= 2:
  two_rocks.append(i)
if empty_cnt >= 3:
  three_empty.append((i, empty_cnt))

flag = True
left = A if A < B else B
right = B if A > B else A
left_rock = left
right_rock = 200001


for i in two_rocks:
  # 目標の間に岩があるか確認
  if A > i > C or B > i > D or A < i < C or B < i < D:
    flag = False
    break
  # 左と右にいる人から一番近い岩の位置
  if right_rock == 200001 and right < i:
    right_rock = i

if not flag:
  # 目標との間に2岩があるとき
  print("No")
elif (A > B and C > D) or (A < B and C < D):
  # 木彫との間に2岩がなく、交差が発生しない場合。
  print("Yes")
elif not three_empty:
  # 交差点となる3emptyがない場合
  print("No")
else:
  # 双方の一番近い岩との間に3emptyがあるかどうか 
  flag = False
  left = max(A, B)
  right = min(C, D)
  for i, e_cnt in three_empty:
    if left < i - e_cnt + 1 < right or (left < i < right):
      flag = True
      break
  if flag:
    print("Yes")
  else:
    print("No")



Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <queue>
#include <map>
using namespace std;
#define pb          emplace_back
#define fi          first
#define se          second
#define show(...)   fprintf(stderr, __VA_ARGS__ )
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i<(n); ++i)
#define inside(x,y,w,h) ((x)>=0 && (y)>=0 && (x)<(w) && (y)<(h))
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
constexpr int       INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};


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

    int a, b;
    cin >> a>> b;

    outl( a <= 8 && b <= 8 ? "Yay!" : ":(" );
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    long long ans; cin >> ans;
    for (int i = 1; i < n; i++) {
        long long x; cin >> x;
        ans = ans / __gcd(ans, x) * x;
    }
    cout << ans;
    return 0;
}


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

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e6 + 1;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}

int found[mxN];
int a[mxN];

int main() {
	fast();
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		found[a[i]]++;
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		bool success = true;
		if (found[a[i]] > 1) continue;
		if (a[i] > 1 && found[1] > 0) continue;
		for (int j = 2; j*j <= a[i]; ++j)
		{
			if (a[i] % j == 0) {
				if (found[j] || found[a[i]/j]) {
					success= false;
					break;
				}
			}
		}
		if (success) {
			++ans;
		}
	}
	cout << ans << nl;
}


Measured memory_bytes: 8232
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
long long int h,w;
vector<vector<char>> grid;
vector<vector<long long int>> dist;
queue<pair<long long int,long long int>> hoge;
long long int saiki(long long int high){
  if(hoge.empty()){
    return high;
  }
  pair<long long int,long long int> huga=hoge.front();
  hoge.pop();
  high=max(high,dist.at(huga.first).at(huga.second));
  //cout<<huga.first<<" "<<huga.second<<" "<<high<<endl;
  if(huga.first!=0&&grid.at(huga.first-1).at(huga.second)=='.'&&dist.at(huga.first-1).at(huga.second)==-1){
    hoge.push(make_pair(huga.first-1,huga.second));
    dist.at(huga.first-1).at(huga.second)=dist.at(huga.first).at(huga.second)+1;
  }
  if(huga.first!=h-1&&grid.at(huga.first+1).at(huga.second)=='.'&&dist.at(huga.first+1).at(huga.second)==-1){
    hoge.push(make_pair(huga.first+1,huga.second));
    dist.at(huga.first+1).at(huga.second)=dist.at(huga.first).at(huga.second)+1;
  }
  if(huga.second!=0&&grid.at(huga.first).at(huga.second-1)=='.'&&dist.at(huga.first).at(huga.second-1)==-1){
    hoge.push(make_pair(huga.first,huga.second-1));
    dist.at(huga.first).at(huga.second-1)=dist.at(huga.first).at(huga.second)+1;
  }
  if(huga.second!=w-1&&grid.at(huga.first).at(huga.second+1)=='.'&&dist.at(huga.first).at(huga.second+1)==-1){
    hoge.push(make_pair(huga.first,huga.second+1));
    dist.at(huga.first).at(huga.second+1)=dist.at(huga.first).at(huga.second)+1;
  }
  return saiki(high);
}
int main(void){
  cin>>h>>w;
  grid=vector<vector<char>>(h,vector<char>(w));
  dist=vector<vector<long long int>>(h,vector<long long int>(w,-1));
  for(long long int i=0; i<h; i++){
    for(long long int j=0; j<w; j++){
      cin>>grid.at(i).at(j);
    }
  }

  long long int ans=0;
  for(long long int i=0; i<h; i++){
    for(long long int j=0; j<w; j++){
      if(grid.at(i).at(j)=='#') continue;
      hoge.push(make_pair(i,j));
      dist=vector<vector<long long int>>(h,vector<long long int>(w,-1));
      dist.at(i).at(j)=0;
      ans=max(ans,saiki(0));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x,y;
  x=0;
  y=0;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(),vec.end());
  
    for (int j=0; j<N/2; j++){
      x += vec.at(j*2);
      y += vec.at(1+j*2);
    }
    if (N%2 == 0){
      x += 0;
    }
    else{
      x += vec.at(N-1);
    }
  cout << x-y << endl;
}
    

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

int main() {
    int L, R, result = 2019;
    cin >> L >> R;
    for (int x = L; x < min(R, L + 2018); x++) {
        for (int y = x + 1; y <= min(R, x + 2018); y++) {
            int tmp = ((x % 2019) * (y % 2019)) % 2019;
            result = min(result, tmp);
            if (result == 0) {break;}
        }
        if (result == 0) {break;}
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include <bits/stdc++.h>
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int lli;
lli gcd(lli a, lli b){
    return !b? a : gcd(b, a % b);
}
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
void solve(){
    lli n1, n2;
    cin >> n1 >> n2;
    cout << lcm(n1, n2) << endl;
}
int main(){
    //freopen("input.txt","r",stdin);
    fastio
    solve();

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(), x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define pb push_back
#define x first
#define y second
#define endl "\n"
#define MOD int(1e9+7)
#define N 200123
int n, t, k;
vi r[3];
ll ans ;
string s;
int val(char c){
    if(c=='R')return 0;
    if(c=='G')return 1;
    return 2;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> s;
    for(int i=0;i<n;i++){
        r[val(s[i])].pb(i);
    }
    /*
    for(int i=0;i<=2;i++){
        for(auto q:r[i])cout << q << " ";
        cout << endl;
    }
    */
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ll dif = j-i;
            if(s[i]!=s[j]){
                k = 3-(val(s[i])+val(s[j]));
                auto existe = lower_bound(all(r[k]),j+1);
                if(existe == r[k].end())continue;
                ans+=int(r[k].size())-(existe-r[k].begin());
                auto pos = lower_bound(all(r[k]),int(j+dif));
                if(pos!=r[k].end() && *pos == j+dif)ans--;

            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3680
#include <iostream>
#include <set>

using namespace std;
int main() {
  set<int> s;
  int q, x;
  cin >> q; // skip n
  while (cin >> q >> x) {
    if (q == 0) {
      s.insert(x);
      cout << s.size() << endl;
    }
    if (q == 1)
      cout << s.count(x) << endl;
    if (q == 2)
      s.erase(x);
  }
}


Measured memory_bytes: 12404
n=int(input())
a=list(map(int,input().split()))
d=1
mx=[]
for i in range(n+1):
  d-=a[i]
  mx.append(d)
  d*=2

mx.append(1)
f=mx[n]>=0
d=0
c=0
for i in range(n,-1,-1):
  d+=a[i]
  c+=d
  t=(d+1)//2
  if t>mx[i-1]:
    f=False
    break
  d=min(d,mx[i-1])
print(c if f else -1)


Measured memory_bytes: 705728
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int n; cin >> n;
	vector<double> x (n);
	vector<string> u (n);
	double yen = 0;
	forn(i, n){
		cin >> x[i] >> u[i];
		if(u[i] == "JPY") yen+=x[i];
		else yen+=380000*x[i];
	}
	cout << fixed << setprecision(8) << yen << endl;
}


Measured memory_bytes: 256
import std.stdio,std.array;

void main(){
    string[] n = split(readln());
    int sevenCount = 0;
    for(int i=0;i<3;i++){
        if("7" == n[i]) sevenCount++;
    }

    int fiveCount =0;
    for(int i=0;i<3;i++){
        if("5" == n[i]) fiveCount++;
    }
    if(fiveCount == 2 && sevenCount == 1){
        writeln("YES");
    }else{
        writeln("NO");
    }
}


Measured memory_bytes: 256
residence = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
sep = "#"*20
s = ""
for i in range(n):
    b,f,r,v = map(int,input().split())
    residence[b-1][f-1][r-1] += v

for i in residence:
    for j in i:
        s += " "+" ".join(map(str,j)) + "\n"

    s += sep+"\n"

print(s.rstrip(sep+"\n"))

Measured memory_bytes: 7728
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;
int main()
{
	int N,H;
	cin>>H>>N;
	vector<int>A(N);
	int sum=0;
	rep(i,0,N){
		cin>>A[i];
		sum+=A[i];
	}
	if(H<=sum){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}


}



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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i = a; i <= b; ++i) {
        if (c % i == 0) {
            ++ans;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, c, x; cin >> a >> b >> c >> x;
  int ans = 0;
  REP(i, a+1) for (int j = 0; j<=b && 500*i+100*j<=x; ++j) {
    if ((x - 500*i - 100*j) % 50 == 0 && (x - 500*i - 100*j)/50 <= c) ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
import numpy as np
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

tmp = []
tmp.append(-1)
for i, x in enumerate(S):
	if x != "A" and x != "T" and x != "G" and x != "C":
		tmp.append(i)
tmp.append(len(S))
#print(tmp)

tmp2 = [tmp[i+1] - tmp[i] for i in range(len(tmp)-1)]
print(max(tmp2)-1)


Measured memory_bytes: 13008
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }

    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        Arrays.sort(A);
        int max = A[N-1];
        boolean[] dp = new boolean[max+1];
        Arrays.fill(dp, true);
        for (int i = 0; i < N; i++) {
            if (dp[A[i]] == false) {
                continue;
            }
            for (int j = 2; A[i] * j <= max; j++) {
                dp[A[i]*j] = false;
            }
        }
        for (int i = 1; i < N; i++) {
            if (A[i-1] == A[i]) {
                dp[A[i]] = false;
            }
        }
        int a = 0;
        for (int i = 0; i < N; i++) {
            if (dp[A[i]]) {
                a += 1;
            }
        }
        System.out.println(a);
    }
}


Measured memory_bytes: 60808
#include<stdio.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
const int maxn = 2e5 + 5;
map<int,int>dp[maxn];
vector<int>ve[maxn];
int n;
int ans[maxn];
int dfs2(int x,int ba,int v) {
	if(dp[x].count(v)) return dp[x][v];
	int sm = 1;
	for(int y:ve[x]) {
		if(y==ba) continue;
		if(y<v) sm += dfs2(y,x,v);
	}
	return dp[x][v] = sm;
}
void dfs1(int x,int ba,int pr,int cc) {
	cc += dfs2(x,ba,max(ba,pr));
	if(pr>x) cc -= dfs2(x,ba,pr);
	ans[x] = cc;
	for(int y:ve[x]) {
		if(y==ba) continue;
		dfs1(y,x,max(pr,ba),cc);
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		int x,y; scanf("%d%d",&x,&y);
		ve[x].push_back(y);
		ve[y].push_back(x);
	}
	for(int y:ve[1]) {
		dfs1(y,1,1,0);
	}
	for(int i=2;i<=n;i++) printf("%d ",ans[i]);
}


Measured memory_bytes: 53888
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define fr(i, k, n) for (int i = k; i < n; i++)
#define rep(i, n) fr(i, 0, n)
#define aintl(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define rdd(a) int a; cin >> a
#define rrd rdd(a); rep(i, a)
//min({a,b,c,d})などの記法
using namespace std;
template <class X> void pr(X x) { cout << x << endl; }
template <class X> void prr(X x) { for (auto it : x) { cout << it<< endl; } }


int main(int argc, const char * argv[]) {
    int n,m;
    cin>>n>>m;
    int s[n+1],g[n+1];
    rep(i, n+1) s[i]=0;
    rep(i, n+1) g[i]=0;
    rep(i, m){
        int t,y;
        cin>>t>>y;
        if(t==1){
            s[y]=1;
        }else if(y==1){
            s[t]=1;
        }
        if(t==n){
            g[y]=1;
        }else if(y==n){
            g[t]=1;
        }
    }
    string ss="IMPOSSIBLE";
    rep(i, n+1){
        if(s[i]==1 && g[i]==1){
            ss="POSSIBLE";
        }
    }
    pr(ss);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;


int to_i(string &s){
	int a=0;
	for(int i=0;i<s.size();i++)a=a*10+s[i]-'0';
	return a;
}
string to_s(int n){
	string s;
	while(n){
		s+=n%10+'0';
		n/=10;
	}
	while(s.size()<4)s+='0';
	reverse(s.begin(),s.end());
	return s;
}


int cache[10000];

int solve(int n){
	if(n==6174)return 0;
	if(cache[n])return cache[n];
	string s=to_s(n);
	int a,b;
	sort(s.begin(),s.end());
	a=to_i(s);
	sort(s.begin(),s.end(),greater<char>());
	b=to_i(s);
	return cache[n] = 1+solve(b-a);
}


int main(){
	string s;
	while(cin>>s&&s!="0000"){
		if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){
			cout<<"NA\n";
			continue;
		}
		cout<<solve(to_i(s))<<endl;
	}
	return 0;
}

Measured memory_bytes: 1252
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{

    static long M=(long)1e9+7;
    
    public static void main(String[] args) {
        FastReader fs=new FastReader();
        int h=fs.nextInt();
        int n=fs.nextInt();
        boolean f=false;
        long sum=0;
        for(int i=0;i<n;i++){
            long temp=fs.nextLong();
            sum+=temp;
        }
        if(sum>=h){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");    
        }
            
    }
    
    public static long min(long a, long mod){
        return pow(a, mod-2,mod);
    }
    public static long mul(long a,long b,long mod){
        long res=0;
        while(b!=0){
            if ((b & 1) == 1){ res = (res + a) % mod;}
            a = (a + a) % mod;
            b >>= 1;
        }
        return res;
    }
    
    public static long pow(long a, long n, long mod){
        long res=1;
        while(n != 0){
            if ((n & 1) == 1) res = mul(res, a, mod)%mod;
            a = mul(a , a, mod)%mod;
            n >>= 1;
        }
        return res;
    }
    
    public static long gcd(long a, long b){
        if(a == 0) return b;
        return b == 0 ? a: gcd(b, a % b);
    }

    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


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

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

	long long a[100010][3];

	long long dp[100010][3];

int main(){

	int N; cin >> N;

	for(int i=0;i<N;i++) for (int j = 0; j < 3; ++j) cin >> a[i][j];


	// ループ
	for (int i = 0; i < N; ++i) {
		for(int j = 0; j < 3; ++j){
			for(int k = 0; k < 3; ++k){
				if(j==k) continue;
    			chmax(dp[i+1][k], dp[i][j] + a[i][k]);
			}
		}
	}

	cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;

	}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
int n;
int main()
{
    scanf("%d",&n);
    long long ans=0;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        ans+=mp[s];
        mp[s]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main(void){
    int k, t;
    cin >> k >> t;
    int ai;
    int ans = 100000;
    for(int i=0; i<t; i++){
        cin >> ai;
        if(2*ai-k>=0){
            ans = min(max(2*ai-k-1,0),ans);
        }
    }
    if(ans == 100000){
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n,cnt;
bool flag;
string s;
int main()
{
    cin>>n>>s;
    rep(i,0,n-1){
        if(s[i]=='A'){
            if(s[i+1]=='B'&&s[i+2]=='C')cnt++;
        }
    }
    pf(cnt);
    return 0;
}


Measured memory_bytes: 256
/*author - swapno7064*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long int
#define MOD 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define for0(i, n) for (int i = 0; i < n; i++)
#define tc(t) int t; cin >> t; while (t--)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ps(x,y)         fixed<<setprecision(y)<<x
using namespace std;
using namespace __gnu_pbds;
int main()
{
	IOS
		int dx[4]={-1,0,1,0};
		int dy[4]={0,-1,0,1};
		ll h,w,k,x1,y1,x2,y2;
		cin>>h>>w>>k;
		cin>>x1>>y1>>x2>>y2;
		x1--,y1--,x2--,y2--;
		vector<string> grid;
		for(int i=0;i<h;i++)
		{
			string s;
			cin>>s;
			grid.pb(s);
		}
		const ll inf = 1e18;
		vector<vector<ll>> dist(h,vector<ll>(w,inf));
		dist[x1][y1]=0;
		queue<pll> q;
		q.push({x1,y1});
		while(!q.empty())
		{
			auto temp=q.front();
			ll x=temp.fi;
			ll y=temp.se;
			q.pop();
			if(x==x2 && y==y2)
			{
				cout<<dist[x][y]<<endl;
				return 0;
			}
			for(int i=0;i<4;i++)
			{
				for(int j=1;j<=k;j++)
				{
					ll nx=x+dx[i]*j;
					ll ny=y+dy[i]*j;
					if(nx<0 || nx>=h || ny<0 || ny>=w )
					break;
					if(grid[nx][ny]=='@')
					break;
					if(dist[nx][ny]<=dist[x][y])
					break;
					if(dist[nx][ny]==inf)
					{
						dist[nx][ny]=dist[x][y]+1;
						q.push({nx,ny});
					}
				}
			}
		}
		cout<<"-1\n";
		return 0;
}
					
		


Measured memory_bytes: 19932
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000019
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int dp[120][20000];
vector<int> w(2000);
vector<int> v(2000);

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    int maxi=0,f=0,sum=0;
    string str,str1,str2;
    int i;
    double h;
    int n,x,m;
    int a,b,d,c;
    int e,weight;

    //nが宝石数、weightがバッグサイズ
    cin>>n>>weight;
    
    //サイズをいい感じにする
    w.resize(n+1);
    v.resize(n+1);

    //i番目の宝石の価値と重さを入力
    rep(i,n){
        cin>>v[i]>>w[i];
    }

    //DPテーブルを0で初期化(負のvが入るときは-INFとかにしたほうがよい?)
    for(ll i=0;i<n;i++){
        for(ll j=0;j<weight+1;j++){
            dp[i][j]=0;
        }
    }

    //dpテーブル0行目の入力
    rep(i,weight+1) {
        if(i>=w[0]) {
            dp[0][i]=v[0];
            dp[0][i]=max(dp[0][i],dp[0][i-w[0]]+v[0]);

        }
        else dp[0][i]=0;
                 //   cout<<dp[0][i]<<" ";
    }
    //cout<<endl;

    //DPテーブルの1行目からの入力
    REP(i,1,n){
        rep(j,weight+1){

            //i個めの宝石が入るだけのバッグサイズになったら、過去のDPテーブル+今の宝石したときの価値と今の宝石を入れない場合で比較し、価値が高いほうを入れる
            if(j>=w[i]) {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
                dp[i][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }

            //i個めの宝石が入らないバッグサイズだったら、その宝石を入れる前の状態を引き継ぐのみ
            else dp[i][j]=dp[i-1][j];
                        //        cout<<dp[i][j]<<" ";

        }
       // cout<<endl;
    }

    //dpテーブルのこたえにあたる部分を出力
    //i軸はn-1番目でj軸がw番目なところに注意する!
    cout<<dp[n-1][weight]<<endl;


    return 0;
}



Measured memory_bytes: 7444
#include<iostream>
using namespace std;
int main()
{
   long long int n;
    cin>>n;
   long long int a,b;
    cin>>a>>b;
   long long int arr[100000];
    for(long long int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
  long long   int cost=0;
    for(long long int i=1;i<n;i++)
    {
        cost+=min((arr[i]-arr[i-1])*a,b);
    }
    cout<<cost;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>v(n); for(auto&&i:v)cin>>i;
	cout<<v.back();
	for(auto i=v.rbegin()+1;i!=v.rend();++i){
		cout<<" "s<<*i;
	}
	cout<<"\n"s;
}


Measured memory_bytes: 3216
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main(void) {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }
 
  vector<ll> B(N);
  rep(i, N) {
    B[i] = A[i] - (i + 1);
  }
 
  sort(B.begin(), B.end());
 
  ll b = 0;
  if (N % 2 != 0) {
    b = B[N / 2];
  } else {
    b = (B[N / 2] + B[N / 2 - 1]) / 2;
  }
 
  ll ans = 0;
  rep(i, N) {
    ans += abs(B[i] - b);
  }
 
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6268
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let sa = Array.make (n+1) 0 in
  for i = 1 to n do sa.(i) <- sa.(i-1) + a.(i-1) done;

  let dp = Array.init (n+1) (fun _ -> Array.make (n+1) max_int) in
  for i = 0 to n-1 do dp.(i).(i+1) <- 0 done;
  for w = 2 to n do
    for i = 0 to n-w do
      for j = i+1 to i+w-1 do
        dp.(i).(i+w) <- min dp.(i).(i+w) (dp.(i).(j) + dp.(j).(i+w) + sa.(i+w) - sa.(i))
      done;
    done;
  done;
  Printf.printf "%d\n" dp.(0).(n)


Measured memory_bytes: 3712