akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100+10;
int n;
string s[N];
map<string,int>p;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
        p[s[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(p[s[i]]!=1)
        {
            cout<<"No"<<endl;
            return 0;
        }

    }
    for(int i=2;i<=n;i++)
    {
        int len=s[i-1].size();
        if(s[i][0]!=s[i-1][len-1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;




	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

// Simple Calculator
int main(){
	int a, b;
	char op;

	while(1){
		cin >> a >> op >> b;
		if(op == '?'){
			break;
		}
		else if(op == '+'){
			cout << a + b << endl;
		}
		else if(op == '-'){
			cout << a - b << endl;
		}
		else if(op == '*'){
			cout << a * b << endl;
		}
		else if(op == '/'){
			if(b == 0){
				cout << "ERROR" << endl;;
			}else{
				cout << a / b << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
}

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

static const int MAX_PROFIT = -2000000000;
static const int MAX_NUM = 200000;

int main(int argc, char const *argv[])
{
    int R[MAX_NUM], n;

    std::cin >> n;
    
    for(int i = 0;i < n;i++) std::cin >> R[i];

    int maxv = MAX_PROFIT;
    int minv = R[0];

    for(int i = 1;i < n;i++){
        maxv = std::max(maxv,R[i] - minv);
        minv = std::min(minv,R[i]);
    }

    std::cout << maxv << std::endl;

    return 0;
}



Measured memory_bytes: 3888
import itertools

N = int(input())

ans = [0] * (100**2)
for x, y, z in itertools.product(range(1, 101), repeat=3):
    n = x**2 + y**2 + z**2 + x * y + y * z + z * x
    if  n <= 100**2:
        ans[n - 1] += 1

for i in range(N):
    print(ans[i])

Measured memory_bytes: 9128
N = gets.chomp.to_i
# 10の倍数とその他を分けて配列に入れる
array_x0 = []
array_xx = []
N.times do
    point = gets.chomp.to_i
    if point % 10 == 0
        array_x0.push point
    else
        array_xx.push point
    end
end
# 配列のソートと合計出し
array_xx.sort!
sum_xx = 0
array_xx.each do |i|
    sum_xx += i
end
sum_x0 = 0
array_x0.each do |i|
    sum_x0 += i
end
# 表示の場合分け
if array_xx.empty? && !(array_x0.empty?)
    puts 0
elsif sum_xx % 10 == 0
    puts (sum_xx - array_xx[0]) + sum_x0
else
    puts sum_xx + sum_x0
end


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

int main() {
    string S;
    cin >> S;

    int cnt = 0;

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (S.at(i) == 'A' && S.at(j) == 'B') {
                cnt++;
            }
        }
    }

    if (cnt > 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

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


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

long long int INF = 1e18;
int const TREE_SIZE = 1 << 21;
long long int seg_tree[TREE_SIZE] = {};
long long int c_diff[TREE_SIZE] = {}; // 子との差

// [a, b) の最小値を求める
// find(a, b + 1, 1, 0, 0, TREE_SIZE / 2)
long long int find(int a, int b, int index, long long int diff, int l, int r){
	seg_tree[index] += diff;
	c_diff[index] += diff;
	
	if(r <= a || b <= l){
		return INF;
	}
	if(a <= l && r <= b){
		return seg_tree[index];
	}
	
	long long int ret = INF;
	ret = min(ret, find(a, b, index * 2, c_diff[index], l, (l + r) / 2));
	ret = min(ret, find(a, b, index * 2 + 1, c_diff[index], (l + r) / 2, r));
	c_diff[index] = 0;
	return ret;
}

// [a, b) に num を足す
// add(a, b + 1, 1, num, 0, 0, TREE_SIZE / 2);
long long int add(int a, int b, int index, long long int num, long long int diff, int l, int r){
	seg_tree[index] += diff;
	c_diff[index] += diff;
	
	if(r <= a || b <= l){
		return seg_tree[index];
	}
	if(a <= l && r <= b){
		seg_tree[index] += num;
		c_diff[index] += num;
		return seg_tree[index];
	}
	
	long long int ret = INF;
	ret = min(ret, add(a, b, index * 2, num, c_diff[index], l, (l + r) / 2));
	ret = min(ret, add(a, b, index * 2 + 1, num, c_diff[index], (l + r) / 2, r));
	c_diff[index] = 0;
	return seg_tree[index] = ret;
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	for(int loop = 0; loop < q; loop++){
		long long int num, s, t, x;
		cin >> num;
		if(num == 0){
			cin >> s >> t >> x;
			add(s, t + 1, 1, x, 0, 0, TREE_SIZE / 2);
		}else{
			cin >> s >> t;
			cout << find(s, t + 1, 1, 0, 0, TREE_SIZE / 2) << endl;
		}
	}
	
	return 0;
}




Measured memory_bytes: 6268
import numpy as np
from sys import stdin

def main():
    nm = [int(x) for x in stdin.readline().rstrip().split()]
    gate = np.zeros([nm[1], 2], dtype=int)
    
    for i in range(nm[1]):
        g = [int(x) for x in stdin.readline().rstrip().split()]
        gate[i] = g
    
    l_max = np.max(gate[:, 0])
    r_min = np.min(gate[:, 1])
    c = 0
    if l_max <= r_min:
        c = r_min-l_max+1
    print(c)

if __name__ == "__main__":
    main()

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

#define ll long long

string S;


void input() {
  cin >> S;
}

void solve() {
  for (int i=0; i<S.length(); i++) cout << 'x';
  cout << endl;
}


int main() {
  input();
  solve();
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n,m;
	cin>>n>>m;
	int cnt=0;
    vector<vector<char>>a(n,vector<char>(m));
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			cin>>a[i][j];
			if(a[i][j]=='#')cnt++;
		}
	}
	if(cnt>n+m-1){
		cout<<"Impossible"<<endl;
	}
	else cout<<"Possible"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a[4];

signed main() {
	rep(i,4) cin >> a[i];
	sort(a,a+4);
	if (a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    string s;
    cin >> s;
    string t = "2019/04/30";
    if (s > t){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int a, b, d;
pii ans;

void check(int x, int y)
{
	if (ans.first + ans.second > x + y) ans = pii(x, y);
	else if (ans.first + ans.second == x+y)
	{
		if (ans.first*a + ans.second*b > a*x + b*y) ans = pii(x, y);
	}
}

int main()
{
	while (cin >> a >> b >> d, a)
	{
		ans = pii(INF, INF);
		REP(i, 100000)
		{
			int res = d + i*a;
			if (res % b == 0) check(i, res / b);
			res = d - i*a;
			if (res % b == 0) check(i, abs(res / b));
		}
		cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

typedef long long ll;

int main(){
   ll A, B, K;
   std::cin >> A >> B >> K;

   std::cout << (A>K ? A-K : 0) << ' ';
   if (K>A) {
      K -= A;
      std::cout << (B>K ? B-K : 0) << std::endl;
   } else  std::cout << B << std::endl;
   return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main () {
	int a,b,k,x;
	cin>>a>>b;
	set <int> s;
	while (b--){
		cin>>k;
		while(k--){
			cin>>x;
			s.insert(x);
		}
	}
	cout<<a-s.size();
	return 0;
}


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

int main(){
    int N;
    vector<long long int> L(90);

    cin>>N;
    L[0]=2;
    L[1]=1;
    if(N>1){
        for(int i=2;i<=N;i++){
            L[i]=L[i-1]+L[i-2];
        }
    }
    cout<<L[N]<<endl;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=998244353;
//head
const int nax = 2e5+1;
ll fact[nax];
ll modpow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll choose(ll n, ll k) {
    return (((fact[n] * modpow(fact[k], mod - 2)) % mod) * modpow(fact[n-k], mod - 2)) % mod;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n, m, k;
    cin >> n >> m >> k;
    fact[0] = 1;
    for(ll i = 1; i <= nax; i++) {
        fact[i] = i * fact[i-1] % mod;
    }
    ll ans = m*modpow(m-1,n-1)%mod;
    for(int i = 1; i <= k; i++) {
        ans += ((m*modpow(m-1,n-i-1))%mod)*choose(n-1,i);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5208
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k = inpm()
    v = inpl()
    a = [0 for _ in range(n+1)]
    b = [0 for _ in range(n+1)]
    ans = 0
    for i in range(n):
        a[i+1] = a[i] + v[i]
        b[i+1] = b[i] + v[n-1-i]
    for x in range(min(n+1,k+1)):
        for y in range(min(n-x+1,k-x+1)):
            que = []
            for i in range(x):
                que.append(v[i])
            for i in range(y):
                que.append(v[n-1-i])
            que.sort()
            l = len(que)
            pre = a[x] + b[y]
            for z in range(min(l,k-x-y)):
                if que[z]>=0:
                    break
                pre -= que[z]
                ans = max(ans,pre)
            ans = max(ans,pre)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 41328
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int n, q, k;
vector<P> edge[110000];
queue<int> que;
long long dist[110000];
bool done[110000];

void dfs(int u) {
  done[u] = true;
  for (P p: edge[u]) {
    int v = p.first, d = p.second;
    if (done[v]) continue;
    dist[v] = dist[u] + d;
    dfs(v);
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n-1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[a].push_back(P(b, c));
    edge[b].push_back(P(a, c));
  }
  cin >> q >> k;
  
  dfs(k);
  
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    cout << dist[x] + dist[y] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 11520
import java.util.*;
import java.io.*;
import java.text.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        DecimalFormat df = new DecimalFormat("0.0000000000");
        int n = in.nextInt();
        int a[] = new int[n+1];
        a[1]=1;
        for(int i=2;i<=n;i++){
            a[i] = a[i-1];
            if(i%2==1) a[i]++;
        }
        int odd = a[n];
        double ans = odd/(n+.0);
        out.println(df.format(ans));
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(30)<<fixed;
	
	int x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	int t=x/d;
	
	if(k<=t)
		cout<<x-k*d<<endl;
	else
	{
		x-=t*d;
		k-=t;
		if(x==0)
		{
			
			if(k%2==0)
				cout<<0<<endl;
			else
				cout<<abs(d)<<endl;
		}
		else
		{
			if(k%2==1)
				cout<<abs(x-d)<<endl;
			else
				cout<<x<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3636
N, K = map(int, input().split())
X = list(map(int, input().split()))
from itertools import accumulate
for i in range(N):
    X[i] = 1 + (X[i]-1)/2

X = list(accumulate([0] + X))
mm = 0
for i in range(N-K+1):
    mm = max(mm, X[i+K] - X[i])
print(mm)


Measured memory_bytes: 85000
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

/* MACROS SAMPAH */
#define Jehian using
#define Norman namespace
#define Saviero std
#define cepet {ios_base::sync_with_stdio(0);cin.tie(0);}

Jehian Norman Saviero;

/* MACROS FOR TYPE */
typedef long l;
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

/* MACROS FOR PRINT */
#define nl printf("\n")
#define sp printf(" ")

/* MACROS FOR FUNCTION AND METHOD */
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define eb emplace_back
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for(int _je = sizeof(x)/sizeof(x[0]); _je--;) x[_je] = y
#define SQR(x) (x)*(x)
#define CUBE(x) SQR(x)*(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLSIZE(x,n) (x), (x)+(n)

/* MACROS FOR ATTRIBUTE */
#define fi first
#define se second

/* MACROS FOR SCAN */
#define scc(x) scanf("%c", &x)
#define scd(x) scanf("%Lf", &x)
#define scf(x) scanf("%f", &x)
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scld(x) scanf("%Lf", &x)
#define scui(x) sci(x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main(){
	string A;
	cin >> A;
	cout << 2018;
	for (ll i = 4; i < A.size(); ++i){
		cout << A[i];
	}
	cout << endl;
	return 0;
}

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

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


int main() {
int a,b,c;cin>>a>>b>>c;
bool j = false;
for(int i=a;i<=a*b;i++){
    if((i*a)%b==c)j=true;
}
if(j)cout << "YES" << endl;
else cout << "NO" << endl;
return 0;

}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define P 1000000007
#define N 2010
int n;
int a[N];
vector<int> A[N];
int f[N][N][3];
int g[N][3];
int s[N];

void ff(int x) {
	s[x] ++;
	f[x][0][0] = 1;
	for (vector<int>::iterator i = A[x].begin(); i != A[x].end(); i ++) {
		ff(*i);
		for (int j = 0; j < s[x]; j ++)
			for (int jj = 0; jj < 3; jj ++) {
				g[j][jj] = f[x][j][jj];
				f[x][j][jj] = 0;
			}
		
		for (int j = 0; j < s[x]; j ++)
			for (int jj = 0; jj < 3; jj ++)
				for (int k = 0; k < s[*i]; k ++)
					for (int kk = 0; kk < 3; kk ++) {
						// no delete
						int s = (ll)g[j][jj]*f[*i][k][kk]%P;
						int pp = jj;
						if (kk == 1) s = s*2%P;
						(f[x][j+k][pp] += s) %= P;
						
						// delete
						if (jj == 2 || kk == 2) continue;
						s = (ll)g[j][jj]*f[*i][k][kk]%P;
						if (jj && kk) {s = s*2%P; pp = 2;}
						if (jj && !kk) {s = s*2%P; pp = 2;}
						if (!jj && kk) {pp = 1;}
						if (!jj && !kk) {pp = 1;}
						(f[x][j+k+1][pp] += s) %= P;
					}
		s[x] += s[*i];
	}
}

int F[N];

int main() {
	F[0] = 1;
	for (int i = 1; i < N; i ++) F[i] = (ll)F[i-1]*i%P;
	cin >> n;
	a[0] = -1;
	for (int i = 1; i < n; i ++) {
		cin >> a[i];
		a[i] --;
		A[a[i]].pb(i);
	}
	memset(f, 0, sizeof f);
	ff(0);
	int S = 0;
	for (int i = 0; i < s[0]; i ++)
		for (int ii = 0; ii < 3; ii ++) {
			int s = f[0][i][ii];
			if (ii == 1) s = s*2%P;
			if (i%2) s = (P-s)%P;
			s = (ll)s*F[n-i]%P;
			S = (S+s)%P;
		}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 48000
def main(): 
    
    N = int(input())
    A = []
    B = list(map(int, input().split()))
    B.insert(0, 100000)
    B.append(100000)

    for i in range(len(B)-1):
        A.append(min(B[i],B[i+1]))
    print(sum(A))

if __name__ == "__main__":
    main() 

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

int main(){
  string s;
  cin >> s;
  
  int ans = 0;
  for (int i=0 ; i<3 ; i++){
    if (s.at(i) == '1')
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = s.length();
        int displayLen = len - 2;
        System.out.println(s.charAt(0) + String.valueOf(displayLen) + s.charAt(len-1));
    }
}


Measured memory_bytes: 21844
from sys import stdin

def BinarySearch(x):
    l, r = 0, n
    while l < r:
        mid = (l + r) // 2
        a = x - S[mid]
        if a == 0:
            return True
        elif a > 0:
            l = mid + 1
        elif a < 0:
            r = mid
    return False

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

cnt = 0
for x in T:
    if BinarySearch(x):
        cnt += 1
print(cnt)


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

#define lb(x) (x&(-x))

using namespace std;

const int mmax = 1e5 + 10;

int n, m;
int fen[mmax], cnt[mmax], ans[mmax];
vector < pair < int, int > > v[mmax];

void update(int pos, int val) {
    for ( ; pos <= m; pos += lb(pos))
        fen[pos] += val;
}

int query(int pos) {
    int res = 0;
    for ( ; pos ; pos -= lb(pos))
        res += fen[pos];
    return res;
}

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        int x, y; scanf("%d %d", &x, &y);
        update(x, 1); update(y + 1, -1);

        cnt[y-x+1]++;
        v[y-x+1].push_back({x, y});
    }

    for (int i = m; i ; --i)
        cnt[i] += cnt[i+1];

    for (int d = m; d; --d) {
        ans[d] = cnt[d];
        for (auto &it : v[d])
            update(it.first, -1), update(it.second + 1, 1);
        for (int i = d; i <= m; i += d)
            ans[d] += query(i);
    }

    for (int i = 1; i <= m; ++i)
        printf("%d\n", ans[i]);

    return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a - mod; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
      solve();
    }
}


// https://atcoder.jp/contests/abc153/submissions/9764873

void solve() {
  int n, d, a;
  cin >> n >> d >> a;
  vector<pair<int, ll> > v(n);
  rep(i, n) cin >> v[i].F >> v[i].S;
  sort(all(v));

  deque<pair<int, ll> > q;
  ll ans = 0, dmg = 0;

  rep(i, n) {
    while (sz(q) && q.front().F < v[i].F) { // そのダメージを無効にする
      dmg -= q.front().S;
      q.pop_front();
    }
    ll rem = v[i].S - dmg;
    if (rem <= 0) continue;

    ll aa = (rem + a - 1) / a; // -(-rem / a)
    ans += aa;
    dmg += a * aa; // ダメージを累積
    q.push_back({v[i].F + 2 * d, a * aa});
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
using s64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

template <typename T>
int gcd(T a, T b){ return b%a==0 ? a : gcd(b%a, a); }

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    int g = a[0];
    rep(i,n) g = gcd(g, a[i]);    
    cout << g << endl;

    return 0;
}

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

int main(){
 int N,M,f,g;
  cin>>N>>M;
 vector<pair<int,int>> a(M),b(N+1);
  for(int i=0;i<M;i++){
    cin>>f>>g;
    if(f>g){
      swap(f,g);
    }
    a[i]=make_pair(f,g);
  }
  sort(a.begin(),a.end());
  f=1;
    for(int i=0;i<M;i++){
   if(a[i].first==f){
     b[f].first++;
     b[f].second++;
   }
      else{
        b[a[i].first].first=b[f].first+1;
        f=a[i].first;
        b[f].second++;
      }
    }
  for(int i=0;i<N;i++){
    if(a[i].first==1){
    g=a[i].second;
     if(b[g].second==0){
       continue;
     }
      else{
        for(int j=b[g].first-1;j<b[g].first+b[g].second-1;j++){
          if(a[j].second==N){
            cout<<"POSSIBLE"<<endl;
            return 0;
          }
        }
      }
    }
    else{
      cout<<"IMPOSSIBLE"<<endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define int long long int
using namespace std;

const int N = 1e6+5;
const int mod = 1e9+7;

void solve() {
	int n,k;
	cin >> n >> k;
	vector<bool> vis(n+1,false);
	int d,x;
	for(int i=0;i<k;i++) {
		cin >> d;
		for(int j=0;j<d;j++) {
			cin >> x;
			vis[x] = true;
		}
	}
	int cnt = 0;
	for(int i=1;i<n+1;i++)
		if(vis[i] == false)
			cnt++;
	cout << cnt;
	return;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int testcases = 1,i = 1;
	//cin >> testcases;
    while(testcases--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int main(){
    vector<int> a(4);
    vector<int> b(4);
    while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
        rep(i,4) cin >> b[i];
        int hit = 0,blow = 0;
        rep(i,4){
            if(a[i] == b[i]) hit++;
            else {
                rep(j,4) if(a[j] == b[i]) blow++;
            }
        }
        cout << hit << " " << blow << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	char buf[128];
	while (!cin.eof())
	{
		cin.getline(buf, sizeof(buf));
		if (strlen(buf) == 0)
			break;

		stack<double> s;
		for (char* p = strtok(buf, " "); p; p = strtok(NULL, " "))
		{
			if (isdigit(*p) || strlen(p) >= 2)
				s.push(atof(p));
			else
			{
				double a, b;
				b = s.top(); s.pop();
				a = s.top(); s.pop();
				double res;
				if (*p == '+')
					res = a + b;
				else if (*p == '-')
					res = a - b;
				else if (*p == '*')
					res = a * b;
				else if (*p == '/')
					res = a / b;
				s.push(res);
			}
		}
		printf("%.6f\n", s.top());
	}

	return 0;
}

Measured memory_bytes: 0
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

n = onem()

k = prime_decomposition(n)
print("{0}: {1}".format(n,jo(k)))


Measured memory_bytes: 6028
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

class State{
public:
  int x;
  int y;
  int cost;
  int level;
  State(int _x,int _y,int _c,int _l) : x(_x),y(_y),cost(_c),level(_l) {}
  bool operator<(const State& s) const{
    return cost < s.cost;
  }
  bool operator>(const State& s) const{
    return cost > s.cost;
  }
};

int pos2idx(int x,int y,int W){
  return W * y + x;
}

int dp[2505][2505];//dp[level][pos]
int levels[2505];

int main(){
  int W,H;
  while(~scanf("%d %d",&W,&H)){
    if(W == 0 && H == 0) break;

    int sx,sy;
    int gx,gy;

    int max_level = 0;
    memset(levels,0,sizeof(levels));
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
        string tmp;
        cin >> tmp;
        if(tmp == "S"){
          sx = x;
          sy = y;
        }
        else if(tmp == "G"){
          gx = x;
          gy = y;
        }
        else if(tmp != "."){
          stringstream ss;
          ss << tmp;
          int level = 0;
          ss >> level;
          levels[y * W + x] = level;
          max_level = max(level,max_level);
        }
      }
    }
    
    priority_queue<State,vector<State>,greater<State> > que;

    memset(dp,0x3f,sizeof(dp));

    dp[1][pos2idx(sx,sy,W)] = 0;
    que.push(State(sx,sy,0,1));

    int res = 0;

    while(!que.empty()){
      State s = que.top();
      que.pop();

      for(int i=0;i<4;i++){
        int dx = s.x + tx[i];
        int dy = s.y + ty[i];
        if(dx < 0 || dx >= W || dy < 0 || dy >= H) continue;
        int dst = pos2idx(dx,dy,W);

        if(levels[dst] == s.level){
          if(dp[s.level+1][dst] <= s.cost + 1) continue;
          dp[s.level+1][dst] = s.cost + 1;
          que.push(State(dx,dy,s.cost + 1,s.level+1));
        }
        else {
          if(dp[s.level][dst] <= s.cost + 1) continue;
          dp[s.level][dst] = s.cost + 1;
          que.push(State(dx,dy,s.cost + 1,s.level));
        }
      }
    }

    printf("%d\n",dp[max_level+1][gy * W + gx]);
  }
}

Measured memory_bytes: 25868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,ans = 0;
    cin>>n;
    vector<int>sum(n + 1,1);
    rep(i,2,n + 1){
        sum[i]++;
        ll tmp = 2;
        while(true){
            if(i * tmp > n)break;
            else sum[i * tmp]++;
            tmp++;
        }
    }
    rep(i,1,n + 1){
        ans += sum[i] * i;
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 42248
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n;
    set<string> gacha;
    cin>>n;
    rep(i,n){
        string t;
        cin>>t;
        gacha.insert(t);
    }
    cout<<gacha.size();
    return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 100002
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL {printf("-1\n"); return 0;}

int N;
int H[MAXN];
LL dp[MAXN];
int B[MAXN];

LL f(int i) {
    if (i == N-1) return 0;
    if (B[i]) return dp[i];
    B[i] = 1;

    LL& ret = dp[i] = abs(H[i+1]-H[i]) + f(i+1);
    if (i < N-2) ret = min(ret, abs(H[i+2]-H[i]) + f(i+2));

    return ret;
}

int main(int argc, char **argv)
{
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", &H[i]);

    printf("%lld\n", f(0));
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    string temp;
    set<string> s;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        s.insert(temp);
    }
    cout<<s.size();
    return 0;
}

Measured memory_bytes: 19140
#include <bits/stdc++.h>
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 998244353
#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())
int n;
vector<P>vec;
ll cnt[100005],S[100005],S2[100005];
ll A,B;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b; cin>>a>>b;
		vec.pb(mp(a,i));
		vec.pb(mp(b,i));
		S[i] = S2[i] = a+b;
		A += a; B += b;
	}
	SORT(vec);
	ll sum2=0,sum1=0,sum=0;
	for(int i=0;i<n;i++){
		if(i<n-2) sum2 += vec[i].fi;
		if(i<n-1) sum1 += vec[i].fi;
		sum += vec[i].fi;
		cnt[vec[i].sc]++;
		S2[vec[i].sc] -= vec[i].fi;
	}
	ll ans = min(A,B);
	for(int i=0;i<n;i++){
		if(cnt[i] == 0 || cnt[i] == 2){
			ans = min(ans,sum);
		}
		else{
			if(vec[n-1].sc == i){
				ans = min(ans,1LL*S[i]+sum2);
			}
			else{
			    ans = min(ans,1LL*S2[i]+sum1);
			}
		}
	}
	cout << ans << endl;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  ll n;cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(), a.end());
  ll ans=0;
  for(int i=0;i<n;i++){
    if(i==n-1 || a[i]>=0){
      ans+=a[i];
    }else {
      ans+=abs(a[i]+a[i+1]);i++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3992
import math
import sys

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

a_min = math.ceil(a*12.5)
a_max = math.ceil((a+1)*12.5)
b_min = math.ceil(b*10)
b_max = math.ceil((b+1)*10)

ab_and = set(range(a_min, a_max)) & set(range(b_min, b_max))

if not ab_and:
    print(-1)
    sys.exit()

ab_and_sort = sorted(list(ab_and))

print(ab_and_sort[0])

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

int main() {
    int N, a;
    cin >> N;
    int mina = 1000;
    int maxa = 0;
    for (int n = 0; n != N; ++n){
        cin >> a;
        if (a < mina) mina = a;
        if (a > maxa) maxa = a;
    }
    cout << maxa - mina << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
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;}

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  for(ll i = 0; i < n; i++) cin >> b[i];
  for(ll i = 0; i < n; i++) cin >> c[i];
  sort(all(a)); sort(all(b)); sort(all(c));
  
  ll ans = 0;
  for(ll i = 0; i < n; i++){
    ll itr1 = upper_bound(all(c), b[i]) - c.begin();
    ll itr2 = lower_bound(all(a), b[i]) - a.begin();
    ans += (n - itr1) * itr2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7;

ll add(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (a + b) % mod;
}

ll mul(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return 1LL * a * b % mod;
}

vector<pair<ll, ll> > v, p;
map<pair<ll, ll>, ll> mp, mp2, mp3;
ll n, dp[N], pw[N];


ll solve(int idx){
    if(idx == p.size()) return 1;
    if(dp[idx] != -1) return dp[idx];
    ll op1 = solve(idx + 1);
    ll op2 = 0, op3 = 0;
    if(mp.find(p[idx]) != mp.end()) op2 = mul(add(pw[mp[p[idx]]], -1), solve(idx + 1));
    if(mp2.find(p[idx]) != mp2.end()) op3 = mul(add(pw[mp2[p[idx]]], -1), solve(idx + 1));
    return dp[idx] = add(add(op1, op2), op3);
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    pw[0] = 1;
    for(int i = 1; i < N; i++) pw[i] = mul(pw[i - 1], 2);
    cin >> n;
    int kam = -1;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        if(!a && !b) {
            kam++;
            continue;
        }
        v.push_back({a, b});
    }
    for(int i = 0; i < v.size(); i++){
        auto p = v[i];
        if(!p.first || !p.second){
            if(!p.first) mp[{0, 1}]++;
            else mp2[{0, 1}]++;
            continue;
        }
        bool found = 0;
        ll a = p.first, b = p.second;
        if(a > 0 && b > 0) found = 1;
        if(a < 0 && b < 0) found = 1;
        a = abs(a);
        b = abs(b);
        ll g = __gcd(a, b);
        a /= g;
        b /= g;
        if(found) mp[{a, b}]++;
        else mp2[{b, a}]++;
    }
    for(auto i: mp) mp3[i.first] = 1;
    for(auto i: mp2) mp3[i.first] = 1;
    for(auto i: mp3) p.push_back(i.first);
    memset(dp, -1, sizeof dp);
    cout << add(kam, solve(0));

    return 0;

}


Measured memory_bytes: 60984
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
int main(){
  int n;
  cin>>n;
  long long t[n];
  REP(i,n){
    cin>>t[i];
  }
  long long ans;
  REP(i,n){
    if(i==0){
      ans = t[i];
    }else{
      ans = lcm(ans,t[i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
	// sengen
	long long x;
	// nyuryoku
	cin >> x;
	// keisan
	long long a,b,a5,b5;
	int deki = 0;
	a = 0;
	while(1){
		a++;
		a5 = (long long)pow(a,5);
		if(a5 < x){
			b = -1;
			while(1){
				b5 = (long long)pow(b,5);
				if(a5 - b5 == x){
					deki = 1;
					goto END;
				}
				if(a5 - b5 > x){
					break;
				}
				b--;
			}
		}else if(a5 > x){
			b = 1;
			while(1){
				b5 = (long long)pow(b,5);
				if(a5 - b5 == x){
					deki = 1;
					goto END;
				}
				if(a5 - b5 < x){
					break;
				}
				b++;
			}
		}else{
			b = 0;
			goto END;
		}
	}
	// syutsuryoku
	END : cout << a << ' ' << b;
}


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

int main(){

  long long int  n;
  cin >> n;
  long long int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  sort(a,a+5);
  long long int ans;

  if(n%a[0]!=0){
    cout << 5 + n/a[0] << endl;
  }else{
    cout << 4 + n/a[0] << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define FAST_IO                  \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define MOD 1000000007
#define MAX 1e9
#define MIN -1e9

using namespace std;

typedef long long ll;
// struct item
// {
//     ll val, wt;
// };
int main()
{

    FAST_IO
    ll n, W;
    cin >> n >> W;
    ll v[n], wt[n];
    // vector<item> v(n + 1);
    for (ll i = 0; i < n; i++)
    {
        cin >> wt[i] >> v[i];
    }
    ll dp[n + 1][W + 1];
    memset(dp, 0, sizeof(dp[0][0]) * (n + 1) * (W + 1));
    for (ll i = 0; i <= n; i++)
    {
        for (ll w = 1; w <= W; w++)
        {
            if (i == 0 || w == 0)
            {
                dp[i][w] = 0;
            }
            else if (wt[i - 1] <= w)
            {
                dp[i][w] = max(v[i - 1] + dp[i - 1][w - wt[i - 1]], dp[i - 1][w]);
            }
            else
            {
                dp[i][w] = dp[i - 1][w];
            }
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 79104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

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

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        int h = Integer.parseInt(tokenizer.nextToken());
        int w = Integer.parseInt(tokenizer.nextToken());
        int m = Integer.parseInt(tokenizer.nextToken());
        int[][] targets  = new int[m][2];
        int[] rows = new int[h];
        HashSet<Integer>[] colsInRow = new HashSet[h];
        for (int i = 0; i < h; i++) colsInRow[i] = new HashSet<Integer>();
        int[] cols = new int[w];
        for (int i = 0; i < m; i++) {
            tokenizer = new StringTokenizer(f.readLine());
            targets[i][0] = Integer.parseInt(tokenizer.nextToken()) - 1;
            targets[i][1] = Integer.parseInt(tokenizer.nextToken()) - 1;
            rows[targets[i][0]]++;
            cols[targets[i][1]]++;
        }

        int maxInACol = 0;
        for (int i = 0; i < w; i++) {
            maxInACol = Math.max(maxInACol, cols[i]);
        }
        int maxInARow = 0;
        for (int i = 0; i < h; i++) {
            maxInARow = Math.max(maxInARow, rows[i]);
        }


        HashMap<Integer, Integer> colUsed = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> rowUsed = new HashMap<Integer, Integer>();
        for (int i = 0; i < w; i++) {
            if (cols[i] == maxInACol) colUsed.put(i, 0);
        }
        ArrayList<Integer> maxRows = new ArrayList<Integer>();
        for (int i = 0; i < h; i++) {
            if (rows[i] == maxInARow) rowUsed.put(i, 0);
        }



        for (int[] coord : targets) {
            if (rowUsed.containsKey(coord[0]) && colUsed.containsKey(coord[1])) {
                rowUsed.put(coord[0], rowUsed.get(coord[0]) + 1);
                colUsed.put(coord[1], colUsed.get(coord[1]) + 1);
            }
        }

        boolean foundPerfect = false;
        for (int row : rowUsed.keySet()) {
            if (rowUsed.get(row) != colUsed.keySet().size()) foundPerfect = true;
        }

        if (foundPerfect) {
            out.println(maxInACol + maxInARow);
        } else {
            out.println(maxInACol + maxInARow - 1);
        }
        out.close();
    }
}

Measured memory_bytes: 115044
#include <stdio.h>

long abs(long p){
  return(p>=0?p:-p);
}

long min(long p0,long p1){
  return(p0<p1?p0:p1);
}

int main(){
  long n,k,m;
  scanf("%ld",&n);
  scanf("%ld",&k);
  m=abs(n%k);
  printf("%ld",min(abs(k-m),m));
  return(0);
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){

    int n;
    int k;
    int q;

    cin >> n;
    cin >> k;
    cin >> q;

    int a[100000];

    for (int i=0;i<q ;i++) cin >> a[i];

    int b[100000];

    for (int i=0;i<n;i++) b[i] = k-q;

    for (int i=0;i<q;i++) 
        b[a[i]-1]=b[a[i]-1]+1;

    for (int i=0;i<n;i++)
        if (b[i] > 0)
        cout << "Yes" << endl;
        else cout << "No" << endl;
}

Measured memory_bytes: 4360