akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String s = sc.next();
    String t = sc.next();
    HashMap<Character, Character> conversion = new HashMap<>();
    for (int i = 0; i < s.length(); i++) {
      if (
          (conversion.containsKey(s.charAt(i)) && conversion.get(s.charAt(i)) != t.charAt(i)) ||
              (!conversion.containsKey(s.charAt(i)) && conversion.containsValue(t.charAt(i)))) {
        System.out.println("No");
        return;
      }
      conversion.put(s.charAt(i), t.charAt(i));
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 25940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main() {
   int x;
   cin>>x;
   if(x>=30) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

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

int main() {
	
  int i, n, a, b, x;
  cin >> n;
  x = 0;
  
  for(i = 0; i < n; i++){
    cin >> a >> b;
    x += b - a + 1;
  }
  cout << x << endl;
    
  
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

n,k = map(int,input().split())

a = list(map(int,input().split()))

MOD = pow(10,9) + 7

p = 0

c = 0
d = 0
for i in range(n):
  for j in range(i+1,n):
    if(a[i] > a[j]):
      c += 1
      d += 1
    elif(a[i] < a[j]):
      d += 1


ans = int(c * k % MOD) + int( (k *(k-1)//2) % MOD * d)
ans = int(ans%MOD)

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int a;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>a;
  	cout<<a+a*a+a*a*a<<endl;
  	return 0;
}



Measured memory_bytes: 3644
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadLong;

            if (N == 1) {
                Console.WriteLine('0');
            }
            else
            {
                Console.WriteLine(N * (N - 1) / 2);
            }

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main() {
  int N;
  long int L[87];
  cin >> N;
  L[0] = 2, L[1] = 1;
  for (int i = 2; i <= N; i++)
    L[i] = L[i-1] + L[i-2];
  cout << L[N] << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  rep(i, n) {
    int xx, yy, hh;
    cin >> xx >> yy >> hh;
    x.at(i) = xx;
    y.at(i) = yy;
    h.at(i) = hh;
  }
  int cx, cy;
  int H;
  bool flag = false;
  rep(i, 101) {
    rep(j, 101) {
      cx = i;
      cy = j;
      rep(k, n) {
        if (h.at(k) > 0) {
          H = h.at(k) + abs(x.at(k) - cx) + abs(y.at(k) - cy);
          int count = 0;
          rep(l, n) {
            if (h.at(l) == max(H - abs(x.at(l) - cx) - abs(y.at(l) -cy), 0)) {
              count++;
            }
          }
          if (count == n) {
            cout << cx << " " << cy << " " << H << endl;
            flag = true;
            break;
          }
        }
      }
      if (flag) {
        break;
      }
    }
    if (flag) {
      break;
    }
  }
}
        
        
 

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int h[1000] = { 0 };

int main()
{
	int a, b;

	cin >> a >> b;
	repc(i, 1, 999) h[i] = h[i - 1] + i;
	cout << h[b - a - 1] - a << endl;

	return 0;
}


Measured memory_bytes: 256
program ABC049A
    implicit none
    character(1)::c
    read(5,*)c
    if(c=="a".or.c=="e".or.c=="i".or.c=="o".or.c=="u")then
        print'(A)',"vowel"
    else
        print'(A)',"consonant"
    end if
end program ABC049A

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a * c <= b) {
		cout << c << endl;
	}
	else {
		cout << b / a << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> T(N);
    rep(i, N) cin >> T[i];
    int M;
    cin >> M;
    vector<pii> drink(M);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        drink[i] = MP(a - 1, b);
    }
    int sum = 0;
    rep(i, N) sum += T[i];
    rep(i, M) { cout << sum - T[drink[i].first] + drink[i].second << endl; }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define out(n) cout << (n) << "\n";
#define vut(v) rep(i, v.size()) out(v[i]);

int main() {
  ios::sync_with_stdio(false);

  int n, m, d[100001] = {0};
  cin >> n >> m;

  int a, b;
  rep(i, 0, m) {
    cin >> a >> b;
    d[a]++, d[b]++;
  }

  rep(i, 0, n + 1) {
    if(d[i] & 1) {
      out("NO")
      return 0;
    }
  }

  out("YES")
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> bars(n);
  rep(i, n) cin >> bars[i];
  
  sort(all(bars));

  int cnt_of_possible_triangles = 0;
  for (int c = n - 1; c >= 0; --c) {
    for (int b = c - 1; b >= 0; --b) {
      cnt_of_possible_triangles += max(0, b - (int)(upper_bound(all(bars), bars[c] - bars[b]) - bars.begin()));
    } 
  }

  cout << cnt_of_possible_triangles << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<bitset>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;

    int ans = 1;
    vector<string> s;
    string tmp_s1;

    for(int i = 0; i < n; i++){
        cin >> tmp_s1;
        s.push_back(tmp_s1);
    }

    sort(s.begin(), s.end());
    tmp_s1 = s[0];
    for(int i = 1; i < n; i++){
        if(tmp_s1 != s[i]){
            ans++;
            tmp_s1 = s[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 11540
#include <bits/stdc++.h>
    using namespace std;
    #define FOR(i,n) for(int i=0;i<n;i++)
    #define why(n,x) int n;while(cin >>n,n!=x)
    #define iFOR(i,x,n)for(int i=x;i<n;i++)
    #define unless(flg) if ( !(flg) )
    #define read cin<<
    #define echo cout<<
    #define fin <<'\n'
    #define __ <<" "<<
    #define ___ <<" "
    #define bash push_back
    #define ALL(x) x.begin(),x.end()
    #define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
    #define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
    #define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
    #define memmin(x) memset((x),-1,sizeof((x)))
    #define memzer(x) memset((x), 0,sizeof((x)))
    #define meminf(x) memset((x),0x3f,sizeof((x)))
    #define int long long
    typedef long long ll;
    typedef pair < int , int > pii;
    typedef vector < int > vit;
    typedef map < string , int > mstit;
    typedef vector < pii > vpi ;
    typedef greater < pii > gpi;
    typedef priority_queue < pii , vpi , gpi > dijk ;
    static const signed int INF = 0x3f3f3f3f;
    static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
    static const signed int SMOD = 1000000007;
    static const signed int NMOD = 1000000009;
    static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
    static const signed int dy[]={0,-1,0,1,-1,1,-1,1};
     
    bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
    template<class T>T abs(T &x){return x<0 ? -x : x;}
    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; }
    int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
    int gcd(int a,int b){return b?gcd(b,a%b):a;}
     
     
     
    signed main(){
    int n, a, b;
    string str;
    cin >> str;
    if(str> "2019/04/30")cout << "TBD\n";
    else cout <<"Heisei\n";
    return 0;
    }
     
     
     
    struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;
     

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

int n;
const int MAX_N = 1.0e5 + 100;
int a[MAX_N];

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

    sort(a, a+n);

    int a_i = a[n-1];
    int a_j = a[0];
    for (int i = 1; i < n-1; i++) {
        if (a_j < a[n-1]/2) {
            if (a_i - a[i] > a_j) {
                a_j = a[i];
            }
        }
    }

    cout << a_i << " " << a_j << endl;
    
    return 0;
}


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

int main(){
  int n,a[3][100010],dp[3][100010],t;
  cin>>n;
  fr(i,n) cin>>a[0][i]>>a[1][i]>>a[2][i];
  fr(j,3) dp[j][0]=a[j][0];
  for(int i=1;i<n;i++){
    fr(j,3){
      t=0;
      fr(k,3) if(j!=k) t=max(t,dp[k][i-1]);
      dp[j][i]=t+a[j][i];
    }
  }
  t=0;fr(j,3) t=max(t,dp[j][n-1]);
  cout<<t<<endl;
}

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

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

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	Int N;
	cin >> N;

	vector<vector<Int>> ba(N, vector<Int>(2, 0));
	for (Int i = 0; i < N; i++) {
		cin >> ba[i][1] >> ba[i][0];
	}

	sort(ba.begin(), ba.end());
	Int temp = 0;

	Int flag = 0;
	for (Int i = 0; i < N; i++) {
		temp += ba[i][1];
		if (temp > ba[i][0]) {
			flag = 1;
			break;
		}
	}

	cout << (flag ? "No" : "Yes") << "\n";

}

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

typedef long long ll;
const int N = 500;

ll f[N][N], sum[N];
int n, a[N], ans = 0;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]), sum[i] = sum[i - 1] + a[i];
	memset(f, 0x3f, sizeof(f));
	for(int i = 1; i <= n; ++i) f[i][i] = 0;
	for(int len = 2; len <= n; ++len) {
		for(int l = 1; l <= n; ++l) {
			int r = l + len - 1;
			if(r > n) break;
			for(int k = l; k < r; ++k) {
				f[l][r] = min(f[l][r], f[l][k] + f[k + 1][r] + sum[r] - sum[l - 1]);
			}
		}
	}
	printf("%lld\n", f[1][n]);
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll x, y;
    cin >> x >> y;
    ll c = y/x;
    //cout << c << endl;
    ll ans = 1;
    ll count = 2;
    while(count <= c){
        count*=2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
typedef vector<ll> VL;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999

int h[100010],dp[100010],N;

int main(){
  cin >>N;
  REP(i,N){
    scanf("%d",&h[i]);
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  FOR(i,2,N){
    dp[i]=min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  }
  cout << dp[N-1]<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}
int main(void){
  ll n,a=0;
  cin >> n;
  a=n/11*2;
  if(n%11==0)cout << a;
  else if(n%11<=6)cout << a+1;
  else cout << a+2;
}

Measured memory_bytes: 3596
# C - Grand Garden

N = int(input())
h = list(int(x) for x in input().split())

ans = 0
for i in range(N):
    while True:
        if h[i] == 0:
            break
        ans += 1
        for j in range(i, N):
            if h[j] == 0:
                break
            h[j] -= 1
        
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <limits.h>

using namespace std;

int main() {
	int n, nextNum, max = INT_MIN, preMin = INT_MAX;
	cin >> n;
	

	for (int i = 0; i < n; i++)
	{
		cin >> nextNum;
		if (nextNum - preMin > max) {
			max = nextNum - preMin;
		}
		if (nextNum < preMin) preMin = nextNum;
	}

	

	cout << max << endl;
	return 0;
}

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

main()
{
    string s,s1,t;
    cin>>s>>s1;
    int ok=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=s1[i])
        {
            ok=1;
            break;
        }
    }
    if(ok==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3628
n = int(input())
a = [int(_) for _ in input().split()]
b = [0 for i in range(n+1)]

for i in reversed(range(n)):
    b[i] += a[i]+b[i+1]

ans = 0

MOD = 10**9+7

for i in range(n-1):
    ans = (ans+a[i]*b[i+1]) % MOD

# print(a, b)

print(ans)


Measured memory_bytes: 31756
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233;
int n;char s[N];
char s1[N],s2[N];int t1,t2,f[22][22];
int main() {
	read(n);scanf("%s",s+1);ll res=0;
	rep(S,0,(1<<n)-1){
		t1=0;t2=0;
		rep(i,1,n)if((S>>i-1)&1)s1[++t1]=s[i];else s2[++t2]=s[i];
		memset(f,0,sizeof(f));f[0][0]=1;
		rep(i,0,t1)rep(j,0,t2)if(i+j){
			char c=s[n+n-(i+j)+1];
			f[i][j]=(s2[j]==c?f[i][j-1]:0)+(s1[i]==c?f[i-1][j]:0);
		}
		res+=f[t1][t2];
	}
	cout<<res;
	return 0;
}


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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  string s;
  cin >> s;
  string ans;
  ans+=s[0];
  int len=s.size();
  if(len>10) ans+=char((len-2)/10+'0');
  ans+=char((len-2)%10+'0');
  ans+=s[s.size()-1];
  print(ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    cin >> N;
    string s;
    switch(N%10){
        case 0:
        case 1:
        case 6:
        case 8:
            s = "pon";
            break;
        
        case 3:
            s = "bon";
            break;
            
        default:
            s = "hon";
    }
    
    cout << s << endl;
}

Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    int[] p = new int[n];
    int[] q = new int[n];
    int[] route = new int[n];

    for (int i = 0; i < n; i++) {
      p[i] = sc.nextInt();
      route[i] = i + 1;
    }

    for (int i = 0; i < n; i++) {
      q[i] = sc.nextInt();
    }

    boolean pok = false;
    boolean qok = false;
    int cnt = 0;
    int porder = 0;
    int qorder = 0;

    do {
      cnt++;
      if (Arrays.equals(p, route)) {
        pok = true;
        porder = cnt;
      }

      if (Arrays.equals(q, route)) {
        qok = true;
        qorder = cnt;
      }

      if (pok && qok) {
        break;
      }
    } while ((route = nextPermutation(route)) != null);

    System.out.println(Math.abs(porder - qorder));

  }

  static int[] nextPermutation(int[] array) {
    int i = Integer.MAX_VALUE;
    int j = 0;
    int[] returnarray = new int[array.length];

    for (int l = array.length - 2; l >= 0; l--) {
      if (array[l] < array[l + 1]) {
        i = l;
        break;
      }
    }

    if (i == Integer.MAX_VALUE) {
      return null;
    }

    for (int l = array.length - 1; l >= 0; l--) {
      if (array[i] < array[l]) {
        j = l;
        break;
      }
    }

    int temp = array[i];
    array[i] = array[j];
    array[j] = temp;
    i++;

    for (int l = 0; l < i; l++) {
      returnarray[l] = array[l];
    }
    for (int l = 0; l < array.length - i; l++) {
      returnarray[l + i] = array[array.length - l - 1];
    }

    return returnarray;

  }

}

Measured memory_bytes: 26068
/**
*    created: 10.07.2020 16:57:24
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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 long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n; cin >> n;
    int ans = 0;
    ans += (n / 11) * 2;
    int r = n % 11;
    if (r != 0) {
        if (r <= 6) ans++;
        else ans += 2;
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val s = sc.next
  val t = sc.next

  val res =
    (if(s(0) == t(0)) 1 else 0) +
      (if(s(1) == t(1)) 1 else 0) +
      (if(s(2) == t(2)) 1 else 0)

  println(res)
}

Measured memory_bytes: 27332
from itertools import accumulate


N,Q = list(map(int,input().split()))
S = input()
A = [list(map(int,input().split())) for i in range(Q)]

flg = []
for i in range(N-1):
    tmp_s = S[i:i+2]
    if tmp_s == 'AC':
        flg.append(1)
    else:
        flg.append(0)

flg2 = [0] + flg
flg2 = list(accumulate(flg2))

for a in A:
    print(flg2[a[1]-1] - flg2[a[0]-1])

Measured memory_bytes: 33176
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
	map<ll, int>mp;
	int N;
	cin >> N;
	vector<ll>v;
	for (int i = 0; i < N; i++) {
		ll tmp;
		cin >> tmp;
			v.push_back(tmp);
	}
	sort(v.begin(), v.end());
	int cnt = 0;
	for (int i = 0; i < v.size(); i++)
		for (int j = i + 1; j < v.size(); j++)
			for (int k = j + 1; k < v.size(); k++)
			{
				if (v[i] == v[j] || v[j] == v[k] || v[i] == v[k])continue;
				if (v[i] + v[j]  > v[k]) {
					cnt += 1;
				}
			}
	cout << cnt;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

 int a,b,c,d;
 cin>>a>>b>>c>>d;
  float r1=float(c)/float(b);
  float r2=float(a)/float(d);

  if(ceil(r1)<=ceil(r2))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {

	final static int MAX = 24 * 60 * 60;

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

		while (true) {
			final int n = sc.nextInt();

			if (n == 0) {
				break;
			}
			
			int[] count = new int[MAX];
			int	max = 0;
			
			for (int i = 0; i < n; i++) {
				String[] st = sc.next().split(":");
				String[] en = sc.next().split(":");

				final int start = Integer.parseInt(st[0]) * 60 * 60
						+ Integer.parseInt(st[1]) * 60
						+ Integer.parseInt(st[2]);
				final int end = Integer.parseInt(en[0]) * 60 * 60
						+ Integer.parseInt(en[1]) * 60
						+ Integer.parseInt(en[2]);
				
				for(int j = start; j < end; j++){
					count[j]++;
					max = Math.max(max, count[j]);
				}
			}
			
			System.out.println(max);

		}

	}

}

Measured memory_bytes: 17000
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int x;

bool isp(int x)
{
  for(int i=2;i*i<=x;i++) if(x%i==0) return false;
  return true;
}

int main()
{
  cin>>x;
  for(int i=2;;i++)
  {
    if(isp(i)&&i>=x)
    {
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}

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

using namespace std;

using ll = long long;

mt19937 mt(736);


template<class T>
T remax(T &x, const T &y)
{
	return x = max(x, y);
}


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	vector<pair<int, int>> arr(n);

	for (auto &it : arr)
		cin >> it.first >> it.second;

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

	vector<bool> bad(n);

	int lp = numeric_limits<int>::min();

	for (int i = 0; i < bad.size(); i++)
		if (arr[i].first - arr[i].second <= lp)
			bad[i] = true;
		else
			lp = arr[i].first - arr[i].second;

	lp = numeric_limits<int>::max();

	for (int i = (int) bad.size() - 1; i >= 0; i--)
		if (arr[i].first + arr[i].second >= lp)
			bad[i] = true;
		else
			lp = arr[i].first + arr[i].second;

	typeof(arr) tmp;

	for (int i = 0; i < arr.size(); i++)
		if (!bad[i])
			tmp.push_back(arr[i]);

	swap(tmp, arr);
	tmp.clear();

	for (int i = 1; i < arr.size(); i++)
		assert(arr[i - 1].first - arr[i - 1].second < arr[i].first - arr[i].second);

	vector<int> jmp(arr.size());

	for (int i = 0; i < jmp.size(); i++)
	{
		int l = i, r = jmp.size();

		while (l + 1 < r)
		{
			auto t = (l + r) / 2;

			if (arr[t].first - arr[t].second < arr[i].first + arr[i].second)
				l = t;
			else
				r = t;
		}

		jmp[i] = r;
	}

	vector<int> dp(arr.size() + 1, -1);
	dp[0] = 0;

	for (int i = 0; i < jmp.size(); i++)
	{
		remax(dp[i + 1], dp[i]);
		remax(dp[jmp[i]], dp[i] + 1);
	}

	cout << dp.back() << endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");

	solve(fin);

	cout << "clock: " << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , y ;
  cin >> n >> y ;
  int a = -1 ;
  int b = -1 ;
  int c = -1 ;
  
  rep(i,n){
   for(int j=0; n-i-j >= 0; j++){
      int h = n - i - j ;
      if(10000*i + 5000*j + 1000*h == y ){
         a = i ;
         b = j ; 
         c = h ;
         break; 
      }
    }
  }
  
  cout << a << " " << b << " " << c << " " ;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int n,pos;
char S[100005];
int Ans[100005];
int main() {
	scanf("%s",S),n=strlen(S);
	for(int i=0; i<n; ++i)
		if(S[i]=='R')pos=i;
		else {
			if((i-pos)%2)++Ans[pos+1];
			else ++Ans[pos];
		}
	for(int i=n-1; i>=0; --i)
		if(S[i]=='L')pos=i;
		else {
			if((pos-i)%2)++Ans[pos-1];
			else ++Ans[pos];
		}
	for(int i=0; i<n; ++i)printf("%d ",Ans[i]);
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, A, B;
	in >> N >> A >> B;
	out << std::min(A * N, B) << std::endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Educational DP Contest / DP まとめコンテスト
//A - Frog 1
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int h[] = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		int[] dp = new int[N + 2];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		for (int i = 0; i < N; i++) {
			if (i > 1) {
				dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i - 2] - h[i]));
			}
			if (i > 0) {
				dp[i] = Math.min(dp[i], dp[i-1] + Math.abs(h[i - 1] - h[i]));
			}
		}

		System.out.println(dp[N-1]);
	}
}


Measured memory_bytes: 47080
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = il()
    print('Yes' if (A * B) % 2 != 0 else 'No')


if __name__ == '__main__':
    main()


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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, K;
  cin >> N >> K;
  vector<P> v;
  for (int i = 0; i < N; i++) {
    int t, d;
    cin >> t >> d;
    v.push_back({d, t});
  }

  sort(ALL(v));
  reverse(ALL(v));

  int ans = 0, sum = 0;
  vector<int> cont(101010, 0);
  set<int> s;
  priority_queue<P, vector<P>, greater<P>> que;

  for (int i = 0; i < K; i++) cont[v[i].second]++;

  for (int i = 0; i < K; i++) {
    s.insert(v[i].second);
    if (cont[v[i].second] >= 2) que.push(v[i]);
    sum += v[i].first;
  }
  ans = sum + s.size() * s.size();

  for (int i = K; i < N && !que.empty(); i++) {
    if (!EXIST(s, v[i].second)) {
      P p = que.top();
      que.pop();

      s.insert(v[i].second);

      sum += v[i].first - p.first;
      int tmp = sum + s.size() * s.size();
      chmax(ans, tmp);
    }
  }

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


Measured memory_bytes: 6512
S = input()

if S[0] == "A":
    count = S[2:-1].count("C")
    if count == 1:
        S = S.replace("A", "").replace("C", "")
        if S.islower():

            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 2940
import sys


def input():
    return sys.stdin.readline().strip()


n = int(input())
ABC = [list(map(int, input().split())) for i in range(n)]

# i日目にjを選択した後の幸福度 dp[i][j]
dp = [[0 for j in range(3)] for i in range(n + 1)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + ABC[i][k])

print(max(dp[-1]))


Measured memory_bytes: 47324
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DKnapsack1 solver = new DKnapsack1();
        solver.solve(1, in, out);
        out.close();
    }

    static class DKnapsack1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int w = in.nextInt();
            long weights[] = new long[n + 1];
            long values[] = new long[n + 1];
            for (int i = 1; i <= n; i++) {
                weights[i] = in.nextInt();
                values[i] = in.nextInt();
            }

            long dp[][] = new long[n + 1][w + 1];
            for (int i = 0; i <= w; i++)
                dp[0][i] = 0;
            for (int i = 0; i <= n; i++)
                dp[i][0] = 0;

            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= w; j++) {
                    dp[i][j] = dp[i - 1][j];
                    if (j - weights[i] >= 0) {
                        dp[i][j] = Math.max(dp[i][j], dp[i - 1][(int) (j - weights[i])] + values[i]);
                    }
                }
            }

            out.println(dp[n][w]);

        }

    }
}



Measured memory_bytes: 126932
<?php
    fscanf(STDIN,"%d", $r);
    if($r < 1200){
      echo 'ABC';
    }elseif($r < 2800){
      echo 'ARC';
    }else{
      echo 'AGC';
    }
    // switch($r){
    //   case $r < 1200:
    //   echo 'ABC';
    //   break;
    //   case $r < 2800 && $r >= 1200:
    //   echo 'ARC';
    //   break;
    //   case $r <= 4208 && $r >= 2800:
    //   echo 'AGC';
    //   break;
    // }
  ?>

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

int main(){

    int n;
    cin>>n;

    int x=0,y=0;
    long long t=0;
    for(int i=0;i<n;i++){
        long long tt;
        int xx,yy;
        cin>>tt>>xx>>yy;

        int d=abs(x-xx)+abs(y-yy);
        //cout<<d<<" "<<tt-t<<endl;
        if(tt-t<d || (d-(tt-t))%2){
            cout<<"No"<<endl;
            return 0;
        }

    }

    cout<<"Yes"<<endl;

	return 0;
}


Measured memory_bytes: 256
#![allow(unused)]

use std::cmp::{min, max};

macro_rules! dbg {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Scanner<'a, R> {
        Scanner { reader: reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let s: Vec<char> = sc.get_str().chars().collect();
    let l: Vec<char> = sc.get_str().chars().collect();

    let mut dp = vec![vec![0; l.len() + 1]; s.len() + 1];

    for i in 1..(s.len() + 1) {
        for j in 1..(l.len() + 1) {
            dp[i][j] = *[
                if s[i - 1] == l[j - 1] { dp[i - 1][j - 1] + 1 } else { 0 },
                dp[i - 1][j],
                dp[i][j - 1],
            ].iter().max().unwrap();
        }
    }

    let mut i = s.len();
    let mut j = l.len();
    let mut lcs = vec![];
    while i > 0 || j > 0 {
        if i > 0 && dp[i - 1][j] == dp[i][j] {
            i -= 1;
        } else if j > 0 && dp[i][j - 1] == dp[i][j] {
            j -= 1;
        } else {
            lcs.push(s[i - 1]);
            i -= 1;
            j -= 1;
        }
    }

    println!("{}", lcs.into_iter().rev().collect::<String>());
}

Measured memory_bytes: 41212
#include<bits/stdc++.h>
using namespace std;
int main(){int A,B,c;cin>>A>>B;
           c=B/100-A/100;
if(A%100>A/1000%10*10+A/10000)c--;
if(B%100>=B/1000%10*10+B/10000)c++;
 cout<<c<<endl;}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a<10 && a>0 && b<10 && b>0){
			System.out.println(a*b);
		}else{
			System.out.println(-1);
		}
	}
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

ll cal(vector<ll>& A, int sign)
{
  int n = A.size();
  ll ret = 0, diff = 0;
  for (int i = 0, s = sign; i < n; ++i, s *= -1) {
    ll val = A[i] + diff;
    if (s < 0) {
      if (val < 0) { continue; }
      ret += val + 1;
      diff -= (val + 1);
    }
    else if (s > 0) {
      if (val > 0) { continue; }
      ret += abs(val) + 1;
      diff += abs(val) + 1;
    }
  }

  return ret;
}

int main()
{
  int N; scanf("%d", &N);
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &A[i]);
  }
  for (int i = 1; i < N; ++i) {
    A[i] += A[i - 1];
  }

  ll ans = min(cal(A, 1), cal(A, -1));
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024