akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;


int main(){
  ll k,q;
  cin >> k >> q;
  vector<ll> d(k);
  rep(i,k){
    cin >> d[i];
  }

  while(q--){
    ll n,x,m;
    cin >> n >> x >> m;
    vector<ll> z(k+1,0);
    vector<ll> r(k+1,0);
    rep(i,k){
      z[i+1] += z[i];
      if(d[i]%m==0){
        z[i+1]++;
      }
      r[i+1] = r[i] + d[i]%m;
    }
    ll ans = n-1 - (x%m+(r[k]*((n-1)/k))+r[(n-1)%k])/m - ((z[k]*((n-1)/k))+z[(n-1)%k]);
    cout << ans << ln;
  }
  return 0;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__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((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

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;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
int n, m;
vector<pair<int, pii>> e;
int kuras(){
	int cnt = 0;
	int res = 0;
	UnionFind uf(n);
	REP (i,e.size()) {
		if (uf.find(e[i].second.first) != uf.find(e[i].second.second)) {
			uf.unite(e[i].second.first, e[i].second.second);
			res = e[i].first;
			cnt++;
		}
		if (cnt == n - 1)
			break;
	}
	if (cnt != n - 1)
		return -1;
	else
		return res-e[0].first;
}
int main() {
	
	while (cin >> n >> m,n) {
		e.clear();
		e.resize(m);
		REP(i, m) {
			cin >> e[i].second.first >> e[i].second.second >> e[i].first;
			e[i].second.first--;
			e[i].second.second--;
		}
		SORT(e);
		int ans = 1000000000;
		while (!e.empty()) {
			int mi = kuras();
			if (mi == -1)break;
			ans = min(ans, mi);
			e.erase(e.begin());
		}

		if (ans == 1000000000)
			cout << -1 << endl;
		else
			cout << ans << endl;
	}
}

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

void dfs(vector<bool> &used,int s,vector<vector<int> > &g,vector<int> &res){
    used[s] = false;
    for(int i=0;i<g[s].size();i++){
	if(used[g[s][i]])dfs(used,g[s][i],g,res);
    }
    res.push_back(s);
    return ;
}
vector<int> tsort(vector<vector<int> > &g){
    int n = g.size();
    vector<bool> used(n,true);
    vector<int> res;
    for(int i=0;i<n;i++)if(used[i])dfs(used,i,g,res);
    return res;
}



int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int> > g(n);
    vector<int> dp(n,0);
    for(int i=0;i<m;i++){
	int x,y;
	cin>>x>>y;
	x--,y--;
	g[x].push_back(y);
    }
    vector<int> res = tsort(g);
 
    for(int i=0;i<n;i++){
	int now = res[i];
	for(int j=0;j<g[now].size();j++){
	    dp[now] = max(dp[now],dp[g[now][j]] + 1);
	}
    }
    int ans = 0;
    for(int i=0;i<n;i++)ans = max(ans,dp[i]);
    cout<<ans<<endl;
  //  for(int i=0;i<n;i++)cout<<' '<<dp[res[i]]<<' '<<res[i]<<endl;

    return 0;
}


Measured memory_bytes: 9468
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(n<10 && m<10) p(n*m);
    	else p(-1);
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
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 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 long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<string.h>
using namespace std;

int N;
int a[3001];
int main(){
    int sum = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        sum += a[i] - 1;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



typedef long long ll;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int A, B, C, D;
//-----------------------------------------------------------------
ll solve() {
	int W = abs(A - C);
	int H = abs(B - D);

	if (W == 0 || H == 0) return 0;

	int g = gcd(W, H);

	W /= g;
	H /= g;

	if (W > H) swap(W, H);
	if (W == H) return g;

	// これ以降 W <= H が成立
	
	ll ans = H + W - 1;
	ans *= g;

	return ans;
}
//-----------------------------------------------------------------
int main() {
	cin >> A >> B >> C >> D;

	cout << solve() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#ifndef LIB_REPEAT_HPP
#define LIB_REPEAT_HPP
#define repeat(i,n) for (int i = 0; i < (n); ++i)
#define repeat_from(i,m,n) for (int i = (m); i < (n); ++i)
#define repeat_one(i,n) for (int i = 1; i <= (n); ++i)
#define repeat_rev(i,n) for (int i = (n)-1; 0 <= i; --i)
#define foreach(it, cont) for (decltype(cont.begin()) it = cont.begin(); it != cont.end(); ++it)
#endif
using namespace std;
typedef int tribool;
tribool tri_negate(tribool x) { return 2 - x; }
tribool tri_mult(tribool x, tribool y) { return min(x,y); }
tribool tri_plus(tribool x, tribool y) { return max(x,y); }
string s;
int p, q, r;
int ix;
tribool eval() {
    switch (s[ix]) {
        case '0':
        case '1':
        case '2':
            ix += 1; return s[ix-1]-'0';
        case 'P':
            ix += 1; return p;
        case 'Q':
            ix += 1; return q;
        case 'R':
            ix += 1; return r;
        case '-':
            ix += 1; return tri_negate(eval());
        case '(': {
            ix += 1; tribool a = eval();
            char op = s[ix]; ix += 1;
            tribool b = eval();
             ix += 1; // consume ')'
            switch (op) {
                case '*':
                    return tri_mult(a,b);
                case '+':
                    return tri_plus(a,b);
                default:
                    assert(false);
            }
        }
        default:
            assert(false);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    while (true) {
        cin >> s;
        if (s == ".") break;
        int cnt = 0;
        repeat (i,27) {
            p = i/9;
            q = (i/3)%3;
            r = i%3;
            ix = 0;
            if (eval() == 2) {
                cnt += 1;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.*;
 
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] map=new char[h][w];
for(int i=0;i<h;i++){
map[i]=br.readLine().toCharArray();
}
Deque <Point> fifo  =new  ArrayDeque<Point>();
            int ans=0;
            for(int m=0;m<h;m++){
                for(int n=0;n<w;n++){
            if(map[m][n]!='.'){
                ans++;
                Point p = new Point(n,m);
                fifo.addLast(p);
            while(fifo.peekFirst()!=null){
                p=fifo.pollFirst();
                int x=p.x;
                int y=p.y;
                char crop = map[y][x];
                map[y][x]='.';
                int [] dx ={0,1,0,-1};
                int [] dy ={1,0,-1,0};
                  
                for(int i=0;i<4;i++){
                    int nx =x+dx[i];
                    int ny =y+dy[i];
                    if(0<=nx&&nx<w&&0<=ny&&ny<h&&map[ny][nx]==crop&&map[ny][nx]!='.'){
                        Point np = new Point();
                        np.x=nx;
                        np.y=ny;
                     fifo.addLast(np);                       
}
}
}
}
}
}System.out.println(ans);
}
}
}

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

int main()
{
  int n, k, r, s, p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;
  string u;

  for (int i = 0; i < n; i++) {
    switch (t[i]) {
    case 'r': u += 'p'; break;
    case 's': u += 'r'; break;
    case 'p': u += 's'; break;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i < k || u[i] != u[i - k]) {
      switch (u[i]) {
      case 'r': ans += r; break;
      case 's': ans += s; break;
      case 'p': ans += p; break;
      }
    } else {
      if (i + k < n) {
        switch (u[i + k]) {
        case 'r': u[i] = 's'; break;
        case 's': u[i] = 'p'; break;
        case 'p': u[i] = 'r'; break;
        }
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >>s ;
	string t = s;
	rSORT(t);
	//S = rSORT(s);
	int count = 0;
	for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] != t[i]){
			count ++;
		}
	}
	int ans = count / 2;
	cout << ans << endl;
}



Measured memory_bytes: 256
import bisect
n=int(input())
a=sorted([int(i) for i in input().split()])
b=sorted([int(i) for i in input().split()])
c=sorted([int(i) for i in input().split()])
ans=0
for B in b:
    m=bisect.bisect_left(a,B)
    l=bisect.bisect_right(c,B)
    ans+=m*(n-l)
print(ans)

Measured memory_bytes: 23244
def main():
    N, M = map(int, input().split())
    AB = sorted([tuple(map(int, input().split()))
                 for _ in range(N)], key=lambda x: x[0])
    ans = 0
    for A, B in AB:
        ans += min(M, B) * A
        M -= B
        if 0 >= M:
            break
    print(ans)


main()


Measured memory_bytes: 18856
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            String c = in.next();
            out.printf("%C%C%C\n", a.charAt(0), b.charAt(0), c.charAt(0));
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

vector<double> A;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        A.resize(n);
        FOR(i,0,n)
            cin >> A[i];
        while (A.size() > 1) {
            sort(ALL(A)); reverse(ALL(A));
            const double a = A.back(); A.pop_back();
            const double b = A.back(); A.pop_back();
            const double c = (a+b)/2;
            A.push_back(c);
        }
        const double ans = A[0];
        printf("%.6f\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define lop(i,a,b) for(ll i=a;i<b;i++)
using namespace std;

void func(){
    string s,t;
    cin>>s>>t;
    int ss=s.size(),ts=t.size(),score,min=ts;
    lop(i,0,ss-ts+1){
        score=0;
        lop(j,0,ts){
            if(s[i+j]!=t[j])
                score++;
        }
        if(score<min)min=score;
        if(!min)break;
    }
    cout<<min<<endl;
}

int main(){
    fastio;
    func();
}

Measured memory_bytes: 3636
class UnionFind:
    __slots__ = ["_data_size", "_roots"]

    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size

    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x


import sys

readline = sys.stdin.buffer.readline

N, Q = map(int, readline().split())
tree = UnionFind(N)
res = []
for _ in range(Q):
    t, u, v = map(int, readline().split())
    if t:
        res.append(int(tree.is_connected(u, v)))
    else:
        tree.unite(u, v)
print("\n".join(map(str, res)))


Measured memory_bytes: 84336
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int n,q,com,x,y;
int *parent,*club,*rank;

int find(int x){
	if(x == parent[x])return x;
	else{
		return parent[x] = find(parent[x]);
	}
}

bool isSame(int x,int y){
	return find(x) == find(y);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);

	if(x == y)return;

	if(rank[x] < rank[y]){
		parent[x] = y;
	}else{
		parent[y] = x;
		if(rank[x] == rank[y])rank[x]++;
	}
}

int main(){

	int N,M,K,tmp,left,right;
	scanf("%d %d %d",&N,&M,&K);

	parent = new int[N+1];
	club = new int[N+1];
	rank = new int[N+1];
	for(int i = 1; i <= N; i++){
		parent[i] = i;
		club[i] = -1;
		rank[i] = 0;
	}

	int ans = 0;

	for(int loop = 1; loop <= K; loop++){
		scanf("%d",&tmp);

		if(tmp == 1){
			scanf("%d %d",&left,&right);
			if(club[find(left)] == -1 && club[find(right)] == -1){
				unite(left,right);
			}else if(club[find(left)] == -1 && club[find(right)] != -1){
				club[find(left)] = club[find(right)];
				unite(left,right);
			}else if(club[find(left)] != -1 && club[find(right)] == -1){
				club[find(right)] = club[find(left)];
				unite(left,right);
			}else{
				if(club[find(left)] != club[find(right)]){
					if(ans == 0)ans = loop;
				}else{
					unite(left,right);
				}
			}
		}else{
			scanf("%d %d",&left,&right);
			if(club[find(left)] == -1){
				club[find(left)] = right;
			}else{
				if(club[find(left)] == right){
					//Do nothing
				}else{
					if(ans == 0)ans = loop;
				}
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 3820
#include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define ALL(x) (x).begin(),(x).end()
#define CASET2 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d:\n", case_n++) : 0), ___T-- > 0)
#define CASET1 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d: ", case_n++) : 0), ___T-- > 0)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define WRI(argv...) while (RI(argv) != EOF)
#define DWRI(x...) int x; WRI(x)
#define RS(x) scanf("%s",x)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define V(x) vector<x >

typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;

void print(int i) { printf("%d", i); }
void print(LL i);
template<class T> void PI(T i) { print(i); puts(""); }
template<class T> void PIS(T i) { print(i); printf(" "); }

template<class T>
void PV(T const &v, int N) {
    REP(i, N) {
        print(v[i]);
        printf("%c", i == N-1 ? '\n' : ' ');
    }
}

template<class T> void PV(T const &v) { PV(v, SZ(v)); }

template<class T, class S> bool has_bit(T mask, S i) { return (mask >> i) & 1; }
long long shift(int i) { return 1ll << i; }

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
int popcount(int x) { return __builtin_popcount(x); } 
int popcount(long long x) { return __builtin_popcountll(x); } 

#include <unordered_set>
#include <unordered_map>
#define EB emplace_back
#define RL(x) scanf("%lld", &(x))
#define PL(x) printf("%lld\n", x)
#define DRL(x) LL x; RL(x)

int main() {
  DRI(N);
  int c = 0;
  REP(i, N) {
    DRI(a);
    c += a % 2;
  }
  if (N == 1 || c % 2 == 0) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        double[] x={scan.nextDouble()};
        
        System.out.println(String.format("%f", x[0]*x[0]*Math.PI)+" "+String.format("%f", 2*x[0]*Math.PI));
    }
}


Measured memory_bytes: 28240
from itertools import groupby

N=int(input())
H=list(map(int,input().split()))
New=[1 if H[_]>=H[_+1] else 0 for _ in range(N-1)]
_max=0
for k,h in groupby(New):
    _sum=sum(list(h))
    if k==1 and _sum>_max:
        _max=_sum
print(_max)


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

int main () {
    ll l, r;
    cin >> l >> r;
    if(r - l >= 2019){
        cout << 0 << endl;
        return 0;
    }
    l %= 2019;
    r %= 2019;
    int Min = 2019;
    for(int i = min(l, r); i < max(l, r); i++) {
        for(int j = i + 1; j <= max(l, r); j++) Min = min((i * j) % 2019, Min);
    }
    cout << Min << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
#define inf 1010000000
#define infll 1010000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
using namespace std;

int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
int n,s[1000009]; char ch[1000009];
int main(){
	scanf("%d%s",&n,ch+1);
	int i;
	for (i=1; i<=n; i++) s[i]=s[i-1]+(ch[i]=='#');
	int ans=n;
	for (i=0; i<=n; i++) ans=min(ans,s[i]+(n-i-(s[n]-s[i])));
	printf("%d\n",ans);
	return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,data,m,h,w,x,y,xcmp,ycmp,sum=0;

string s;

vector<int> z;

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


    double aa, bb;
       cin >> aa >> bb;
       Cout(2*bb-aa);
return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String string = scanner.next();
        if (string.charAt(0) != string.charAt(1) && string.charAt(2) == string.charAt(3) && string.charAt(4) == string.charAt(5))
            System.out.println("Yes");
        else
            System.out.println("No");
    }

}

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

#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n";
#define all(a)  (a).begin(),(a).end();
#define SORT(a) sort((a).begin(),(a).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()

typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int n;

int main(){
    cin >> n;
    vector<int> p(n);
    REP(i,n){
        cin >> p[i];
    }
    p.push_back(1e6);
    int con = 0;
    int res = 0;
    REP(i,n+1){
        if(i+1==p[i]){
            con++;
        }else{
            res+=(con+1)/2;
            con = 0;
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 1024
import math

#n, a, b= map(int, input().split())
n, x  = map(int, input().split())
a = list(map(int, input().split()))
#s = list(str(input()))
#n = int(input())

#a = [""]*n
#for i in range(n):
#  a[i] = str(input())

#for i in range(n):
a.sort()
tot = 0
for i in range(n):
  tot = tot + a[i]
  if(x < tot):
    print(i)
    break

if(x == tot):
  print(i+1)
if(x > tot):
  print(i)

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int a,b;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3632
s = input()
now = 0
t = 0
ans = 1
LEN = len(s)
while now <= LEN-2:
  if s[now] == s[now+1] and t == 0:
    now += 2
    if now >= LEN:
      break
    t = 1
  else:
    now += 1
    t = 0
  ans += 1
print(ans)

Measured memory_bytes: 3500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        Set<Integer> notTargetSet = new HashSet<>();

        int result = 0;
        
        for(int i = 0; i < K; i++) {
            String d = br.readLine();
            String[] d_array = br.readLine().split(" ");

            for(String str : d_array) {
                notTargetSet.add(Integer.parseInt(str));
            }
        }

        for(int j = 1; j <= N; j++) {
            if(!notTargetSet.contains(j)) result++;
        }

        pw.print(result);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 34292
#include<cstdio>

int main(){
    long long n,amin=1000000,amax=-1000000,asum=0;
    scanf("%ld",&n);
    for(int i=0;i<n;i++){
        long long tmp;
        scanf("%ld",&tmp);
        if(amin>tmp)amin=tmp;
        if(amax<tmp)amax=tmp;
        asum+=tmp;
    }
printf("%ld %ld %ld\n",amin,amax,asum);
return 0;
    
}


Measured memory_bytes: 2704
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const [input, ...rest] = stdin.split('\n')

const res = {
  ['A']: 'T',
  ['G']: 'C',
  ['T']: 'A',
  ['C']: 'G',
}[input]

console.log(res)


Measured memory_bytes: 7372
//author : raghav_0901

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

void _main();
signed main(void){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t=1,i=0;
//cin>>t;
while (t--){
//cout<<"Case #"<<(++i)<<": ";

	_main();

}return 0;}

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


void _main(){
    int s,w;cin>>s>>w;
    cout<<((w>=s)?"unsafe":"safe");
    return;
}


Measured memory_bytes: 3636
import * as fs from 'fs';

namespace AtCoder.abc163 {

    export class Program {

        constructor(private readonly args: string[]) {
        }

        /**
         * in
         *
         * out
         *
         */
        main(this: Program): void {
            const r :number = parseInt(this.args[0],10);
            console.log((r*2)*Math.PI);
        }
    }
}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg: AtCoder.abc163.Program = new AtCoder.abc163.Program(args);
prg.main();


Measured memory_bytes: 29656
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    private static double MAX = 10_000;
    private static double MIN = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            double  r = Double.parseDouble(sc.nextLine());
            if (r > MAX || r < MIN) {
                throw new IllegalTestCaseException();
            }
            double a = Math.PI * r * r;
            double c = 2 * Math.PI * r;
            System.out.printf("%.8f %.8f\n", a, c);
        } catch (IllegalTestCaseException
                | NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static class IllegalTestCaseException extends RuntimeException {
        IllegalTestCaseException() {
            super("Condition is invalid.");
        }
    }
}



Measured memory_bytes: 26476
#include <stdio.h>
int main(){
int i, j, H, W;
for (;;){
scanf("%d %d", &H, &W);
if (H == 0 && W == 0 ) break;
for ( i = 1; i < H+1; i++ ){
for ( j = 1; j < W+1; j++)
if ( ( i + j ) % 2 == 0 )
printf("#");
else
printf(".");
printf("\n");
}
printf("\n");
}
return 0;
}



Measured memory_bytes: 2036
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<u32> = (0..5).map(|_| read()).collect();
    for (i,v) in s.iter().enumerate() {
        if *v == 0 {
            print!{"{}", i + 1}
        }
    }

}


Measured memory_bytes: 2072
#include <stdio.h>

int main(){
  char a[5];
  int count[26]={0};
  int i,j,flag=0;
  scanf("%s",a);
  
  for(i=0;i<4;i++){
  	for(j=0;j<26;j++){
    	if(a[i]=='A'+j) count[j]++;
    }
  }
  
  for(j=0;j<26;j++){
    //printf("count[%d]=%d\n",j,count[j]);
    if(count[j]==0 || count[j]==2) flag =0;
    else{
      flag=1;
      break;
    }
  }
  
  if(flag == 1) printf("No\n");
  else printf("Yes\n");
  
  return 0;
  
}

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

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

bool check(const vector<int>& a, int len) {
  set<int> d, e;
  d.insert(0);
  for (auto& x : a) {
    e.clear();
    for (auto& it : d) {
      e.insert(it + x);
      e.insert(it - x);
    }
    swap(d, e);
  }
  return d.count(len);
}

int main() {
  string s;
  int x, y;
  cin >> s >> x >> y;
  s += 'T';
  vector<int> a[2];
  int k = 0, cnt = 0;
  bool first = true;
  for (auto& c : s) {
    if (c == 'T') {
      if (k == 0 && first) {
        first = false;
        x -= cnt;
      } else {
        a[k].push_back(cnt);
      }
      k = 1 - k;
      cnt = 0;
    } else {
      ++cnt;
    }
  }
  // for (auto& it : a[0]) cout << it << " ";
  // cout << endl;
  // for (auto& it : a[1]) cout << it << " ";
  // cout << endl;
  // trace(x, y);
  if (check(a[0], x) && check(a[1], y)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n,d;
bool f(double x,double y){
	int z=ceil(sqrt(x*x+y*y));
	return z<=d;
}
int main() {
	cin>>n>>d;
	int res=0;
	for(int i=0,x,y;i<n;i++){
		cin>>x>>y;
		res+=f(x,y);
	}
	cout<<res;
	return 0;
}

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

int main(){
	int a[10];
	int b[3]={0,0,0};
	for(int i=0;i<10;i++){
		cin>>a[i];}
	for(int i=0;i<10;i++){
			if(a[i]>b[0]){
				b[2]=b[1];
				b[1]=b[0];
				b[0]=a[i];}
			else if(a[i]>b[1]){
				b[2]=b[1];
				b[1]=a[i];}
			else if(a[i]>b[2]){
				b[2]=a[i];}}
	for(int i=0;i<3;i++){
		cout<<b[i]<<endl;}
}

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

int Prime(int);

int main(){
  int n,i,count = 0,a,j,option;

  scanf("%d",&n);
  
  for(i = 0;i < n;i++){
    scanf("%d",&a);
    if(Prime(a)){
      count += 1;
    }
  }
  printf("%d\n",count);
  return 0;
}
int Prime(int i)
{
    int j;
    if(i <= 1){
      return 0;
    }
    else if(i == 2){
      return 1;
    }
    if(i%2 == 0)return 0;
    j = 3;
    while(j <= sqrt(i)){
      if(i%j == 0){
	return 0;
      }
      j = j+2;
    }
    return 1;
}



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

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

  int ans = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; i + j <= min(k, n); j++)
    {
      vector<int> hands;
      for (int p = 0; p < i; p++)
        hands.push_back(a[p]);
      for (int p = 0; p < j; p++)
        hands.push_back(a[n - 1 - p]);

      sort(hands.begin(), hands.end(), greater<int>());
      int sum = 0;
      for (int p = 0; p < i + j; p++)
      {
        sum += hands[p];
        if (i + j + i + j - p - 1 <= k)
          ans = max(ans, sum);
      }
    }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main(){
  int N, Q; string S; cin >> N >> Q >> S;
  //累積和
  vector<int> s(N+1, 0);
  for(int i=0; i<N; i++){
    if(i+1 < N && S[i] == 'A' && S[i+1] == 'C') s[i+1] = s[i] + 1;
    else s[i+1] = s[i];
  }
  
  for(int q=0; q<Q; q++){
    int l, r; cin >> l >> r;
    l--;
    r--;
    cout << s[r] - s[l] << endl;
  }
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

  public static void main(String [] args)throws IOException{
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int casos = Integer.parseInt(br.readLine());
    
    for(int i = 0; i < casos;i++){
      
      StringTokenizer st = new StringTokenizer(br.readLine());
      int [] l = new int [3];
      
      for(int t = 0; t < 3; t++)
        l[t] = Integer.parseInt(st.nextToken());
      
      Arrays.sort(l);
      
      if(l[0]*l[0] + l[1]*l[1] == l[2]*l[2])
        System.out.println("YES");
      else
        System.out.println("NO");        
    
    }
    
  }  
}

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

int main() {
    vector<int> x(5);
    rep(i,5){cin>>x[i];}
    int ans;
    rep(i,5){
        if(x[i] == 0){
            ans = i+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

#define f first 
#define s second 
#define mp make_pair
#define pb push_back

typedef long long ll;

const int mod=1e9+7;
const int INF=INT_MAX;

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

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


int main(){
    ll r,d,x;
    cin >> r >> d >> x;
    for(int i=0;i<10;i++){
        x=r*x-d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int dp[201][201][402];
int a[201][201];

int h,w;


int dfs(int x1,int x2,int k){
    if(~dp[x1][x2][k]) return dp[x1][x2][k];
    int ret = (x1==x2?a[k-x1][x1]:a[k-x1][x1]+a[k-x2][x2]);
    int t = 0;
    if(k==h+w) return ret;
    if(x1+1<w&&x2+1<w) chmax(t, dfs(x1+1,x2+1,k+1));
    if(k+1-x1<h&&x2+1<w) chmax(t, dfs(x1,x2+1,k+1));
    if(x1+1<w&&k+1-x2<h) chmax(t, dfs(x1+1,x2,k+1));
    if(k+1-x1<h&&k+1-x2<h) chmax(t, dfs(x1,x2,k+1));
    ret += t;
    return dp[x1][x2][k] = ret;
}



int main(){
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    cout << dfs(0,0,0) << endl;
    return 0;
}


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

class MainClass
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());

        var h = new int[N];

        var input = Console.ReadLine().Split(' ');

        // テーブル
        var dp = new int[N];

        for (var i = 0; i < N; i++)
        {
            h[i] = int.Parse(input[i]);
            dp[i] = int.MaxValue;
        }

        dp[0] = 0;

        for (var i = 1; i < N; i++)
        {
            dp[i] = chmin(dp[i], dp[i - 1] + Math.Abs(h[i] - h[i - 1]));

            if(i > 1)
            {
                dp[i] = chmin(dp[i], dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
            }
        }

        Console.WriteLine(dp[N - 1]);
    }

    public static T chmin<T> (T a, T b) where T : IComparable
    {
        if (a.CompareTo(b) > 0)
        {
            a = b;
            return a;
        }
        return a;
    }

    public static T chmax<T> (T a, T b) where T : IComparable
    {
        if (a.CompareTo(b) < 0)
        {
            a = b;
            return a;
        }
        return a;
    }
}

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

int a[55],b[55],c[55],d[55];
int A[20];
int ans = 0;
int n,m,q;

void dfs(int dep, int pre)
{
	if(dep == n+1)
	{
		int sum = 0;
		for(int i=0; i<q; i++)
		{
			if(A[b[i]] - A[a[i]] == c[i]) sum+=d[i];
		}
		ans = max(ans, sum);
		return;
	}
	for(int i=pre; i<=m; i++)
	{
		A[dep] = i;
		dfs(dep+1, i);
	}
}


int main()
{
	
	cin>>n>>m>>q;
	for(int i=0; i<q; i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(1,1);
	cout<<ans;
	return 0;
}

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

typedef struct PLIST{
	struct PLIST *pre;
	struct PLIST *next;
	int key;
}plist;

plist *head;
plist *tail;

int compStr(char *str0, char *str1){
	int i = 0;
	for( i = 0; str0[i] != '\0' || str1[i] != '\0'; i++ ){
		if( str0[i] != str1[i] ){ return 0; }
	}
	if( str0[i] != str1[i] ){ return 0; }
	return 1;
}

void insert(plist *p, plist *next){
	if( p == NULL ){ return; }
	if( next != NULL ){
		p->next = next;
		next->pre = p;
	}else{
		p->next = NULL;
		tail = p;
	}
	p->pre = NULL;
	head = p;
	return;
}

void delete(plist *p){
	if( p == NULL ){ return; }
	if( p->pre != NULL ){
		p->pre->next = p->next;
	}else{
		head = p->next;
	}
	if( p->next != NULL ){
		p->next->pre = p->pre;
	}else{
		tail = p->pre;
	}
	free(p);
	return;
}

int main(){
	int i = 0;
	int n = 0;
	char com[1024];
	int x = 0;
	scanf("%d", &n);
	plist *temp;
	for( i = 0; i < n; i++ ){
		scanf("%s", com);
		if( compStr(com, "insert\0") ){
			scanf("%d", &x);
			temp = (plist*)malloc(sizeof(plist));
			temp->key = x;
			insert(temp, head);
		}
		if( compStr(com, "delete\0") ){
			scanf("%d", &x);
			temp = head;
			while( temp != NULL ){
				if( temp->key == x ){ break; }
				temp = temp->next;
			}
			delete(temp);
		}
		if( compStr(com, "deleteFirst\0") ){
			delete(head);
		}
		if( compStr(com, "deleteLast\0") ){
			delete(tail);
		}
		/*
		temp = head;
		if( temp != NULL ){
			printf("%d", temp->key);
			while( (temp = temp->next) != NULL ){ printf(" %d", temp->key); }
		}
		printf("\n");
		*/
	}
	temp = head;
	if( temp != NULL ){
		printf("%d", temp->key);
		while( (temp = temp->next) != NULL ){ printf(" %d", temp->key); }
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; };
}
void solve() {
  int ans = INF;
  auto f = [](int k) {
    int cnt = 0;
    int kk = k;
    while ((kk & 1) == 0) {
      cnt++;
      kk >>= 1;
    }
    return cnt;
  };
  int oror = 0;
  for (auto x : va) {
    oror |= x;
  }
  ans = f(oror);
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

s = input()
bef = ""
ct = 0
for i in range(len(s)):
    if i == 0:
        bef = s[i]
        continue
    else:
        if bef != s[i]:
            bef = s[i]
        else:
            ct +=1
            if s[i] == "0":
                bef = "1"
            else:
                bef = "0"

ct1 = ct

s = s[::-1]

bef = ""
ct = 0
for i in range(len(s)):
    if i == 0:
        bef = s[i]
        continue
    else:
        if bef != s[i]:
            bef = s[i]
        else:
            ct +=1
            if s[i] == "0":
                bef = "1"
            else:
                bef = "0"

ct2 = ct
print(min([ct1,ct2]))












Measured memory_bytes: 3316
s = input()

if s == "SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
elif s == "SAT":
  print(1)


Measured memory_bytes: 2940