akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
int main(){
    lint l,r;
    lint result = 2000000000;
    cin>>l>>r;
    for(lint i=l;i<r;i++){
        for(lint j=l+1;j<=r;j++){
            result = min(result,i*j%2019);
            if(result==0){
                break;
            }
        }
        if(result==0){
            break;
        }
    }
    if(result < 2000000000){
        cout<<result;
    }
    else{
        cout<<l*r;
    }
}

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

int main()
{
  ll n,k;
  cin>>n>>k;
  vector<ll> arr(n),dp(n,INT_MAX);
  for(int i=0;i<n;i++)
    cin>>arr[i];

  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    int count=0;
    for(int j=i-1;j>=0&&count<k;j--)
    {
      dp[i]=min(dp[i],abs(arr[i]-arr[j])+dp[j]);
      count++;
    }
  }
  cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 4844
#include <iostream>
#include <string>
using namespace std;
typedef long long i64;
const int MAXN = 400 + 5;
const int MOD = 1e9 + 7;

int n, c;
i64 powSum[MAXN][MAXN];
i64 A[MAXN], B[MAXN];
i64 DP[MAXN][MAXN];

i64 fastPow(i64 base, i64 exp)
{
    i64 ans = 1;
    while(exp)
    {
        if(exp & 1)
            ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        exp >>= 1;
    }
    return ans;
}

void Init()
{
    for(int i = 1; i <= 400; i++)
        for(int j = 0; j <= 400; j++)
            powSum[i][j] = fastPow(i, j);
    for(int j = 0; j <= 400; j++)
        for(int i = 0; i <= 400; i++)
            powSum[i][j] = (powSum[i][j] + powSum[i-1][j]) % MOD;
}

int main()
{
    Init();

    cin >> n >> c;
    for(int i = 1; i <= n; i++)
        cin >> A[i];
    for(int i = 1; i <= n; i++)
        cin >> B[i];

    DP[0][0] = 1;
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= c; j++)
            for(int k = 0; k <= j; k++)
            {
                DP[i][j] += (DP[i-1][j-k] * (powSum[B[i]][k] - powSum[A[i]-1][k])) % MOD;
                DP[i][j] %= MOD;
            }

    cout << (DP[n][c] + MOD) % MOD << endl ;
    return 0;
}


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


def answer(H: int, N: int, A: list) -> str:
    damage = 0                          
    for i in range(0, N):               
        damage += int(A[i])             
                                        
        i += 1                          
    if damage < H:
        return 'No'
    else:
        return 'Yes'

print(answer(H, N, A))

Measured memory_bytes: 20600
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

cnt = sorted(list(Counter(A).values()), reverse=True)
print(sum(cnt[K:]))


Measured memory_bytes: 31932
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author Nikunj
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        OddString solver = new OddString();
        solver.solve(1, in, out);
        out.close();
    }

    static class OddString {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            String s = in.scanString();
            for (int i = 0; i < s.length(); i += 2) {
                out.print(s.charAt(i));
            }
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public String scanString() {
            int c = scan();
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



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

const ll mod = ll(1e9) + 7;
const int INF = 1<<29;
const ll lINF = 1l<<40;

int main(){
    int n;
    cin >> n;
    map<ll,ll> a;
    rep(i,n){
        ll x;
        cin >> x;
        a[x] += 1;
    }
    ll ans = 0;
    for (auto x:a){
        if (x.second-x.first==0) continue;
        else if (x.second-x.first<0) ans += x.second;
        else ans += x.second - x.first;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6272
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
const int INF = 1e9;
const int MOD = 1e9+7;


#define lint long long
const lint LINF = 1e18;

using namespace std;
lint n,m;
lint ans;
int main(){
  cin >> n >> m;
  if(n==1) ans = max((lint)0,m-2);
  if(m==1) ans = max(ans,n-2);
  if(n!=1&&m!=1) ans = (n-2)*(m-2);
  if(n==1&&m==1) ans = 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1005;
const int mod=1e9+7;

char g[N][N];
int R,C,a,b,c,d,dis[N][N];
bool outrange(int i,int j){
    if(i<=0 or j<=0 or i>R or j>C) return 1;
    if(g[i][j]=='#') return 1;
    return 0;
}
int bfs(int i,int j){
    set<vector<int>>s;
    s.insert({0,i,j});
    rep(i,1,R) rep(j,1,C) dis[i][j]=1e9;
    dis[i][j]=0;
    while(!s.empty()){
        auto v=*s.begin();
        i=v[1],j=v[2];
        s.erase(s.begin());
        rep(u,-2,2) rep(k,-2,2){
            if(outrange(i+u,j+k)) continue;
            int t=1;
            if(abs(u)+abs(k)==1) t=0;
            if(dis[i+u][j+k]>v[0]+t){
                s.erase({dis[i+u][j+k],i+u,j+k});
                dis[i+u][j+k]=v[0]+t;
                s.insert({v[0]+t,i+u,j+k});
            }
        }
    }
    return dis[c][d]==1e9?-1:dis[c][d];
}
signed main(){
    FastIO;
    cin>>R>>C>>a>>b>>c>>d;
    rep(i,1,R) rep(j,1,C) cin>>g[i][j];
    cout<<bfs(a,b);
    return 0;
}


Measured memory_bytes: 8780
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)




int main() {
  string S;
  cin >> S;
  if(S=="RRR") cout << 3 << endl;
  else if(S=="SRR") cout << 2 << endl;
  else if(S=="RRS") cout << 2 << endl;
  else if(S=="SSS") cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int n;
int a;
int ma=0;
int mi=1000;
int ans;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(ma<a){
			ma=a;
		}
		if(mi>a){
			mi=a;
		}
	}
	ans=ma-mi;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  for (int i = 0; i < N; i++){
    cin >> p[i];
    p[i]--;
  }
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    E[x].push_back(y);
    E[y].push_back(x);
  }
  vector<bool> used(N, false);
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (!used[i]){
      used[i] = true;
      set<int> pos;
      pos.insert(i);
      queue<int> Q;
      Q.push(i);
      while (!Q.empty()){
        int v = Q.front();
        Q.pop();
        for (int w : E[v]){
          if (!used[w]){
            used[w] = true;
            pos.insert(w);
            Q.push(w);
          }
        }
      }
      for (int x : pos){
        if (pos.count(p[x])){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 10752
using System;

class Program {
    static void Main (string[] args) {
        int N = int.Parse (Console.ReadLine ());
        string[] input = Console.ReadLine ().Split (' ');
        int[] A = new int[N];
        long step = 0;
        for (int i = 0; i < N; i++) {
            A[i] = int.Parse (input[i]);
            if (i > 0) {
                if (A[i] < A[i - 1]) {
                    step += (A[i - 1] - A[i]);
                    A[i] += (A[i - 1] - A[i]);
                }
            }
        }
        //出力
        Console.WriteLine (step);
    }
}

Measured memory_bytes: 46404
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N, M;
    cin >> N >> M;
    vector<vi> pay(M);
    rep(i, N) {
        int day, money;
        cin >> day >> money;
        if (M - day >= 0)pay[M - day].push_back(money);
    }
    ll ans = 0;
    multiset<int> kouho;
    for (int i = M - 1; i >= 0; --i) {
        each(p, pay[i])kouho.insert(p);

        if (!kouho.empty()) {
            auto it = kouho.end();
            --it;
            ans += *it;
            kouho.erase(it);
        }
    }
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 7808
#include<stdio.h>

int main(){
  int a,b,remainder,tmp;
  

  scanf("%d%d",&a,&b);

  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }

  remainder=a%b;

  while(remainder!=0){
    a=b;
    b=remainder;
    remainder=a%b;
  }

  printf("%d\n",b);
  
return 0;
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll cnt=0;
    rep(i,n){
        while(a[i]%2==0){
            a[i]/=2;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long
#define ull unsigned long long
//#define mod int(1e9+7)
#define endl '\n'
#define Engz ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi double(acos(-1))
#define S second
#define F first

//  freopen("input.txt","r",stdin);

//------------------- BESH ----------------------//
long long mod ;
long long p(long long a ,long long b)
{
    if(b==0)
        return 1;

    long long z=p(a,b/2);


    if(b%2==0)return ((z%mod)*(z%mod))%mod; else return (((z*z)%mod)*a)%mod;
}

long long g(long long a, long long b)
{
    if(a==0)
        return b;
    else return g(b%a , a);
}

//-----------sieve --------------------//

bool prime[1000001];

void sieve()
{
memset(prime , true , sizeof prime);
prime[0]=prime[1]=0;

for(int i=2 ; i*i<=1000000; i++)
{
    if(prime[i]==true)
    for(int j=i*i ; j<=100000 ; j+=i)
    prime[j]=false;
}
}

ll lcm(ll a, ll b)
{
    return (a*b)/__gcd(a,b);
}


//int a[1002][1002]={{}};
   int a[100005][3];
   int ans[100005][3];
int main()
{

    int n;
    cin>>n;

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


    for(int i=0 ; i<3 ; i++)
        ans[0][i]=a[0][i];


    for(int i=1 ; i<n ; i++)
    {

        for(int j=0 ;j<3 ; j++)
        {
            int mx=0;
            for(int k=0; k<3 ; k++)
            {
                if(j==k)
                    continue;

                mx=max(mx, ans[i-1][k]);
            }
            ans[i][j]=mx+a[i][j];
        }
    }

    int res=0;
    for(int i=0; i<3 ; i++)
        res=max(res, ans[n-1][i]);
    cout<<res;


	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){

  int N,K;

  scanf("%d %d",&K,&N);

  
  int A[N];
  int i;
  for(i=0;i<N;i++){
   scanf("%d",&A[i]);
   }
  
   int len[N];
  for(i=0;i<N-1;i++){
     len[i] = -A[i] + A[i+1];
  }
   len[N-1] = K - A[N-1] + A[0];
   qsort(len,N,sizeof(int),compare_int);
  printf("%d",K-len[N-1]);







 return(0);
 }


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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ld dp[302][302][302];
int n;
ld rec(int i,int j,int k){
	if(i<0 || j<0 || k<0)
		return 0;
	if(i==0 && j==0 && k==0)
		return 0;
	if(dp[i][j][k]>0)
		return dp[i][j][k];
	ld x=i+j+k;
	dp[i][j][k]=i*rec(i-1,j,k) + j*rec(i+1,j-1,k) + k*rec(i,j+1,k-1) +(ld)(n);
	dp[i][j][k]/=x;
	return dp[i][j][k];
}

void solve(){
	cin>>n;
	int a;
	int one=0,two=0,three=0;
	fr(i,0,n){
		cin>>a;
		if(a==1)
			one++;
		else if(a==2)
			two++;
		else if(a==3)
			three++;
	}
	cout<<fixed<<setprecision(12)<<rec(one,two,three)<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 213388
#include <stdio.h>
int main()
{
  int n,i,j,z,v,k,m[101][101];
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      m[i][j]=0;
    }
  }
  for(i=0;i<n;i++)
    {
      scanf("%d %d",&v,&z);
      v--;
      for(j=0;j<z;j++)
	{
	  scanf("%d",&k);
	  k--;
	  m[v][k]=1;
	}
    }
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  if(j)
	    printf(" ");
	  printf("%d",m[i][j]);
	}
      printf("\n");
    }
}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    ld x,jpy=0,btc=0;
    string s;
    rep(i,n){
        cin>>x>>s;
        if(s=="JPY") jpy+=x;
        else btc+=x;
    }
    cout<<fixed<<setprecision(8)<<jpy+btc*380000;
}

Measured memory_bytes: 3792
using System;

    class ABC116B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int s = int.Parse(Console.ReadLine());
            int a = s;
            int[] x = new int[10000];
            int m = 0;
            for(int i = 0; i < 10000; i++)
            {
                x[i] = 0;
            }
            x[a] = 1;

            for (int i = 2; i < 1000000; i++)
            {
                if(a%2 == 0)
                {
                    a /= 2;
                }
                else
                {
                    a = 3 * a + 1;
                }
                if(x[a] != 1)
                    x[a] = 1;
                else
                {
                    m = i;
                    break;
                }
            }

            Console.WriteLine(m);
        }
    }


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll K; cin >> K;
    ll A, B; cin >> A >> B;
    if (A/K == B/K && A%K && B%K) {
        cout << "NG" << endl;
    }
    else {
        cout << "OK" << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
from bisect import bisect_left

N = int(input())
a = tuple(sorted(map(int, input().split())))

cnt = bisect_left(a, 0)  # 正の開始点==負の個数

if cnt <= 1:
    print(sum(a) - 2 * a[0])
    t = a[0]
    for i in range(1, N - 1):
        print(t, a[i])
        t -= a[i]
    print(a[-1], t)

else:
    # cnt-1個は正最大に連結
    if cnt == N:
        print(sum(map(abs, a)) + 2 * a[-1])
        t = a[-1]
        for i in range(N - 1):
            print(t, a[i])
            t -= a[i]

    else:
        print(sum(map(abs, a)))
        t = a[-1]
        for i in range(cnt - 1):
            print(t, a[i])
            t -= a[i]
        s = a[cnt - 1]
        for i in range(cnt, N - 1):
            print(s, a[i])
            s -= a[i]
        print(t, s)


Measured memory_bytes: 63500
N = gets.to_i
arr =  Array.new(){ Array.new() }
score = Array.new(N) { |i| i=0 }

while (line = gets) do
  arr << line.split.map(&:to_i)
end
arr = arr.transpose

arr.each_with_index { |a,n| a.each_with_index { |num, i| a.delete_at(i);  score[i] += num if !a.index(num); a.insert(i, num) }}
puts score

Measured memory_bytes: 8704
M[100][200],Z=100,l=100000;main(i,j){
for(M[0][0]=M[0][0+Z]=M[1][1+Z]=M[1][1+Z]=j=1;j<Z;j++)M[0][j+Z]=M[0][j-1+Z];
for(;i<Z;i++)for(M[i][0]=M[i-1][0],j=1;j<Z;j++)M[i][j]=(M[i-1][j]+M[i-1][j-1+Z])%l,M[i][j+Z]=(M[i][j-1+Z]+M[i-1][j-1])%l;
for(;scanf("%d%d",&i,&j),i;)printf("%d\n",(M[i-1][j-1]+M[i-1][j-1+Z])%l);exit(0);}

Measured memory_bytes: 676
def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if i == n: return n
    return i

def solve():
    left, right = 0, 100000*10000
    while right - left > 1:
        mid = (left + right) / 2
        v = check(mid)
        if v >= n: right = mid
        else: left = mid
    return right

if __name__ == '__main__':
    T = []
    n, k = [int(x) for x in input().split()]
    for i in range(n): T.append(int(input()))    
    print(int(solve()))


Measured memory_bytes: 9560
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define ld double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-22
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int n, m;
ll x[100010], y[100010], sX[100010], sY[100010];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> m;
    FOR(i,1,n) cin >> x[i];
    FOR(i,1,m) cin >> y[i];
    ll resX = 0, resY = 0;
    FOR(i,1,n) sX[i] = sX[i-1] + x[i];
    FOR(i,1,m) sY[i] = sY[i-1] + y[i];
    FOR(i,2,n) {
        ll g = x[i] * (i-1);
        ll h = sX[i-1];
        //cout << g << " " << h << endl;
        resX = (resX + (g - h) % base) % base;
    }
    FOR(i,2,m) {
        ll g = y[i] * (i-1);
        ll h = sY[i-1];
        resY = (resY + (g - h) % base) % base;
    }
    cout << resX * resY % base;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define F(i,n) for(long long int i=0;i<n;i++)
#define REF(i,a,b) for(int i=a;i<=b;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ln "\n"
#define milli 1000000
#define M 1000000007
#define fastio ios::sync_with_stdio(0);cin.tie(0);



int main()
{
    fast;
    fastio;
    ll n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
        cout<<t*(n/x)<<ln;
    else
    {
        cout<<t*(n/x+1)<<ln;
    }
}


Measured memory_bytes: 3608
{
  const Main = input => {
    const [a,b,c,d] = input.split(" ").map(v => parseInt(v))
    const start = a < c ? c : a
    const end = b < d ? b : d


    if (end <= start) {
      console.log(0)
    } else {
      console.log(end - start)
    }
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


Measured memory_bytes: 29588
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
//↓,→,↑,←


#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/
struct Timer {
    int64_t start;
    const int64_t CYCLES_PER_SEC = 2800000000;
    Timer() { reset(); }
    void reset() { start = getCycle(); }
    inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
    inline int64_t getCycle() {
        uint32_t low, high;
        __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
        return ((int64_t)low) | ((int64_t)high << 32);
    }
};


bool multicase = false;

ll n, m, k, w, num, a, b, c, d, e, h, q, ans, sum, l;

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

void solve(){
	string s;
    cin >> s;
    n = s.size();
    ll cnt = 0;
    ll ans = 0;
    for(int i=0;i<n;i++){
        if (s[i] == 'R') cnt ++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    p(ans);
    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}



Measured memory_bytes: 3620
def frog(l,n):
  dp=[0]*n
  dp[0]=0
  dp[1]=abs(l[1]-l[0])
  for i in range(2,n):
    dp[i]=min(dp[i-1]+ abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))
  return dp[n-1]
n=int(input())
l=list(map(int,input().split()))
print(frog(l,n))

Measured memory_bytes: 13928
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;

int n,a[N];

int main() {
    n=read();
    for (re int i=1;i<=n;++i) a[i]=read();
    sort(a+1,a+n+1,greater<int>());
    for (re int i=1;i<=n;++i) {
        if (i+1>a[i+1]) {
            int u=a[i]-i,r=0;
            while (i+r<n&&a[i+r+1]==i) ++r;
            if ((u&1)||(r&1)) puts("First");
            else puts("Second");
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }return 0; }
#define all(a)  (a).begin(),(a).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;

int main(){
  ll N; cin >>N ;
  vector<long long int> dp(N+1) ;
  dp[0] =0;
  FOR(i,1,N+1){
    dp[i] = INF;
    chmin(dp[i],dp[i-1]+1) ;
    ll S=6;
    while(S<= i){
      chmin(dp[i],dp[i-S]+1) ;
      S *=6;
    }
    ll T=9;
    while(T<=i){
      chmin(dp[i],dp[i-T]+1) ;
      T *=9;
    }
  }
  cout << dp[N] << endl;
}
  

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

int main() {
    ll n,i,l; cin>>n; set<ll>a;
    for(i=0;i<n;i++) {cin>>l; a.insert(l);}
    if (n==a.size()) {cout<<"YES";} 
    else {cout<<"NO";}
	return 0;
}

Measured memory_bytes: 12944
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<climits>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define F first
#define S second
#define MIN INT_MIN
using namespace std;
typedef pair<int,int> P;
 int dp[55][55][10][10];

  int info[55][3];
int main(){
  int n,m;
  cin >> n >> m;

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


 
  rep(i,55)rep(j,55)rep(k,10)rep(l,10)dp[i][j][k][l] = MIN;
  rep(i,m+2)dp[0][m-i][i][0] = 0;

  rep(i,n){
    rep(j,m+1){//のこり
      rep(k,9){//今
	rep(l,9){//５分前
	  if(j+k+l > m)break;
	  if(dp[i][j][k][l] == MIN )continue;
	  int isol = l;

	  int mex = info[i][2];
	 
	  rep(x,k+1){
	    rep(y,isol+1){
	      if(x+y > 8)break;
	      if(x == 0 && y == 0)continue;
	      mex = max(mex,info[i][0]*x+info[i][1]*y);
	    }
	  }
	  
	  rep(z,j+1){
	    dp[i+1][j-z][z][k] = max(dp[i+1][j-z][z][k],dp[i][j][k][l]+mex);
	  }
	}
      }
    }
  }
  int ans = MIN;
  rep(i,m+1){
    rep(j,9){
      rep(k,9){
	if(j+k > 8)continue;
	ans = max(ans,dp[n][i][j][k]);
      }
    }
  }
  cout << ans << endl;

return 0;
}

Measured memory_bytes: 2344
N, K = map(int, input().split())
count = 0
sunuke = [0 for _ in range(N)]
for _ in range(K):
    d = int(input())
    if d == 1:
        A = [int(input())]
    else:
        A = list(map(int, input().split()))
    for s in A:
        if sunuke[s-1] == 0:
            sunuke[s-1] = 1
            count += 1
print(N-count)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
  int N;

  cin >> N;

  vector<int64_t> H(N);
  for (int i = 0; i < N;i++){
    cin >> H.at(i);
  }

  int64_t memo = 0;
  int64_t count = 0;

  for (int i = 0; i < N;i++){
    if(memo<=H.at(i)){
      memo = H.at(i);
    }
    else{
      if(memo-H.at(i)>=2){
        count = 1;
        cout << "No" << endl;
        break;
      }
    }
  }

  if(count==0){
    cout << "Yes" << endl;
  }

  /* if(N>=3){
    for (int i = 0; i < N - 2; i++)
    {
      if (H.at(i) <= H.at(i + 1) && H.at(i + 1) <= H.at(i + 2))
      {
        H.at(i + 1)--;
      }
      else
      {
        if (H.at(i) <= H.at(i + 1) - 1 && H.at(i + 1) - 1 <= H.at(i + 2))
        {
          H.at(i + 1)--;
        }
        else if (H.at(i)-1 <= H.at(i + 1) ){
          H.at(i)--;
        }
        else
        {
          memo = 1;
          cout << "No" << endl;
          break;
          }
      }
    }

    if (memo == 0)
    {
      cout << "Yes" << endl;
    }
  }

  else if(N==2){
    if(H.at(0)-H.at(1)>1){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }

  else{
    cout << "Yes" << endl;
  }*/
}

Measured memory_bytes: 1024
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    string s,t;
    cin>>s>>t;
    
    
    int x=s.length();
    
    
    for(int i=0;i<x;i++){
        int b=0;
        for(int g=0;g<x;g++){
            if(g+i<x){
                if(t[i+g]!=s[g]){
                    b=1;
                    break;
                    
                }
            }else{
                if(t[i+g-x]!=s[g]){
                    b=1;
                    break;
                }
                
            }
            
        }
        if(b==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    
    cout<<"No"<<endl;
        
        
        
    
   
    return 0;
}








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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  int N;
  while(1){
    int ans = 0;
    cin>>N;
    if(N == 0) break;
    REP(i,1,N){
      int num = 0;
      REP(diff,0,N){
        num += (i + diff);
        if(num == N){
          ans++;
          break;
        }
        if(num > N){
          break;
        }
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x_) cerr << #x_ << ":" << x_ << endl;
#define debug2(x__) for(auto a__ : x__) cerr << a__ << " "; cerr << endl;
#define debug3(x___ , sx___) rep(i, sx___) cerr << x___[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

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

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    set<ll> st;
    for (ll i = 1; i < sqrt(m) + 2; i++) {
        if (m % i == 0) {
            st.insert(i);
            st.insert(m / i);
        }
    }
    ll ans = 1;
    for (auto a : st) {
        if (a * n <= m) ans = max(ans, a);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main() {
  string text_T;
  string string_P;

  cin >> text_T;
  cin >> string_P;

  int currIdx;
  int count;
  for (int i=0; i<text_T.length(); i++) {
    currIdx = i;
    count = 0;
    for(int o=0; o<string_P.length(); o++) {
      if(text_T[currIdx] == string_P[o]) {
        if(count == (string_P.length() - 1)) {
          cout << currIdx - (string_P.length() - 1) << "\n";
        }else {
          currIdx++;
          count++;
        }
      }else {
        break;
      }
    }
  }

  return 0;
}



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

int main(void){
   int N;
   cin>>N;
   vector<int> h(N);
   for(int i=0;i<N;i++){
       cin>>h[i];
   }
   int ans=0;
   for(int i=0;i<N;i++){
       while(h[i]>0){
           for(int j=i;j<N;j++){
               if(h[j]>0) h[j]--;
               else break;
           }
        ans++;
       }
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e3;

int n;
int had[N + 1];
struct Edge {
	int to, next;
} edge[(N << 1) + 1];
int start[N + 1], tot;
int f[N + 1], sum[N + 1], val[N + 1];
int ans = 1e9;

inline void addedge(int u, int v)
{
	edge[++tot] = Edge{ v, start[u] };
	start[u] = tot;
	edge[++tot] = Edge{ u, start[v] };
	start[v] = tot;
	return;
}
inline void dfs(int u, int fa)
{
	val[u] = had[u];
	sum[u] = 0;
	int maxx = 0;
	for (int i = start[u]; i; i = edge[i].next) {
		int v = edge[i].to;
		if (v != fa) {
			dfs(v, u);
			val[u] += val[v];
			sum[v] += val[v];
			sum[u] += sum[v];
			if (sum[v] > sum[maxx])
				maxx = v;
		}
	}
	if (!maxx) {
		f[u] = 0;
		return;
	}
	if (sum[u] - sum[maxx] >= sum[maxx])
		f[u] = sum[u] / 2;
	else
		f[u] = sum[u] - sum[maxx] + min(f[maxx], ((sum[maxx] << 1) - sum[u]) / 2);
	return;
}
int main()
{
	n = read();
	string s;
	cin >> s;
	for (int i = 1; i <= n; i++)
		had[i] = s[i - 1] - '0';
	for (int i = 1; i < n; i++) {
		int u = read(), v = read();
		addedge(u, v);
	}

	for (int i = 1; i <= n; i++) {
		dfs(i, 0);
		if (sum[i] & 1)
			continue;
		if (f[i] << 1 == sum[i])
			ans = min(ans, sum[i] / 2);
	}

	printf("%d\n", ans == 1e9 ? -1 : ans);
	return 0;
}


Measured memory_bytes: 3944
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

struct median{
    multiset<lint> mid;
    multiset<lint>::iterator itr;
    lint size=0;
    void in(lint X){
        if(size==0){
            size++;
            mid.insert(X);
            itr=mid.begin();
        }
        else{
            size++;
            mid.insert(X);
            if(X>=*itr && size%2!=0 && size!=1) itr++;
            if(X<*itr && size%2==0 && size!=0) itr--;
        }
    }
    lint midleft(){
        return *itr;
    }
    lint midright(){
        if(size%2==0){
            itr++;
            lint res=*itr;
            itr--;
            return res;
        }
        else return *itr;
    }
};

int main(void){
    median test;
    lint Q;
    lint B=0;
    lint ans=0;
    cin >> Q;
    rep(i,Q){
        lint q;
        cin >> q;
        if(q==1){
            lint a,b;
            cin >> a >> b;
            B+=b;
            if(test.size!=0){
                if(a<test.midleft()) ans+=test.midleft()-a;
                if(a>test.midright()) ans+=a-test.midright();
            }
            test.in(a);
        }
        else{
            cout << test.midleft() << " " << ans+B << endl; 
        }
    }
}

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

using namespace std;

void devide(int a, int &cnt) {
  if (a % 2 == 0) {
    a /= 2;
    ++cnt;
    devide(a, cnt);
  }
}

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

  int n;
  cin >> n;

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    devide(a, cnt);
  }

  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;

int main(){
	long long int MOD = 1e9+7;
	long long int n, k;
	cin >> n >> k;
	vector<int> p(n);
	long long int counta = 0;
	long long int countb = 0;
	for(int i=0;i<n;i++){
		cin >> p.at(i);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(p.at(i) > p.at(j)){
				counta++;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(p.at(i) > p.at(j)){
				countb++;
			}
		}
	}
	long long int ans1 = k*(k-1)/2%MOD;
	long long int ans2 = (counta * ans1);
	long long int ans3 = (countb*k)%MOD;
	long long int ans = (ans2 + ans3)%MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)){

            int n = sc.nextInt();
			int[] R = new int[n];

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

            System.out.println(getB(R));
		}
    }

    public static int getB(int[] R){
        int minv = R[0];
        int maxv = R[0];
        for (int i = 1; i < R.length; i++) {
            if (R[i] > maxv) {
                maxv = R[i];
            } else if (R[i] < minv){
                minv = R[i];
            }
        }
        return maxv - minv;
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
const int N=55, INF=1e9;
using namespace std;
int n, x;
priority_queue< int > pq;
signed main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> x;
        pq.push(x);
    }
    int ops=0;
    while(true)
    {
        int a = pq.top();
        pq.pop();
        a+=ops;
        if(a<n) break;
        ops+=a/n;
        //cout << a << " " << ops << endl;
        a=a%n;
        a-=ops;
        pq.push(a);
    }
    cout << ops;
}

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

string S;
int K;
vector<string> st;

/*出現分布でも作るのかと思ったけど、SKが小さいのでごり押しできる問題だった*/
int main(){
  cin >> S >> K;

  for(int i = 0; i < S.size(); i++){
    for(int j = 1; j <= K; j++){
      string tmpS = S.substr(i, j);    //iからi+j番目まで取得
      st.push_back(tmpS);
    }
  }

  sort(st.begin(), st.end());
  st.erase(unique(st.begin(), st.end()), st.end());   //uniqueでゴミ集積領域の先頭を取得
  cout << st[K-1] << endl;
  return 0;

}

  

Measured memory_bytes: 1660
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

A.sort()
B.sort()
C.sort()

import bisect

ans = 0
for b in B:
    a = bisect.bisect_left(A, b)
    b = bisect.bisect_right(C, b)
    ans += a * (N - b)
    # print(a, b)

print(ans)

Measured memory_bytes: 99868
S = input()
N = len(S)
ans = 0

for n in range(1 << N-1):
    s = S
    cnt = 0
    for i in range(N-1):
        if (n >> i) & 1 == 1:
            s = s[:i+cnt+1] + "+" + s[i+cnt+1:]
            cnt += 1
    ans += eval(s)

print(ans)


Measured memory_bytes: 2940
//To include everything you need
#include <bits/stdc++.h>
using namespace std;
typedef std::vector<int>  vi;
typedef std::vector<std::pair<int,int> > vpi;
typedef std::vector<string>  vs;
typedef std::vector<char>  vc;


int main(){

    int a,b,c;
    cin>>a>>b>>c;
    set<int> numbers;
    numbers.insert(a);
    numbers.insert(b);
    numbers.insert(c);
    if(numbers.size()==1 || numbers.size()==3)
        cout<<"No";
   else
        cout<<"Yes";     
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int ans=0x3f3f3f3f;
int main(){
	int l,r;
	cin>>l>>r;
	if(r-l+1>2019){
		cout<<0<<endl;
	}
	else{
		l%=2019,r%=2019;
		for(int i=l;i<=r-1;i++){
			for(int j=i+1;j<=r;j++){
				int k=(i*j)%2019;
				ans=min(ans,k);
				
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    LL N;cin >> N;
    LL ins = 0;
    for(LL a = 1;a < N;a++){
        if(N >= a*a){
            ins = a*a;
        }else{
            break;
        }
    }
    COUT(ins==0?1:ins);
    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    if "RRR" in S:
        print(3)
    elif "RR" in S:
        print(2)
    elif "R" in S:
        print(1)
    else:
        print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8992
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define SIZ 1000005
#define SIZE 200005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll n, dp[100005], a[100005];

ll func(){
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    fo(i, 2, n){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }
    return dp[n-1];
}

signed main(){ 
    IOS
    //io_set();
    cin >> n;
    rep(i, n){
        cin >> a[i];
    }
    cout << func() << endl;
    return 0;
}

 

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

string makeString(string s, int l, int r) {
    string t;
    t = s.substr(l, r );
    return t;
}
int main() {
    int h, w;
    string s;
    cin >> h >> w;
    int a[52][52] = {};
    for (int i = 1; i <= h;i++) {
        cin >> s;
        for (int j = 1; j <= w; j++) {
            if (s[j-1] == '#') a[i][j] = 1;
        }
    }
    bool f = 1;
    for (int i = 1; i <= h;i++) {
        for (int j = 1; j <= w; j++) {
            if (a[i][j] == 1 && a[i - 1][j] == 0 && a[i + 1][j] == 0 && a[i][j - 1] == 0 && a[i][j + 1] == 0) {
                f = 0;
                break;
            }
        }
    }
    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256