akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#pragma GCC optimize ("O3")

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}

inline static int sp(char* str, unsigned short i){
    if(i>99){
        char c0 = i%10; i/=10;
        char c1 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c1+48;
        str[2] = c0+48;
        return 3;
    }else if(i>9){
        char c0 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c0+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

char a[1001*500];
char buffer[8*1024*1024];

int main(void){
    const int h=gl(), w=gl();
    int p = 0;
    int pos=0;
    char *aa = a; 
    fread(a, 1, 2*w*h, stdin);
    {
        char haveCoin = 0;
        short old_y, old_x;
        for(int i=1; i<=h; i++){
            //fgets_unlocked(a, 1001, stdin);
            if(i%2==1){
                for(int j=1; j<=w; j++){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= aa[(j-1)*2]&1;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(int j=w; j>0; j--){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= aa[(j-1)*2]&1;
                    old_y = i;
                    old_x = j;
                }
            }
            aa+=2*w;
        }
    }
    pl(pos); putchar_unlocked('\n');
    fwrite(buffer, 1, p, stdout);
    return 0;
}


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

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[2] - a[0] << endl;
  return 0;
}

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

int main() {
	int n, k, x,y=0;
	cin >> n >> k;
	rep(i, n) {
		cin >> x;
		if (x > k) {
			y += (x - k) * 2;
		}
		else if (k - x < x) {
			y += (k - x) * 2;
		}
		else {
			y += x * 2;
		}
	}
	cout << y << endl;
	return 0;
}

Measured memory_bytes: 3568
# @author 

import sys

class GLongestPath:
    def dfs(self, s):
        if self.done[s]:
            return self.dp[s]

        self.done[s] = 1

        ans = 0
        for x in self.adj[s]:
            ans = max(ans, 1 + self.dfs(x))

        self.dp[s] = ans
        return ans

    def solve(self):
        import sys
        sys.setrecursionlimit(10 ** 5 + 5)
        from collections import defaultdict
        n, m = [int(_) for _ in input().split()]
        self.adj = defaultdict(list)
        self.dp = [0] * (n + 1)
        self.done = [0] * (n + 1)
        for i in range(m):
            u, v = [int(_) for _ in input().split()]
            self.adj[u].append(v)

        ans = 0
        for i in range(1, n + 1):
            ans = max(ans, self.dfs(i))

        print(ans)

solver = GLongestPath()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 127324
alphabet = list("abcdefghijklmnopqrstuvwxyz")
s = list(input())
t = list(input())
lis = []
lit = []
c = 0
for i in s:
    lis.append(alphabet.index(i))
for i in t:
    lit.append(alphabet.index(i))
lis.sort()
lit.sort(reverse = True)
if len(lis) < len(lit):
    for i in range(len(s)):
        if lis[i] < lit[i]:
            print("Yes")
            c = 0
            break
        elif lis[i] == lit[i]:
            c = 1
            continue
        else:
            print("No")
            c = 0
            break
    if c == 1:
        print("Yes")
        
else:
    for i in range(len(lit)):
        if lis[i] < lit[i]:
            print("Yes")
            c = 0
            break
        elif lis[i] == lit[i]:
            c = 1
        else:
            print("No")
            c = 0
            break
    if c == 1:
        print("No")

Measured memory_bytes: 3064
import numpy as np
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
a = np.array(v)
b = np.array(c)
c = a - b
c1 =c.tolist()
c2 = sorted(c1)
ans = 0
for i in c2:
    if(i >= 0):
        ans += i
print(ans)
        

Measured memory_bytes: 27064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  std::string s;
  std::cin >> s;
  std::string t;
  std::cin >> t;

  vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
  for (int i = 0; i < s.size(); ++i)
  {
    for (int j = 0; j < t.size(); ++j)
    {
      if (s[i] == t[j])
      {
        dp[i + 1][j + 1] = max({dp[i + 1][j], dp[i][j + 1], dp[i][j] + 1});
      }
      else
      {
        dp[i + 1][j + 1] = max({dp[i + 1][j], dp[i][j + 1], dp[i][j]});
      }
    }
  }
  string ans = "";
  for (int i = s.size(), j = t.size(); i > 0 && j > 0;)
  {
    if (dp[i][j] == dp[i - 1][j])
      i--;
    else if (dp[i][j] == dp[i][j - 1])
      j--;
    else
    {
      ans = s[i - 1] + ans;
      i--, j--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c; cin >> a >> b >> c;
  if(a==b && b==c){
    cout << "No" << endl;
    return 0;
  }
  if(a!=b && b!=c && a!=c){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int LGN = 18;
int x[MAXN], dp[MAXN][LGN];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &x[i]);
	}
	int l;
	scanf("%d", &l);
	int p2 = 1;
	for (int i = 1; i <= n; ++i)
	{
		while(p2+1 <= n && x[p2+1] - x[i] <= l)
			p2++;
		dp[i][0] = p2;
	}
	for (int j = 1; j < LGN; ++j)
	{
		for (int i = 1; i <= n; ++i)
		{
			dp[i][j] = dp[dp[i][j-1]][j-1];
		}
	}
	int q;
	scanf("%d", &q);
	while(q--)
	{
		int a,b;
		scanf("%d %d", &a, &b);
		if(a > b)
			swap(a,b);
		int lo = 1, hi = n, mid;
		while(lo < hi)
		{
			mid = (lo+hi)/2;
			int pos = a;
			for (int i = 0; i < LGN; ++i)
			{
				if(mid & (1<<i))
					pos = dp[pos][i];
			}
			if(pos >= b)
				hi = mid;
			else
				lo = mid+1;
		}
		printf("%d\n", lo);
	}
	return 0;
}

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

typedef long long ll;

int N;
ll T[100];

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

int main() {
    cin >> N;
    rep(i, N) {
        cin >> T[i];
    }
    // rep(i, N) {
    //     cout << T[i] << endl;
    // }

    ll ans = T[0]; 
    for (int i = 1; i <= N - 1; i++) {
        ans = lcm(ans, T[i]);
    }
    // printf("%lld\n", ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <queue>
using namespace std;

const int INF = 1000000000;

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

struct Tree	//create tree(directed) from graph(undirected)
{
    int n;
    int root;
    vector<vector<int>> t;
    vector<int> par;
    vector<int> dpt;
    
    void init(Graph &g, int root_){
        n = g.n;
        root = root_;
        t.resize(n);
        par.resize(n);
        dpt.resize(n);
        fill(dpt.begin(), dpt.end(), -1);
        queue<int> que;
        par[root] = -1;
        dpt[root] = 0;
        que.push(root);
        while(que.size()){
            int pa = que.front();
            que.pop();
            for(int ch : g.g[pa]){
                if(dpt[ch] == -1){
                    t[pa].push_back(ch);
                    par[ch] = pa;
                    dpt[ch] = dpt[pa] + 1;
                    que.push(ch);
                }
            }
        }
    }

    Tree(){}
    
    Tree(Graph &g, int root_){
        init(g, root_);
    }
    
    vector<int> toposort(){
        typedef pair<int, int> P;
        vector<P> p(n);
        for(int i = 0; i < n; i++) p[i] = P(dpt[i], i);
        sort(p.begin(), p.end(), greater<P>());
        vector<int> res(n);
        for(int i = 0; i < n; i++) res[i] = p[i].second;
        return res;
    }
};

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        g.add_edge(b, a);
    }
    int ans = INF;
    for(int i = 0; i < n; i++){
        Tree t(g, i);
        vector<int> topo = t.toposort();
        int c[2003]{0};
        int d[2003]{0};
        int e[2003]{0};
        for(int j = 0; j < n; j++){
            int u = topo[j];
            c[u] += s[u] - '0';
            d[u] += s[u] - '0';
            if((int)t.t[u].size() == 0){
                e[u] = d[u];
                continue;
            }
            int al = -1, r = 0;
            for(int v : t.t[u]){
                c[u] += c[v];
                d[u] += d[v] + c[v];
                if(al == -1 || d[v] > d[al]) al = v;
                r += d[v];
            }
            r = r - d[al] + e[al];
            e[u] = max(r % 2, e[al] * 2 - r) + c[u];
        }
        if(e[i] == c[i]){
            ans = min(ans, (d[i] - (c[i] - (s[i] - '0'))) / 2);
        }
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3912
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) v.begin(), v.end()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

class AHarmony {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int A, B;
	    in>>A>>B;
	    if(A==B){out<<0<<endl;}
	    else if(A>B) swap(A, B);
	    if(A%2!=B%2){out<<"IMPOSSIBLE"<<endl;}
	    else out<<(A+B)/2<<endl;
	}
};


int main() {
	AHarmony solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();
		int n = Integer.parseInt(str);
		int m = n;
		int[] amida = new int[n];
		for(int i = 0; i < n; i++)
			amida[i] = i+1;
		str = br.readLine();
		n = Integer.parseInt(str);
		int[][] yoko = new int[n][2];
		
		for(int i = 0; i < n; i++){
			str = br.readLine();
			String str1 = str.substring(0, str.indexOf(","));
			str = str.substring(str.indexOf(",")+1);
			yoko[i][0] = Integer.parseInt(str1);
			yoko[i][1] = Integer.parseInt(str);
		}
		for(int i = 1; i < n+1; i++){
			int c1=0, c2=0;

			for(int j = 0; j < m; j++){
				if(amida[j] == yoko[n-i][0] )c1 = j;
				if(amida[j] == yoko[n-i][1] )c2 = j;
			}
			int tmp = amida[c1];
			amida[c1] = amida[c2];
			amida[c2] = tmp;
		}
		for(int k = 0; k < m; k++){
			System.out.println(amida[k]);
		}
				
	}

}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  vector<char> ans;
  rep(i, ty - sy) ans.push_back('U');
  rep(i, tx - sx) ans.push_back('R');
  rep(i, ty - sy) ans.push_back('D');
  rep(i, tx - sx) ans.push_back('L');
  ans.push_back('L');
  rep(i, ty - sy + 1) ans.push_back('U');
  rep(i, tx - sx + 1) ans.push_back('R');
  ans.push_back('D');
  ans.push_back('R');
  rep(i, ty - sy + 1) ans.push_back('D');
  rep(i, tx - sx + 1) ans.push_back('L');
  ans.push_back('U');
  rep(i, ans.size()) cout << ans[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int main()
{
	int A=read(),B=read(),C=read();
	if(A==B&&B==C&&C==A)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
from collections import deque

def bfs(s):
    q = deque()
    q.append(s)
    dist = [-1] * (n + 1)
    dist[s] = 0
    while q:
        p = q.popleft()
        for i in G[p]:
            if dist[i] == -1:
                dist[i] = dist[p] + 1
                q.append(i)
    return dist

n, u, v = map(int, input().split())
G = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
dist1 = bfs(u)
dist2 = bfs(v)
ans = 0
for i in range(1, n + 1):
    if dist1[i] <= dist2[i]:
        ans = max(ans, dist2[i] - 1)
print(ans)

Measured memory_bytes: 29336
#include <iostream>
#include <string>
#include <set> 
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long
using namespace std;

int main(){
    int N;
    ll amin=999999990;
    ll amax=-1;
    cin>>N;

    vector <ll> A(0);
    for(int i=0;i<N;i++){
        ll a;
        cin>>a;
        A.push_back(a);
    }

    for(int i=0;i<N;i++){
        amin=min(amin,A[i]);
        amax=max(amax,A[i]);
    }
  //  cout<<amax<<"   "<<amin<<endl;
    cout<<amax-amin<<endl;

  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

int N;
size_t MASK;
vector<vector<int>> v;
vector<int> dp;

inline size_t add(size_t res, size_t delta)
{ 
  return (res + delta) % 1000000007;
}

size_t solution(int i, size_t mask = 0)
{ 
  if (dp[mask] != -1) return dp[mask];
  size_t res = 0; 
  for (int j = 0; j < N; ++j)
  { 
    if (v[i][j] && !(mask & (1<<j)))
    { 
      const size_t new_mask = mask | (1<<j);
      if (new_mask == MASK)
      { 
        res = add(res, 1);
        break;
      }
      res = add(res, solution(i+1, new_mask));
    }
  }
  dp[mask] = res;
  return res;
}

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

  cin >> N;

  MASK = (1 << N) - 1;

  v = vector<vector<int>>(N, vector<int>(N));
  dp = vector<int>(1<<N, -1);

  for (int i = 0; i < N; ++i)
  {
    for (int j = 0; j < N; ++j)
    {   
      cin >> v[i][j];
    }   
  }

  cout << solution(0);

  return 0;
}

Measured memory_bytes: 8448
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x+r<=W){
        if(y+r<=H){
            if(x-r>=0){
                if(y-r>=0){
                    cout<<"Yes"<<endl;
                }else{
                    cout<<"No"<<endl;
                    }
                }else{
                    cout<<"No"<<endl;
                }
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
        return 0;
}        


Measured memory_bytes: 3120
def sumDigits(i):
    s = 0
    while i > 0:
        s += (i % 10)
        i = int(i / 10)
    return s

def main():
    N = int(input())
    m2 = 9 * 6
    for i in range(1, N + 1):
        k = N - i
        if k > 0:
            m2 = min(m2, sumDigits(i) + sumDigits(k))
    print(m2)

main()

Measured memory_bytes: 3060
#define CPP17
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#ifdef CPP17
#include <variant>
#endif

#define endl codeforces

#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
using size_type = ssize_t;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

template <typename T, std::size_t Head, std::size_t... Tail> 
struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };

template <typename T, std::size_t Head> 
struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };

template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

#ifdef CPP17
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { 
    if constexpr (std::is_invocable<F, Args...>::value) { 
        t = f(args...); 
    } else { 
        for (size_type i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); 
    } 
}
#endif

template <typename T> vec<T> make_v(size_type sz) { return vec<T>(sz); }

template <typename T, typename... Tail> 
auto make_v(size_type hs, Tail&&... ts) { 
    auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); 
    return vec<decltype(v)>(hs, v); 
}

namespace init__ { 
struct InitIO { 
    InitIO() { 
        std::cin.tie(nullptr); 
        std::ios_base::sync_with_stdio(false); 
        std::cout << std::fixed << std::setprecision(30); 
    } 
} init_io; 
}
template <typename T>
T ceil_pow2(T bound) {
    T ret = 1;
    while (ret < bound) ret *= 2;
    return ret;
}
template <typename T>
T ceil_div(T a, T b) { return a / b + !!(a % b); }
#define CPP17


int main() {
    ll d, t, s;
    std::cin >> d >> t >> s;
    std::cout << (d <= s * t ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 3644
import collections

N,M = map(int,input().split())

a = []
for i in range(N):
	tmp = list(map(int,input().split()))
	a += tmp[1:]

c = collections.Counter(a)
#print(c)
ans = 0
for key,val in c.items():
    if val == N:
        ans += 1
    #print(key)
print(ans)  

Measured memory_bytes: 3316
/**
 *  Solution by Bektemir Srazhdinov
**/
#include <bits/stdc++.h>
using namespace std;
const int N=(int)1e5+5;
const int mod=(int)1e9+7;
int n,m,a;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>a>>n>>m;
    if(a==n){
        cout<<m<<endl;
    }else if(a==m){
        cout<<n<<endl;
    }else if(n==m){
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
	int N, T;
	std::cin >> N >> T;

	long long result = 0;

	int prev;
	for(int i = 0; i < N; i++) {
		int now;
		std::cin >> now;
		if(i == 0) {
			result += T;
		} else {
			if(now - prev <= T) {
				result += now - prev;
			} else {
				result += T;
			}
		}
		prev = now;
	}

	std::cout << result << std::endl;

	return 0;
}

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

using namespace std;

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

pii A[200000];

int main() {
    int n; cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> A[i].second >> A[i].first;
    
    sort(A, A + n);
    
    int mx = 0;
    
    for(int i = 0; i < n; ++i)
        if((mx += A[i].second) > A[i].first) { cout << "No"; return 0; }
    
    cout << "Yes";
    
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const int INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int N,T;
	cin >> N >>T;
	vector<int> c(N),t(N);
	for(int i = 0; i < N; i++){
		cin >> c[i] >> t[i];
	}

	int ans = INF;
	for(int i = 0; i < N; i++){
		if(t[i] <= T && c[i] < ans) ans = c[i];
	}
	if(ans == INF) cout << "TLE" << endl;
	else{
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

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

	int res=0;
	for(int i=0; i<N; i++){
		if(i != a[i]) continue;
		if(i==N-1){
			swap(a[i], a[i-1]);
			res++;
			continue;
		}
		swap(a[i], a[i+1]);
		res++;
	}

	cout << res << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  double n;
  cin >> n;
  cout << 2.0 * 3.14159265 * n << endl;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n+2);
  for(ll i=1;i<=n;i++) cin >> a[i];
  ll ans=0;
  for(ll i=1;i<=n+1;i++) ans+=abs(a[i]-a[i-1]);
  for(ll i=1;i<=n;i++) {
    ll tans=ans-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
    cout << tans << endl;
  }
}

Measured memory_bytes: 2048
N = int(input())
H = list(map(int,input().split()))
ans = [0]
count = 0
for i in range(N-1):
  if i == N-2:
    if H[i] >= H[i+1]:
      count += 1
    ans.append(count)
    break
  if H[i] < H[i+1]:
    ans.append(count)
    count = 0
  else:
    count += 1
print(max(ans))

Measured memory_bytes: 14224
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


a,b,c = map(int, input().split())

if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)


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

using namespace std;

const int N = 2e5 + 55;

struct line{
    long long m, c;
    long long eval(long long x){
        return x * m + c;
    }
    long double inter(line l){
        return (0.0 + l.c - c) / (0.0 + m - l.m);
    }
};

long long n, c, h[N], pt;
line a[N];

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

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

    a[++ pt] = {h[1], c + h[1] * h[1]};

    long long ret;

    for(int i = 2; i <= n; i ++){
        ret = h[i] * h[i];
        int lo = 1, hi = pt - 1, id = pt;
        long long x = -2 * h[i];
        while(lo <= hi){
            int md = (lo + hi) >> 1;
            if(a[md].inter(a[md + 1]) <= x)
                hi = md - 1, id = md;
            else
                lo = md + 1;
        }
        ret += a[id].eval(x);
        line cur = {h[i], c + h[i] * h[i] + ret};
        while(pt >= 2 && cur.inter(a[pt]) >= a[pt].inter(a[pt - 1]))
            pt --;
        a[++ pt] = cur;
    }
    cout << ret << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

vector<ll> fac_prime(ll n){
    vector<ll> prime;
    ll sq = sqrt(n) + 1;

    for(int i = 2; i <= sq; ++i){
        sq = sqrt(n) + 1;
        if(n%i == 0){
            prime.push_back(i);
            while(n%i == 0)n/=i;
        }
    }

    if(n != 1)prime.push_back(n);

    return prime;
}

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

    vector<ll> fac = fac_prime(a);

    ll ans = 1;
    rep(i, fac.size()){
        if(b % fac[i] == 0)ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3696
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

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

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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

int Digit(ll n) {
  int digit = 0;
  ll Pow10 = 1;
  while (n >= Pow10) {
    digit++;
    Pow10 *= 10;
  }
  return digit;
}


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

  ll N;
  cin >> N;

  ll i = 1;
  int digit = 10;
  while (i * i <= N) {
    if (N % i == 0) {
      digit = min(digit, max(Digit(i), Digit(N / i)));
    }
    i++;
  }

  cout << digit << endl;
  return 0;
}

Measured memory_bytes: 256
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>  
#define endl "\n"
using namespace std;
	typedef long long ll;
	const int inf=0x3f3f3f3f;
	const int maxn=100500;
	const int maxe=100500;
	int cnt;
	int head[maxn];
	struct Edge{
		int next;
		int to;
	} edge[maxe];
	int dp[maxn]; 
	int in[maxn];
	int n,m,ans;
	char s[maxn];
	
	void init(){
		memset(head,-1,sizeof(head));
		cnt=0;
		return ;	
	}
	
	void add(int u,int v){
		edge[cnt].to=v;
		edge[cnt].next=head[u];
		head[u]=cnt++;
		return ;
	}

	int main(){
		IOS
		init();
		cin>>n>>m;
		for(int i=0;i<m;i++){
			int u,v;
			cin>>u>>v;
			add(u,v);
			in[v]++;
		}
		queue<int>q;
		for(int i=1;i<=n;i++)
			if(!in[i])
				q.push(i);
		
		while(q.size()){
			int u=q.front(); q.pop();
			for(int i=head[u];i!=-1;i=edge[i].next){
				int v=edge[i].to;
				dp[v]=max(dp[v],dp[u]+1);
				if(--in[v]==0) 
					q.push(v);
			}
		}
		for(int i=1;i<=n;i++){
			ans=max(ans,dp[i]);
		}	
		cout<<ans<<endl;
		return 0;
	} 

Measured memory_bytes: 5644
#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<LL,LL> 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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

template< typename T >
struct BinaryIndexedTree{

    //0-indexed
    vector< T > bit;

    BinaryIndexedTree(int sz){
        bit.assign(sz, 0);
    }

    //[0,k)までの総和を返す
    T sum(int k){
        T ret = 0;
        for (--k; k >= 0; k = (k&(k+1))-1) ret += bit[k];
        return ret;
    }
    
    //[l,r)の総和を返す
    T sum(int l, int r){
        return sum(r) - sum(l);
    }

    //kにx加算する
    void add(int k, T x){
        for (; k < bit.size(); k |= k+1) bit[k] += x;
    }
};

int main(){
    int n;cin >> n;
    string s;cin >> s;
    vector<BinaryIndexedTree<int>> bit;
    for (int i = 0; i < 26; i++) {
        BinaryIndexedTree<int> tmp(n);
        bit.emplace_back(tmp);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 26; j++) {
            if(s[i] - 'a' == j) bit[j].add(i, 1);
        }
    }
    int q;cin >> q;
    while(q--){
        int c;cin >> c;
        if(c == 1){
            int k;char c;cin >> k >> c;
            k--;
            int p = c - 'a';
            for (int i = 0; i < 26; i++) {
                bit[i].add(k, -bit[i].sum(k, k + 1));
            }
            bit[p].add(k, 1);
        }
        else{
            int l,r;cin >> l >> r;
            l--;
            int ans = 0;
            for (int i = 0; i < 26; i++) {
                if(bit[i].sum(l, r)) ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 53472
//50000 for aizu0056
//1000000 for aizu0185
#define M 32769
p[M+1];
int main(){
  int n,i=2,j;
  p[1]=1;
  for(;i<=M;i++)
    if(!p[i])
      for(j=i*2;j<=M;j+=i)
        p[j]=1;
  for(;scanf("%d",&n),n;){
    int i=2,s=0;
    for(;i<=n/2;i++){
      if(p[i])continue;
      if(!p[n-i]){
        s++;
      }
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    private static final int INF = (int)1e9 + 7;

    int N;
    long[] a;

    private void solve() {
        N = nextInt();

        a = new long[N];
        for(int i = 0;i < N;i++) {
            a[i] = nextLong();
        }

        int ans = 0;
        for(int i = 0;i < N;i++) {
            while(a[i] % 2 == 0) {
                a[i] /= 2;
                ans++;
            }
        }

        out.println(ans);

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 24972
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c; cin >> a >> b >> c;
  if(min({a,b,c}) == 5 && max({a,b,c}) == 7 && a + b + c == 17) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a.sort()
b.sort()
sa=set(a)
sb=set(b)
mod=10**9+7
ans=1
if len(set(a))!=n or len(set(b))!=m:
    print(0)
else:
    for x in range(1,n*m+1):
        if x in sa and x not in sb:
            idx=bisect_left(b,x)
            ans*=(m-idx)
        elif x not in sa and x in sb:
            idx=bisect_left(a,x)
            ans*=(n-idx)
        elif x not in sa and x not in sb:
            idxa=bisect_left(a,x)
            idxb=bisect_left(b,x)
            ans*=max((n-idxa)*(m-idxb)-(n*m-x),0)
        ans%=mod
    print(ans)

Measured memory_bytes: 9436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);	
	ll a,b;cin>>a>>b;
	for(ld i=10*b;i<(10*(b+1));i++)
	{
		ld temp=i*8/100;
		if((ll)temp==a) 
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"-1\n";
	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(a*n,b)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int A[100][100]={0};
  int b[100][1]={0};
  int C[100][1]={0};
  int n,m,i,j,num;
 
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&num);
      A[i][j]=num;
    }
  }
  for(i=0;i<m;i++){
    scanf("%d",&num);
    b[i][0]=num;
  }
 
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      C[i][0]+=A[i][j]*b[j][0];
    }
  }
 
  for(i=0;i<n;i++){
    printf("%d\n",C[i][0]);
  }
 
  return 0;
 
}

Measured memory_bytes: 648
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve3(N, K, A));
    }

    private static int solve3(int N, int K, int[] A) {
        int count = (N-1)/(K-1);

        if ((N-1)%(K-1) != 0) {
            count++;
        }

        return count;
    }
}

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

const int maxn = 2e5 + 10;
long long a[maxn], f[maxn];
int n;

long long bs(long long l, long long r, long long k){
	if (r == l + 1)
		return r;
	long long mid = (l + r) / 2;
	long long y = 0;
	for (int i = 0; i < n; i ++){
		y += max(0ll, a[i] - mid / f[i]);
	}
	if (y <= k)
		return bs(l, mid, k);
	return bs(mid, r, k);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long k;
	cin >> n >> k;
	for (int i = 0; i < n; i ++)
		cin >> a[i];
	for (int i = 0; i < n; i ++)
		cin >> f[i];
	sort(a, a + n);
	sort(f, f + n);
	reverse(f, f + n);
	cout << bs(-1, 1e12 + 10, k);
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int t = sc.nextInt();
        int sand = x - t;
        if (sand < 0 ) {
            System.out.println(0);
        } else {
            System.out.println(sand);
        }
    }
}

Measured memory_bytes: 23760
#include<bits/stdc++.h>
#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i, x) for(int i = 1; i <= (int)(x); i++)
#define UNIQUE(v) v..erase( unique(v.begin(), v.end()), v.end() );
#define Size(x) ((int)(x).size())
using namespace std;

int a[1000];

int main(){
	int n;
	cin >> n;
	int x = 0;
	int y = 1000000009;
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		x = max(x, tmp);
		y = min(y, tmp);
	}
	int ans = abs(x - y);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M, X = map(int, input().split())
As = []
C = []
for _ in range(N):
    c, *A = map(int, input().split())
    C.append(c)
    As.append(A)

INF = 10**18
ans = INF
for bit in range(1<<N):
    cost = 0
    Get = [0]*M
    for i in range(N):
        if bit&(1<<i):
            cost += C[i]
            for m in range(M):
                Get[m] += As[i][m]
    ok = True
    for m in range(M):
        if Get[m] < X:
            ok = False
            break
    if ok:
        ans = min(ans, cost)
if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68504
# -*- coding: utf-8 -*-


def main():
    s = input().splitlines()[0]
    t = input().splitlines()[0]

    Slen = len(s)

    LookupTable = [[] for i in range(26)]
    for i, c in enumerate(s):
        v = ord(c) - ord('a')
        LookupTable[v].append(i)
    for i in range(26):
        LookupTable[i].append(-1)
        
    IndexTable = [0 for i in range(26)]
    NextTable = []
    for i, c in enumerate(s):
        v = ord(c) - ord('a')
        NextTable.append( [LookupTable[k][IndexTable[k]] for k in range(26)] )
        IndexTable[v] += 1
        if LookupTable[v][IndexTable[v]] < 0:
            IndexTable[v] = 0

    Index = 0
    Loop = 0
    for i, c in enumerate(t):
        v = ord(c) - ord('a')
        if NextTable[Index][v] < Index:
            Loop += 1
        Index = NextTable[Index][v]
        if Index < 0:
            print(-1)
            return
        Index += 1
        if Index >= Slen:
            Index = 0
            Loop += 1

    print(Loop*Slen+Index)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42484
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

    int N,K;cin >> N >> K;
    string s;cin >> s;
    int cnt = 0;
    for(int i = 0;i < N -1;i++){
        if(s[i] == s[i+1])cnt++;
    }
    cout<<(min(N-1,2 * K + cnt))<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define rem(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;

int N, M;


int main() {
	
	cin >> N >> M;
	vv.resize(N+1);
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b;
		vv[a].push_back(b);
		vv[b].push_back(a);
	}
	
	vector<int> dist(N+1, -1);
	vector<int> ans(N + 1, -1);
	queue<int> que;

	dist[1] = 0;
	que.push(1);
	ans[0] = 0;

	while (!que.empty()) {
		int x = que.front(); // キューから先頭頂点を取り出す
		que.pop();

		// v から辿れる頂点をすべて調べる
		for (int nv : vv[x]) {
			if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

			// 新たな白色頂点 nv について距離情報を更新してキューに追加する
			dist[nv] = dist[x] + 1;
			ans[nv] = x;
			que.push(nv);
		}
	}

	if (binary_search(ans.begin(), ans.end(), -1)) {
		cout << "No" << '\n';
		return 0;
	}
	cout << "Yes" << '\n';
	rep(i, 2, N + 1) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 10628
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>
//#include "mylibrary.hpp"

const int INF = 10000000;

using namespace std;

class query{
public:
    int T;
    int F;
    char C;
    
    query(int T, int F, char C){
        this->T = T;
        this->F = F;
        this->C = C;
    }
    query(int T){
        this->T = T;
        this->F = -1;
        this->C = '!';
    }
    
};

int main(){
    string S;
    int Q;
    cin >> S;
    cin >> Q;
//    vector<query> query_list(Q);
//    query query_list[200000];
    
    int T[200000];
    int F[200000];
    char C[200000];
    bool Is_from_left = true;
    
    deque<char> data; for(int i=0;i<S.size();i++) data.push_back(S[i]);
    
    for(int i=0;i<Q;i++){
        cin >> T[i];
        if(T[i]==1){
            Is_from_left =! Is_from_left;
            continue;
        }
        if(T[i] == 2){
            cin >> F[i] >> C[i];
            if(F[i]==1){
                if(Is_from_left==true){
                    data.push_front(C[i]);
                }else{
                    data.push_back(C[i]);
                }
            }
            else if(F[i]==2){
                if(Is_from_left==true){
                    data.push_back(C[i]);
                }else{
                    data.push_front(C[i]);
                }
            }
        }
        
    }

    if(Is_from_left == false){
        reverse(data.begin(),data.end());
    }
    string ans;
    for(char c : data) ans+=c;
    cout << ans << endl;
    
    return 0;
 
}


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

int n, m;
vector<int> a;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
long long ans;
map<int, int> mp;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m;
	readVector(n, a);
	for(int i=0; i<n; ++i)
		a[i] %= m;
	for(int i=1; i<n; ++i){
		a[i] += a[i-1];
		a[i] %= m;
	}
	mp[0] = 1;
	for(int i=0; i<n; ++i){
		if(mp.find(a[i]) != mp.end()){
			ans += mp[a[i]];
			++mp[a[i]];
		}else{
			mp[a[i]] = 1;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3576
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int n,i,c=1,a;
long long r;
int main() {
  scanf("%d",&n);
  for (i=0; i<n; i++) {
    scanf("%d",&a);
    if (a%c==0) {
      r+=a/c-1;
      if (a==c || c==1) c++;
    } else r+=a/c;
  }
  printf("%lld\n",r);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> x(n);
    for(int i=0; i<n;i++){
       cin>>x[i];
    }
    sort(x.begin(),x.end());
    int ans= 100 * 100 * 100 +1;
    for(int i=x.at(0); i<=x.at(x.size()-1); i++ ){
        int tmp=0;
        for(int j=0; j<n; j++){
            tmp += (i-x.at(j) )*(i-x.at(j) );
        }
        ans = min(tmp, ans);
    }
    cout<<ans<<endl;
    

}

Measured memory_bytes: 256