akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;


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

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		StringBuilder result = new StringBuilder();
		for(int i = 0; i < s.length(); i++) {
			result.append('x');
		}
		
		System.out.println(result);
	}
}


Measured memory_bytes: 22868
a, b, q = map(int, input().split())
S = [int(input()) for _ in range(a)]
T = [int(input()) for _ in range(b)]
S.sort()
T.sort()
INF = 10**18
S = [-INF] + S + [INF]
T = [-INF] + T + [INF]

import bisect
for _ in range(q):
    x = int(input())
    i = bisect.bisect_right(S, x)
    j = bisect.bisect_right(T, x)
    ans = INF
    for s in [S[i-1], S[i]]:
        for t in [T[j-1], T[j]]:
            d1 = abs(s-x) + abs(t-s)
            d2 = abs(t-x) + abs(s-t)
            ans = min([ans, d1, d2])
    print(ans)

Measured memory_bytes: 12796
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 100000

int main(void) {
  ll a, b, c;

  cin >> a >> b >> c;

  if (a + b >= c) {
	cout << "Yes" << endl;
  }
  else {
	cout << "No" << endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int x, a, b;
    cin >>x >> a >> b;
    if (-a + b <= 0)
    {
        cout << "delicious" << endl;
    }
    else if (-a + b <= x)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "dangerous" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<ll> d(n, 1e18);
    vector<int> from(m), to(m);
    vector<ll> cost(m);
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        cin >> from[i] >> to[i] >> cost[i];
        from[i]--, to[i]--;
        cost[i] = -cost[i];
        g[to[i]].emplace_back(from[i]);
    }
    d[0] = 0;
    vector<int> y(n), x;
    function<void(int)> dfs = [&](int v) {
        y[v] = 1;
        for (int to : g[v]) {
            if (y[to]) {
                continue;
            }
            dfs(to);
        }
    };
    dfs(n - 1);
    for (int i = 0; i < m; i++) {
        if (y[from[i]] && y[to[i]]) {
            x.emplace_back(i);
        }
    }
    for (int i = 0; i <= n; i++) {
        if (i == n) {
            cout << "inf" << '\n';
            return 0;
        }
        bool ok = true;
        for (int j : x) {
            if (d[to[j]] > d[from[j]] + cost[j]) {
                d[to[j]] = d[from[j]] + cost[j];
                ok = false;
            }
        }
        if (ok) {
            break;
        }
    }
    cout << -d[n - 1] << '\n';
    return 0;
}

Measured memory_bytes: 3768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int main(void)
{
  int i, j;
  char aa[100000+2];
  char aar[200000+2];
  char aal[200000+2];
  memset(aa, '\0', sizeof(aa));
  memset(aar, '\0', sizeof(aar));
  memset(aal, '\0', sizeof(aal));
  int cntaa;
  int cntr=0;
  int cntl=0;
  int min, max;
  int len, flg;
  int cnt, maxcnt;
  char ee;
  int  bb,cc,dd;
  scanf("%s\n", aa);
  cntaa = strlen(aa);
//  printf("%d",cntaa);
  scanf("%d\n", &bb);
  cnt=0;
  for(i=0;i<bb;i++){
    scanf("%d", &cc);
    if(cc == 2){
      scanf("%d %c", &dd,&ee);
      if(dd ==2){
        if((cnt%2) ==0){
          aar[cntr]=ee;
          cntr++;
        }
        else{
          aal[cntl]=ee;
          cntl++;
        }
      }
      else{
        if((cnt%2) ==0){
          aal[cntl]=ee;
          cntl++;
        }
        else{
          aar[cntr]=ee;
          cntr++;
        }
      }
    }
    else{
      cnt++;      
    }
    //    printf("%s %d %d %d %c\n", aa,bb,cc,dd,ee);
  }
  //	printf("aar%s\n",aar);
  //	printf("aal%s\n",aal);
  if((cnt%2) ==0){
    for(i=cntl-1;i>=0;i--){
      printf("%c",aal[i]);
    }
    printf("%s",aa);
    printf("%s\n",aar);
  }
  else{
    for(i=cntr-1;i>=0;i--){
      printf("%c",aar[i]);
    }
    for(i=cntaa-1;i>=0;i--){
      printf("%c",aa[i]);
    }
    printf("%s\n",aal);
  }

  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}

// no change 
const ll MOD = 1e9+7;  
int n,k;
const int mx = 2e5;
int H[mx];
int dp[mx];
void Titan(){
	read(n,k);
	fo(n)cin >> H[i+1];
	dp[0] =0;
	
	fo(i,2,n+1){
		dp[i] = MOD;
		for(int j = 1;j<=k;j++){
			if(i-j> 0)
			umin(dp[i], dp[i-j] + abs(H[i] - H[i-j]));

		}
	}

	cout << dp[n];

	debug() << range(dp,dp+n+1);








}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T--){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


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

int main() {
    int n;
    cin >> n;

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

    for (int i = 0; i < n - 1; i++){
        if (i == 0){
            a.at(i) = b.at(i);
            a.at(i + 1) = b.at(i);
        }
        else{
            if (b.at(i - 1) < b.at(i)){
                a.at(i + 1) = b.at(i);
            }
            else{
                a.at(i) = b.at(i);
                a.at(i + 1) = b.at(i);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++){
        ans += a.at(i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>void precise(T x) { cout << setprecision(21) << x << '\n'; }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 1e9 + 7;




int main()
{
    ll N;
    cin >> N;
    vll A(N), B(N), C(N);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> B[i];
    rep(i, 0, N) cin >> C[i];
    srt(A); srt(B); srt(C);
    //rep (i, 0, N) cout << A[i] << ' ';
    ll acnt, bcnt, ccnt;
    ll bel;
    ll tmp;
    ll s = 0;
    rep(i, 0, N) {
        bel = B[i];
        tmp = lower_bound(A.begin(), A.end(), bel) - A.begin();
        acnt = tmp;
        //if (tmp >= N) acnt = 0;
        tmp = upper_bound(C.begin(), C.end(), bel) - C.begin();
        ccnt = N - tmp;
        //if (tmp >= N) ccnt = 0;
        s += acnt * ccnt;
    }
    cout << s << endl;

}

Measured memory_bytes: 2560
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (auto& e : A)cin >> e;
  int span = K + A[0] - A[N - 1];
  for (int i = 0; i < N - 1; ++i)
    span = max(span, A[i + 1] - A[i]);
  cout << K - span << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <ctype.h>
#define NMAX 100000

int *stack;  int top=0;

void push(int x)
{
  if(top>NMAX-1){
    free(stack);  exit(-1);
  }
  stack[top++]=x;
}

int pop()
{
  if(top<0){
    free(stack);  exit(-1);
  }
  return stack[--top];
}

void solve()
{
  bool intflag=false;
  int temp=0;  char ch;
  while(1){
    fscanf(stdin,"%c",&ch);
    if(ch=='\n')  break;
    else if(ch==' '){
      if(intflag){  push(temp);  temp=0;  intflag=false;  }
    }else if(isdigit(ch)){  temp=temp*10+((int)ch-'0');  intflag=true;  }
    else if(ch=='+'){  int t=pop();  stack[top-1] +=t;  }
    else if(ch=='-'){  int t=pop();  stack[top-1] -=t;  }
    else if(ch=='*'){  int t=pop();  stack[top-1] *=t;  }
  }
}

int main()
{
  stack=malloc(NMAX*sizeof(int));
  solve();
  printf("%d\n",stack[0]);
  free(stack);
  return 0;
}

Measured memory_bytes: 1860
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		char[]a = A.toCharArray();
		char[]b = B.toCharArray();
		
		if(a[0]==b[0]) {
			System.out.print("H");
		}else {
			System.out.print("D");
		}
	}
}


Measured memory_bytes: 35556
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
 
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,i,j;
	cin>>n;
	ll a[n+2][3];
	for(i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	ll dp[n+2][3];
	for(i=0;i<3;i++)
		dp[0][i]=a[0][i];
	for(i=1;i<n;i++)
	{
		dp[i][0] = a[i][0]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = a[i][1]+max(dp[i-1][2], dp[i-1][0]);
		dp[i][2] = a[i][2]+max(dp[i-1][1], dp[i-1][0]);
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<nl;
	return 0;
}

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

int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> nums(40);

	for(int i=0; i<n; i++){
		cin >> a[i];
		for(int j=0; j<40; j++) if(a[i] & (1ll << j)) nums[j]++;	
	}

	ll ans = 0;
	for(int i=39; i>=0; i--){
		if(nums[i]*2 <= n) ans += (1ll << i);
		if(ans > k) ans -= (1ll << i);
	}

	ll sum = 0;
	for(ll A : a) sum += A^ans;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3980
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>

int main() {
	int n;
	std::cin >> n;
	switch (n) {
	case 1: std::cout << "Hello World" << std::endl; break;
	case 2:
		int a, b;
		std::cin >> a >> b;
		std::cout << a + b << std::endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
constexpr int INF = 1e9;
using namespace std;
using YX = pair<int, int>;

istream &operator>>(istream &is, YX &p) {
    is >> p.first >> p.second;
    return is;
}

int dist[51][51];

int bfs(vector<string> maize, int r, int c, YX start, YX goal) {
    const vector<YX> MOVES = {
        make_pair(-1, 0),  // up
        make_pair(0, 1),   // right
        make_pair(0, -1),  // left
        make_pair(1, 0)    // bottom
    };
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            dist[i][j] = INF;  // 未到達をINFで初期化
        }
    }
    dist[start.first][start.second] = 0;  // start地点は0

    queue<YX> que;
    que.push(start);

    while (!que.empty()) {
        YX prev = que.front();
        que.pop();

        for (YX p : MOVES) {
            int y = prev.first + p.first;
            int x = prev.second + p.second;
            // maizeの外ならskip
            if (y < 0 || y >= r || x < 0 || x >= c) continue;
            // 黒ならskip
            if (maize[y][x] == '#') continue;
            // 通過済みならskip
            if (dist[y][x] != INF) continue;

            // 直前のノードまでの最短距離+1
            dist[y][x] = dist[prev.first][prev.second] + 1;
            if (y == goal.first && x == goal.second) {
                return dist[y][x];
            }
            // このノードから距離1で到達できるところを探したいのでqueueに突っ込む
            que.push(make_pair(y, x));
        }
    }
    return -1;
}

int main() {
    int H, W;
    cin >> H >> W;

    YX start = make_pair(0, 0);
    YX goal  = make_pair(H - 1, W - 1);

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

    int dst = bfs(s, H, W, start, goal);
    if (dst == -1)
        cout << "-1\n";
    else {
        int whites = 0;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (s.at(i).at(j) == '.') whites++;
            }
        }
        cout << whites - (dst + 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int x;
	cin >> x;
	if (x == 7 || x == 5 || x == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int max_pairs = (n-2) * (n-1) / 2; 
    if(k > max_pairs){
        cout << -1 << endl;
        return 0;
    }
    cout << (n-1) + max_pairs - k << endl;
    for(int i=0;i<n-1;++i)
    {
        cout << "1 " << i+2 << endl;
    }

    int src = 2;
    int dst = 3;
    for(int i=0;i<(max_pairs - k); ++i)
    {
        cout << src << " " << dst << endl;
        if(dst == n)
        {
            src++;
            dst = src + 1;
        }
        else
        {
            dst++;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
	int d;
	scanf("%d",&d);
	if(d==25){
		printf("Christmas\n");
	}else if(d==24){
		printf("Christmas Eve\n");
	}else if(d==23){
		printf("Christmas Eve Eve\n");
	}else if(d==22){
		printf("Christmas Eve Eve Eve\n");
	}

	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,m,c;
  cin >> n >> m >> c;
  ll b[m];
  ll ans =0;
  rep(i,m) cin >> b[i];
  
  rep(i,n){
    ll lo=c;
    ll mo;
    rep(j,m){
      cin >> mo;
      lo = lo + mo * b[j];
    }
    if(lo>0) ans++;
  }
  pri(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[4], dp[4];
signed main(){
	int n;
	rep(i,4)scanf("%lld", &a[i]);
	scanf("%lld", &n);
	rep(i,4){
		dp[i] = a[i];
		if(i-1 >= 0)dp[i] = min(dp[i], dp[i-1]*2);
	}
	//rep(i,4)printf("%lld ", dp[i]);
	int ans = 0;
	int t = n/2;n -= 2*t;
	ans += t*dp[3];
	ans += n*dp[2];
	printf("%lld\n",ans);
	return 0;
}




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

int a,b,c,d;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>a>>b>>c>>d;
	if(b < c ||d < a)
		cout<<0;
	else
		cout<<min(b,d) - max(a,c);
	return 0;
}

Measured memory_bytes: 256
#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 fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, d, x;
  cin >> n >> d;
  v1i v(n);
  rep(i, n) cin >> v[i];
  x = abs(v[0] - d);
  rep(i, n-1) x = __gcd(x, abs(d - v[i+1]));
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		System.out.println((A + B) < 10 ? (A + B) : "error");
		scan.close();

	}

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double n = sc.nextInt();
		if(n%2 == 0) {
			System.out.println(n/(2*n));
		}else {
			System.out.println((n+1)/(2*n));
		}
		sc.close();

	}

}

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

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    const ll off(-'a'+'A');

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    printf("%c%c%c\n", s1[0]+off, s2[0]+off, s3[0]+off);
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n;
	cin >> n;
	cout << n * n * n;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3620
N, K = map(int, input().split())
D = [int(n) for n in input().split()]
ans = 10000000000

for i in range(N-K+1):
    L = D[i]
    R = D[i+K-1]
    LR = abs(L) + abs(L - R)
    RL = abs(R) + abs(R - L)
    ans = min(ans, min(LR, RL))

print(ans)


Measured memory_bytes: 19964
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    int n, i, j, k, r, g, b, ans=0;
    scanf("%d %d %d %d", &r, &g, &b, &n);
    
    for(i=0; i*r<=n; i++){
        for(j=0; (i*r)+(j*g)<=n; j++){
            if((n-(i*r)-(j*g))%b == 0) ans++;
        }
    }
    printf("%d", ans);
    
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	n  = 10
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	heights := make([]int, n, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		heights[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(heights)))

	for i := 0; i < 3; i++ {
		fmt.Println(heights[i])
	}
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    vvi dp(2, vi(52, 0));

    string line;
    int before_n = 0;
    bool latter = false;
    while (cin >> line) {
        int n = 1;
        size_t idx = 0, found;
        while ((found = line.find(',', idx)) != string::npos) {
            n++;
            idx = found + 1;
        }
        if (!latter && n < before_n) {
            latter = true;
        }
        before_n = n;
        stringstream ss(line);
        vi ns(n, 0);
        ss >> ns[0];
        FOR(i, 1, n) {
            char sep;
            ss >> sep >> ns[i];
        }

        REP(i, n) {
            if (latter) {
                dp[1][i+1] = max(dp[1][i+1], dp[0][i+1] + ns[i]);
                dp[1][i+1] = max(dp[1][i+1], dp[0][i+2] + ns[i]);
            } else {
                dp[1][i+1] = max(dp[1][i+1], dp[0][i] + ns[i]);
                dp[1][i+1] = max(dp[1][i+1], dp[0][i+1] + ns[i]);
            }
        }
        dp[0] = dp[1];

//        REP(i, 7) {
//            LOG("%d ", dp[0][i]);
//        }
//        LOG("\n");
    }
    cout << dp[0][1] << endl;
}

Measured memory_bytes: 1244
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;
int n;
int a[200005];
int dp[200005];

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		--a[i];
	}
	int maxn=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]==0)
		{
			dp[a[i]]=1;
			continue;
		}
		dp[a[i]]=dp[a[i]-1]+1;
		maxn=max(maxn,dp[a[i]]);
	}
	cout<<n-maxn<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include "atcoder/all"

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[300005];

ll op(ll a, ll b) { return std::max(a, b); };

ll e() { return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    vector<ll> B(300005, 0);
    atcoder::segtree<ll, op, e> seg(B);

    ll ans = 0;
    for (ll i = N - 1; i >= 0; --i) {
        ll mn = std::max(0LL, A[i] - K);
        ll mx = std::min(300002LL, A[i] + K) + 1;
        ll p = seg.prod(mn, mx) + 1;
        ans = std::max(ans, p);
        seg.set(A[i], p);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 100001;
ll par[N];
ll n,m,kotoba[N];

void init(ll n){
	FOR(i,1,n+1)par[i]=i;
}
ll root(ll x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = root(par[x]);
	}
}
void unite(ll x,ll y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}

int main(){
	cin>>n>>m;
	FOR(i,0,N)kotoba[i]=-1;
	init(n);
	FOR(i,1,n+1){
		ll k;
		cin>>k;
		FOR(j,1,k+1){
			ll l;
			cin>>l;
			if(kotoba[l]==-1)kotoba[l]=i;
			else {
				unite(kotoba[l],i);
			}
		}
	}

	FOR(i,2,n+1){
		if(root(1)!=root(i)){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;
	if (S[A] != '-') {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < A; ++i) {
		if (S[i] == '-') {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = A + 1; i < A + B; ++i) {
		if (S[i] == '-') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

int main() {

  int N;
  int M;
  cin >> N >> M;
  vector<int> high(N,0);
  vector<vector<int>> roadHigh(N);

  for(int i=0; i<N; i++){
    cin >> high.at(i);
    roadHigh.at(i).push_back(high.at(i));
  }

  for(int i=0; i<M; i++){
    int matiA;
    int matiB;
    cin >> matiA >> matiB;
    roadHigh.at(matiA-1).push_back(high.at(matiB-1));
    roadHigh.at(matiB-1).push_back(high.at(matiA-1));
  }

  int ans = 0;

  for(int i=0; i<N; i++){
    sort(roadHigh.at(i).begin(),roadHigh.at(i).end());
    reverse(roadHigh.at(i).begin(),roadHigh.at(i).end());

    if(roadHigh.at(i).size()==1){
      ans++;
      continue;
    }
    
    if(roadHigh.at(i).at(0)==high.at(i)){
      if(roadHigh.at(i).at(0)>roadHigh.at(i).at(1)){
        ans++;
      }
    }
  }

  cout << ans << endl;
}


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

int	main(void)
{
	vector<int> array(3);
	int judge = 0;
	for (int i = 0; i < 3; i++)
	{
		cin >> array[i];
			if (array[i] == 5)
			{
				judge += 1;
			}
			else if (array[i] == 7)
			{
				judge -= 1;
			}
	}

	if (judge == 1)
		cout << "YES" << endl;

	else
		cout << "NO" << endl;

	return (0);
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N = int(input())
A = list(map(int, input().split()))
d = dict()
for i in range(1,N+1):
    d[i] = 0

for i in range(len(A)):
    d[A[i]] += 1

for i in range(1,N+1):
    print(d[i])

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

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint A[N];
  REP(i,N)cin>>A[i];
  lint t=0;
  lint ans=0;
  REP(i,N){
    if(A[i]>=t){
      t=A[i];
    }else{
      ans+=t-A[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5156
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# レベルNバーガーの下からX層目まで
N, X = getNM()

# レベルNバーガーの中間地点、全体のサイズ
cnt_burger = [[0 for i in range(2)] for i in range(51)]
cnt_burger[0] = [1, 1]
for i in range(1, 51):
    cnt_burger[i][0] = 1 + cnt_burger[i - 1][1] + 1
    cnt_burger[i][1] = cnt_burger[i][0] + cnt_burger[i - 1][1] + 1

# レベルNバーガーにパティが何枚含まれる？
cnt_patty = [0] * 51
cnt_patty[0] = 1
for i in range(1, 51):
    cnt_patty[i] = 2 * cnt_patty[i - 1] + 1

# レベルNの下からX番目までにパティが何枚含まれるか
# xが大きいのでdpはできない
def count(n, x):
    # レベル0バーガーの場合
    if n == 0 and x == 1:
        return 1

    # バーガーの一番下のパンのみ食べる場合
    if x == 1:
        return 0

    # 中間地点以前のどこかまで食べる場合
    elif 1 < x < cnt_burger[n][0]:
        # レベルn - 1バーガーの下からx - 1層目まで
        return count(n - 1, x - 1)

    # 中間地点まで食べる
    elif x == cnt_burger[n][0]:
        return cnt_patty[n - 1] + 1

    # 中間地点 ~ 最後以前のうちのどこか
    elif cnt_burger[n][0] < x < cnt_burger[n][1]:
        return cnt_patty[n - 1] + 1 + count(n - 1, x - cnt_burger[n][0])

    # 最後
    else:
         return 2 * cnt_patty[n - 1] + 1

print(count(N, X))

Measured memory_bytes: 83704
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;

int n,k;
vector<int> heights;
int dp[100005];

int solve(int curr){
    if(curr == n) return 0;
    if(curr > n) return INT_MAX;
    if(dp[curr] != -1) return dp[curr];
    int ans = INT_MAX;
    for(int i = 1 ; i <= k ; i++){
        if(curr + i > n) break;
        ans = min(ans, solve(curr + i) + abs(heights[curr] - heights[curr + i] ));
    }
    return dp[curr] = ans;
}

int32_t main()
{
    cin>>n>>k;
    heights.resize(n+1);
    memset(dp, -1, sizeof dp);
    for(int i = 1 ; i <= n ; i++) cin>>heights[i];
    cout<<solve(1);

    return 0;
}


Measured memory_bytes: 11088
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll b,c,cnt=0,n;
ll a[205]={},flag=0;
string s;

int main(){
    cin>>n;
    for(int i=0; i<n; i++){
       cin>>a[i];
    }
    while(1){
        for (int j = 0; j < n; j++)
        {
            if (a[j] % 2 != 0){
                flag = 1;
                break;

            }else{
                a[j] /= 2;
            }
        }
        if(flag)break;
        cnt++;
    }
    
    cout<<cnt<<endl;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VI a(n);
    FOR(i,0,n-1) cin >> a[i];
    
    int mn = *min_element(a.begin(), a.end());
    int mx = *max_element(a.begin(), a.end());
    
    if (mx - mn > 1) {
        cout << "No";
        return 0;
    }
    
    if (mn == mx) {
        if (mn == n-1) {
            cout << "Yes";
        } else {
            int minColors = 1;
            int maxColors = (n - n%2) / 2;
            
            if (minColors <= mn && mn <= maxColors) {
                cout << "Yes";
            } else {
                cout << "No";
            }
        }
        
        return 0;
    }
    
    int cntA = 0, cntB = 0;
    for (int x : a) {
        if (x == mn) cntA++;
        else cntB++;
    }
    
    if (cntB == 1) {
        cout << "No";
        return 0;
    }
    
    int minColors = cntA + (cntB != 0);
    int maxColors = cntA + (cntB % 2 == 0 ? cntB / 2 : (cntB - 1) / 2);
    
    if (minColors <= mx && mx <= maxColors) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 640
#include <stdio.h>
 
int main() {
  int x, y;
  while(1) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0) break;
    if (x <= y) {
      printf("%d %d\n", x, y);
    } 
    else {
      printf("%d %d\n", y, x);
    }
  }
  return 0;
}
/*
int main()
{
  int x, y;
  while(1)
  {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0) break;
    if (x <= y) printf("%d %d\n", x, y);
    else printf("%d %d\n", y, x);
  }
  return 0;
}
*/

Measured memory_bytes: 1028
S = input() # 文字列を変数に格納

L = len(S)
K = 0
next = 1

for i in range(L):
    if i == L-1:
        if next == 1:
            K += 1
        break
    
    if next ==1 or next == 2:
        K += 1


    if next == 3:
        next = 1
    elif next == 2:
        next = 3        
    elif S[i] == S[i+1] and next == 1:
        next = 2
    elif S[i] != S[i+1] and next == 1:
        next = 1
    
print(K)

Measured memory_bytes: 3500
#include <stdio.h>
#include <limits.h>
#define MAX 101
void matrixChainOrder(int);
void min(int,int,int);
int p[MAX];
int m[MAX][MAX];


int main(){
  int i,n,a,j,b,result=0;
  for(i = 0;i<MAX;i++){
    for(j=0;j<MAX;j++){
      m[i][j]=0;
    }
  }
  for(i = 0 ;i<MAX;i++){
    p[i] =0;
  }
  scanf("%d",&n);
  for(i = 0 ;i<=n;i++){
    scanf("%d %d",&b,&a);
    if(i==n-1){
      p[i] =b;
      p[i+1] =a;
      break;
    }
    else p[i] = b;
  }
  matrixChainOrder(n);
  
  printf("%d\n",m[1][n]);


  
  return 0;
}
void matrixChainOrder(int a){
  int i,l,j,k,q;
  for(i = 1;i<=a;i++){
    m[i][i]=0;
  }
  for(l = 2 ;l<=a;l++){
    for(i=1;i<=a-l+1;i++){
      j=i+l-1;
      m[i][j] =INT_MAX;
      for(k = i;k<=j-1;k++){
	q = m[i][k] +m[k+1][j] +p[i-1]*p[k]*p[j];
	min(q,i,j);
      }
    }
  }
}

void min(int q,int i,int j){
  if(m[i][j]>q){
    m[i][j]=q;
  }
}



Measured memory_bytes: 2112
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9) cout << -1;
    else cout << a * b;
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

int n;
int sx, sy, gx, gy;
int lx, ly;

struct Point{
	int cost, t;
	int x, y;
	bool operator < ( const Point &right ) const {
		return cost <= right.cost;
	}
	bool operator > ( const Point &right ) const {
		return cost > right.cost;
	}
};

//typedef pair<pair<int,int>,Point> P;
const int dx[16] = { 0, 1, 1, 0,-1,-1, 0, 0, 1, 1, 0,-1,-1, 0};
const int dy[16] = { 1, 0,-1,-1,-1, 0, 0, 1, 1, 0,-1, 0, 1, 0};
bool m[300][300];
const int BASE = 150;

const int N = 300;
const int T = 6;
int dis[N][N][T];

int bfs(Point p, Point g){
	priority_queue<Point, vector<Point>, greater<Point>> q;
	rep(i,N) rep(j,N) rep(k,T) dis[i][j][k] = INF;

	dis[p.y][p.x][0] = 0;
	Point tmp = Point{0,0,p.x,p.y};
	q.push(tmp);

	while(not q.empty()){
		Point c = q.top(); q.pop();

		int order = abs((c.x - BASE) * (c.y - BASE) * c.t) % 6;
		rep(i,7){
			Point next;
			next.x = c.x + dx[i + (c.x % 2 ? 7 : 0)];
			next.y = c.y + dy[i + (c.x % 2 ? 7 : 0)];
			next.t = c.t + 1;
			if(next.x < BASE - lx || next.x > BASE + lx || 
			   next.y < BASE - ly || next.y > BASE + ly) continue;

			int add = i == order ? 0 : 1;
			if(m[next.y][next.x] == false && dis[next.y][next.x][next.t % 6] > dis[c.y][c.x][c.t % 6] + add){
				dis[next.y][next.x][next.t % 6] = dis[c.y][c.x][c.t % 6] + add;
				Point tmp = Point{dis[next.y][next.x][next.t % 6], next.t, next.x, next.y};
				q.push(tmp);
			}
		}

	}
	int ans = INF;
	rep(i,T) ans = min(ans, dis[g.y][g.x][i]);
	return ans;
}

int main(){
	Point s, g;
	cin >> s.x >> s.y >> g.x >> g.y >> n;
	s.x += BASE;
	s.y += BASE;
	g.x += BASE;
	g.y += BASE;
	rep(i,n){
		int x, y;
		cin >> x >> y;
		m[BASE + y][BASE + x] = true;
	}
	cin >> lx >> ly;
	int ans = bfs(s,g);
	cout << (ans == INF ? -1 : ans) << endl;
}

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

int main(){
  string s;
  int ans = 0;
  cin >> s;
  
  for (int i = s.size() - 2; i > 1; i -= 2){
    int half = i / 2;
    for ( int j = 0; j < half; j++ ){
      if(s[j] != s[j + half]){
        break;
      }else if(j == half - 1){
        cout << i << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		return gcd(b, a % b);
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

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

		System.out.println(gcd(a, b));

		scan.close();
	}

}

Measured memory_bytes: 17228
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<set>
typedef long long ll;

const int maxn=1e5+5;

using namespace std;

char s[15];

int main()
{
    scanf("%s",s);
    if(!strcmp(s,"hi")||!strcmp(s,"hihi")||!strcmp(s,"hihihi")||!strcmp(s,"hihihihi")||!strcmp(s,"hihihihihi"))
        printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC50(void);
void ABC51(void);
void ABC52(void);
void ABC53(void);
void ABC54(void);
void ABC55(void);
void ABC56(void);
void ABC57(void);
void ABC58(void);
void ABC59(void);

int main(void){
    ABC57();
}

void ABC57(){
    int n,m,i,j,min,index,dis;
    cin>>n>>m;
    int a[n],b[n],c[m],d[m];
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(i=0;i<m;i++){
        cin>>c[i]>>d[i];
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            dis=abs(c[j]-a[i])+abs(d[j]-b[i]);
            if(j==0){
                min=dis;
                index=j;
            }
            if(dis<min){
                min=dis;
                index=j;
            }
        }
        cout<<index+1<<endl;
    }
}

Measured memory_bytes: 256
//omajinai c++
#include <iostream>
#include<cmath>

#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <map>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
constexpr auto mod = 1000000007;
using namespace std;
int main() {
	int n, r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r;
	}
	else {
		cout << r + 100 * (10 - n);
	}
}


Measured memory_bytes: 256
import sys
import string
sys.setrecursionlimit(5 * 10**5)
input = sys.stdin.readline

N = int(input())
S = input().rstrip('\n')

ans = ""

letters = list(string.ascii_uppercase)
for s in S:
    tmp = letters.index(s)
    ans += letters[(tmp + N) % 26]

print(ans)


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

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll ans = 0;
	ll m = a[0];
	REP(i,n-1){
		if(m > a[i]){
			ans += m - a[i];
		}
		m = max(m, a[i]);
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4744
/**
 * @author torith
 * @date 2018-10-24
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

    int N; cin >> N;
    vector<int> A,B,C;
    for (int i = 0; i < N; ++i) {
        int t; cin >> t;
        A.push_back(t);
    }

    for (int i = 0; i < N; ++i) {
        int t; cin >> t;
        B.push_back(t);
    }

    for (int i = 0; i < N; ++i) {
        int t; cin >> t;
        C.push_back(t);
    }

    sort(A.begin(),A.end());
    sort(C.begin(),C.end());

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ll l = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        ll r = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += l*r;
    }

    cout << ans << "\n";


    return 0;
}



Measured memory_bytes: 1784
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,k[100],ueee=0;
  cin>>a>>b;
  for(int i=0;i<a;i++){
    cin>>k[i];
    ueee+=k[i];
  }
  int n=b-ueee;
  sort(k,k+a);
  int ans=n/k[0];
  
  cout<<ans+a<<endl;
}

Measured memory_bytes: 256