akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N; cin >> N;
	vi arr (N);
	F0R(i, N) {
		cin >> arr[i];
		arr[i] -= i + 1;
	}

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

	int b = arr[N/2];
	ll ans = 0;
	F0R(i, N) ans += abs(arr[i] - b);
	print(ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        // cout << " " << *t++;
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<vector<int>> c(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    bool ch = 1;
    vector<int> a(3, 0), b(3);
    rep(i, 3) b[i] = c[0][i];
    rep(i, 3) a[i] = c[i][0] - b[0];
    rep(i, 3) rep(j, 3) if(a[i] + b[j] != c[i][j]) ch = 0;
    cout << (ch ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,a[100],i,s,min,max,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    max=a[0]; min=a[0];
    for(i=0;i<n;i++){
        if(max<a[i]){
            tmp=a[i]; a[i]=max; max=tmp;
        }
        if(min>a[i]){
            tmp=a[i]; a[i]=min; min=tmp;
        }
    }
    s=max-min;
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 1708
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int count = 0;
        for(int i=0; i<n; i++) {
            a[i] = Integer.parseInt(sc.next());
            if(a[i] % 2 == 1 && (i+1) % 2 == 1) count++;
        }
        System.out.println(count);
    
    }
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> x(N), y(M);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i].first >> x[i].second;
    }
    for (int i = 0; i < M; i++)
    {
        cin >> y[i].first >> y[i].second;
    }
    for (int i = 0; i < N; i++)
    {
        int index = 0;
        int ans = abs(x[i].first - y[0].first) + abs(x[i].second - y[0].second);
        for (int j = 1; j < M; j++)
        {
            if ((abs(x[i].first - y[j].first) + abs(x[i].second - y[j].second)) < ans)
            {
                ans = abs(x[i].first - y[j].first) + abs(x[i].second - y[j].second);
                index = j;
            }
        }
        cout << index + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll N,W;
    cin>>N>>W;
    ll arr[N+1][2];
    for(ll i=1;i<=N;i++)
        cin>>arr[i][0]>>arr[i][1];
    ll dp[N+1][W+1];
    for(ll i=0;i<=N;i++)
        dp[i][0]=0;
    for(ll i=0;i<=W;i++)
         dp[0][i]=0;
    for(ll i=1;i<=N;i++)
        for(ll j=1;j<=W;j++)
        {
            if(arr[i][0]>j)
                dp[i][j]=dp[i-1][j];
            else if(arr[i][0]<=j)            
                dp[i][j]=max(dp[i-1][j],arr[i][1]+dp[i-1][j-arr[i][0]]);           
        }
    cout<<dp[N][W]<<"\n";    
}

Measured memory_bytes: 82356
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  // 添え字0をリーダーにした場合の向きの変わる人数は
  // Eの人数を数える
  int right = 0;
  for (int i = 1; i < N; ++i) {
    if (S[i] == 'E') {
      right++;
    }
  }

  int ans = right;
  int left = 0;
  // 他がリーダーだった時
  for (int i = 1; i < N; ++i) {
    if (S[i - 1] == 'W') {
      left++;
    }

    if (S[i] == 'E') {
      right--;
    }
    ans = min(ans, left + right);
  }

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

Measured memory_bytes: 3924
def Q3(N, M, *arg):
    import numpy as np
    route = np.reshape(np.array(*arg), (M, 2))
    string = 'IMPOSSIBLE'
    p = [False] * N
    q = [False] * N
    for x in route:
        if x[0] == 1:
            p[x[1]] = True
        elif x[1] == N:
            q[x[0]] = True
    for i in range(N):
        if p[i] and q[i]:
            string = 'POSSIBLE'
            break
    return string

N, M = map(int, input().split())
l = [list(map(lambda x: int(x), input().split())) for i in range(M)]
l = [flatten for inner in l for flatten in inner]
print(Q3(N,M,l))

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using pll = pair < ll , ll >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vl  = vector < ll >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;

void solve(){
    scanf("%d %d" , &n , &m);


    printf("%d\n" , max(n + m , max(n - m , n*m)));

}

main(){
    int t = 1;
    //scanf("%d" , &t);

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

    return 0;
}



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

using namespace std;

int main(int argc, char* argv[])
{
    int N, K; cin >> N >> K;
    
    int total = 0;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        total += 2*min(abs(x), abs(x-K));
    }

    cout << total << endl;
    return 0;
}


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

void Input_elements_column(int& n, int&m);
std::vector<std::vector<int>> Input_matrix(int n, int m);
std::vector<int> Input_vector(int m);
std::vector<int> Calc_vector_c(std::vector<std::vector<int>>matrix_A, std::vector<int>vector_b, int n, int m);
void output(std::vector<int> vector_c);

int main()
{
	int n, m;
	Input_elements_column(n, m);

	std::vector<std::vector<int>> matrix_a = Input_matrix(n, m);
	std::vector<int> vector_b = Input_vector(m);

	std::vector<int> vector_c = Calc_vector_c(matrix_a, vector_b, n, m);

	output(vector_c);

	return 0;
}

void Input_elements_column(int& n, int&m)
{
	std::cin >> n >> m;
}

std::vector<std::vector<int>> Input_matrix(int n, int m)
{
	std::vector<std::vector<int>> matrix_a(n, std::vector<int>(m));
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			std::cin >> matrix_a[i][j];
		}
	}
	return matrix_a;
}

std::vector<int> Input_vector(int m)
{
	std::vector<int> vector_b(m);
	for (int i = 0; i < m; ++i)
	{
		std::cin >> vector_b[i];
	}

	return vector_b;
}

std::vector<int> Calc_vector_c(std::vector<std::vector<int>>matrix_A, std::vector<int>vector_b, int n, int m)
{
	std::vector<int> vector_c(n);

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			vector_c[i] += matrix_A[i][j] * vector_b[j];
		}
	}

	return vector_c;
}

void output(std::vector<int> vector_c)
{
	size_t size = vector_c.size();

	for (int i = 0; i < size; ++i)
	{
		std::cout << vector_c[i] << std::endl;
	}
}


Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

void solve()
{
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int sum = 0;
	if (N <= K)
	{
		sum += N * X;
	}
	else
	{
		sum += K * X + (N - K) * Y;
	}
	cout << sum << endl;
}

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

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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;

struct PT{
	ld x, y;
	PT (ld x = 0, ld y = 0) : x(x), y(y) {}
	PT operator + (PT ro) const{
		return PT(x+ro.x, y+ro.y);
	}
	PT operator - (PT ro) const{
		return PT(x-ro.x, y-ro.y);
	}
	PT operator * (ld co) const{
		return PT(x*co, y*co);
	}
	PT operator / (ld co) const{
		return PT(x/co, y/co);
	}
	ld operator * (PT ro) const{
		return x*ro.x + y*ro.y;
	}
	ld operator ^ (PT ro) const{
		return x*ro.y - y*ro.x;
	}
};

PT operator * (ld co, PT p){
	return p*co;
}

ld len(PT a){
	return sqrt(a*a);
}

PT unit(PT a){
	return a/len(a);
}

PT perp(PT a){
	return PT(-a.y, a.x);
}

PT proj(PT a, PT b, PT c){
	b = b-a, c = c-a;
	return a + (b*c)/(b*b)*b;
}

PT reflect(PT a, PT b, PT c){
	PT d = c;
	b = b-a, c = c-a;
	return d + (c^b)/len(b)*perp(unit(b))*2;
}

int main(){
	PT a, b;;
	cin >> a.x >> a.y >> b.x >> b.y;
	PT p;
	cout << setprecision(10) << fixed;
	for (int i = in(); i; i--){
		cin >> p.x >> p.y;
		PT img = reflect(a, b, p);
		cout << img.x << ' ' << img.y << '\n';
	}
	return 0;
}


Measured memory_bytes: 3344
#include<stdio.h>
int main(void)
{
	int n,k,l[50],i,j,x;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(l[i]<l[j]){
				x=l[i];
				l[i]=l[j];
				l[j]=x;
			}
		}
	}
	x=0;
	for(i=0;i<k;i++){
		x=x+l[i];
	}
	printf("%d",x);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>

int N;

int minNum = 10000;
int sum = 0;

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		int a;
		scanf("%d", &a);
		if (a % 10) minNum = std::min(minNum, a);
		sum += a;
	}
	if (sum % 10) printf("%d\n", sum);
	else if (minNum == 10000) printf("%d\n", 0);
	else printf("%d\n", sum - minNum);
	return 0;
}

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

int main(void)
{
	int card[200], temp1[200], temp2[200];
	int n;
	int m;
	int shuf;
	int i, j;
	
	scanf("%d", &n);
	
	for (i = 0; i < 2 * n; i++){
		card[i] = i + 1;
	}
	
	scanf("%d", &m);
	
	for (i = 0; i < m; i++){
		scanf("%d", &shuf);
		if (shuf != 0){
			memset(temp1, 0, sizeof(temp1));
			memset(temp2, 0, sizeof(temp2));
			
			memcpy(temp1, card, shuf * sizeof(int));
			memcpy(temp2, &card[shuf], (2 * n - shuf) * sizeof(int));
			
			memcpy(card, temp2, (2 * n - shuf) * sizeof(int));
			memcpy(&card[2 * n - shuf], temp1, shuf * sizeof(int));
		}
		else {
			memset(temp1, 0, sizeof(temp1));
			memset(temp2, 0, sizeof(temp2));
			for (j = 0; j < 2 * n; j++){
				if (j < n){
					temp1[j] = card[j];
				}
				else {
					temp2[j - n] = card[j];
				}
			}
			for (j = 0; j < 2 * n; j++){
				if (j % 2 == 0){
					card[j] = temp1[j / 2];
				}
				else {
					card[j] = temp2[j / 2];
				}
			}
		}
	}
	
	for (i = 0; i < 2 * n; i++){
		printf("%d\n", card[i]);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;


int main() {
	string s, t; int n=0;
	cin >> s >> t;
	for (int a = 0; a < 3; a++) { if (s[a] == t[a]) { n++; } }
	cout << n;
	return 0;
}

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


int main(){
  long long int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<long long int> P(A);
  vector<long long int> Q(B);
  vector<long long int> R(C);
  for(auto& p : P){
    cin >> p;
  }
  for(auto& q : Q){
    cin >> q;
  }
  for(auto& r : R){
    cin >> r;
  }

  sort(P.rbegin(), P.rend());
  sort(Q.rbegin(), Q.rend());
  sort(R.rbegin(), R.rend());

  vector<int> S(X+Y+C);
  for(int ii=0; ii<X; ii++){
    S[ii]=P[ii];
  }
  for(int ii=0; ii<Y; ii++){
    S[X+ii]=Q[ii];
  }
  for(int ii=0; ii<C; ii++){
    S[X+Y+ii]=R[ii];
  }

  sort(S.rbegin(), S.rend());
  long long int ans = 0;
  for(int ii=0; ii<X+Y; ii++){
    ans += S[ii];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n, k;
    cin >> n >> k;
    vector<double> p(n);
    for (int i = 0; i < n; i++)
    {

        cin >> p[i];
    }
    vector<double> q(n);
    for (int i = 0; i < n; i++)
    {
        q[i] = 0.5 * p[i] * (p[i] + 1)*(1/p[i]);
    }
    double ans = 0;
    double res = 0;
    for (int i = 0; i < n; i++)
    {
        if(i<k-1){
            ans += q[i];
        }
        else{
            ans -= q[i - k];
            ans += q[i];
            res = max(res, ans);
        }
    }
    //show(q);
    printf("%.10f\n", res);


    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n,p;cin>>n>>p;
    vector<ll> dp(6000,0);
    dp[0]=1;
    rep(i,n){
        int a;cin>>a;
        for(int i=5999-a;i>=0;i--){
            if(dp[i]!=0){
                dp[i+a]+=dp[i];
            }
        }
    }
    ll res=0;
    rep(i,6000){
        if(i%2==p)res+=dp[i];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, K) = nextIntList()
    val P = nextIntList().sorted()
    println(P.take(K).sum())
}

Measured memory_bytes: 40808
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int h, w;
int ch, cw, dh, dw;
string s[1000];

struct D{
    typedef pair<long long, int> P;
    struct edge{
        int to;
        long long cost;
        edge(int to, long long cost) : to(to), cost(cost){}
    };
    vector< vector<edge> > graph;
    vector< long long > dist;

    void init(int size){
        dist.assign(size, 1e18);
        graph.assign(size, vector<edge>() );
    }

    void add_edge(int from, int to, long long cost){
        graph[from].push_back(edge(to, cost));
    }

    void dijkstra(int from){
        priority_queue<P, vector<P>, greater<P> > q;
        dist[from] = 0;
        q.push(P(0, from));
        while(!q.empty()){
            P p = q.top();
            q.pop();
            int v = p.second;
            if(dist[v] < p.first)continue;
            for(int i = 0; i < graph[v].size(); i++){
                edge e = graph[v][i];
                if(dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    q.push(P(dist[e.to], e.to));
                }
            }
        }
    }
};

int main(void){
    cin >> h >> w >> ch >> cw >> dh >> dw;
    for(int i=0;i<h;i++) cin >> s[i];

    D d;
    d.init(h*w);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j] != '.') continue;
            for(int dx = -2; dx <= 2; dx++){
                int nx = i+dx;
                if(nx < 0 || nx >= h) continue;
                for(int dy = -2; dy <= 2; dy++){
                    int ny = j+dy;
                    if(ny < 0 || ny >= w) continue;
                    if(s[nx][ny] != '.') continue;
                    if(abs(dx) + abs(dy) <= 1){
                        d.add_edge(i*w+j, nx*w+ny, 0);
                    }else{
                        d.add_edge(i*w+j, nx*w+ny, 1);
                    }
                }
            }
        }
    }
    ch--;
    cw--;
    dh--;
    dw--;
    d.dijkstra(ch*w+cw);
    long long ans = d.dist[dh*w+dw];
    if(ans == 1e18) ans = -1;
    cout << ans << endl;

}


Measured memory_bytes: 175912
#include <stdio.h>

#define int long long

signed main(){
	int N, A, B, C, D, i;
	scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
	for(i = 0; i < N; i++){
		if(i * C - (N - 1 - i) * D <= B - A && B - A <= i * D - (N - 1 - i) * C){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    bool flg = 1;
    if(s[0] != 'A')flg = 0;
    for(int i = 1; i < n; i++){
        if(isupper(s[i])){
            if(s[i] == 'C' && i >= 2 && i <= n-2)cnt++;
            else flg = 0;
        }
    }
    if(cnt != 1)flg = 0;
    if(flg)puts("AC");
    else puts("WA");
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x1,y1,x2,y2,x3,y3,x4,y4;
	scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
        x3=x2-(y2-y1);
        y3=y2+(x2-x1);
        x4=x1-(y2-y1);
        y4=y1+(x2-x1);
	printf("%d %d %d %d\n",x3,y3,x4,y4);
	return 0;
}


Measured memory_bytes: 128
a = map(int,raw_input().split())
arr = [0]*(10)
for i in range(4):
	arr[a[i]]+= 1
if arr[1] == 1 and arr[9] == 1 and arr[7] == 1 and arr[4] == 1:
	print "YES"
else:
	print "NO"

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

int main() {
    bool P = false, W = false, G = false, Y = false;
    int N;
    string t;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> t;
        if (t == "P") {
            P = true;
        }
        else if (t == "W") {
            W = true;
        }
        else if (t == "G") {
            G = true;
        }
        else if (t == "Y") {
            Y = true;
        }
    }
    if (P && W && G && Y) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

cnt2 = 0
cnt4 = 0
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 4 != 0:
            cnt2 += 1
        else:
            cnt4 += 1

if cnt2:
    if ((n-cnt2+1)//2) <= cnt4:
        print('Yes')
    else:
        print('No')
else:
    if (n-cnt2)//2 <= cnt4:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14252
#include <iostream>
#include <stdlib.h>
#include <math.h>

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

using namespace std;

int main(){
	long b = 1, y = 0;
	long K, A, B;
	cin >> K >> A >> B;
	if (A + 2 >= B) {
		cout << K + 1;
		return 0;
	}

	if (K < A + 1) {
		cout << K + 1;
		return 0;
	}
	K -= (A - 1);
	b += A - 1;
	long d = K / 2;
	b += d * (B - A);
	b += K % 2;
	cout << b;
	return 0;
}

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;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	int res = 0;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S.at(i) == 'C') {
			for (int j = i + 1; j < S.size(); j++) {
				if (S.at(j) == 'F') res++;
			}
		}
	}
	if (res == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void pf(ll a, vl &s){
	while(a%2==0){
		a=a/2;
		s.pb(2);
	}
	for(ll i=3;i*i<=a;i++){
		while(a%i==0){
			a/=i;
			s.pb(i);
		}
	}
	if(a>2)s.pb(a);
}
int main() {
	fast_io;
	ll a, b;
	cin >> a >> b;
	if(a>b)swap(a,b);
	set<ll> sa,sb;
	vl sva,svb;
	pf(__gcd(a,b),sva);
	// pf(b,svb);
	set<ll> aa;
	for(auto i:sva){
		if(a%i==0 && b%i==0)aa.insert(i);
	}
	// for(auto i:svb){
	// 	if(a%i==0 && b%i==0)aa.insert(i);
	// }
	cout<<1+aa.size();
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
 
template<class T> struct Prim {
 
    struct Edge {
        int to; T cost;
        Edge (int t, T c) : to(t), cost(c) {}
        bool operator < (const Edge &a) const {
            return cost > a.cost;
        }
    };
 
    int N;
    vector< vector< Edge > > G;
    vector< vector< Edge > > MST;
    vector< bool > used;
 
    Prim (int n) : G(n), MST(n), used(n), N(n) {}
 
    void add_edge(int a, int b, T cost) {
        G[a].push_back(Edge(b,cost));
        G[b].push_back(Edge(a,cost));
    }
 
    void init(int root) {
        priority_queue< pair< Edge, int > > que;
        for (int i = 0; i < G[root].size(); i++) {
            que.push(make_pair(G[root][i],root));
        }
        for (int i = 0; i < N; i++) {
            used[i] = false;
            MST[i].clear();
        }
        used[root] = true;
        while (que.size() != 0) {
            Edge e = que.top().first;
            int from = que.top().second;
            que.pop();
            if (used[e.to]) continue;
            used[e.to] = true;
            MST[e.to].push_back(Edge(from,e.cost));
            MST[from].push_back(e);
            for (int i = 0; i < G[e.to].size(); i++) {
                que.push(make_pair(G[e.to][i],e.to));
            }
        }
    }
 
    T get_cost(void) {
        T ret = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < MST[i].size(); j++) {
                ret += MST[i][j].cost;
            }
        }
        return ret / 2;
    }
 
    vector< Edge > & operator [] (int n) {
        return MST[n];
    }
 
    int size(void) {
        return N;
    }
 
};
 
map< pair<ll,ll>, int> trans;
 
int main () {
 
    int N; cin >> N;
 
    Prim<ll> inst(100010);
 
    vector< pair<ll,ll> > xy(N);
 
    REP(i,N) cin >> xy[i].first >> xy[i].second;
    sort(xy.begin(),xy.end());
    REP(i,N) {
        trans[xy[i]] = i + 1;
    }
 
    REP(i,N - 1) {
        ll cost = min(abs(xy[i].first-xy[i+1].first),abs(xy[i].second-xy[i+1].second));
        inst.add_edge(trans[xy[i]],trans[xy[i+1]],cost);
    }
 
    vector< pair<ll,ll> > ct(N);
    REP(i,N) ct[i] = make_pair(xy[i].second,xy[i].first);
 
    sort(ct.begin(),ct.end());
 
    REP(i,N - 1) {
        ll cost = min(abs(ct[i].first-ct[i+1].first),abs(ct[i].second-ct[i+1].second));
        pair<ll,ll> a = make_pair(ct[i].second,ct[i].first);
        pair<ll,ll> b = make_pair(ct[i+1].second,ct[i+1].first);
        inst.add_edge(trans[a],trans[b],cost);
    }
 
    int v = trans.begin() -> second;

    inst.init(v);
 
    cout << inst.get_cost() << endl;
 
    return 0;
}

Measured memory_bytes: 34796
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i)) count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
int main (){
  int N,M,c=0;
  cin>>N>>M;
  int d=N;
  vector<int>a(M),b(M);
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=0;i<M;i++){
  if(c<a[i]){
    c=a[i];
  }
  }
  for(int i=0;i<M;i++){
  if(b[i]<=d){
    d=b[i];
  }
  }
  if(c<=d){
    int e=d-c+1;
    cout<<e<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 1024
s=input()
if s == s[::-1] and s[:((len(s)-1)//2)] == s[:((len(s)-1)//2)][::-1] and s[(len(s)+3)//2-1:] == s[(len(s)+3)//2-1:][::-1]:
    print("Yes")
else:
    print("No")

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

int N,M,x,y,arr[200010],cnt[200010],sum[200010],total; 

void CreateArray(){
	for(int i=1; i<=N; i++){
		sum[arr[i]]++;
	}
	for(int i=1; i<=N; i++){
		for(int j=i; j>i-min(i,sum[i]); j--)cnt[j]++;
	}
	for(int i=1; i<=N; i++){
		if(cnt[i]==0)total++;
	}
}

void ChangeIdx(){
	cin>>x>>y;
	if(arr[x]>=sum[arr[x]]){
		cnt[arr[x]-sum[arr[x]]+1]--; 
		if(cnt[arr[x]-sum[arr[x]]+1]==0)total++;
	}
	sum[arr[x]]--;
	if(y>sum[y]){
		cnt[y-sum[y]]++;
		if(cnt[y-sum[y]]==1)total--;
	}
	sum[y]++;
	arr[x]=y;
	cout<<total<<'\n';
}

int main(){
	cin>>N>>M;
	for(int i=1; i<=N; i++)cin>>arr[i];
	CreateArray();
	for(int i=0; i<M; i++)ChangeIdx();
}

Measured memory_bytes: 5940
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int AC = 0,WA = 0 ,TLE = 0 ,RE = 0;
    string S;
    cin >> N ;
    for(int i = 0; i < N; i++){
        cin >> S;
        if(S == "AC") AC++;
        if(S == "WA") WA++;
        if(S == "TLE") TLE++;
        if(S == "RE") RE++;
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
    return 0;
}

Measured memory_bytes: 3248
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int x = kbd.nextInt();
        int a = kbd.nextInt();
        if (x < a) {
            System.out.println("0");
        }else{
            System.out.println("10");
        }
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

signed main() {
  int ans = 0, m = -1;
  rep(i, 3) {
    int a;
    cin >> a;
    ans += a;
    cmax(m, a);
  }
  ans -= m;
  int k;
  cin >> k;

  while (k--) {
    m *= 2;
  }
  cout << ans + m << endl;
  return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long n;
	cin >> n;
	if(n & 1) {
		cout << 0;
		exit(0);
	}

	n /= 2;

	long long c = 0;
	while(n) {
		c += n / 5;
		n /= 5;
	}

	cout << c;
	

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#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;
	string s,t;cin >> s >> t;
	ll ans=1,mod=1000000007;
	s+=' ';
	t+=' ';
	bool first=true,before=true;
	rep(i,n){
		if(s.at(i)==t.at(i)){
			if(first){
				ans*=3;
				first=false;
			}
			else if(before){
				ans*=2;
				ans%=mod;
			}
			before=true;
		}
		else{
			if(first){
				ans*=6;
				first=false;
			}
			else if(before){
				ans*=2;
				ans%=mod;
			}
			else{
				ans*=3;
				ans%=mod;
			}
			before=false;
			i++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
a = n/1000
b = n/100%10
c = n/10%10
d = n%10

if a+b+c+d == 7:
	print str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7"
elif a+b+c-d == 7:
	print str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7"
elif a+b-c+d == 7:
	print str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7"
elif a+b-c-d == 7:
	print str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7"
elif a-b+c+d == 7:
	print str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7"
elif a-b+c-d == 7:
	print str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7"
elif a-b-c+d == 7:
	print str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7"
elif a-b-c-d == 7:
	print str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7"

Measured memory_bytes: 2808
#include <stdio.h>
main(){
  int i,j,n,m,a,h[1000],p[1000],q[1000],hmax,jj;
  while(1){
    scanf("%d%d%d",&n,&m,&a);
    if(n==0 && m==0 && a==0) break;
    for(i=0;i<m;i++){
      scanf("%d%d%d",&h[i],&p[i],&q[i]);
    }

    for(i=0;i<m;i++){
      hmax=0;
      for(j=0;j<m;j++){
	if(hmax<h[j]){
	  hmax=h[j];
	  jj=j;
	}
      }
      h[jj]=0;
      if(a == p[jj]) a=q[jj];
      else if(a == q[jj]) a=p[jj];
    }

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

  }
  return 0;
}

Measured memory_bytes: 416
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

int main(){
    string s; cin >> s;
    int ans=0;
    for(int i=0; i<s.size()/2; ++i){
        ans+=!(s[i]==s[s.size()-i-1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main()
{
	long long int a,b,c,d,ans1,ans2;
	
	scanf ("%lld%lld%lld%lld",&a,&b,&c,&d);
	
	ans1 = a*b;
	ans2 = c*d;
	
	if (ans1 >= ans2)
	 printf ("%lld\n",ans1);
	else
	 printf ("%lld\n",ans2);
	
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A=Integer.parseInt(sc.next());
		int B=Integer.parseInt(sc.next());
		if(A >= 13) {

		}else if(A <= 5) {
			B = 0;

		} else {
			B /=2;

		}
		System.out.println(B);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

struct Matrix{
    vector<vector<ll>> mat;
    Matrix(ll size , ll val){
        mat.resize(size,vector<ll>(size,val));
    }
    void resize(ll size , ll val){
        mat.resize(size,vector<ll>(size,val));
    }
    
};

ll size_of(Matrix x){
    return x.mat.size();
}

Matrix operator*(Matrix a,Matrix b){
    ll n = size_of(a);
    Matrix c(n,0);
    rep(i,n) rep(j,n) rep(k,n){
        c.mat.at(i).at(j) += (a.mat.at(i).at(k) * b.mat.at(k).at(j))%mod;
        c.mat.at(i).at(j) %= mod;
        //pr2d(c.mat);
    }
  	return c;
}

Matrix I(0,0);

Matrix matpow(Matrix a, ll k){
    if(k<0){
        cout << "err" << endl;
        return Matrix(1,-LINF);
    }
    if(k==0) return I;
    Matrix ret = matpow(a,k/2);
    ret = ret * ret;
    if(k%2) ret = ret * a;
    return ret;
}

int main(){
    ll n,k ; cin >> n >> k;
    I.resize(n,0);
    rep(i,n) I.mat.at(i).at(i) = 1;

    Matrix a(n,0);
    rep(i,n) rep(j,n) cin >> a.mat.at(i).at(j);
    //pr2d(a.mat);
  
    a = matpow(a,k);

    //pr2d(a.mat);

    ll ans = 0;
    rep(i,n) rep(j,n){
        ans += a.mat.at(i).at(j);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

//挿入，検索，削除の計算量はすべてO(logn)

int main(){
  int N,temp;
  cin>>N;
  set<int> S;
  for(int i=0;i<N;i++){
    cin>>temp;
    S.insert(temp);
  }
  cout<<S.size()<<endl;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template <class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template <class T> inline void amax(T & a, T const & b) { a = max(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }


ll solve(int N, ll K, vll& a) {
    ll cnt[40][2];
    memset(cnt, 0, sizeof(cnt));

    for (int i=0; i<N; ++i) {
        for (int b=0; b<40; ++b) {
            cnt[b][!!(a[i] & 1LL << b)]++;
        }
    }

    int H = 1 << 20;
    vll upper(H, 0), lower(H, 0);
    for (int i=0; i<H; ++i) {
        for (int b=0; b<20; ++b){
            upper[i] += cnt[20+b][!(i & 1<<b)] << 20+b;
            lower[i] += cnt[b][!(i & 1<<b)] << b;
        }
    }

    int u = K >> 20, v = K % H;


    ll best = upper[u] + *max_element(lower.begin(), lower.begin()+v+1);
    if (u > 0) {
        amax(best, *max_element(upper.begin(), upper.begin()+u) + *max_element(lower.begin(), lower.end()));
    }
    return best;
}

int main() {
    int N; ll K; scanf("%d%lld",&N,&K);
    vll a(N); rep(i,N) scanf("%lld", &a[i]);
    cout << solve(N,K,a) << endl;
    return 0;
}


Measured memory_bytes: 17408
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import random
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	#N = int(input())
	#S = list(input())
	L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))

	ans = -1
	ed = min(L+2020, R+1)


	for a in range(L, ed):
		for b in range(a+1, ed):
			tmp = (a*b)%2019

			if ans > tmp or ans == -1:
				ans = tmp

	print(ans)




if __name__ == "__main__":
	main()

Measured memory_bytes: 4720
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	a := getNextFloat64(scanner)
	b := getNextFloat64(scanner)
	x := getNextFloat64(scanner)

	if a*a*b > x*2 {
		fmt.Fprintln(writer, math.Atan2(b, x*2/b/a)*180/math.Pi)
	} else {
		fmt.Fprintln(writer, math.Atan2((b-x/a/a)*2, a)*180/math.Pi)
	}
	writer.Flush()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define L long long
using namespace std;
int t,n,m;
L p;
inline L calc(int a,int b,int c)
{
    if(a>m)
      return (L)(b+1)*m;
    int k=min((m-a)/c,b);
    return (L)a*(k+1)+(L)c*(k+1)*k/2+(L)(b-k)*m;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	//scanf("%d",&t);
	t=1;
	while(t--)
	  {
	   scanf("%d%d",&n,&m);
	   if(!m)
	     {
          printf("%lld\n",(L)n*n);
          continue;
         }
	   m--;
	   p=(L)(m+1)*n;
	   for(i=m+2;i<=n;i=j+1)
	     {
          k=n/i;
          j=n/k;
          p+=(L)(j-i+1)*k*(m+1)+calc(n-j*k,j-i,k);
         }
       p=(L)n*n-p;
       printf("%lld\n",p);
      }
	return 0;
}


Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())
M_list = list(range(1, M+1))
Q_list = []
points = []

for _ in range(Q):
    Q_list.append(list(map(int, input().split())))

for i in itertools.combinations_with_replacement(M_list, N):
    point = 0
    for a, b, c, d in Q_list:
        if i[b-1] - i[a-1] == c:
            point += d
        points.append(point)

print(max(points))

Measured memory_bytes: 74072
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
typedef long long ll;
using namespace std;

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

int main()
{
    int N,M;
    cin >> N >> M;
    int left = 1;
    int rignt = N;
    for(int i = 0; i < M; i++)
    {
        int a,b;
        cin >> a >> b;
        left = max(left,a);
        rignt = min(rignt,b);
    }
    cout << max(rignt - left + 1,0) << endl;
}

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

typedef long long ll;

int M = 1000000007;

int main() {
	ios::sync_with_stdio(0);
	srand(time(NULL));
	
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	a.push_back(0);
	
	ll ans = 0;
	ll pt = 0;
	ll pt2 = 0;
	ll sum = 0;
	ll xr = 0;
	while (pt < n) {
		sum += a[pt];
		xr ^= a[pt];
		while (sum != xr) {
			sum -= a[pt2];
			xr ^= a[pt2];
			pt2++;
		}
		ans += pt - pt2 + 1;
		pt++;
	}
	
	cout << ans;
	
	return 0;
}

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

using namespace std;

int main () {
    ios::sync_with_stdio(0);
    string s;
    cin >> s;

    stack<char> st;
    for (int i = 0; i < s.length(); ++i) {
        if (st.empty() || s[i] == 'S')
            st.push(s[i]);
        else if (st.top() == 'S' && s[i] == 'T')
            st.pop();
        else
            st.push(s[i]);
    }

    cout << st.size();
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

vector<string> ans;

void dfs(int num, int keta, string now){
    int nowl=now.length();
    if(nowl<=10){
    if(keta==0){
        rep(i,9){
            now[keta]=i+1+'0';
            if(nowl==1){
                ans.push_back(now);
                num++;
            }
            else dfs(num,keta+1,now);
        }
        //if(num<10){
        now='1'+now;
        dfs(num,0,now);
        //}
    }
    if(keta==nowl-1){
        for(int i=-1; i<=1; i++){
            now[keta]=now[keta-1];
            if(now[keta-1]=='9' && i==1) continue;
            if(now[keta-1]=='0' && i==-1) continue;
            now[keta]+=i;
            //cout << now << ' ' << num << endl;
            ans.push_back(now);
            num++;
        }
        //return num;
    }
    else{
        for(int i=-1; i<=1; i++){
            now[keta]=now[keta-1];
            if(now[keta-1]=='9' && i==1) continue;
            if(now[keta-1]=='0' && i==-1) continue;
            now[keta]+=i;
            dfs(num,keta+1,now);
        }
    }
    }
}

int main(){
    int k; cin >> k;
    dfs(0,0,"0");
    cout << ans[k-1] << endl;
return 0;
}


Measured memory_bytes: 18672
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var p = cin.ReadIntArray(N);
            int[] ans = new int[N];
            for(int i = 0; i < N; i++)
            {
                ans[i] = i + 1;
            }
            if (p.SequenceEqual(ans))
            {
                WriteLine("YES");
                return;
            }
            for (int i = 0; i < N; i++)
            {

                for(int j = i+1; j < N; j++)
                {
                    p[i] = p[i] + p[j];
                    p[j] = p[i] - p[j];
                    p[i] = p[i] - p[j];
                    if (p.SequenceEqual(ans))
                    {
                        WriteLine("YES");
                        return;
                    }
                    p[i] = p[i] + p[j];
                    p[j] = p[i] - p[j];
                    p[i] = p[i] - p[j];
                }
            }
            WriteLine("NO");
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13396