akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef pair<ll,ll> Q;
typedef pair<Q,ll> R;
vector<pair<ll,int>>ret;
vector<ll>ans;
int k;
void make(ll cur,int num,int zan){
    if(zan == 0){
		ret.pb(mp(cur,num));
		return;
	}
    if(cur >= 100) make(cur*10LL+9,num+9,zan-1);
    else for(int i=(cur==0?1:0);i<10;i++) make(cur*10LL+i,num+i,zan-1);
}
int main(){
	repn(d,15){
		make(0,0,d);
	}
	SORT(ret); ERASE(ret);
	rep(i,ret.size()){
		for(int j=i+1;j<ret.size();j++){
			ll a = ret[i].fi, b = ret[i].sc;
			ll c = ret[j].fi, d = ret[j].sc;
			//a/b > c/d?
			if(a*d > b*c) goto fail;
		}
		ans.pb(ret[i].fi); fail:;
	}
	int k; cin >> k;
	rep(i,k) cout << ans[i] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <tuple>
#include <algorithm>
#include <ctime>
#include <map>
using namespace std;


const long long MOD = static_cast<long long>(1e9+7);
const long long INFINITE = static_cast<long long>(1e16);
const bool IS_DEBUG = false;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long X,K,D;
    cin>>X>>K>>D;

    long long reset = min(K,abs(X)/D);
    if(X < 0) {
        X += D*reset;
    } else {
        X -= D*reset;
    }
    K-=reset;

    K%=2;
    if(K) {
        if(X < 0) {
            X += D;
        } else {
            X -= D;
        }
    }
    cout<<abs(X);
}


Measured memory_bytes: 3648
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn travel(pos: usize, mat: &Vec<Vec<usize>>, visited: &mut Vec<bool>) {
    if visited[pos] {
        return;
    }
    visited[pos] = true;
    for i in 0..mat[pos].len() {
        let next = mat[pos][i];
        travel(next, mat, visited);
    }
}

fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let m = line[1];

    let mut l: Vec<Vec<usize>> = Vec::with_capacity(n);
    let mut mat = vec![Vec::new(); n + m];
    for i in 0..n {
        let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        l.push(Vec::from(line.split_at(1).1));
        for j in 1..line.len() {
            let lan = line[j] - 1;
            mat[lan].push(m+i);
            mat[m+i].push(lan);
        }
    }

    let mut visited = vec![false; n+m];
    travel(m, &mat, &mut visited);
    let ans = visited.split_at(m).1.iter().find(|&&v| !v).is_none();

    if ans {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N, K;
  cin >> N >> K;
  map<int, int> ans{};
  REP(i, K) {
    int l;
    cin >> l;
    REP(j, l) {
      int k;
      cin >> k,k--;
      ans[k] = 1;
    }
  }
  ll num = 0;

  REP(i,N){
    if(ans[i]==0){
      num++;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, A; cin >> N >> A;
  string result;
  if (A>=N%500) result = "Yes";
  else result = "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

from bisect import bisect_left, bisect_right

res = 0
for b in B:
    res += bisect_left(A, b) * (N - bisect_right(C, b))
print(res)


Measured memory_bytes: 24096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			String s = Integer.toString(n, k);
			System.out.println(s.length());
		}

	}

}


Measured memory_bytes: 22996
n = int(input())
s = [0]
l = []
while s:
    p = s.pop()
    if p > n:
        continue
    l.append(p)
    s.append(p * 10 + 3)
    s.append(p * 10 + 5)
    s.append(p * 10 + 7)
ans = 0
for x in l:
    p = str(x)
    if p.count('3') and p.count('5') and p.count('7'):
        ans += 1
print(ans)


Measured memory_bytes: 75048
#include <bits/stdc++.h>
#define rep( i, n ) for (ll i = 0; i < ( ll )(n); i++)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;



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

    for(int i=k-1;i<n-1;i++){
        if(a[i+1]>a[i-k+1]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}  

Measured memory_bytes: 4836
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
#define X first
#define Y second
//#define int long long int 
const int MAXN = (int)2e5 + 10;
const int MOD = (int) 1e9;

void solve(){
    int n; cin >> n;
    int ans[n + 1] = {0};
    for(int i = 1; i < n; ++i){
        int x; cin >> x;
        ans[x]++;
    }
    for(int i = 1; i <= n; ++i){
        cout << ans[i] << '\n';
    }

}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}
/*
Sample inp
*/


Measured memory_bytes: 4404
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
A = LI()
A.sort()

cusum = [0]*N
cusum[0] = A[0]
for i in range(1,N):
    cusum[i] = cusum[i-1]+A[i]

lim = 0
for i in range(N-1)[::-1]:
    if cusum[i]*2 < A[i+1]:
        lim = i+1
        break

print(N-lim)

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

int h, w, r, c;
vector<vector<int>> res;

bool solve();

int main() {
  cin >> h >> w >> r >> c;
  if(solve()) {
    cout << "Yes" << endl;
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        if(j != 0) cout << " ";
        cout << res[i][j];
      }
      cout << endl;
    }
  }
  else
    cout << "No" << endl;
  return 0;
}

bool solve() {
  res.assign(h, vector<int>(w, 0));
  if(w % c != 0) {
    for(int i = 0; i < h; ++i)
      for(int j = 0; j < w; j += c) {
        res[i][j] = 1000;
        if(j + c <= w) res[i][j + c - 1] = -1001;
      }
    return 1;
  }
  if(h % r != 0) {
    for(int j = 0; j < w; ++j)
      for(int i = 0; i < h; i += r) {
        res[i][j] = 1000;
        if(i + r <= h) res[i + r - 1][j] = -1001;
      }
    return 1;
  }
  return 0;
}


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

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

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

const int N=1e5+5;
vi adj[N];

pll dfs(int u,int p){
	pll cur={1,1};
	pll temp;
	for(auto v: adj[u]){
		if(v!=p){
			temp=dfs(v,u);
			cur.first=(cur.first * temp.second)%MOD;
			cur.second=(cur.second * (temp.first+temp.second))%MOD;
		}
	}
	return cur;
}

void solve(){
	int n;
	cin>>n;
	int u,v;
	fr(i,0,n-1){
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	pll ans=dfs(1,0);
	cout<<(ans.first + ans.second)%MOD <<endl;
	return;
}

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

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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      if (i * 4 + j * 7 == N) return cout << "Yes" << "\n", 0;
    }
  }
  cout << "No" << "\n";
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 INF=1e9+7;

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

int main()
{
    ll a,b;
    cin >> a >> b;
    ll c=gcd(a,b);
    set<ll> ans;
    for(ll i=2;i*i<=c;i++){
        while(c%i==0){
            c/=i;
            ans.insert(i);
        }
    }
    if(c!=1) ans.insert(c);
    cout << ans.size()+1 << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];

	ll ans = 0;

	for (int i = n - 1; i >= 0; i--) {
		int inc = b[i] - (a[i] + ans) % b[i];
		if (inc < b[i]) {
			ans += inc;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first;
#define se second;
#define print(x,y) (cout << (x) << (y))
#define inf INT_MAX
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
typedef vector<pss> vss;
const int MOD = 1e9 + 7; //998244353;
int nums[200005]{0};
int main(){
    boost;
    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    if(a[0] == a[2] || (a[0] != a[1] && a[1] != a[2])){
        cout << "No";
    }else cout << "Yes";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    vint x(N+1), y(M+1); 
    x[0] = X; y[0] = Y;
    rep(i,N)cin>>x[i+1];
    rep(i,M)cin>>y[i+1];
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    if(x[N] < y[0])cout<<"No War"<<endl;
    else cout<<"War"<<endl; return 0;
}


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

using namespace std;

int main()
{
    int n; cin >> n;
    int t[n + 1], x[n + 1], y[n + 1];
    t[0] = 0, x[0] = 0, y[0] = 0;

    bool traveling = true;

    for (int i = 1; i <= n; i++) {
        cin >> t[i] >> x[i] >> y[i];
        int dt = t[i] - t[i - 1];
        int ds = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);

        // 旅行がプラン実行が不可能な場合
        if ((dt < ds) || (ds % 2 == 0 && dt % 2 != 0) || (ds % 2 != 0 && dt % 2 == 0)) traveling = false;
    }

    if (traveling) cout << "Yes" << endl;
    else           cout << "No" << endl;

    return 0;
}

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

using namespace std;
 
 

typedef long long ll;
//c++ templte for help............................................................................................................................................


template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;





	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
#define M int(1e9+7)
const int INF=1e9+5;
 
//iterate map
//template<typename T>
//void itR(T map){
	 //for(auto itr=map.begin();itr!=map.end();itr++){
				//deb(itr->first,itr->second);
			//}
	//cout<<endl;
//}


 

 
//c++ template for help...........................................................................................................................................

ll solve(){
	ll n;
	cin>>n;
	
	string s;
	cin>>s;
	
	ll r=0;
	for(int i=0;i<(ll)s.size();i++){
		if(s[i]=='R') r++;
	}
	
	ll w=0;
	for(int i=0;i<r;i++){
		if(s[i]=='W') w++;
	}
	
	return w;
}



int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ofstream myfile;
	//myfile.open ("output.txt");
	

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		ll ans=solve();
		cout<<ans<<endl;
	//}
	//myfile.close();
	return 0;
}


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

#define ll long long
#define fi first
#define sec second

ll n,m,k,x,x2,y,y2,sol=0,q;
char c;
string s;
vector <ll> V;
ll L[100010];

int main()
{
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> x;
        sol+=x;
        L[x]++;
    }
    cin >> q;
    for (int i=0;i<q;i++){
        cin >> x >> y;
        sol-=L[x]*x;
        sol+=L[x]*y;
        L[y]+=L[x];
        L[x]=0;
        cout << sol << "\n";
    }
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<int> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    sort(ALL(lis), greater<>());
    int a = 0, b = 0;
    for(int i = 0; i < n; i += 2){
        a += lis[i];
    }
    for(int i = 1; i < n; i += 2){
        b += lis[i];
    }
    cout << a-b << endl;
}

Measured memory_bytes: 256
from collections import Counter
N,A,B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

c = Counter(v)
ans_num = sum(v[:A]) / A
ans_cnt = 0

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

num = v[A-1]
num_all = c[num]
cc = Counter(v[:A])
tmp = cc[num]

for i in range(A-1, B):
    last = v[i]
    if i != A-1:
        if last != v[0]:
            break
    ans_cnt += cmb(num_all, (i+1)-(A-tmp))


print(ans_num)
print(ans_cnt)


Measured memory_bytes: 3564
#include <stdio.h>

int main()
{

  int i,j,N,v,k;
  int A[100];

 
  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(k=0;k<N-1;k++){
    printf("%d ",A[k]);
  }
  printf("%d\n",A[k]);

  for (i= 1; i < N ;i++){
    v = A[i];
    j = i - 1;
  
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
    j--;
    
  }
  A[j+1] = v;
  for(k=0;k<N-1;k++){
    printf("%d ",A[k]);
  }
  printf("%d\n",A[k]);
  }
  
  return 0;

}

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

int main() {
    ll k,a,b;
    bool flag=false;
    cin >> k >> a >> b;
    for(int i = a; i<=b; i++){
        if(i%k == 0)flag = true;
    }
    if(flag)cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()





int main()
{
  ul n, m, i;
  cin >> n >> m;
  vector<ul> arr(n), v;
  for(i = 0; i < n; i++) cin >> arr[i];
  arr.PB(m);
  n++;
  sort(arr.begin(), arr.end());
  for(ul i = 1; i < n; i++)
  {
      v.PB(arr[i]-arr[i-1]);
  }
   ul k = v[0];
   for(i = 1; i < v.size(); i++) k = __gcd(k, v[i]);
   cout << k;

    return 0;
}



Measured memory_bytes: 2800
$\=8e18;<>=~$";@x=sort{$a-$b}<>;
until(@x<($k=$')){
	for($k-1..@x-1){
		@p=sort{$a-$b}map{/ /;$'}@x[0..$_];
		$\-=$-=$\-($p[$k-1]-shift@p)*($x[$_]-"@x")until@p<$k
	}
	shift@x;
}
print

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

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

	map<string, bool> used;
	char prev;
	rep(i, N){
		string w;
		cin >> w;
		if (used.count(w) || (i != 0 && w.at(0) != prev)){
			cout << "No" << endl;
			return 0;
		}
		used[w] = true;
		prev = w.at(w.size() - 1);
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
#define PI                      3.1415926535897932384626
#define int                     long long int
#define fi                      first
#define se                      second
#define pq                      priority_queue
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define fill(x,y)               memset(x,y,sizeof(x));
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define hash                    _H
#define lg                      long double         
#define vi                      std::vector<int>
#define sz(x)                   ((int)x.size())
 
 
 
template<typename T> T pow(T a,T b, int m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
template<typename T>T InverseMod(T a,int m){return pow(a,m-2,m);}
template<typename T>int SquareDist(T a,T b){int x = abs(a.fi - b.fi),y = abs(a.se - b.se); return x*x + y*y;}
 
const int N = 1e5+2;
int dp[N];
 
void solve() {
    int n,k;
    cin >> n >> k;
    int arr[n+1];
    for(int i =  0; i < n; ++i) { 
        cin >> arr[i+1];
        dp[i+1] = 2e18;
    }
    dp[1] = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= k;++j) {
            if(i-j >= 1) {
                dp[i] = min(dp[i],dp[i-j] + abs(arr[i]- arr[i-j]));
            }
        }
    }
    cout << dp[n] << endl;
}   
 
 
 
 
signed main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
} 

Measured memory_bytes: 1792
(let* ((s (read-line))
       (n (length s))
       (x (subseq s 0 (/ (1- n) 2)))
       (y (subseq s (/ (+ n 1) 2))))
  (if (and (string= s (reverse s))
           (string= x (reverse x))
           (string= y (reverse y)))
      (format t "Yes~%")
      (format t "No~%")))


Measured memory_bytes: 23240
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n, m; cin >> n >> m;
  int mi = n - 1;
  int ma = -1;
  REP (i, m) {
    int l, r; cin >> l >> r;
    l--;
    r--;
    chmin(mi, r);
    chmax(ma, l);
  }
  dump(mi, ma);
  cout << max(0LL, mi - ma + 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
ll n,k,ans[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    ll res=0;
    for(int i=k;i>=1;i--)
    {
        ans[i]=(ans[i]+qpow(k/i,n))%mod;
        res=(res+ans[i]*i)%mod;
        for(int j=1;j*j<=i;j++)
            if(i%j==0)
            {
                if(j!=i)
                    ans[j]=(ans[j]-ans[i])%mod;
                if(i/j!=j&&i/j!=i)
                    ans[i/j]=(ans[i/j]-ans[i])%mod;
            }
    }
    res=(res+mod)%mod;
    printf("%lld\n",res);
}


Measured memory_bytes: 4496
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e9;
 
 
 
signed main(){
	int r;
	cin >> r;
	printf("%.20lf\n",2 * r * acos(-1));
}

Measured memory_bytes: 3752
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int l,x[100],y[100],z[100],k,o;
int main(){
    cin>>l;
    for(int i=3;i<=19;++i){
        x[++k]=i,y[k]=i+1,z[k]=0;
        x[++k]=i,y[k]=i+1,z[k]=1<<(19-i);
    }
    for(int i=0;i<=17;++i){
        if((1<<i)&l){
            x[++k]=1,y[k]=20-i,z[k]=o;
            o+=(1<<i);
        }
    }
    l>>=18;
    if(l==1){
        x[++k]=1,y[k]=2,z[k]=o;
        x[++k]=2,y[k]=3,z[k]=0;
        x[++k]=2,y[k]=3,z[k]=1<<17;
    }
    if(l==2){
        x[++k]=1,y[k]=2,z[k]=o;
        x[++k]=1,y[k]=2,z[k]=o+(1<<18);
        x[++k]=2,y[k]=3,z[k]=0;
        x[++k]=2,y[k]=3,z[k]=1<<17;
    }
    if(l==3){
        x[++k]=1,y[k]=2,z[k]=o;
        x[++k]=1,y[k]=2,z[k]=o+(1<<18);
        x[++k]=1,y[k]=2,z[k]=o+(1<<19);
        x[++k]=2,y[k]=3,z[k]=0;
        x[++k]=2,y[k]=3,z[k]=1<<17;
    }
    cout<<20<<' '<<k<<endl;
    for(int i=1;i<=k;++i)cout<<x[i]<<' '<<y[i]<<' '<<z[i]<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
import math
import sys
sys.setrecursionlimit(10 ** 5 + 10)

Q = int(input())

l = [0 for _ in range(Q)]
r = [0 for _ in range(Q)]
i = 0
while True:
  try:
    lr=list(map(int,input().split()))
    l[i] = lr[0]
    r[i] = lr[1]
    i+=1
  except:
    break

def is_prime(num):
  #if(type(num) != type(0)):
  #  print('error at '+str(num)+' type = '+str(type(num)))
  #  print(type(int))
  #  return 0
  #if(num<2):
  #  return 0
  if(num == 2):
    return 1
  n = math.ceil(math.sqrt(num))
  for i in range(2,n+1):
    if((num%i) == 0):
      return 0
  return 1

def create_list():
  MAXI = max(r)+1
  
  prime = [1 for _ in range(MAXI+1)]
  prime[0] = 0
  prime[1] = 0
  for i in range(2,MAXI):
    if(prime[i] == 0):
      continue
    else:
      prime[i] = is_prime(i)
      for j in range(i*2,MAXI,i*2):
        prime[j] = 0
      for j in range(i*5,MAXI,i*3):
        prime[j] = 0
      for j in range(i*5,MAXI,i*5):
        prime[j] = 0
  #print(prime)
  sn = [0 for _ in range(MAXI+2)]
  for i in range(1,MAXI+1,2):
    #print('int(('+str(i+1)+')/2) = '+str(int((i+1)/2))+' when '+str(prime[int((i+1)/2)]))
    sn[i] += sn[i-1] + (prime[i] * prime[int((i+1)/2)]) #odd
    sn[i+1] = sn[i]
  return sn

base = create_list()
#print(base)
for i in range(Q):
  print( base[r[i]] - base[l[i]-1] )#sum(rnum)-sum(lnum) )

Measured memory_bytes: 57800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, n, sum = 0, maxi = 0, last = 0;
  cin >> k >> n;
  int a[n];
  for (int i = 0; i < n; i++){
  	cin >> a[i];
    if (i > 0){
    	sum += a[i] - a[i - 1];
      	maxi = max(a[i] - a[i - 1], maxi);
    }
  }
  last = k - sum;
  if(maxi < last){
    last = maxi;
  }
  cout << sum + last - maxi  << endl;

}

Measured memory_bytes: 1024
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

ll gcd(ll a,ll b){
  a=abs(a); b=abs(b);
  if(a==0 || b==0){
    return abs(a+b);
  }
  if(a<b){
    ll tmp=a; a=b; b=tmp;
  }
  ll r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}

ll RepSq(ll a,ll n,ll mod){
  if(n==0){
    return 1;
  }else if(n%2!=0){
    return (a*RepSq(a,n-1,mod))%mod;
  }else{
    ll x=RepSq(a,n/2,mod);
    return (x*x)%mod;
  }
}

int main(){
  ll n;
  cin>>n;
  ll mod=1000000007;
  ll a[n],b[n],g[n];
  map<pair<ll,ll>,ll> mp;
  ll iwashinainotoissyo=0;
  rep(i,n){
    cin>>a[i]>>b[i];
    if(a[i]!=0 || b[i]!=0){
      g[i]=gcd(a[i],b[i]);
      a[i]/=g[i]; b[i]/=g[i];
      if(a[i]<0 || (a[i]==0 && b[i]>0)){
        a[i]*=-1; b[i]*=-1;
      }
    mp[make_pair(a[i],b[i])]++;
    }else{
      iwashinainotoissyo++;
    }
  }
  ll ans=1; ll rest=n-iwashinainotoissyo;
  for(auto p:mp){
    ll x,y,z,w;
    x=p.first.first; y=p.first.second;
    z=p.second;
    if(y<0){
      w=mp[make_pair(-y,x)];
      if(w!=0){
        ans=(ans*(RepSq(2,z,mod)+
                  RepSq(2,w,mod)-1))%mod;
        rest=rest-z-w;
      }
    }
  }
  ans=(RepSq(2,rest,mod)*ans)%mod;
  cout<<(ans+mod-1+iwashinainotoissyo)%mod;
}


Measured memory_bytes: 26868
#pragma GCC target (*sse4.2*)
#pragma GCC optimization ("O3")
#pragma GCC optimize ("Ofast")
#define mod 1000000007
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PB push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define vvii vector<vii>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read(x) long long x;cin>>x;
#define FOR(a,b,c,d) for(int a=b;a<=c;a+=d)
#define MP make_pair
#define F first
#define S second
#define debug(x) cout<<("#x)<<": "<<(x)<<"\n"
#define SZ(x) x.size()
#define INF (1<<63)-1

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double d64;



int main(){
fast
string a,b;
cin>>a>>b;
int coun=0;
for(int i=0;i<a.size();i++){
    if(a[i]!=b[i])coun++;
}
cout<<coun;
return 0;
}


Measured memory_bytes: 3800
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let a:isize = read!();
    if a/100 == 7 || (a/10)%10 == 7 || a%10 == 7 {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

Measured memory_bytes: 2140
package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var S string
	
	S = nextStr()
	re := regexp.MustCompile(`.`)
	
	fmt.Println(re.ReplaceAllString(S, "x"))
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	// if err != nil {
	// 	panic(err)
	// }
	return i
}


Measured memory_bytes: 640
def main():
    N = int(input())
    S = 'abcdefghij'
    cur = set([(0, '')])
    for i in range(N):
        nxt = set()
        for c, s in cur:
            for m in S[:c]:
                nxt.add((c, s + m))
            nxt.add((c + 1, s + S[c]))
        cur = nxt
    cur = sorted(i[1] for i in cur)
    print('\n'.join(cur))

main()


Measured memory_bytes: 29112
#include <stdio.h>
#include <string.h>

int main(void)
{
    long long int a,b,c,k;
    long long int ans=0;

    scanf("%ld %ld %ld %ld",&a,&b,&c,&k);
    // printf("%d %d %d %d\n",a,b,c,k);

    if (a>=k)
        ans=1*k;
    else if (a<k && (k-a)==b)
        ans=1*a;
    else if (a<k)
    // else if (a<k && (k-a)>b)
        ans=1*a+0*(k-a)+(-1*(k-a-b));
    // else if (a<k && (k-a)<b)
    //     ans=1*a;
    

    printf("%ld\n",ans);
    // if (strcmp(s,"ABC")==0)
    //     printf("%s\n","ARC");
    // else if (strcmp(s,"ARC")==0)
    //     printf("%s\n","ABC");

    return 0;
    

}

Measured memory_bytes: 1736
import java.io.*;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedList;
import java.util.StringTokenizer;

import static java.lang.Math.*;

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

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      int n = in.nextInt();
      String s = in.next();

      StringBuilder bufF = new StringBuilder();
      StringBuilder bufB = new StringBuilder();
      Deque<Character> deq = new ArrayDeque<>(100);

      for (char ch : s.toCharArray()) {
        if(ch == '(') deq.push(ch);
        else {
          if(!deq.isEmpty()) deq.pop();
          else bufF.append('(');
        }
      }

      while(!deq.isEmpty()) {
        deq.pop();
        bufB.append(')');
      }

      String ans = bufF.reverse().append(s).append(bufB).toString();
      out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  int atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }

  static class InputReader implements AutoCloseable {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream), 32768);
      st = null;
    }
    public String next() {
      if (st == null || !st.hasMoreTokens()) {
        try { st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return st.nextToken();
    }
    public int nextInt() { return Integer.parseInt(next()); }
    public long nextLong() { return Long.parseLong(next()); }
    int[] mapInt(int len) {
      int[] ret = new int[len];
      for (int i = 0; i < len; i++) ret[i] = Integer.parseInt(next());
      return ret;
    }
    long[] mapLong(int len) {
      long[] ret = new long[len];
      for (int i = 0; i < len; i++) ret[i] = Long.parseLong(next());
      return ret;
    }
    @Override public void close() throws IOException { br.close(); }
  }
}

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

using namespace std;

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

    long long cnt = 0;
    int k, s;

    cin >> k >> s;
    for (int x = 0; x <= k; ++x)
        for (int y = 0; y <= k; ++y) {
            int z = s - x - y;
            if (0 <= z && z <= k)
                ++cnt;
        }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			B();
		}


		public static void B()
		{
			Scanner cin = new Scanner();
			int n = cin.NextInt();
			string s = cin.Next();
			int k = cin.NextInt();

			char t = s[k - 1];
			string ss = "";
			for (int i = 0; i < n; ++i) {
				if (s[i] == t) {
					ss += s[i];
				} else {
					ss += "*";
				}
			}

			Console.WriteLine(ss);
		}



	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main()
{
  int n,x,i=0,count=0;cin>>n;
  	while(n--)
    {
      i++;
      cin>>x;
      if((i&1) && (x&1))
        count++;
    }
  	cout<<count;
	return 0;
}


Measured memory_bytes: 3592
S = input()

ACGT = ['A', 'C', 'G', 'T']

count = 0
max_count = 0
for s in S:
    if s in ACGT:
        count += 1
    else:
        max_count = max(max_count, count)
        count = 0
max_count = max(max_count, count)
print(max_count)

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

int main(){
    int cont =0;
    int k,s;
    scanf("%d %d",&k,&s);
    for(int i=0;i<=k;i++){
        for(int j= 0;j<=k;j++){
            int z = s-i-j;
            if(0<=z && z<=k)
                cont+=1;
        }
    }
    printf("%d\n",cont);

    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    ll a[x], b[y], c[z];
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    sort(a, a + x, greater<ll>());
    sort(b, b + y, greater<ll>());
    sort(c, c + z, greater<ll>());
    priority_queue<ll> que;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            for (int l = 0; l < z; l++) {
                if ((i + 1) * (j + 1) * (l + 1) <= k) que.push(a[i] + b[j] + c[l]);
                else break;
            }
        }
    }
    for (int i = 0; i < k; i++) {
        cout << que.top() << endl;
        que.pop();
    }
}

Measured memory_bytes: 4352
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]

#print(N,M,C,B,A)
ans = 0
for i in range(N):
    s = 0
    for j in range(M):
         s += A[i][j]*B[j]
    s += C
    if s > 0:
        ans += 1
print(ans)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

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

    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    vector<int> x(n+1);
    rep(i,n){
        x[a[i]]=i+1;
    }
    Rep(i,1,n+1){
        cout<<x[i]<<endl;
    }

}


Measured memory_bytes: 2048
#include<iostream>
using namespace std;
int prime[500];
int main(){
	int count=0,i=2;
	while(true){
		bool t=true;
		for(int j=0;j<count;j++)
			if(i%prime[j]==0)
				t=false;
		if(t==true){
			prime[count]=i;
			count++;
		}
		i++;
		if(i==500)
			break;
	}
	int n;
	while(true){
		cin>>n;
		int ans=0;
		if(n==0)break;
		for(int i=2;i*2<=n;i++){
			bool t=true;
			for(int j=0;j<count;j++)
				if(i%prime[j]==0&&i!=prime[j])
					t=false;
			for(int j=0;j<count;j++)
				if((n-i)%prime[j]==0&&(n-i)!=prime[j])
					t=false;
			if(t==true){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
def 解():
    input = sys.stdin.readline
    H,W,N = [int(_) for _ in input().split()]
    dT={}
    高橋 = H
    if 0 < N  :
        for  _ in range(N):
            x,y = [int(_) - 1 for _ in input().split()]
            if x >= y:
                系列 = x-y
                if 系列 in dT:
                    if x + y < dT[系列][2] :
                        dT[系列] = (x,y,x+y)
                else:
                    dT[系列] = (x,y,x+y)
        aB = sorted(dT.items())
        iL = len(aB)
        if iL == 1:
            高橋,青木,距離 = aB[0][1]
        else:
            #入力例2
            #[(0, (1, 1, 2)), (1, (3, 2, 5)), (2, (5, 3, 8)), (4, (6, 2, 8)), (7, (7, 0, 7))]
            if 0 < len(aB) :
                aG= [aB[0][1]]
                for i in range(1,iL):
                    if aB[i][0]-1 == aB[i-1][0]:
                        if aB[i][1][2] < aB[i-1][1][2] :
                            aG.append(aB[i][1])
                    else:
                        aG.append(aB[i][1])
                if 0 < len(aG) and  aG[0][0] - aG[0][1] == 0 :
                    del aG[0]
                if 0 < len(aG) :
                    高橋,青木,距離 = sorted(aG,key=lambda x:x[0])[0]
    print(高橋)
解()


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

int main() {
    ll W,H,x,y;
    cin>>W>>H>>x>>y;
    cout<<fixed<<setprecision(10);
    cout<<double(W)*double(H)/2<<" ";
    if(x+x==W&&y+y==H) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>

#define ll long long
#define endl endl
using namespace std;

const int INF = 0x3f3f3f3f;

ll X[1000];
ll Y[1000];
ll Z[1000];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, y, z, K;
    cin >> x >> y >> z >> K;
    vector<ll> vec;
    for(int i=0; i<x; i++)
    {
        cin >> X[i];
    }
    for(int i=0; i<y; i++)
    {
        cin >> Y[i];
    }
    for(int i=0; i<z; i++)
    {
        cin >> Z[i];
    }
    sort(X, X+x, greater<ll>());
    sort(Y, Y+y, greater<ll>());
    sort(Z, Z+z, greater<ll>());
    for(int i=0; i<x; i++)
    {
        for(int j=0; j<y; j++)
        {
            for(int k=0; k<z; k++)
            {
                if((i+1)*(j+1)*(k+1)<=K) vec.push_back(X[i] + Y[j] + Z[k]);
                else break;
            }
        }
    }
    sort(vec.begin(), vec.end(), greater<ll>());
    for(int i=0; i<K; i++)
    {
        cout << vec[i] << endl;
    }
}



Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

int main() {
    int n; cin >> n;
    vector<string> m(n);
    vector<vector<int> > children(n);
    repeat (i, n) {
        int k_i; cin >> k_i >> m[i]; -- k_i;
        if (k_i != -1) {
            children[k_i].push_back(i);
        }
    }
    vector<bool> used(n);
    function<void (int, int)> go = [&](int i, int depth) {
        assert (not used[i]);
        used[i] = true;
        cout << string(depth, '.') << m[i] << endl;
        for (int j : children[i]) {
            go(j, depth + 1);
        }
    };
    repeat (i, n) if (not used[i]) {
        go(i, 0);
    }
    return 0;
}

Measured memory_bytes: 3364
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    int    n;
    double p1 = 0, p2 = 0, p3 = 0, p_inf = 0;
 
    do {
        cin >> n; 
    } while (n < 0 || n > 100);
       
    int* x = new int[n];
    int* y = new int[n]; 
    
    for (int i = 0; i < n; i++) {
         do {
             cin >> x[i];	    
         } while (x[i] < 0 || x[i] > 1000);
    }

    for (int i = 0; i < n; i++) {
         do {
             cin >> y[i];
         } while (y[i] < 0 || y[i] > 1000);
    }

    for (int i = 0; i < n; i++) {
         p1 += abs(x[i] - y[i]);
         p2 += pow(abs(x[i] - y[i]), 2);
         p3 += pow(abs(x[i] - y[i]), 3);

         if (abs(x[i] - y[i]) > p_inf) {
             p_inf = abs(x[i] - y[i]);
         }

         if (i == n - 1) {
	     p2 = sqrt(p2);
             p3 = pow(p3, 1.0 / 3.0);
         }
    }
   
    cout << fixed << setprecision(8) << p1 << endl;
    cout << fixed << setprecision(8) << p2 << endl;
    cout << fixed << setprecision(8) << p3 << endl;
    cout << fixed << setprecision(8) << p_inf << endl;
   
    delete[] x;
    delete[] y;

    return (0);
}
      

Measured memory_bytes: 1308
N=int(input())
h=list(map(int,input().split()))

dp=[ -1  for i in range(N)]
dp[0]=0

for i in range(N-1):
    dp[i+1]= (dp[i]+abs(h[i]-h[i+1])) if(dp[i+1]<0) else min(dp[i+1],dp[i]+abs(h[i]-h[i+1]))
    if(i==N-2): break
    dp[i+2]= (dp[i]+abs(h[i]-h[i+2])) if(dp[i+2]<0) else min(dp[i+2],dp[i]+abs(h[i]-h[i+2]))

print(dp[N-1])

Measured memory_bytes: 54584
#include<iostream>
#include<cstdio>
using namespace std;
char a,b;
int ans;
int main()
{
	scanf("%c",&a);
	while(~scanf("%c",&b) && b != '\n')
	{
		if(a != b) ans++;
		a = b;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256