akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    VI a(n), b(n);
    REP(i,n) cin >> a[i] >> b[i];
    sort(ALL(a));
    sort(ALL(b));
    int l,r;
    if ( n%2==0 ) {
        l=a[n/2-1]+a[n/2];
        r=b[n/2-1]+b[n/2];
    } else {
        l=a[n/2];
        r=b[n/2];
    }
    cout << r-l+1 << '\n';
    return 0;
}






Measured memory_bytes: 4788
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    int n;
    cin >> n;
    int p_taro = 0, p_hanako = 0;
    FOR(i, 0, n){
        string taro, hanako;
        cin >> taro >> hanako;
        if(taro==hanako){
            p_taro++;
            p_hanako++;
        }
        else taro > hanako ? p_taro += 3 : p_hanako += 3;
    }
    cout << p_taro << " " << p_hanako << endl;
}

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


int main() {
  string moji;
  
  cin >> moji ;
    
  int flag = 0;
  
  for(int i = 0; i<moji.size(); i++){
    if(moji.at(i) == '1')
      flag++;
  }
  
  cout << flag;
  
  
  
  
  
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long int


int main (){
	ll num[4]={0};
	scanf ("%lld %lld %lld %lld", &num[0], &num[1], &num[2], &num[3]);
	ll sum = -1000000000000000000;
	for (int i=0; i<2; i++){
		for (int j=2; j<4; j++){
			if (sum < num[i] * num[j]){
				sum=num[i] * num[j];
			}
		}
	}
	printf ("%lld\n", sum);
return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
#define ll          long long
#define pll         vector< pair<ll ,ll> >
#define vll         vector<ll>
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(v)      v.begin(), v.end()
#define lb          lower_bound  //value not less than(>=)
#define ub          upper_bound  //value greater than(>)
#define bs          binary_search
#define pcont(v)    for(auto it:v) cout<<it<<" ";cout<<endl
#define ret(x)      return cout << x,0;
#define pi          pair<ll,pair<ll,ll> >

ll const MAX = 1e5+5;
using namespace std;

ll a[MAX],dp[MAX];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

    ll n,k;
    cin >> n >> k;
    rep(i,0,n) cin >> a[i];

    dp[n-1]=0;
    for(ll i=n-2;i>=0;i--) {
        ll add[k+1];
        dp[i]=hell;
        rep(j,1,k+1) add[j]=hell;
        rep(j,1,k+1) {
            if(i+j<n) {
                add[j]=dp[i+j]+abs(a[i]-a[i+j]);
            }
        }
        //cout << add[1] << endl;
        rep(j,1,k+1) dp[i]=min(dp[i],add[j]);
    }
    cout << dp[0] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>

using namespace std;

int cmax(int n, int s[200]){
	int max;
	for(int i = 0;i < n;i++){
		if(i == 0 || max < s[i]){
			max = s[i];
		}
	}
	return max;
}

int cmin(int n, int s[200]){
	int min;
	for(int i = 0;i < n;i++){
		if(i == 0 || min > s[i]){
			min = s[i];
		}
	}
	return min;
}

int main(){
	int n, sum, s[200];
	while(1){
		cin >> n;
		if(n == 0) break;
		
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> s[i];
		}
		int max = cmax(n, s);
		int min = cmin(n, s);

		for(int i = 0;i < n;i++){
			sum += s[i];
		}

		sum = sum - max - min;
		int ans = sum / (n-2);

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    string s;
    cin>>s;
    set<char> st;
    rep(i,26){
        st.insert(i+'a');
    }
    int n=s.size();
    rep(i,n) st.erase(s[i]);
    if(!st.empty()) cout<<s<<*begin(st)<<endl;
    else{
        if(s=="zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
        else{
            bool ok=false;
            int m;
            char v;
            for(int i=n-1;i>0;i--){
                set<char> ss;
                for(int j=n-1;j>=i;j--){
                    ss.insert(s[j]);
                }
                while(!ss.empty()){
                    char u=*begin(ss);
                    ss.erase(u);
                    if(s[i-1]<u){
                        ok=true;
                        v=u;
                        break;
                    }
                }
                if(ok){
                    m=i-1;
                    break;
                }
            }
            for(int i=0;i<m;i++) cout<<s[i];
            cout<<v<<endl;
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

string s, t;
bool ch(int ss)
{
	for (int i = 0; i<t.length(); i++)
		if (s[ss + i] != '?' && s[ss + i] != t[i])return false;
	for (int i = 0; i<t.length(); i++)
		s[ss + i] = t[i];
	replace(s.begin(), s.end(), '?', 'a');
	return true;
}
int main()
{
	cin >> s >> t;
	for (int i = s.length() - t.length(); i>=0; i--)
	{
		if (ch(i))
		{
			cout << s << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        int minj = i;
        for(int j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(A[i], A[minj]);
            cnt++;
        }
    }

    for (int i = 0; i < N; i++) (i != N-1) ? cout << A[i] << ' ' : cout << A[i] << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3088
let () =
  let s = read_line () in
  Printf.printf "%d\n" @@ fst @@ 
  List.fold_left (fun (acc, s) c ->
    match s, c with
    | '1' :: s, '0' | '0' :: s, '1' -> (2 + acc, s)
    | _, _ -> (acc, c :: s)) (0, []) @@
  Array.to_list @@ Array.init (String.length s) @@ String.get s



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

typedef __int128 num;

// returns g,s,t such that gcd(a,b) == g == s*a + t*b
tuple<num,num,num> eea(num a, num b) {
	if (b == 0) return {a, 1, 0};
	auto [g,s,t] = eea(b,a%b);
	return {g, t, s-t*(a/b)};
}

struct eqn { num a, m; }; // x == a (mod m)

eqn operator*(eqn C, eqn D) {
	auto [g,s,t] = eea(C.m,D.m); t = t;
	if (g == 1) {
		num b = ((D.a-C.a) * s) % D.m;
		if (b < 0) b += D.m;
		return {C.a + b*C.m, C.m*D.m};
	} else {
		if ((C.a - D.a) % g) return {0,0};
		eqn E = eqn{C.a/g, C.m/g} * eqn{D.a/g, D.m/g};
		return {E.a*g + C.a%g, E.m*g};
	}
}

ll solve(num n) {
	num res = LLONG_MAX;
	auto consider = [&](num d) {
		num m = 2*n/d;
		num g, s, t;
		tie(g,s,t) = eea(d,m);
		if (g != 1) return;
		ll a = -s % m;
		if (a <= 0) a += m;
		assert((d*a+1)%m == 0);
		assert(get<0>(eea(a,m)) == 1);
		num k = d*a;
		// cerr << ll(k) << endl;
		assert((k*(k+1)) % (2*n) == 0);
		assert((k*(k+1)/2) % n == 0);
		res = min(res, k);
	};

	for (num d = 1; d*d <= 2*n; d++) if (2*n%d == 0) {
		consider(d);
		consider(2*n/d);
	}
	return res;
}

ll solve_naive(ll n) {
	FOR(k,1,oo) if ((k*(k+1)/2) % n == 0) return k;
	return -1;
}

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

	/*
	FOR(n,1,1000) {
		ll a = solve(n), b = solve_naive(n);
		cout << n << " " <<  a << " " << b << endl;
		assert(a == b);
	}
	*/

	ll n; cin >> n;
	cout << solve(n) << endl;
}



Measured memory_bytes: 3656
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
// #define int unsigned long long int
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int mul1 = 1003, mul2 = 5, mul3 = 8;
const int MOD3 = 179424673, MOD2 = 982451653, MOD1 = 1190494759;
const ld EPS = 1e-9;

int N;
v64 H;

int main()
{
    cin >> N;
    forn(i, N)
    {
        ll tmp;
        cin >> tmp;
        H.push_back(tmp);
    }

    ll max_h = H[0];
    ll st_need = 0;
    forsn(i, 1, N)
    {
        ll c_h = H[i];
        if (c_h >= max_h)
        {
            max_h = c_h;
        }
        else
        {
            st_need += max_h - c_h;
        }   
    }

    cout << st_need << endl;
    return 0;
    
}

Measured memory_bytes: 5336
abhm = gets.split(' ').map(&:to_i)

a = abhm[0]
b = abhm[1]
h = abhm[2]
m = abhm[3]

angle = (h / 12.0 + m/(60.0*12.0) - m/60.0) * Math::PI * 2

c = Math::sqrt(a**2 + b**2 - 2 * a * b * Math::cos(angle))

puts c


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

using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int n, t;
	cin >> n >> t;
	
	ll last = -INF;
	ll ans = 0;
	
	REP(i, n) {
		ll now;
		scanf("%lld", &now);
		
		if (last == -INF) ans -= t;
		
		if (now - last <= t) ans += now - last;
		else ans += t;
		
		last = now;
	}
	
	ans += t;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	//ll a[200000] = {};
	//ll b[200000] = {};
	ll v[100] = {};
	ll *a, *b, *x;
	string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	

	//char p;
	cin >> N ;
	//cin >> S;

	//a = (ll *)malloc(M * sizeof(ll));
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(N+1);
	//vector<bool> flag(N);
	
	//count--;
	//	cout << X << endl;
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(is.begin(), is.end());

	A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;

	if (A + B + C + D == 7)
		cout << A << "+" << B << "+" << C << "+" << D << "=" << 7 << endl;
	else if (A + B + C - D == 7)
		cout << A << "+" << B << "+" << C << "-" << D << "=" << 7 << endl;
	else if (A + B - C + D == 7)
		cout << A << "+" << B << "-" << C << "+" << D << "=" << 7 << endl;
	else if (A - B + C + D == 7)
		cout << A << "-" << B << "+" << C << "+" << D << "=" << 7 << endl;
	else if (A - B + C - D == 7)
		cout << A << "-" << B << "+" << C << "-" << D << "=" << 7 << endl;
	else if (A + B - C - D == 7)
		cout << A << "+" << B << "-" << C << "-" << D << "=" << 7 << endl;
	else if (A - B - C + D == 7)
		cout << A << "-" << B << "-" << C << "+" << D << "=" << 7 << endl;
	else if (A - B - C - D == 7)
		cout << A << "-" << B << "-" << C << "-" << D << "=" << 7 << endl;


	
	
	//cout << v[0] << v[1] << v[2] << v[3] << endl;

	
	

	



	


	return 0;

}

ll gcd(ll a, ll b) {
	ll c;
	c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}

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

int main(){
	int i,n,m;
	string s, t, u = "";
	cin >> s >> t;

	n = s.size() + t.size();
	i = 0;
	while(n){
		if(i % 2 == 0){
			u += s[i/2];
		}else{
			u += t[i/2];
		}
		++i;
		--n;
	}
	cout << u << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from collections import deque

    h, w, k = map(int, readline().split())
    x1, y1, x2, y2 = map(lambda x: int(x) - 1, readline().split())
    c = [readline().rstrip().decode() for _ in range(h)]
    dict = [[-1] * w for _ in range(h)]
    move = [(0, 1), (1, 0), (-1, 0), (0, -1)]
    q = deque()
    q.append((x1, y1))
    dict[x1][y1] = 0
    while q:
        x, y = q.popleft()
        if x == x2 and y == y2:
            exit(print(dict[x][y]))
        for dx, dy in move:
            for i in range(1, k + 1):
                xx = x + dx * i
                yy = y + dy * i
                if 0 > xx or xx >= h or 0 > yy or yy >= w:
                    break
                if 0 <= dict[xx][yy] <= dict[x][y] or c[xx][yy] == '@':
                    break
                if dict[xx][yy] == -1:
                    q.append((xx, yy))
                dict[xx][yy] = dict[x][y] + 1
    print(-1)


if __name__ == '__main__':
    main()


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

  int W,H,x,y;
  cin >> W >> H >> x >> y;

  float s = (float)W*H/2;
  bool is_center = W == 2*x && H == 2*y;

  cout << s << ' ' << is_center << endl;

  return 0;
}


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

signed main(void)
{
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;
	long long ans = 0;
	rep(i, n)
	{
		map<char, int> mp;
		mp[a[i]]++;
		mp[b[i]]++;
		mp[c[i]]++;
		ans +=  mp.size() - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int n, l;
    cin >> n >> l;
    vector<string> s(n); 

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

    sort(s.begin(), s.end());

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

    cout << ans << endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    int N = read(), T = read(), A = read(), ans;
    float tmp = 1e5;
    vector<int> H(N);
    for (auto &h:H) h = read();
    for (int i = 0; i < N; i++) if(abs(T-(float)H[i]*0.006-A) < tmp) {
        tmp = abs(T-(float)H[i]*0.006-A);
        ans = i+1;
    }
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
var input=require("fs").readFileSync("/dev/stdin","utf8");
input=input.split("\n");
var n=input[0];
var tbl=new Array(4);
for (let i=0;i<4;i++){
    tbl[i]=new Array(4).fill(0);
}

for(var i=1;i<=n;i++){
    var card=input[i].split(" ");
    switch(card[0]){
        case "S":
            tbl[0][parseInt(card[1])-1]=1;
            break;
        case "H":
            tbl[1][parseInt(card[1])-1]=1;
            break;
        case "C":
            tbl[2][parseInt(card[1])-1]=1;
            break;
        case "D":
            tbl[3][parseInt(card[1])-1]=1;
            break;
    }
}

for(var j=0;j<4;j++){
    for(let i=0;i<13;i++){
        if(tbl[j][i]!=1){
            switch(j){
                case 0:
                    console.log("S "+(parseInt(i)+1));
                    break;
                case 1:
                    console.log("H "+(parseInt(i)+1));
                    break;
                case 2:
                    console.log("C "+(parseInt(i)+1));
                    break;
                case 3:
                    console.log("D "+(parseInt(i)+1));
                    break;
            }
        }
    }
}


Measured memory_bytes: 15144
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    int num[m]={};
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        
        for(int j=0;j<k;j++){
            int tmp;
            cin>>tmp;
            num[tmp-1]++;
        }

    }
    int ans=0;
    for(int i=0;i<m;i++){
        if(num[i]==n)ans++;
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
void A() {
    int n;
    cin>>n;
    vector<int> a(n,0);
    for(int i=0; i<n; i++)
        cin>>a[i];
    vector<int> dp(n+1,inf);
    dp[0]=0;
    for(int i=1; i<n; i++) {
        dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
        if(i>=2)
            dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;

}
void B()
{
    int n,k;
    cin>>n>>k;
    vector<int> dp(n+1,inf);
    vector<int> h(n,0);
    for(int i=0;i<n;i++) cin>>h[i];
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int len=1;len<=min(k+1,i+1);len++){
            int j=i-len+1;
            dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n-1]<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    B();
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define IF_DEBUG 0
typedef long long ll;
typedef double db;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}
const int maxn = 100050;

int n, a[maxn], t[maxn], Ans;

int main()
{
	sf("%d",&n);
	fo(i,1,n) 
	{
		sf("%d",&a[i]); ++ a[i];
		t[a[i]-1] ++;
		t[a[i]] ++;
		t[a[i]+1] ++;
	}
	fo(i,1,100000) gmax(Ans, t[i]);
	pf("%d\n",Ans);
	return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  
  int a = 1, b = 1;
  bool ok = true;
  if(x == 2 || y == 2 || x == 11 || y == 4) ok = false;
  if(x == 4 || x == 6 || x == 9) a = 2;
  if(y == 6 || y == 9 || y == 11) b = 2;
  
  if(ok){
    if(a != b) ok = false;
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

const int N=200010;
int n,m,a[N];

bool check(int p)
{
    for(int i=p;i<=n*2;i++)
        if(a[i]+a[n*2-i+p]<m) return 0;
    return 1;
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n*2;i++) scanf("%d",a+i);
    sort(a+1,a+1+n*2);
    int l=-1,r=n,mid;
    while(r-l>1)
    {
        mid=(l+r)/2;
        if(check(mid*2+1)) r=mid;
        else l=mid;
    }
    r<<=1;
    int ans=0;
    for(int i=1;i<=r;i++)
        ans=max(ans,a[i]+a[r-i+1]);
    for(int i=r+1;i<=n*2;i++)
        ans=max(ans,a[i]+a[n*2-i+r+1]-m);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    AS = [int(input()) for _ in range(N)]
    AS_dup = AS[:]
    AS.sort()
    for i in range(N):
        if AS_dup[i] == AS[-1]:
            print(AS[-2])
        else:
            print(AS[-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 14424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int D[2001][2001];
vector<int> E[2001];
void dfs(int v, int r, int d) {
	D[r][v] = d;
	for (int to : E[v]) {
		if (D[r][to] < 0) dfs(to, r, d + 1);
	}
}

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


	int N, K;
	cin >> N >> K;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
	}

	rep1(i, N) rep1(j, N) D[i][j] = -1;
	rep1(i, N) dfs(i, i, 0);

	if (K % 2 == 0) {
		int kotae = N;
		rep1(i, N) {
			int kazu = 0;
			rep1(j, N) if (D[i][j] > K / 2) kazu++;
			kotae = min(kotae, kazu);
		}
		co(kotae);
	}
	else {
		int kotae = N;
		rep1(i, N) {
			for (int j : E[i]) {
				if (i < j) {
					int kazu = 0;
					rep1(k, N) if (min(D[j][k], D[i][k]) > K / 2) kazu++;
					kotae = min(kotae, kazu);
				}
			}
		}
		co(kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 16128
#include <stdio.h>
#include <string.h>
int main()
{
    int i;
    char O[51],E[51];
    scanf("%s %s",O,E);
    if(strlen(O)==strlen(E)){
        for(i=0;i<strlen(O);i++){
            printf("%c%c",O[i],E[i]);
        }
        printf("\n");
    }
    else{
        for(i=0;i<strlen(E);i++){
            printf("%c%c",O[i],E[i]);
        }
        printf("%c\n",O[strlen(O)-1]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}
}

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

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

    int n;
    cin >> n;

    int ec = 1;   //even_counter
    REP(i, n){
        int a;
        cin >> a;
        if(a % 2);
        else ec *= 2;
    }
    cout << pow(3, n) - ec << endl;

    return 0;
}

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

string s;
int n, p, c, v[10010];
long long ans = 0;

int main() {
    cin >> n >> p >> s;
    if(p == 2 || p == 5) {
        for(int i = 0; i < n; i++) {
            if((s[i] - '0') % p == 0) ans += i + 1;
        }
        cout << ans;
    }
    else {
        v[0] = 1;
        int a = 1, b = 0;
        for(int i = n - 1; i > -1; i--) {
            b = ((s[i] - '0') * a + b) % p;
            a = (a * 10) % p;
            ans += v[b];
            v[b]++;
        }
        cout << ans;
    }
}


Measured memory_bytes: 644
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e17+100)
#define N 100005


// Driver code to test above functions
int32_t main()
{
    
 
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    //srand(time(0));

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

    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        for(int k=0;k<3;k++){
            for(int j=0;j<3;j++){
                if(x==a[k][j]) 
                    a[k][j] = -1;
            }
        }

    }

    int flag = 0;
    for(int i=0;i<3;i++)
    {
        if(a[i][0]==-1 and a[i][1]==-1 and a[i][2]==-1)
            flag = 1;
        if(a[0][i]==-1 and a[1][i]==-1 and a[2][i]==-1)
            flag=1;
    }

    if(a[0][0]==-1 and a[1][1]==-1 and a[2][2]==-1)
        flag = 1;
    if(a[0][2]==-1 and a[1][1]==-1 and a[2][0]==-1)
        flag=1;

    if(flag==1)
        cout << "Yes";
    else
        cout << "No";

    return 0;
    
} 



Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array


def operation(p, c, cards):
    return cards[p - 1: p + c - 1] + cards[:p - 1] + cards[p + c - 1:]


if __name__ == "__main__":
    while True:
        n, r = map(int, input().split())
        if n == 0 and r == 0:
            break
        else:
            cards = array.array("B", range(n, 0, -1))
            for i in range(r):
                p, c = map(int, input().split())
                cards = operation(p, c, cards)
            print(cards[0])

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

public class Main {
    private final static String NEG = "NO\n";

    private final static String AFF = "YES\n";

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in), 1024);
        int number = Integer.parseInt(br.readLine());
        int sides[] = new int[3];
        StringTokenizer tknz;
        StringBuilder builder = new StringBuilder();

        for (; 0 < number; number--) {
            tknz = new StringTokenizer(br.readLine());
            for (int i = 0; i < 3; i++) {
                sides[i] = Integer.parseInt(tknz.nextToken());
            }
            Arrays.sort(sides);
            if (sides[1] % 2 != 0) {
                builder.append(NEG);
            } else if (sides[0] * sides[1] * sides[2] % 60 != 0) {
                builder.append(NEG);
            } else if (Math.pow(sides[0], 2) + Math.pow(sides[1], 2) != Math
                    .pow(sides[2], 2)) {
                builder.append(NEG);
            } else {
                builder.append(AFF);
            }
        }
        System.out.print(builder);
    }
}

Measured memory_bytes: 18336
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function lowerBound(ary,v,l=0,r=ary.length){--l;for(var c;1<r-l;)ary[c=l+r>>1]<v?l=c:r=c;return r;}
function upperBound(ary,v,l=0,r=ary.length){--l;for(var c;1<r-l;)ary[c=l+r>>1]<=v?l=c:r=c;return r;}
function griddist(grid,startx,starty){
  const road = ".", wall = "#", INF = 1e9;
  const h = grid.length, w = grid[0].length;
  const res = Array(h).fill().map(a=>Array(w).fill(INF));
  const dx = [0, 1, 0, -1], dy = [-1, 0, 1, 0], dd = 4;
  var q = [startx, starty], dist = 1;
  res[starty][startx] = 0;
  while(q.length){
    var qq = [];
    while(q.length){
      var y = q.pop(), x = q.pop();
      for(var i = 0; i < dd; i++){
        var xx = x+dx[i], yy = y+dy[i];
        if(xx < 0 || xx === w || yy < 0 || yy === h)continue;
        if(grid[yy][xx] === wall || res[yy][xx] !== INF)continue;
        res[yy][xx] = dist;
        qq.push(xx,yy);
      }
    }
    dist++, q = qq;
  }
  return res;
}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var [n,m] = nexts(2);
  var setx = new Set([0]), sety = new Set([0]);
  var xl = nextm(n,3).sort((a,b)=>a[2]-b[2]);
  var yl = nextm(m,3).sort((a,b)=>a[0]-b[0]);
  for(var i = 0; i < n; i++)setx.add(xl[i][2]);
  for(var i = 0; i < m; i++)sety.add(yl[i][0]);
  var gx = Array.from(setx).sort((a,b)=>a-b);
  var gy = Array.from(sety).sort((a,b)=>a-b);
  var w = gx.length * 2 + 1;
  var h = gy.length * 2 + 1;
  var grid = xArray("'.'",h,w);
  var dh = xArray(0,h), dw = xArray(0,w);
  for(var i = 1; i < gx.length; i++)dw[i+i] = gx[i]-gx[i-1];
  for(var i = 1; i < gy.length; i++)dh[i+i] = gy[i]-gy[i-1];
  var id = 0;
  for(var i = 0; i < n; i++){
    while(gx[id] < xl[i][2])id++;
    var t = id+id+1;
    var u = lowerBound(gy,xl[i][0])*2+1;
    var d = upperBound(gy,xl[i][1])*2-1;
    for(; u <= d; u++)grid[u][t] = "#";
  }
  for(var i = 0, id = 0; i < m; i++){
    while(gy[id] < yl[i][0])id++;
    var t = id+id+1;
    var l = lowerBound(gx,yl[i][1])*2+1;
    var r = upperBound(gx,yl[i][2])*2-1;
    for(; l <= r; l++)grid[t][l] = "#";
  }
  var dist = griddist(grid,lowerBound(gx,0)*2+1,lowerBound(gy,0)*2+1);
  if(dist[0][0] < 1e9)return "INF";
  var sumy = xArray(0,h);
  for(var y = 2; y < dh.length-2; y += 2)
  for(var x = 2; x < dw.length-2; x += 2){
    if(dist[y][x] === 1e9)continue;
    sumy[y] += dw[x];
  }
  var ans = 0n;
  for(var y = 2; y < dh.length-2; y += 2)ans += BigInt(sumy[y]) * BigInt(dh[y]);
  return ans.toString();
}

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

int main() {
	int a, b, c, d, e,x;
	cin >> a >> b >> c >> d >> e;
	if (a < 0) {
		x = -1 * a*c + d + b * e;
	}
	else {
		x = (b - a)*e;
	}

	cout << x << endl;
	return 0;
}


Measured memory_bytes: 3084
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    S = lines.pop(0)
    T = lines.pop(0)
    for i in range(len(S)):
        S = S[-1] + S[:-1]
        if S == T:
            print('Yes')
            sys.exit(0)

    print('No')

#
# main
#

# 1. use list instead of stdin

#contents = '''\
#abcdefg
#abcdegg\
#'''
#lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

const int MAX_N = 300001;
const ll MOD = 1000000007;

ll dp[MAX_N+1];

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

    vector<int> prev(MAX_N+1, -1);
    dp[0] = 1LL;
    for(int i=0;i<n;++i) {
        if(i) {
            dp[i] += dp[i-1];
            dp[i] %= MOD;
        }
        if(prev[a[i]] != -1 && prev[a[i]] != i-1) {
            dp[i] += dp[prev[a[i]]];
            dp[i] %= MOD;
        }
        // cerr << a[i] << ": " << dp[i] << endl;
        prev[a[i]] = i;
    }

    cout << dp[n-1] << endl;
}


Measured memory_bytes: 3712
//Catchharsh
      //I Luv Kunj017
      #include<bits/stdc++.h>
      #define ll long long int 
      #define ld long double
      #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
      #define F first
      #define S second
      #define pb push_back
      #define endl '\n'
      const ll MOD = 1e9+7;
      const ll INF = 1011111111;
      const ll LLINF = 1000111000111000111LL;
      const ld EPS = 1e-10;
      const ld PI = 3.14159265358979323;
      using namespace std;
      ll power (int x,int n)
      {
          if(n==0)
          return 1;
          else if(n%2==0)
          return power((x*x),n/2);
          else
          return x*power((x*x),(n-1)/2); 
      }
     bool comp(pair< ll, pair <ll,ll> > a, pair< ll, pair <ll,ll> > b)
     {return a.F<b.F;}
      int main()
      {   
           IOS;
          ll n,m,i,j,k;
           cin>>n>>m;
           if(n%2019==0)
            {return cout<<0,0;}
          if(m/2019 - n/2019 >0)
            {return cout<<0,0;}
           ll size = m-n;
           ll cnt=min(2020LL,size);
           vector<ll> v;
n=n%2019;
v.pb(n);
           while(cnt--)
           {
            // cout<<(n+1)%2019<<endl;
              v.pb((n+1)%2019);
              n++;
           }
           ll sz=v.size();
         ll ans=20205;
         for(i=0;i<sz;i++)
         {
          for(j=i+1;j<sz;j++)
          {
            ans=min(ans,(v[i]*v[j])%2019);
          }
         }
         cout<<ans;
    }


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

const int MAX_N = 100005;
int A[MAX_N];

int GCD(int a,int b)
{
	if (a < b) swap(a,b);
	if (b == 0) return a;
	return GCD(b,a%b);
}

int main()
{
	int N;
	cin >> N;
	int ans;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		if (i != 0) ans = GCD(ans,A[i]);
		else ans = A[i];
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>

using ll = long long;
using namespace std;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

int main() {
  ll n,k; cin>>n>>k;
  vector<ll> a(n+1);
  rep(i,n) cin>>a[i+1];
  struct Data{ ll offset; ll cycle;};
  map<ll,Data> m;

  ll now = 1;
  for(ll i=0; i<k; i++){
    if(m.count(now) == 0){
      m[now].offset = i;
    }else{
      m[now].cycle = i-m[now].offset;
      break;
    }
    now = a[now];
  }
  
  ll ans = now;
  if(m[now].cycle > 0){
    k-=m[now].offset;
    k%=m[now].cycle;
    while(k>0){
      ans=a[ans];
      k--;
    }
  }
  
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 14732
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];

void initialize();
void print();
void succ(int);

int main(){
    int k,r,c;
    initialize();
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            X[i][j]=0;
        }
    }
    scanf("%d",&k);
    for(int i=0;i<k;i++){
       scanf("%d%d",&r,&c);
       X[r][c]=1;
    }
    succ(0);

    return 0;
}
void initialize(){
    for(int i=0;i<N;i++){
        row[i]=FREE; col[i]=FREE; }
    for(int i=0;i<2*N-1;i++){
        dpos[i]=FREE; dneg[i]=FREE; }   
}

void print(){
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(X[i][j]){
                if(row[i]!=j) return;
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            printf("%c",row[i]==j?'Q':'.');
        }
        printf("\n");
    }
}

void succ(int i){
    if(i==N){
        print();
        return;
    }
   for(int j=0;j<N;j++){
       if(NOT_FREE==col[j] ||
          NOT_FREE==dpos[i+j] ||
          NOT_FREE==dneg[i-j+N-1]) continue;
          row[i]=j;col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
          succ(i+1);
          row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
   }
}




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

int bubblesort(int *A, int N){
    int count=0;
    int flag = 1;
    while(flag){
        flag = 0;
        for(int j=N-1; j>0; j--){
            if(A[j] < A[j-1]){
                int temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
                flag = 1;
                count++;
            }
        }
    }
    return count;
}

int main(){
    int N, count=0;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++) cin >> A[i];
    
    count = bubblesort(A, N);
    for(int i=0; i<N; i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
}


Measured memory_bytes: 3076
import sys
f = sys.stdin

trade_count = {}
this_month = set()
last_month = set()
for line in f:
    line = line.strip()
    if len(line) == 0:
        break
    id, day = map(int, line.split(','))
    if id not in trade_count:
        trade_count[id] = 0
    trade_count[id] += 1
    this_month.update([id])

for line in f:
    id, day = map(int, line.split(','))
    if id not in trade_count:
        trade_count[id] = 0
    trade_count[id] += 1
    last_month.update([id])

two_month = this_month & last_month
two_month = sorted(list(two_month))
for id in two_month:
    print(id, trade_count[id])

Measured memory_bytes: 6716
#include <iostream>

using namespace std;

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

  bool ca = a < c;
  bool cb = c < b;

  bool ca2 = b < c;
  bool cb2 = c < a;

  if ((ca && cb) || (ca2 && cb2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main(){
   int a[3];
   int max,min;
   cin>> a[0];
   max=a[0];
   min=a[0];
   for(int i=1;i<3;i++){
        cin>>a[i];
        if(a[i]>max) max=a[i];
        if(a[i]< min) min=a[i];
    }
cout<<max-min<< endl;
}
        

Measured memory_bytes: 256
///RAIYAN_MAHIN
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string a,b,C; cin >> a >> b;
    ll c,d; cin >> c >> d;
    cin >> C;
    if(C == a)
    {
        cout << c - 1 << ' ' << d;
    }
    if(C == b)
    {
        cout << c << ' ' << d - 1;
    }
     

}



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

int main() {
  int n;
  cin >> n;
  vector<int>data(n);
  for(int i = 0;i < n;i++) cin >> data[i];
  sort(data.begin(),data.end());
  if(n%2 == 1){
    if(data[0] != 0){
      cout << 0 << endl;
      return 0;
    }
    for(int i = 1;i < n;i += 2){
      if(data[i] != data[i+1]){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  else{
    for(int i = 0;i < n;i += 2){
      if(data[i] != data[i+1]){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  if(n%2 == 1) n--;
  long ans = 1;
  for(int i = 0;i < n/2;i++){
    ans *= 2;
    ans %= 1000000000+7;
  }
  cout << ans << endl;
}


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

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define eb          emplace_back
#define	endl		'\n' 
#define max(a,b)	((a)>(b)?(a):(b))
#define min(a,b)	((a)<(b)?(a):(b))
#define vi          vector<int>
#define vii         vector<pair<int, int> >
#define mp          make_pair
#define mem1(a)     memset((a),-1,sizeof(a))
#define all(a)      (a).begin(),(a).end()
#define vs          vector<string>
#define F           first
#define S           second
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    (a)*((b)/gcd((a),(b)))
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mi          map<int,int>
#define sz(x)       (ll)(x).size()
#define rep(i,a,b)  for(int i=(a);i<(b);i++)
#define pii         pair<int,int>

int solve()
{
	int n;
	cin>>n;
	int arr[n];
	rep(i,0,n)
	cin>>arr[i];
	int ans[n];
	ans[0]=0;
	ans[1]=abs(arr[1]-arr[0]);
	rep(i,2,n)
	{
		ans[i]=min(ans[i-1]+abs(arr[i-1]-arr[i]),ans[i-2]+abs(arr[i-2]-arr[i]));
	}
	cout<<ans[n-1];
    return 0;
}
signed main()
{
    FAST
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif 
    int t=1;
    //cin>>t;
    while(t)
    {
        solve();
        t--;
    }
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 4588
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <unordered_set>
#include <map>
#include <cstring>

using namespace std;

typedef long long ll;

int mod = 1e9 + 7;

void Solve(int N, int M, vector<vector<pair<int, int> > > P) {
    vector<string> res(M);
    for (int i = 0; i < N; i++) {
        sort(P[i].begin(), P[i].end());
        int n = P[i].size();
        for (int j = 0; j < n; j++) {
            string tmp = to_string(i + 1);
            string id (6 - tmp.size(), '0');
            id += tmp;
            tmp = to_string(j + 1);
            id.insert(id.end(), 6 - tmp.size(), '0');
            id += tmp;
            res[P[i][j].second] = id;
        }
    }
    for (int i = 0; i < M; i++) {
        cout << res[i] << endl;
    }
}


int main() {
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int> > > P(N);
    for (int i = 0; i < M; i++) {
        int p, y;
        cin >> p >> y;
        P[p - 1].push_back({y, i});
    }
    Solve(N, M, P);
    return 0;
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    int sum=0;
    while(t--){
      string s;
      cin>>s;
      s+='Q';
      int cnt=0;
      int maxh=0;
      string s1="ACGT";
      for(int i=0;i<s.length();i++){
          if(s[i]=='A' || s[i]== 'C' || s[i]== 'G' || s[i]=='T') {cnt++;}
          else {maxh=max(maxh,cnt);cnt=0;}
      }
      cout<<maxh;
    }
}
    

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[int(num) for num in input().split()] for i in range(n)]
b = [int(input()) for i in range(m)]
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)

Measured memory_bytes: 8072
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int n;
	cin>>n;
	cout<<n*(n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    ll n;
    ll i;

    cin >> n;

    for (i = sqrt(n) + 1; i >= 1; i--)
    {
        if (n % i == 0)
        {
            n /= i;
            break;
        }
    }

    cout << i + n - 2 << endl;
}

Measured memory_bytes: 256
l,r = map(int,input().split())

if r-l >= 2018:
    print(0)

elif (l % 2019) > (r % 2019):
    print(0)

else:
    li = [i for i in range((l % 2019),(r % 2019)+1)]
    c = 2020
    for i in range(len(li)-1):
        for j in range(i+1,len(li)):
            c1 = (li[i]*li[j]) % 2019
            c = min(c1,c)
    print(c)

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

bool check_prime(int x){
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return false;
    }
    return true;
}

int main(){
    int x;
    cin>>x;
    while(!check_prime(x)) x++;
    cout<<x<<endl;
}

Measured memory_bytes: 3636