akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	if(x<0)putchar('-'),x=-x;
	int y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
ll n,a[3005],dp[3005][3005];
ll gao(int x,int y){
	if(x==y)return dp[x][y]=a[x];
	if(dp[x][y]<1e15)return dp[x][y];
	return dp[x][y]=max(a[x]-gao(x+1,y),a[y]-gao(x,y-1));
}
int main(){
	memset(dp,0x3f,sizeof(dp));
	n=read();
	for(int i=0;i<n;i++)
		a[i]=read();
	print(gao(0,n-1));
    return 0;
}

Measured memory_bytes: 70912
#include <vector>
#include <iostream>
#include <algorithm>
#include <limits>

#define INT_MAX 2147483647
#define INT_MIN -2147483647
using namespace std;

int main()
{
	int maxProf = -2000000000;
	int minVal = 0;
	cin >> minVal;
	cin >> minVal;
	int val = 0;
	while (cin >> val)
	{
		maxProf = std::max(maxProf, val - minVal);
		minVal = std::min(minVal, val);
	}
	cout << maxProf << endl;
	return 0;
}

Measured memory_bytes: 3064
import java.awt.Frame;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import javax.sql.rowset.FilteredRowSet;
import javax.swing.BorderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.events.EndDocument;
import java.math.BigInteger;
import java.time.chrono.MinguoChronology;
import java.util.Scanner;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      int n = in.nextInt();
      int taropoint = 0;
      int hanakopoint = 0;
      String tarocard;
      String hanakocard;
      
      for (int i = 0; i < n; i++) {
        tarocard = in.next();
        hanakocard = in.next();
        
        if (!tarocard.equals(hanakocard)) {   
            for (int j = 0, min = Math.min(tarocard.length(), hanakocard.length());  j < min; j++) {
              if (tarocard.charAt(j) > hanakocard.charAt(j)) {
                taropoint += 3;
                break;
              } else if (tarocard.charAt(j) < hanakocard.charAt(j)){
                hanakopoint += 3;
                break;
              }
            
              if (j == min - 1) {
                if (min == tarocard.length()) {
                  hanakopoint +=3;
                  break;
                } 
                taropoint += 3;
              }
            }
        } else {
          taropoint++;
          hanakopoint++;
        }
      }
      
      out.println(taropoint + " " + hanakopoint);
      
//      End solve()
    }
    
//  End solution
  } 
  

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

Measured memory_bytes: 24768
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

constexpr int64 INF = 1LL<<60;

typedef pair<int64, int64> P;

int N;
int64 X[200000], Y[200000];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N; for (int j = 0; j < N; ++j) {
        cin >> X[j] >> Y[j];
        if (X[j] > Y[j]) swap(X[j], Y[j]);
    }

    vector<P> ps;
    for (int j = 0; j < N; ++j) ps.emplace_back(X[j], Y[j]);
    sort(begin(ps), end(ps));

    int64 bmin = INF, bmax = -INF;
    for (int j = 0; j < N; ++j) {
        bmin = min(bmin, ps[j].second);
        bmax = max(bmax, ps[j].second);
    }

    int64 ans = (bmax - bmin) * (ps[N-1].first - ps[0].first);
    
    bmin = ps[0].first; 
    int64 sndmin = ps[0].second, sndmax = ps[0].second;
    for (int j = 1; j < N; ++j) {
        ans = min(ans, (bmax - ps[0].first) * (max(sndmax, ps[N-1].first) - min(sndmin, ps[j].first)));

        sndmin = min(sndmin, ps[j].second);
        sndmax = max(sndmax, ps[j].second);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int a[100];

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		
		int index = 0;
		int rest = 31;
		
		while(true){
			cout << rest << endl;
			if(rest - a[index] <= 0){
				cout << "0" << endl;
				break;
			}
			cout << rest - a[index] << endl;
			index++;
			if(index >= n){
				index = 0;
			}
			rest -= 5;
		}
		
	}
	return 0;
}

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

int main(){
  int n, cnt=0, x, tmp;
    cin >> n;
  int N = 100000;
  int num[N];
  for(int i=0; i<N; i++) num[i] = 0;
    for(int i=0; i<n; i++){
      cin >> x;
      num[x]++;
    }

    for(int i=0; i<N; i++){
      if(i==0) tmp = num[i]+num[i+1];
      else if(i==N-1) tmp = num[i-1]+num[i];
      else tmp = num[i-1]+num[i]+num[i+1];

      cnt = max(tmp, cnt);
    }
    cout << cnt << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

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

int main() {
	VI n;
	REP(i, 4) {
		int x; cin >> x;
		n.PB(x);
	}
	SORT(n);
	VI a = { 1,4,7,9 };
	puts(n == a ? "YES" : "NO");
}

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

using namespace std;

int main(void)
{
	int N;

	while(cin >> N, N){

		bool flag[300] = {};
		int aaa;
		for(int i = 0; i < N; i++){
			cin >> aaa;
			flag[aaa] = true;
		}

		vector<int> taro,hana;

		for(int i = 1; i <= N*2; i++){
			if(flag[i])
				taro.push_back(i);
			else
				hana.push_back(i);
		}

		sort(taro.begin(), taro.end() );
		sort(hana.begin(), hana.end() );

//		for(int i = 0; i < N; i++)
//			cout << taro[i] << ' ' << hana[i] << endl;

		int tc = 0, hc = 0;
		int ncard = -1;
		bool f;

//		cout << endl;

		while(true){
			sort(taro.begin(), taro.end() );
			sort(hana.begin(), hana.end() );

			f = false;
			for(int i = 0; i < N; i++){
				if(taro[i] > ncard){
					ncard = taro[i];
					taro[i] = 0;
					tc++;
					f = true;
//					cout << ncard << endl;
					break;
				}
			}
			if(!f)
				ncard = 0;
			if(tc == N){
				cout << N-hc << endl << 0 << endl;
				break;
			}

			f = false;
			for(int i = 0; i < N; i++){
				if(hana[i] > ncard){
					ncard = hana[i];
					hana[i] = 0;
					hc++;
					f = true;
//					cout << ' ' << ncard << endl;
					break;
				}
			}
			if(!f)
				ncard = 0;
			if(hc == N){
				cout << 0 << endl << N-tc << endl;
				break;
			}
		
		}
	}
		


	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const string YES = "Yes";
const string NO = "No";

void func(long long N, std::vector<long long> a){

    SORT(a);
    lli minNum=INF,maxNum = -INF;
    REP(i,0,N){
        chmin(minNum,a[i]);
        chmax(maxNum,a[i]);
    }

    if(abs(minNum-maxNum)>=2){
        cout<<NO<<endl;
        return;
    }

    lli x=0,y=0;
    REP(i,0,N){
        if(a[i]==maxNum)y++;
        else x++;
    }

    if(minNum == maxNum){
        if(minNum == N-1 || minNum <= (N/2)){
            cout<<YES<<endl;
        }
        else{
            cout<<NO<<endl;
        }
    }
    else{
        if(x+1 <= maxNum && maxNum <= x+(y/2)){
            cout<<YES<<endl;
        }
        else{
            cout<<NO<<endl;
        }
    }


}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    func(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	char c;
	cin>>c;
	if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
		cout<<"vowel"<<endl;
	}
	else{
		cout<<"consonant"<<endl;
	}
	return 0;
}

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

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

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

using namespace std;

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

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

string yes = "Yes", no = "No";

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

	vector<int> a;
	inputVector(a, N);
	sort(all(a));

	if (N == 2) {
		cout << yes << endl;
		return 0;
	}
	if (a[N - 1] - a[0] > 1) {
		cout << no << endl;
		return 0;
	}
	if (a[N - 1] == a[0]
		&& N - a[0] == 1) {
		cout << yes << endl;
		return 0;
	}

	if (a[0] == a[N - 1]) {
		cout << (N / a[0] >= 2 ? yes : no) << endl;
	} else {
		int cnt1 = 0, cnt2 = 0;
		rep(i, N) {
			if (a[i] == a[0]) cnt1++;
			else cnt2++;
		}

		int tmp = a[0] - cnt1 + 1;

		if (tmp <= 0) {
			cout << no << endl;
		} else if (cnt2 / tmp >= 2 && tmp + cnt1 == a[N - 1]) {
			cout << yes << endl;
		} else {
			cout << no << endl;
		}
	}

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#define N 404
#define p 998244353
#define ll long long
inline int mod(int x){return x<p?x:x-p;}
int a[N],b[N],c[N],d[N],e[N],f[N][N],i,j,k,l,m,n,o,q;
int main()
{
    scanf("%d",&n),c[1]=*d=d[1]=1,*f[0]=p-1;
    for(i=1;i<=n;i++)scanf("%d%d",a+i,b+i),m+=a[i];
    for(i=2;i<=m;i++)c[i]=(ll)(p-p/i)*c[p%i]%p,d[i]=(ll)c[i]*d[i-1]%p;
    for(i=1,m=c[m];i<=n;i++)e[i]=(ll)a[i]*m%p;
    for(i=1,m=0;i<=n;m+=a[i],o+=b[i++]-1)for(j=m;j>=0;j--)for(k=o;k>=0;f[a[i]+j][k]=mod(f[a[i]+j][k]+f[j][k]),f[j][k]=mod(p-f[j][k]),k--)for(l=1,q=p-e[i];l<b[i];q=(ll)q*e[i]%p*c[++l]%p)f[j][k+l]=(f[j][k+l]+(ll)f[j][k]*q)%p;
    for(i=l=0;i<m;i++)for(j=0,k=q=(ll)m*c[m-i]%p;j<=o;q=(ll)k*q%p*++j%p)l=(l+(ll)f[i][j]*q)%p;
    return 0*printf("%d\n",l);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

int32_t main() {

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

    int n;
    cin >> n;

    cout << n*(n-1) / 2 << '\n'; 
}

// Mistakes
// j or k --> i
// read question again

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = ns()
ans = 0
ct = 0
for i in range(len(s)):
    if ct == 0:
        ct += 1
        if s[i] == 'p':
            ans -= 1
    else:
        ct -= 1
        if s[i] == 'g':
            ans += 1
print(ans)


Measured memory_bytes: 10760
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


string sub(string str, int l, int r){
  string res;
  repi(i,l,r)res.pb(str[i]);
  return res;
}

struct st{string str;int n;};
bool cmp(const st &a, const st &b){
  if(a.n > b.n)return true;
  else if(a.n < b.n)return false;
  return a.str < b.str;
}

signed main(){
  while(true){
    string line[100];
    vector<string> str;
    int n;cin >> n;
    if(n == 0)break;
    cin.ignore();
    rep(i,n)getline(cin, line[i]);

    map<string, int> mp;
    rep(i,n){
      int idx = 0;
      rep(j,line[i].size()+1){
        if(line[i][j] == ' ' or j == line[i].size()){
          string s = sub(line[i], idx, j);
          mp[s]++;
          idx = j + 1;
        }
      }
    }
    char c;cin >> c;
    vector<st> vec;
    for(auto it = mp.begin(); it != mp.end(); it++) {
      if(it->fi[0] != c)continue;
      vec.push_back(st{it->fi, it->se});
    }
    sort(all(vec), cmp);
    int size = vec.size();
    size = min(size, (int)5);
    if(size == 0){cout << "NA" << endl;continue;}
    rep(i,size){
      cout << vec[i].str;
      if(i == size-1)cout << endl;
      else cout << " ";
    }
  }
  return 0;
}



Measured memory_bytes: 3172
x = int(input())
aa, bb = 0, 0
for i in range(-200, 200):
  for j in range(-200, 200):
    if(i**5 - j**5 == x):
      aa, bb = i, j
    if(aa != 0 or bb != 0):
      break
  if(aa != 0 or bb != 0):
    break
print(str(aa) + " " + str(bb))

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a+b == c || a+c == b || b+c == a) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


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

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

int lcm(int a, int b){
    return a * b / gcd(a, b);
}

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

    int n;
    cin >> n;
    int v[n];
    rep(i,n) cin >> v[i];
    
    sort(v, v+n);
    
    double ans = v[0];
    for(int i=1; i<n; i++){
        ans = (double) (ans + v[i]) / 2;
    }
    
    printf("%.6f\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  int ans=0;
  int l=0;
  vector<long long> v; v.resize(n);
  for(int i=0;i<n;i++) scanf("%lld",&v[i]);
  for(int i=1;i<n;i++){
    if(v[i]<=v[i-1]) l++;
    else{
      ans=max(ans,l);
      l=0;
    }
    //printf("%lld %lld\n", v[i-1],v[i]);
  }
  ans=max(ans,l);
  printf("%d",ans);
  return 0;
  
}


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

using namespace std;

int main(void){
  vector<string> vowel = {"a","i","u","e","o"};
  string s;
  
  cin >> s;
  
  cout << (vowel.end() == find(vowel.begin(),vowel.end(),s) ? "consonant" : "vowel") << endl;
  
  return 0;
}
  
  

Measured memory_bytes: 256
S = gets.chomp.chars

ans = 0
0.upto(2 ** (S.size - 1) - 1) do |x|
  i = 0
  s =
    S.inject("") do |result, s|
      result += s
      result += '+' unless x & (1 << i) == 0
      i += 1
      result
    end
  ans += eval(s)
end
puts ans


Measured memory_bytes: 1916
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll x;
    cin>>x;
    while(1)
    {
        ll i = 2;
        ll cur = x;
        ll num = 1;
        while(i*i <= cur)
        {
            while(cur%i == 0) 
            {
                cur /= i;
                num++;
            }
            i++;
        }
        if(cur > 1) num++;
        if( num == 2)
            break;
        x++;
    }
    cout<<x<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin >> n >> k;
    vector<ll> t(n);
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    ll ans=t[n-1]+1-t[0];
    vector<ll> v;
    for(int i=0;i<n-1;i++){
        v.push_back(t[i+1]-t[i]-1);
    }
    sort(v.begin(),v.end(),greater<ll>());
    for(int i=0;i<k-1;i++){
        ans-=v[i];
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 4732
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    H, W = list(map(int, input().split()))
    # input
    xs = [[0 for w in range(W)] for h in range(H)]
    for h in range(H):
        a = list(map(int, input().split()))
        for w in range(W):
            xs[h][w] = a[w]

    # 戦略としては、右下にコインをうつしていく
    ops = []
    for h in range(H):
        for w in range(W):
            if xs[h][w]%2 != 0:
                # マスが奇数なら
                if w < W-1:
                    # 右にコインを移す
                    xs[h][w] -= 1
                    xs[h][w+1] += 1
                    ops.append("{} {} {} {}".format(h+1, w+1, h+1, w+1+1))
                elif w == W-1 and h != H-1:
                    # 下にコインを移す
                    xs[h][w] -= 1
                    xs[h+1][w] += 1
                    ops.append("{} {} {} {}".format(h+1, w+1, h+1+1, w+1))
    print(len(ops))
    for op in ops:
        print(op)


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

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long x = 0) : v((x %= M) < 0 ? x + M : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((v += b.v) >= M) v -= M; return *this; }
  m& operator-=(m b) { if (v < b.v) v += M; v -= b.v; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % M; return *this; }
  m& operator/=(m b) { return *this *= power(b, M - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
  friend string to_string(m a) { return to_string(a.v); }
};

constexpr long long mod = 998244353;
using mint = modular<mod>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  mint res;
  vector<mint> f(s + 1);
  for (int e : a) {
    f[0] += 1;
    for (int i = s - e; i >= 0; --i) {
      f[i + e] += f[i];
    }
    res += f[s];
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val Array(a, b) = sc.nextLine.split(" ").map(_.toInt)
    if (a >= 13) println(b)
    else if (a <= 5) println(0)
    else println(b / 2)
  }
}


Measured memory_bytes: 25904
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(void) {
	int N,M;
	std::cin >> N;
	std::map<char, int> mp[51];
	for (int i = 0; i < N; ++i) {
		std::string s;
		std::cin >> s;
		for (size_t j = 0; j < s.size(); ++j) {
			mp[i][s[j]]++;
		}
	}
	for (char temp = 'a'; temp <= 'z';++temp) {
		int count = 100;
		for (int i = 0; i < N; i++) {
			count = std::min(mp[i][temp], count);
		}
		for (int i = 0; i < count; i++) {
			std::cout << temp;
		}
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rpd(i,a,b) for(int i=a;i>=b;--i)
#define ll long long
#define pb push_back
using namespace std;
const int N=1e5+5;
const ll INF=1e15;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,S,T,tot;
int head[N],nxt[N<<1],to[N<<1],b[N<<1][3];
ll dis[N][3],ans[N],Min=INF;
bool v[N];
void add(int u,int v,int w0,int w1)
{nxt[++tot]=head[u];head[u]=tot;to[tot]=v;b[tot][0]=w0;b[tot][1]=w1;}
void dfs(int s,int k){
	rep(i,1,n)dis[i][k]=INF,v[N]=0;
	dis[s][k]=0;v[s]=1;queue<int>Q;Q.push(s);
	while(!Q.empty()){
		int k1=Q.front();Q.pop();v[k1]=0;
		for(int i=head[k1];i;i=nxt[i]){
			int p=to[i];
			if(dis[p][k]<=dis[k1][k]+b[i][k])continue;
			dis[p][k]=dis[k1][k]+b[i][k];
			if(v[p])continue;v[p]=1;Q.push(p);
		}
	}
}
int main(){
	n=read();m=read();S=read();T=read();
	rep(i,1,m){
	    int u=read(),v=read(),w0=read(),w1=read();
		add(u,v,w0,w1);add(v,u,w0,w1);
	}
	dfs(S,0);dfs(T,1);
	rpd(i,n,1){
		ll now=dis[i][0]+dis[i][1];
		Min=min(Min,now);
		ans[i]=Min;
	}
	rep(i,1,n){
		ll now=1e15;
		printf("%lld\n",now-ans[i]);
	}
	return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
int main(){
long X, Y, A, B, C, i, j, k, ans=0;
cin >> X >> Y >> A >> B >> C; vector<long> p(A), q(B), r(C);
for(i=0; i<A; i++){ cin >> p[i]; }
for(j=0; j<B; j++){ cin >> q[j]; }
for(k=0; k<C; k++){ cin >> r[k]; }
sort(p.begin(), p.end()); reverse(p.begin(), p.end());
sort(q.begin(), q.end()); reverse(q.begin(), q.end());
sort(r.begin(), r.end()); reverse(r.begin(), r.end());
for(i=0; i<X; i++){ ans+=p[i]; }
for(i=0; i<Y; i++){ ans+=q[i]; }
j=X-1; k=Y-1;
for(i=0; i<C; i++){
if(j>=0&&k>=0){
if(p[j]<=q[k]){ if(p[j]<r[i]){ ans=ans-p[j]+r[i]; j--; }else{ break; } }
else{ if(q[k]<r[i]){ ans=ans-q[k]+r[i]; k--; }else{ break; } }
}
else if(k>=0){ if(q[k]<r[i]){ ans=ans-q[k]+r[i]; k--; }else{ break; } }
else if(j>=0){ if(p[j]<r[i]){ ans=ans-p[j]+r[i]; j--; }else{ break; } }
else{ break; }  
}
cout << ans << "\n";
}

Measured memory_bytes: 2560
#include <stdio.h>
bool RB[105000];int ans[10005];int main() {int i,j;for (i=0;i<105000;RB[i++]=true);for (i=2;i<325;i++) if (RB[i]) for (j=i*i;j<105000;RB[j]=false,j+=i);for (i=2,j=1,ans[0]=0;i<105000;i++) if (RB[i]) ans[j]=ans[j-1]+i,j++;while (1) {scanf("%d",&i);if (!i) return 0;printf("%d\n",ans[i]);}}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

struct dice {
  int label[7];
};

struct dice *make_dice(int *num) {
  int i;
  struct dice *dice1;
  dice1 = (struct dice *)malloc(sizeof(struct dice));
  for(i = 1;i <= 6;i++) {
    dice1->label[i] = num[i];
  }
  return dice1;
}

void turnS(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[5];
  a->label[5] = a->label[6];
  a->label[6] = a->label[2];
  a->label[2] = temp;
}

void turnW(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[3];
  a->label[3] = a->label[6];
  a->label[6] = a->label[4];
  a->label[4] = temp;
}

void turnN(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[2];
  a->label[2] = a->label[6];
  a->label[6] = a->label[5];
  a->label[5] = temp;
}

void turnE(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[4];
  a->label[4] = a->label[6];
  a->label[6] = a->label[3];
  a->label[3] = temp;
}

void spin(struct dice *a) {
  turnS(a);
  turnE(a);
  turnN(a);
}

int cmp_dice(struct dice *a, struct dice *b) {
  int i;
  for(i = 1;i <= 6;i++) {
    if(a->label[i] != b->label[i]) return 1;
  }
  return 0;
}

int main() {
  int i,j,num[7];
  struct dice *dice1,*dice2;
  for(i = 1;i <= 6;i++) {
    scanf("%d", num+i);
  }
  dice1 = make_dice(num);

  for(i = 1;i <= 6;i++) {
    scanf("%d", num+i);
  }
  dice2 = make_dice(num);
  
  for(i = 0;i < 4;i++) {
    for(j = 0;j < 4;j++) {
      if(cmp_dice(dice1, dice2) == 0) break;
      spin(dice1);
    }
    if(cmp_dice(dice1, dice2) == 0) break;
    turnW(dice1);
  }
  for(i = 0;i < 4;i++) {
    for(j = 0;j < 4;j++) {
      if(cmp_dice(dice1, dice2) == 0) break;
      spin(dice1);
    }
    if(cmp_dice(dice1, dice2) == 0) break;
    turnS(dice1);
  }
  if(cmp_dice(dice1, dice2) == 0) {
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e6+10;
const int mod=1e9+7;
int fac[maxn];
int power(int n,int x){
    int res=1;
    while(x){
        n%=mod;
        if(x&1)res=res*n%mod;
        x>>=1;
        n=n*n%mod;
    }
    return res;
}
int fermat(int x){
    return power(x,mod-2);
}
int c(int n,int m){
    return (fac[m]*fermat(fac[n])%mod)*fermat(fac[m-n])%mod;
}
main(){
    fac[0]=1;
    for(int i=1;i<=2e6;++i){
        fac[i]=fac[i-1]*i%mod;
    }
    int k;
    string s;
    cin>>k>>s;
    int len=s.length();
    int ans=0;
    for(int i=0;i<=k;++i){
        ans=(ans+((power(26,i)*c(len-1,len+k-1-i)%mod)*power(25,k-i)%mod))%mod;
    }
    cout<<ans<<endl;
}


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

ll f(ll b, ll n) {
	if (n < b)return n;
	return f(b, n / b) + n%b;
}
int main() {
	ll n, s; scanf("%lld%lld", &n, &s);
	for (ll i = 2; i*i <= n; i++) {//nをi進表記
		if (f(i, n) == s) {
			printf("%lld\n", i); return 0;
		}
	}
	ll Min = LLONG_MAX;
	for (ll i = 1; i*i < n; i++) {//上位桁を固定
		ll b = (n - (s - i)) / i;
		if (b > 1 && f(b, n) == s)Min = min(Min, b);
	}
	if (Min == LLONG_MAX&&n == s) {
		printf("%lld\n", n + 1); return 0;
	}
	printf("%lld\n", Min == LLONG_MAX ? -1 : Min);
}

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

int main() {
  int N;
  cin >> N;
  
  int tmp = 0;
  int sum = 0;
  int max = 0;
  for(int i=0; i<N; i++) {
    cin >> tmp;
    sum += tmp;
    if(tmp>max) {
      max = tmp;
    }
  }
  
  sum = sum - max/2;
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_set_rev = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using dijkstra = priority_queue<T, vector<T>, greater<T>>;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fbo find_by_order //k th index
#define ook order_of_key // strictly smaller than k
#define PI acos(-1.0)
#define inf 0x3f3f3f3f
#define max_ull 18446744073709551615
#define max_ll 9223372036854775807
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define max5(a, b, c, d, e) max(max3(a, b, c), max(d, e))
#define min5(a, b, c, d, e) min(min3(a, b, c), min(d, e))
#define lead_zero(x) __builtin_clzll(x)
#define trail_zero(x) __builtin_ctzll(x)
#define total_1s(x) __builtin_popcountll(x)
#define first_1(x) __builtin_ffsll(x)
#define log2_(x) __builtin_clz(1) - __builtin_clz(x)
#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))
#define QUERY int test;scanf("%d", &test);for (int _T = 1; _T <= test; _T++)
#define FAST ios_base::sync_with_stdio(0), cin.tie(0)
#define all(v) v.begin(), v.end()
#define reunique(v) v.resize(std::unique(all(v)) - v.begin())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define MERGE(v1, v2, v) merge(all(v1), all(v2), back_inserter(v))
#define MP make_pair
#define EB emplace_back
#define read freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define in_range(v, r, l) upper_bound(all(v), r) - lower_bound(all(v), l)
#define LCM(a,b) (a/__gcd(a,b))*b;
ll rdn(int y, int m, int d) {
    /* Rata Die day one is 0001-01-01 */
    if (m < 3)
        y--, m += 12;
    return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;
}
/* Direction arrays */
/* int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1}; */                        // 4 Direction
/*int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1};       */ // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */            // Hexagonal Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */            // Hexagonal Direction
/* int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */
const int N=1e5+9;
int n;
int ww[104];
ll val[104];
int main() {
    int w;
    scanf("%d %d",&n,&w);
    vector<ll>dp(w+3,0);
    ll ans=0;
    for(int i=1;i<=n;i++){
        scanf("%d %I64d",&ww[i],&val[i]);
        for(int j=w;j>=ww[i];j--){
            dp[j]=max(dp[j],dp[j-ww[i]]+val[i]);
            ans=max(ans,dp[j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadLong();

        for (long h = 1; h <= 3500; h++)
        {
            for (long n = h; n <= 3500; n++)
            {
                if (4 * h * n - N * n - N * h == 0) continue;
                var w = (N * h * n) / (4 * h * n - N * n - N * h);
                if (w > 0 && 4 * h * n * w == (n * w + h * w + h * n) * N)
                {
                    Console.WriteLine(h + " " + n + " " + w);
                    return;
                }
            }
        }
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = 3 * TEN(18) + 10;
const int mod = 998244353;

signed main()
{
	int a[3];
	rep(i, 3) cin >> a[i];

	int mx = max({a[0], a[1], a[2]});

	for (int i = mx; i <= mx + 6; ++i) {
		vi b(3);
		int counter = 0;
		rep(j, 3) {
			b[j] = i - a[j];
			counter += b[j] % 2 == 0;
		}

		if (counter == 1) {
			int ans = 1;

			rep(j, 3) {
				if (b[j] % 2 == 0) {
					ans += b[j] / 2;
				} else {
					ans += (b[j] - 1) / 2;
				}
			}

			cout << ans << endl;
			return 0;
		}

		if (counter == 3) {
			int ans = 0;

			rep(j, 3) {
				ans += b[j] / 2;
			}

			cout << ans << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
N=int(input())
S=['0']*N
for i in range(0,N):
    S[i]=input()
for i in range(1,N):
    if S.count(S[i])>1:
        print('No')
        exit()
    elif S[i-1][-1]!=S[i][0]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  int t = 0;
  for (int i = 0; i < n; i++){
    t += a.at(i);
  }
  
  
  int ans = 0;
  if (t % (4 * m) == 0){
    for (int i = 0; i < n; i++){
      if (a.at(i) >= (t / (4 * m))){
        ans++;
      }
    }
  }
  else{
    for (int i = 0; i < n; i++){
      if (a.at(i) > (t / (4 * m))){
        ans++;
      }
    }
  }
  
  if (ans >= m){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3548
#include <stdio.h>
#include <math.h>

int main(void) {
	double x1, x2, y1, y2;
	double ans;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	ans = sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));
	printf("%f\n", ans);
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define maxN 302
using namespace std;

int n, a[maxN][maxN];

struct Edge
{
    int x, y;
    bool operator < (const Edge &ot) const
    {
        return a[x][y] < a[ot.x][ot.y];
    }
}V[maxN * maxN];
int E, f[maxN];

long long ans;

int root(int x)
{
    if (!f[x])
        return x;
    return f[x] = root(f[x]);
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i)
        for (int j = 1; j <= n; ++ j)
        {
            scanf("%d", &a[i][j]);
            if (i < j)
            V[++ E] = {i, j};
        }
    for (int k = 1; k <= n; ++ k)
        for (int i = 1; i <= n; ++ i)
        if (i != k)
        for (int j = i + 1; j <= n; ++ j)
        if (j != k && (a[i][j] > a[i][k] + a[k][j]))
    {
        printf("-1");
        return 0;
    }

        for (int i = 1; i <= n; ++ i)
        for (int j = i + 1; j <= n; ++ j)
        {
            bool ok = 1;
            for (int k = 1; k <= n && ok; ++ k)
            if (i != k && j != k && a[i][j] == a[i][k] + a[k][j])
               ok = 0;
            if (ok)
            {
                if (root(i) != root(j))
                f[root(i)] = root(j);
                    ans += 1LL * a[i][j];

            }
        }
    /*sort(V + 1, V + E + 1);
    int nrE = 1;
    for (int i = 1; i <= E && nrE < n; ++ i)
    {int rx = root(V[i].x), ry = root(V[i].y);
    if (rx != ry)
    {
        ans += a[V[i].x][V[i].y];
        f[rx] = ry;
        ++ nrE;
    }
    }*/
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;
const int MAX_N = 1e3 + 5;
const int MAX_S = 20123;

struct Block {
	int w, s, v;
	void read() {
		cin >> w >> s >> v;
	}
	bool operator<(const Block& b) const {
		return w + s < b.w + b.s;
	}
};

int N;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	vector<Block> blocks(N);
	for (int i = 0; i < N; ++i) {
		blocks[i].read();
	}
	sort(blocks.begin(), blocks.end());

	vector<ll> dp(MAX_S + 1);
	for (Block b: blocks) {
		for (int w = min(b.s, MAX_S - b.w); w >= 0; --w) {
			dp[w + b.w] = max(dp[w + b.w], dp[w] + b.v);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= MAX_S; ++i) {
		ans = max(ans, dp[i]);
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		int n = s.length() + 1;

		int[] lt = new int[n];
		int[] gt = new int[n];

		for (int i = 0; i < n - 1; i++) {
			if (s.charAt(i) == '<') {
				lt[i + 1] = lt[i] + 1;
			}
		}
		for (int i = n - 2; i >= 0; i--) {
			if (s.charAt(i) == '>') {
				gt[i] = gt[i + 1] + 1;
			}
		}
		long sum = 0;
		for (int i = 0; i < n; i++) {
			sum += Math.max(lt[i], gt[i]);
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 34108
N,C = [int(i) for i in input().split()]
D = [[int(j) for j in input().split()] for i in range(C)]
c_temp = [[int(j)-1 for j in input().split()] for i in range(N)]
c = [[0 for i in range(C)] for j in range(3)]
for i in range(N):
    for j in range(N):
        c[(i+j)%3][c_temp[i][j]] += 1

min = 10**15
for i in [ii for ii in range(C)]:
    for j in [jj for jj in range(C) if jj != i]:
        for k in [kk for kk in range(C) if kk != i and kk != j]:
            count = sum([D[x][i]*c[0][x] + D[x][j]*c[1][x] + D[x][k]*c[2][x] for x in range(C)])
            if min > count:
                min = count
print(min)




Measured memory_bytes: 5492
import java.util.*;
import java.io.*;
 
public class Main{
    ArrayList<Long> list;
    HashMap<Long,Integer> map;
    long ltotal,rtotal,maximum;
    long ans;
    
    public static void main(String[] args){
        Main m = new Main();
        m.input();
        m.solve();
    }
 
    
    public void input(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ltotal = 0;
        rtotal = 0;
        ans = 0;
        maximum = 1000000000;
        list = new ArrayList<Long>();
        map = new HashMap<Long,Integer>();
        for(int i = 0; i < n; i++){
            long num = sc.nextLong();
            list.add(num);
            ltotal += num;
            if(ltotal == 0){
                ans++;
                if(map.containsKey(maximum)){
                    int tmp = map.get(maximum) + 1;
                    map.put(maximum,tmp);
                }else{
                    map.put(maximum,1);
                }
            }
            if(map.containsKey(ltotal)){
                int tmp = map.get(ltotal) + 1;
                map.put(ltotal,tmp);
            }else{
                map.put(ltotal,1);
            }
        }
        sc.close();
    }
    

    public void solve(){
        int max = list.size();
        long now = 0;
        for(int i = 0; i < max; i++){
            now = now + list.get(i);
            
            if(map.containsKey(now)){
                int tmp = map.get(now) - 1;
                if(tmp >= 0){
                    map.put(now,tmp);
                }
            }
            if(map.containsKey(now)){
                int tmp = map.get(now);
                ans += tmp;
            }
        }
        System.out.println(ans);
    }
    
}

Measured memory_bytes: 106672
from itertools import permutations
N, M, R = map(int, input().split())
r = list(map(lambda x: int(x) - 1, input().split()))
G = [[float('inf')] * N for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    G[a][b] = c
    G[b][a] = c

# ワーシャルフロイド
for k in range(N):
    for i in range(N):
        for j in range(N):
            G[i][j] = min(G[i][j], G[i][k] + G[k][j])

# 街の訪れ方を全探索
ans = float('inf')
for perm in permutations(r):
    tmp = 0
    for i in range(R - 1):
        tmp += G[perm[i]][perm[i + 1]]
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 72712
m,d = map(int,input().split())
ans = 0
for i in range(1,d+1):
  if i < 22:
    continue
  else:
    if i%10 == 0:
      continue
    else:
      if i%10 == 0 or i%10 == 1:
        continue
      else:
        if (i//10)*(i%10) <= m:
          ans += 1
print(ans)

Measured memory_bytes: 9116
import numpy as np
N, K = map(int, input().split(' '))
h = np.array([-1] + list(map(int, input().split(' '))), dtype=np.int64)

dp = np.array([-1 for _ in range(N+1)], dtype=np.int64)
# dp[0], dp[1], ..., dp[N] が用意される

dp[1] = 0
for k in range(2, N+1): # k = 2, ..., N
  """
  candidate = []
  for i in range(1, K+1): # i = 1, 2, ..., K
    if k - i <= 0:
      break
    candidate.append(dp[k-i] + abs(h[k] - h[k-i]))
  """
  start_index = max(1, k - K)
  # candidate = [
  #     dp[start_index] + abs(h[k] - h[start_index]),
  #     dp[start_index+1] + abs(h[k] - h[start_index+1]),
  #     ...,
  #     dp[k-1] + abs(h[k] - h[k-1]),
  # ]
  candidate = dp[start_index:k] + np.abs(h[k] - h[start_index:k])
  dp[k] = np.min(candidate)
  # print("candidate: ", candidate)
  # print("dp[{}]=={}".format(k, dp[k]))

print(dp[N])


Measured memory_bytes: 38724