akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000
//bool cmp(P a,P b){ return a.second < b.second;}
	ll N,M,K,ans=0;
	ll A;
	ll B;
    string S;
	ll Fact[500010];
	ll Com[500010];
	ll LP(ll x,ll y){
	    if(y==0)return 1;
	    if(y%2==0)return LP((x*x)%MOD,y/2)%MOD;
	    else return LP(x,y-1)*x%MOD;
	}
	void FC(ll x){
	    Fact[0]=Com[0]=1;
	    ll temp=1;
	    EREP(i,x){
	        temp=temp*i%MOD;
	        Fact[i]=temp;
	        Com[i]=LP(temp,MOD-2);
	    }
	}
	ll MC(ll x,ll y){
	    if(y==0)return 1;
	    if(x<y)return 0;
	    return (Fact[x]*(Com[y]*Com[x-y]%MOD))%MOD;
	}


int main(){
	std::ios_base::sync_with_stdio(false);
    cin>>N>>A>>B;
	ans=LP(2,N)-1;
	ll A1,B1,N1=1,A2=1,B2=1;
	EREP(i,N){
        N1=N1*i%MOD;
		if(i==A)A1=N1;
		if(i>N-A)A2=A2*i%MOD;
		if(i==B)B1=N1;
		if(i>N-B)B2=B2*i%MOD;
    }
	FC(2*100000+1);
//	DEB(N1)DEB(N1*LP(A1,MOD-2)%MOD*LP(A2,MOD-2)%MOD)END
	ans=ans+(MOD-A2*Com[A]%MOD)+(MOD-B2*Com[B]%MOD);
	cout<<ans%MOD;
	return 0;
}

Measured memory_bytes: 5888
#include<stdio.h>
int main(){
  char s[3];
  scanf("%s",&s);
  //printf("%s",s);
  if(s[1]=='R'){
  printf("ABC");
  }
  else if(s[1]=='B'){
  printf("ARC");
  }
  else printf("error");
return 0;
}

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

using namespace std;

const int MX = 100000;

char s[MX + 1], a[MX], b[MX];

int main() {
	ignore = scanf("%s", s);
	
	int m = 0;
	for (int i = 0; s[i] != 0; i++)
		if (s[i] != 'x') {
			a[m] = b[m] = s[i];
			m++;
		}
	
	reverse(b, b + m);
	if (memcmp(a, b, m) != 0) {
		printf("-1\n");
		return 0;
	}
	
	int ans = 0, l = 0, r = strlen(s) - 1;
	while (l < r) {
		if (s[l] == s[r]) {
			l++;
			r--;
			continue;
		}
		
		ans++;
		if (s[l] == 'x') l++;
		if (s[r] == 'x') r--;
	}
	
	printf("%d\n", ans);
	
	return 0;
}


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

int main() {
  char s;
  while (true){
    scanf("%c", &s);
    if(s == '\n') break;
    if('a' <= s && s <= 'z') cout << (char)(s-32);
    else if('A' <= s && s <= 'Z') cout << (char)(s+32);
    else cout << (char)s;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3132
#include <iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && a < c) {
        cout << a << " ";
        if (b < c) 
            cout << b << " " << c << endl;
        else 
            cout << c << " " << b << endl;
    } else if (b < a && b < c) {
        cout << b << " ";
        if (a < c) 
            cout << a << " " << c << endl;
        else 
            cout << c << " " << a << endl;
    } else {
        cout << c << " ";
        if (a < b) 
            cout << a << " " << b << endl;
        else 
            cout << b << " " << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>

int main() {
  int64_t A,B,K;
  cin >> A >> B >> K;

  if(A > K){
    A -= K;
  }else if((A + B) > K){
    B = B - (K - A);
    A = 0;
  }else{
    A = 0;
    B = 0;
  }

  cout << A << " " <<  B << endl;

  return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N; cin>>N;
    int sum=0;
    rep(i,N) {
        int l,r;
        cin>>l>>r;
        sum+=(r-l+1);
    }
    cout<<sum<<endl;
}

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

using namespace std;

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

	string s;
	cin >> s;

	string alp = "abcdefghijklmnopqrstuvwxyz";

	for(const auto c : s)
	{
		const auto itr = find(alp.begin(), alp.end(), c);
		if (itr != alp.end()) {
			alp.erase(itr);
		}
	}

	if(alp.empty())
	{
		cout << "None";
	}
	else
	{
		char min = *min_element(alp.begin(), alp.end());
		cout << min;
	}

	return 0;
}


Measured memory_bytes: 512
import java.util.*

data class Line(val to: Int, val firstTime: Int, val secondTime: Int)
fun minFrom(startA: Int, startB: Int, path: Array<out Collection<Line>>, hasPath: Array<Array<Boolean>>, memo: Array<Array<Int?>>): Int {
    if (memo[startA][startB] == null){
        memo[startA][startB] = when {
            startA == startB -> {
                path[startA].mapNotNull { nextA ->
                    path[startB].map { nextB ->
                        if (nextA == nextB) minFrom(nextA.to, nextB.to, path, hasPath, memo) + nextA.firstTime + nextA.secondTime
                        else minFrom(nextA.to, nextB.to, path, hasPath, memo) + nextA.firstTime + nextB.firstTime
                    }.min()
                }.min() ?: 0
            }
            hasPath[startA][startB] -> {
                path[startA].map { next -> minFrom(next.to, startB, path, hasPath, memo) + next.firstTime }.min()!!
            }
            else -> {
                path[startB].map { next -> minFrom(startA, next.to, path, hasPath, memo) + next.firstTime }.min()!!
            }
        }
    }
    return memo[startA][startB]!!
}
fun hasPath(from: Int, to: Int, path: Array<out Collection<Line>>, memo: Array<Array<Boolean?>>): Boolean {
    if (memo[from][to] == null){
        memo[from][to] = from == to || path[from].any{next -> hasPath(next.to, to, path, memo)}
    }
    return memo[from][to]!!
}
fun main(args:Array<String>?): Unit {
    val (n, p) = readLine()!!.trim().split(' ').map(String::toInt)
    val flags = Array(n){ Stack<Line>() }
    repeat(p){
        val (s, e, t1, t2) = readLine()!!.trim().split(' ').map(String::toInt)
        flags[s - 1].push(Line(e - 1, t1, t2))
    }
    val path = Array(n){Array<Boolean?>(n){null}}.let{memo ->
        for (i in 0 until n) for (j in 0 until n){
            hasPath(i, j, flags, memo)
        }
        memo.map{it.filterNotNull().toTypedArray()}.toTypedArray()
    }
    val memo = Array(n){f -> Array(n){t -> if (f == n - 1 && t == n - 1) 0 else null}}
    println(
            minFrom(0, 0, flags, path, memo)
    )
}


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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    int x;
    cin >> x;
    if (x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

template <typename A, typename B>
ostream &operator<<(ostream &out, const pair<A, B> &a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream &operator<<(ostream &out, const array<T, N> &a) {
  out << "[";
  bool first = true;
  for (auto &v : a) {
    out << (first ? "" : ", ");
    out << v;
    first = 0;
  }
  out << "]";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &a) {
  out << "[";
  bool first = true;
  for (auto &v : a) {
    out << (first ? "" : ", ");
    out << v;
    first = 0;
  }
  out << "]";
  return out;
}
template <typename T, class Cmp>
ostream &operator<<(ostream &out, const set<T, Cmp> &a) {
  out << "{";
  bool first = true;
  for (auto &v : a) {
    out << (first ? "" : ", ");
    out << v;
    first = 0;
  }
  out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream &operator<<(ostream &out, const map<U, T, Cmp> &a) {
  out << "{";
  bool first = true;
  for (auto &p : a) {
    out << (first ? "" : ", ");
    out << p.first << ":" << p.second;
    first = 0;
  }
  out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...)                   \
  cerr << "@" << __LINE__ << " -> "; \
  __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#endif
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#define ll long long
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#pragma endregion

const ll mod = 1e9 + 7;

void add(ll &a, ll b) {
  a += b;
  if (a >= mod) a -= mod;
}

ll get(ll a) { return ((a * (a + 1)) / 2) % mod; }

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, k;
  cin >> n >> k;
  vector<ll> v(n);
  for (ll &x : v) cin >> x;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll left = 0, right = 0;
    for (int j = 0; j < i; j++) {
      if (v[j] < v[i]) left++;
    }
    for (int j = i + 1; j < n; j++) {
      if (v[j] < v[i]) right++;
    }
    ll a1 = (right * get(k)) % mod;
    ll a2 = (left * get(k - 1)) % mod;
    add(ans, a1);
    add(ans, a2);
  }
  cout << ans << '\n';
}

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

using namespace std;

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

  string str;

  cin >> str;

  char cur = str.at(0);
  int curLength = 1;

  int K = 1;

  int i=1;
  while (i < str.size()) {
    if(curLength == 1){
      if(cur == str.at(i)){
        curLength = 2;
        if(i < str.size()-1){
          K++;
        }
        i+=2;
      }
      else{
        cur = str.at(i);
        K++;
        i++;
      }
    }
    else{
      // curLength == 2
      cur = str.at(i);
      curLength = 1;
      K++;
      i++;
    }


  }

  cout << K << '\n';

}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> s(n);
  int ans=0;
  int false_ans=0;
  int index = 0;
  for(int i=0;i<n;i++){
    cin >> s.at(i);
    ans = ans+s.at(i);
  }
  false_ans = ans;
  sort(s.begin(), s.end());

  while(ans%10 == 0 && false_ans!=0){
    if(s.at(index)%10==0){
      false_ans=false_ans-s.at(index);
      index++;
      continue;
    }
    ans=ans-s.at(index);
    false_ans=false_ans-s.at(index);
    index++;
  }
  if(ans%10==0){
    cout << 0 << endl;
  }
  else{
    cout << ans << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    vector<pii> right(n);
    int x, l;
    for (int i = 0; i < n; ++i) {
        cin >> x >> l;
        right[i] = pii(x + l, l);
    }
    sort(right.begin(), right.end());

    int res = 0;
    int loc = - 2 * INF;
    for (int i = 0; i < n; ++i) {
        if(right[i].first - right[i].second * 2 < loc) continue;
        res++;
        loc = right[i].first;
    }
    cout << res << endl;
}

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

#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;
inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}
inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}
ll S;
ll firstk(ll n){
    return (n*(n-1))/2;
}

ll lastk(ll n){
    return S-(n*(n-1))/2;
}


void solve(){
    ll n,k;
    cin>>n>>k;
    S=(n*(n+1))/2;
    ll ans=0;
    rep(i,k,n+2){
        ll diff=lastk(n+1-i)-firstk(i);
        ans=add(ans,diff+1,mod);
    }
    cout<<ans<<endl;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3612
S = input()
T = input()
def par(m):
  if UF[m] == m:
    return m
  r = par(UF[m])
  UF[m] = r
  return r
UF = list(range(len(S)))
for i in range(len(S)):
  c = S[i]
  j = S.find(c, i+1)
  if not(j < 0):
    UF[j] = i
UFS = UF
UF = list(range(len(T)))
for i in range(len(T)):
  c = T[i]
  j = T.find(c, i+1)
  if not(j < 0):
    UF[j] = i
UFT = UF
if UFS == UFT:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 19376
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int N=sc.nextInt();
		if(N%2!=0)N*=2;
		pw.println(N);
		pw.close();
	}

	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21332
#include <stdio.h>
#define N 100000

struct trump{
  char string;
  int num;
  int order;
};

struct trump L[N/2+2], R[N/2+2];

int partition(struct trump *, int, int);
void quickSort(struct trump *, int, int);
int judge(int, int);

int main(){
  int i, j, n, v, fc=0, rs=1;
  struct trump A[N];
  char c[2];

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s %d", c, &v);
    A[i].string=c[0];
    A[i].num=v;
    A[i].order=i;
  }
  
  quickSort(A, 0, n-1);

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){ 
      if(A[i].num!=A[j].num) break;

      if(A[i].num==A[j].num){
         rs=judge(A[i].order, A[j].order);
         if(rs==0) fc++;
      }
    }
  }
  
  if(fc==0) printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++){
    printf("%c %d\n", A[i].string, A[i].num);
  }
  return 0;
}

int partition(struct trump *A, int p, int r){
  int i, j;
  struct trump t, x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].num<=x.num){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(struct trump *A, int p, int r){
  int q;
  if(p<r){
    q=partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

int judge(int a, int b){
  if(a<b) return 1;
   else return 0;
}



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

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();}

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

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n, m;

  cin >> n;
  vector<string> u(n);
  REP(i, n) cin >> u[i];

  cin >> m;
  bool state = true;
  REP(i, m) {
    bool b = true;
    string t;
    cin >> t;
    REP(j, n) {
      if(u[j] == t) {
	if(state) cout << "Opened by " << t << endl;
	else cout<< "Closed by " << t << endl;
	b = false;
	state ^= 1;	
	break;
      }
    }
    if(b) cout << "Unknown " << t << endl;
  }
}

Measured memory_bytes: 1224
import sys
def input():
    return sys.stdin.readline()[:-1]

def match(s, t, lt, offset):
    for i in range(lt):
        if t[i] != s[offset+i] and s[offset+i] != '?':
            return False
    return True

def main():
    S = input()
    T = input()
    len_S = len(S)
    len_T = len(T)
    ans = list(S.replace('?','a'))
    for i in range(len_S-len_T+1):
        offset = len_S-len_T-i
        if match(S, T, len_T, offset):
            for j in range(len_T):
                ans[offset+j] = T[j]
            break
    else:
        print('UNRESTORABLE')
        exit()
    print(''.join(ans))

if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef unsigned long long ull;

#define int long long
#define endl "\n"
#define all(x) x.begin(), x.end()
#define deb(x) cout << #x << " --> " << (x) << endl
#define pb push_back
#define mod 1000000007  // 1e9 + 7
#define prec(x, y) fixed << setprecision(y) << x
#define print(v)                       \
    for (auto x : v) cout << x << " "; \
    cout << endl

int costCalc(int n, int *h, int *dp, int i) {
    if (i >= n) return 0;

    int cost = min(
        abs(h[i + 1] - h[i]) + costCalc(n, h, dp, i + 1),
        abs(h[i + 2] - h[i]) + costCalc(n, h, dp, i + 2));
    return 0;
}

int s(int i, int *h, int n, int *dp) {
    if (i == n) return 0;
    if (dp[i] != -1) {
        return dp[i];
    }
    int op1 = INT_MAX, op2 = INT_MAX;
    if (i + 1 <= n) op1 = abs(h[i + 1] - h[i]) + s(i + 1, h, n, dp);  // if condition not required for this
    if (i + 2 <= n) op2 = abs(h[i + 2] - h[i]) + s(i + 2, h, n, dp);

    return dp[i] = min(op1, op2);
}

void solve() {
    int i, j, n, k;
    cin >> n;
    int h[n + 1];
    for (i = 1; i <= n; ++i) cin >> h[i];
    int dp[n + 1];
    memset(dp, -1, sizeof(dp));
    // cout << s(1, h, n, dp) << endl;
    s(1, h, n, dp);
    cout << dp[1] << endl;
}

//Fuck Ratings
//Once a Charas always a Charas

int32_t main() {
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int _t = 1;

    // cin >> _t;
    while (_t--)
        solve();
}

Measured memory_bytes: 13020
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll a,v,b,w;
 cin>>a>>v>>b>>w;
 ll d = abs(a-b);
 ll t;
 cin>>t;
 if( d <= t*(v-w) )cout<<"YES"<<endl;
 else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 3592
import sys
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True # and False

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
b = [(a[i],i) for i in range(n)]
b.sort()
for i in range(n):
  printn(str(b[i][1]+1))
  printn(' ')
print("")


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

namespace ABC166E
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            var A1 = ReadLong();

            long[] L = new long[N];
            Dictionary<long, long> dic = new Dictionary<long, long>();
            long[] R = new long[N];
            for (int i = 0; i < N; i++)
            {
                L[i] = A1[i] + i;
                if (dic.ContainsKey(L[i])) dic[L[i]] += 1;
                else dic.Add(L[i], 1);

                R[i] = i - A1[i];
            }

            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                if (!dic.ContainsKey(R[i])) continue;
                ans += dic[R[i]];
            }

            Console.WriteLine(ans);
        }



        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int min,max;
  if(A >= B){
    min = B;
  } else {
    min = A;
   }
   if(A+B<N){
    max = 0;
   } else {
    max = (A + B - N);
   }
  cout <<min  << " " <<max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000010
using namespace std;
int main(){
	int n,a[105],i,j,ans;
	double sum=0,mdis=INF;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sum/=n;
	for(i=0;i<n;i++)
		if(fabs(a[i]-sum)<mdis)
		{
			ans=i;
			mdis=fabs(a[i]-sum);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int n; cin >>n;
  string s; cin >>s;
  int k; cin >>k;
  k--;
  rep(i, n){
    if (i == k) continue;
    if (s[i] != s[k]) s[i] = '*';
  }
  cout <<s <<endl;
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int A, B , C, D; cin >> A >> B >> C >> D;
	while(1){
		C -= B;
		if(C <= 0){
			cout << "Yes" << endl;
			return 0;
		}
		A -= D;
		if(A <= 0){
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}


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

void solve() {
	int a, N, M; cin >> N >> M;
	vector<int> impos(N + 1, true);
	rep(i, M) {
		scanf("%d", &a);
		impos[a] = false;
	}

	vector<ll> dp(N + 1);
	dp[0] = 1;
	for (int now = 0; now < N; now++) {
		for (int next = now + 1; next <= min(N, now + 2); next++) {
			if (impos[next]) {
				dp[next] += dp[now];
				dp[next] %= mod;
			}
		}
	}

	cout << dp[N] << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
long long n;
vector <long long> v;
vector <long long> dp;

long long f(long long i) {
	if (i == n-2) return dp[n-2]=abs(v[i]-v[i+1]);
	if (i == n-3) return dp[n-3]=abs(v[i]-v[i+2]);
	long long m1 = dp[i+1] != -1 ? abs(v[i]-v[i+1])+dp[i+1] : abs(v[i]-v[i+1])+f(i+1);
	long long m2 = dp[i+2] != -1 ? abs(v[i]-v[i+2])+dp[i+2] : abs(v[i]-v[i+2])+f(i+2);
	return dp[i] = min (m1,m2);
}

int main () {
  cin >> n;
  long long l = n;
  while (l--) {
    long long x;
    cin >> x;
    v.push_back(x);
    dp.push_back(-1);
  }
  
  cout << f(0);
  return 0;
}

Measured memory_bytes: 9512
N = int(input())
J = [input() for i in range(N)]
M = int(input())
K = [input() for i in range(M)]
L = []
Z = []
for i in range(len(J)):
  if (J[i] not in L):
    L.append(J[i])
for j in range(len(L)):
  p = J.count(L[j])
  q = K.count(L[j])
  Z.append(p-q)
Z.sort()
Z.reverse()
if (Z[0] <= 0):
  print('0')
else:
  print(Z[0])

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100005
int n, a[MAXN], L[MAXN], R[MAXN];
int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
int main() {
    L[0] = 0, R[n + 1] = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++)
        L[i] = gcd(a[i - 1], L[i - 1]);
    for(int i = n; i >= 1; i--)
        R[i] = gcd(a[i + 1], R[i + 1]);
    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans = max(ans, gcd(L[i], R[i]));
    printf("%d\n", ans);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    long long a[n], sum = 0, cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
        if(i%2 == 1) cnt += a[i];
    }
    long long x = sum - 2*cnt;
    cout << x << " ";
    long long y;
    for(int i = 1; i < n; i++){
        y = 2*a[i-1] - x;
        cout << y << " ";
        x = y;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>
 
#define INF 100000000
#define EPS 1e-9
 
using namespace std;
 
typedef long long ll;  

#define MAX 300001
int n;

bool used[MAX];

int per[MAX];
int perNum = 0;

int main(){

  fill(used, used+MAX, true);
  used[0] = used[1] = false;
  for(int i = 0; i < MAX; i++){
    if((i-1)%7 == 0 || (i-6)%7 == 0){
      if(used[i]){
	per[perNum] = i;
	perNum++;
	for(int j = 2; i*j < MAX; j++){
	  used[i*j] = false;
	}
      }
    }
    else{
      used[i] = false;
    }
  }

  while(true){

    cin >> n;
    if(n == 1)
      break;

    cout << n << ":";
    for(int i = 0; i < perNum; i++){
      if(n%per[i] == 0){
	cout << " " << per[i];
      }
    }
    cout << endl;
    
  }


  return 0;

}

Measured memory_bytes: 1596
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define MAXN 363000  //9!==326880
struct node
{
    int s[9];
    int a;
    int b;
    int step;
};
int fac[10]= {1,1,2,6,24,120,720,5040,40320,362880};//分别存储1--9的阶乘值
int dir[4][2]= {-1,0,1,0,0,-1,0,1};
int aim=322561;//123456780对应的hash值
bool vis[MAXN];
node str,now,next;

int cantor(const int *s)
{
    int sum=0;
    for(int i=0; i<9; i++)
    {
        int num=0;
        for(int j=0; j<i; j++)
            if(s[j]>s[i])
                num++;
        sum+=(num*fac[i]);
    }
    return (sum+1);
}
bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<node>q;
    q.push(str);
    vis[str.b]=1;
    while(!q.empty())
    {
        now=q.front();
        q.pop();
        int x=now.a/3;
        int y=now.a%3;
        for(int i=0; i<4; i++)
        {
            int tx=x+dir[i][0],ty=y+dir[i][1];
            if(tx<0||tx>=3||ty<0||ty>=3)
                continue;
            next=now;
            next.a=tx*3+ty;
            next.s[now.a]=next.s[next.a];
            next.s[next.a]=0;
            next.b=cantor(next.s);
            if(!vis[next.b])
            {
                vis[next.b]=1;
                if(next.b==aim)
                {
                    return true;
                }
                next.step=now.step+1;
                q.push(next);
            }
        }
    }
    return 0;
}
char sss[3];
int main()
{
    char q[10];
    for(int i=0; i<9; i++)
    {
        scanf("%s",sss);
        q[i]=sss[0];
    }
    int len=strlen(q);
    int num=0;
    for(int i=0; i<len; i++)
    {
        if(q[i]>='1'&&q[i]<='9')
        {
            str.s[num++]=q[i]-'0';
        }
        else if(q[i]=='0')
        {
            str.s[num]=0;
            str.a=num++;
        }
    }
    str.b=cantor(str.s);
    if(str.b==aim)
        printf("%d\n",0);
    else if(bfs())
        printf("%d\n",next.step+1);
    return 0;
}



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

int main() {
    int N, M, L;
    while (cin >> N >> M >> L, N || M || L) {
        int Q; cin >> Q;
        vector<int> safe(N + M + L, 2);
        vector<int> I(Q), J(Q), K(Q);
        for (int f, q = 0; q < Q; q++) {
            cin >> I[q] >> J[q] >> K[q] >> f;
            I[q]--;
            J[q]--;
            K[q]--;
            if (f) safe[I[q]] = safe[J[q]] = safe[K[q]] = 1;
        }

        for (int q = 0; q < Q; q++) {
            if (safe[I[q]] == 2 && safe[J[q]] == 1 && safe[K[q]] == 1) safe[I[q]] = 0;
            if (safe[J[q]] == 2 && safe[I[q]] == 1 && safe[K[q]] == 1) safe[J[q]] = 0;
            if (safe[K[q]] == 2 && safe[I[q]] == 1 && safe[J[q]] == 1) safe[K[q]] = 0;
        }

        for (auto i : safe) cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 2996
#include<iostream>

using namespace std;

int gcd(int x, int y) {
    if (x < y) {
        swap(x, y);
    }
    if (x % y == 0) {
        return y;
    }
    if (x >= y) {
        return gcd(y, x%y);
    }
    return 0;
}

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

    cout << gcd(a, b) << endl;

    return 0;
}

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

int main(){
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < t.size(); i++){
		if(s[i] == t[i])
			ans++;	
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main()
{
    int costs[101];
    long long sum=0,tsum;
    int n,m,tin,drink;
    std::cin>>n;
    for(int i=0;i<n;i++){
        std::cin>>costs[i];
        sum+=costs[i];
    }
    std::cin>>m;
    for(int i=0;i<m;i++){
        std::cin>>tin>>drink;
        std::cout<<sum-costs[tin-1]+drink<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*

Code for problem B by cookiedoth
Generated 21 Mar 2020 at 03.20 PM


СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█

>_<
¯\_(ツ)_/¯
^_^

*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()

using namespace std;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}

template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

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

const int mx = 1e6 + 228;
int n, a[mx], _a[mx];

signed main() {
	fast_io();
	cin >> n;
	for (int i = 0; i < n; ++i) {
		char c;
		cin >> c;
		a[i] = c - '0';
		a[i]--;
	}
	int is_1 = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] == 1) {
			is_1 = 1;
		}
	}
	if (is_1 == 0) {
		for (int i = 0; i < n; ++i) {
			if (a[i] == 2) {
				a[i] = 1;
			}
		}
	} else {
		for (int i = 0; i < n; ++i) {
			if (a[i] == 2) {
				a[i] = 0;
			}
		}
	}
	// output(a, a + n);
	int res = 0;
	for (int i = 0; i < n; ++i) {
		if (((n - 1) & i) == i) {
			res ^= a[i];
		}
	}
	if (is_1 == 0 && res == 1) {
		res = 2;
	}
	cout << res << endl;
}


Measured memory_bytes: 6016
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#ifndef rd
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int powm(int a, int b, int mod) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

pii a[200005];
int dp[200005];
void solve() {
	int n,t;
	cin>>n>>t;
//	n=2e5,t=1e9;
	fr(i,1,n) {
		cin>>a[i].fi>>a[i].se;
//		a[i].fi=0;
//		a[i].se=i;
	}
	int ans=0;
	sort(a+1,a+n+1,[](pii i, pii j){
		if((i.se+1)*(j.fi+1)+j.se==(j.se+1)*(i.fi+1)+i.se)
			return i.se<j.se;
		return (i.se+1)*(j.fi+1)+j.se<(j.se+1)*(i.fi+1)+i.se;
	});
	int lim=0;
	fr(i,1,n)
		dp[i]=infi;
	fr(i,1,n) {
		int lo=-1,hi=lim,mid=(lo+hi+1)/2;
		while(lo<hi) {
			if((dp[mid]+1)*(a[i].fi+1)+a[i].se>t)
				hi=mid-1;
			else
				lo=mid;
			mid=(lo+hi+1)/2;
		}
		if(lo==lim)
			lim++;
		for(int j=lo; j>=0; j--) {
			if(dp[j+1]>(dp[j]+1)*(a[i].fi+1)+a[i].se) {
				dp[j+1]=(dp[j]+1)*(a[i].fi+1)+a[i].se;
			} else
				break;
		}
	}
	cout<<lim<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(8);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 4992
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

log = list()
ans = 0
for i in range(n):
  if i > k-1:
    if t[i] == log[i-k]:
      ans += 0
      log.append("null")
    else:
      log.append(t[i])
      if t[i] == "r":
        ans += p
      if t[i] == "s":
        ans += r
      if t[i] == "p":
        ans += s  
  else:
    log.append(t[i])
    if t[i] == "r":
      ans += p
    if t[i] == "s":
      ans += r
    if t[i] == "p":
      ans += s  
print(ans)

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

#define swap(type,a,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(int i=0;i<n;i++)
#define forS(i,start,n) for(int i=start;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}
#define DOUBLE fixed << setprecision(15)

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

bool cmp(int a,int b){
    return false;
}
int main(){
    int m,n,cnt=0;
    string s;

    cin>>n;
    vi h(n);
    forN(i,n)cin>>h[i];
    int tmp=h[0];
    forN(i,n-1){
        int x;
        if((x=h[i+1]-h[i])<0){
            cnt-=x;
        }
        tmp=min(tmp,h[i+1]);
    }
    cnt+=(h[n-1]>0?h[n-1]:0);
    cout << cnt << endl;
}


Measured memory_bytes: 3572
using System;

class A{
  static void Main(){
    int a = int.Parse(Console.ReadLine().Replace(" ",""));
    bool ans = false;
    for (int i = 1; i < 1001; i++){
      if (i * i == a) ans = true;
    }
    if (ans) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}

Measured memory_bytes: 27292
import java.util.Scanner;

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

    for(int i=0; i<S.length(); i++) {
      System.out.print('x');
    }
    System.out.println();
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int INF = 1e9;
static const ll MOD = 1e9 + 7;

bool pairCompare(const pair<int, int>& firstElof, const pair<int, int>& secondElof) {
    return firstElof.first > secondElof.first;
}

int main(void) {
    int h, n;
    cin >> h >> n;

    vector<int> a(n);
    vector<int> b(n);
    for(int i=0;i<n;i++) {
        cin >> a.at(i) >> b.at(i);
    }

    vector<int> dp(h+1, INF);
    dp.at(0) = 0;
    for(int i=0;i<n;i++) {
        for(int j=0;j<=h;j++) {
            dp.at(min(j+a.at(i), h)) = min(dp.at(min(j+a.at(i), h)), dp.at(j)+b.at(i));
        }
    }
    cout << dp.at(h) << endl;

    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;
int A[200010];

void _main() {
    cin >> N;
    int sum = 0;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    int tmp = A[0];
    int ans = INF;
    REP(i, N - 1) {
        CHMIN(ans, abs(2 * tmp - sum));
        tmp += A[i + 1];
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();

            string line;
            string suits = "SHCD";
            int[,] cards = new int[4, 14];
            for (; (line = Console.ReadLine()) != null;)
            {
                if(line=="")
                {
                    break;
                }

                string[] sArr = line.Split(' ');
                string s = sArr[0];
                int number = int.Parse(sArr[1]);

                cards[suits.IndexOf(s), number]++;
            }

            for (int i = 0; i < 4; i++)
            {
                for (int j = 1; j <= 13; j++)
                {
                    if (cards[i, j] == 0)
                    {
                        Console.WriteLine("{0} {1}", suits[i], j);
                    }
                }
            }

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9764
#include<stdio.h>
#include<string.h>
int main()
{
    char num[1005];
    int sum=0;
    while(1)
    {
        scanf("%s",num);
        sum=0;
        if (num[0]=='0') break;
        int i, sz=strlen(num);
        for(i=0;i<sz;i++)

        {
            sum+=num[i] - '0';
        }

    printf("%d\n",sum);
}
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long 
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double
 
const int N=1e5+3;
 int spf[205];

 int cal(int n)
  {
  	int cnt=0;
  	for(int i=2;i<n;i++)
  	{
  		if(n%i==0)
  		{
  			if(spf[i]!=i) return 0;
  			else cnt+=i;
  		}
  	}	
  	return cnt;
  }
int32_t main()
{
 

  int n;
  cin >> n;

  int ans=0;
  f(i,1,n+1)
  {
  	f(j,1,n+1)
  	{
  		f(t,1,n+1)
  		{
  			ans+=__gcd(i,__gcd(j,t));
  		}
  	}
  }
  cout<<ans;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define eb emplace_back
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<60;
const ll MOD=998244353LL;
template<class T> void chmin(T &a,T b){a=min(a,b);}
template<class T> void chmax(T &a,T b){a=max(a,b);}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,m;cin>>a>>b>>m;
	vector<ll> c(a),d(b);
	ll mc=INF,md=INF;
	for(int i=0;i<a;i++){
		cin>>c[i];
		chmin(mc,c[i]);
	}
	for(int i=0;i<b;i++){
		cin>>d[i];
		chmin(md,d[i]);
	}
	ll res=mc+md;
	for(int i=0;i<m;i++){
		ll x,y,e;cin>>x>>y>>e;
		--x;--y;
		chmin(res,c[x]+d[y]-e);
	}
	cout<<res<<endl;
}


Measured memory_bytes: 1920