akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String line = scan.nextLine();
		if(line.equals("A")){
			System.out.println("T");
		}
		else if(line.equals("T")){
			System.out.println("A");
		}
		else if(line.equals("C")){
			System.out.println("G");
		}
		else if(line.equals("G")){
			 System.out.println("C");
		}
			
	}
		}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int m = in.nextInt();
        int x = in.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < m; i++){
            int k = in.nextInt();
            list.add(k);
        }
        int cost_left = 0;
        for (int i = x; i >= 0; i--){
            if (list.contains(i)) cost_left++;
        }
        int cost_rigth = 0;
        for (int i = x; i <= n; i++){
            if (list.contains(i)) cost_rigth++;
        }
        System.out.println(Math.min(cost_left, cost_rigth));
    }

}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		boolean flg = true;
		for (int i = 1; i <= 50000; i++) {
			int zeikomi = (int) (i * 1.08);
			if (zeikomi == n) {
				System.out.println(i);
				flg = false;
			}
		}
		if (flg) {
			System.out.println(":(");
		}

	}

}

Measured memory_bytes: 23764
#include <stdio.h>

int main(){
    int x[3];
    int count=0;
    scanf("%d %d %d",&x[0],&x[1],&x[2]);
    for(int i=0;i<2;i++){
        if(x[i]>x[i+1]){
            int t=x[i]+x[i+1];
            x[i]=t-x[i];
            x[i+1]=t-x[i+1];
        }
    }
    for(int i=0;i<2;i++){
        if(x[i]>x[i+1]){
            int t=x[i]+x[i+1];
            x[i]=t-x[i];
            x[i+1]=t-x[i+1];
        }
    }
    int xa=x[0]%2,xb=x[1]%2,xc=x[2]%2;
    if((xa!=xb)&&((xb==xc)||(xa==xc))){
        count+=2;
    }else if((xa==xb)&&(xb==xc)){

    }else{
        count++;
    }
    count +=(x[2]-x[1])/2;
    count +=(x[2]-x[0])/2;
    printf("%d",count);
    return 0;
}

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

using namespace std;
typedef long long ll;

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

    int ans = 0;
    int c = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] == c) c++;
        else ans++;
    }

    if (c == 1) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 1024
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	string n;

	cin >> n;

	for (int i=0; i<3; ++i){
		if (n[i] == '7'){
				cout << "Yes" << endl;
				return 0;
		};
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
 
int main(){
   int n,k,q,an;
   scanf("%d %d %d", &n,&k,&q);
   int a[n];
   for(int i=0;i<n;i++){ a[i]=0;}
   for(int i=0;i<q;i++){
   	scanf("%d", &an);
     //printf("%d\n",an);
    a[an-1]++ ;
   }
   for(int i=0;i<n;i++){
    a[i]=k-q+a[i];
	if(a[i]>0){
      printf("Yes\n");
    }else {
	  printf("No\n");
    }
   }
	return 0;
}

Measured memory_bytes: 896
// OBïÄh2011 Day4 D : nRÌ

#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>

using namespace std;

int cap[500][500];

int maximumFlow(int n, int s, int t, bool first = false){
	int res = 0;
	int prev[500];
	while(true) {
		queue<int> qu; qu.push(s);
		memset(prev, -1, sizeof(prev)); prev[s] = s;
		while(!qu.empty()&&prev[t]<0){
			int u = qu.front(); qu.pop();
			for(int i=0;i<n;i++){
				if(prev[i]<0&&cap[u][i]>0){
					prev[i] = u;
					qu.push(i);
				}
			}
		}
		if(prev[t] < 0) return res;
		// êxÉ¬·t[ÌeÊÍ1Åè
		for(int j=t;prev[j]!=j;j=prev[j])
			cap[prev[j]][j]--, cap[j][prev[j]]++;
		res++;
		// ñÅÈ¯êÎ¬êéÊÍX1
		if(!first) return res;
	}
	return 0;
}

int main(){
	int N, E, Q;
	while(cin >> N >> E >> Q){
		memset(cap, 0, sizeof(cap));
		for(int i=0;i<E;i++){
			int F, T; scanf("%d %d", &F, &T);
			cap[F-1][T-1] = 1;
			cap[T-1][F-1] = 1;
		}
		int cur = maximumFlow(N, 0, N-1, true);
		for(int i=0;i<Q;i++){
			int M, A, B; scanf("%d %d %d", &M, &A, &B);
			if(M==1){
				// }ðÇÁµAt[ðvZ
				cap[A-1][B-1] = 1;
				cap[B-1][A-1] = 1;
				cur += maximumFlow(N, 0, N-1);
			}
			if(M==2){
				int s = A-1, t = B-1;
				for(int k=0;k<2;k++){
					// s->tÌ}ªgpÏÝÌ
					if(cap[t][s] == 2){
						cap[t][s] = 0;
						int tmp = maximumFlow(N, s, t); 
						// s->tÖÌÊÌpXª¶ÝµÈ¢Æ«
						if(tmp==0){
							// 0->s ÖÌt[ðÅ¿Á·
							maximumFlow(N, s, 0);
							// t->N-1ÖÌt[ðÅ¿Á·
							maximumFlow(N, N-1, t);
							// t[ÌÊÍ1¸­
							cur--;
						}
					}
					swap(s, t);
				}
				cap[s][t] = cap[t][s] = 0;
			}
			cout << cur << endl;
		}
	}
}

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

const int INF = 1e9;

int main() {
    int N, M, X; cin >> N >> M >> X;
    int C[N];
    int A[N][M];
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int ans = INF;
    for (int x = 0; x < 1<<N; x++) {
        vector<int> skill(M, 0);
        int cost = 0;
        for (int i = 0; i < N; i++) {
            if (x>>i & 1) {
                cost += C[i];
                for (int j = 0; j < M; j++) {
                    skill[j] += A[i][j];
                }
            }
        }
        bool f = true;
        for (int i = 0; i < M; i++) {
            if (skill[i] < X) f = false;
        }
        if (f) ans = min(ans, cost);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    int n, k;
    long long ans = 0;
    cin >> n >> k;
    vector<int>cnt(k);
    for (int i = 1; i <= n; i++){
        cnt[i % k]++;
    }
    for (int a = 0; a < k; a++){
        int b = k - a;
        int c = k - b;
        if ((a + c) % k != 0) continue;
        ans = ans + (long long) cnt[a] * cnt[b % k] * cnt[c % k];
    }
    cout << ans << endl;
}

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

int main() {
	int a,b;
  	cin >> a >> b;
  	if(a > 0)
      	cout << "Positive" << endl;
  	else if(a <=0 && b>= 0)
      	cout << "Zero" << endl;
  	else {
    	cout << ((a-b)%2 != 0 ? "Positive" :"Negative") << endl; 
    }
  
}

Measured memory_bytes: 256
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define int long long

void solve()
{
    int d, t, s;
    cin >> d >> t >> s;
    if(s * t >= d)
        cout << "Yes\n";
    else 
        cout << "No\n";
}

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


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

int main() {
	int n , cnt  = 0;
	scanf("%d",&n);
	int arr[n];
	for(int i = 0 ; i < n ; ++i)scanf("%d",&arr[i]);
	for(int i = 1 ; i <= n ; ++i){
		if(arr[i-1] != i)++cnt;
	}
	if(cnt > 2)puts("NO");
	else puts("YES");
	return 0;
}

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

struct Point {double x, y;};

void koch(int n, Point a, Point b) {
  if (n == 0) return;
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  cout << s.x << " " << s.y << endl;
  koch(n-1, s, u);
  cout << u.x << " " << u.y << endl;
  koch(n-1, u, t);
  cout << t.x << " " << t.y << endl;
  koch(n-1, t, b);
}

int main() {
  Point a, b;
  int n;
  cin >> n;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  cout << a.x << " " << a.y << endl;
  koch(n, a, b);
  cout << b.x << " " << b.y << endl;
}



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


int max(int a,int b)
{
    if(a>b)
    return a;
    return b;
}

int main()
{
    int N,W;
    cin >> N >> W ;
    int i;
    long long int VW[N][2];
    for (i=0;i<N;i++)
    {
        cin>>VW[i][0]>>VW[i][1];
    }
    long long int KS [N+1][W+1];
    for (int n=0;n<N+1;n++)
    {
        for(int w=0;w<W+1;w++)
        {
            if(n==0||w==0)
            KS[n][w]=0;

            else if (VW[n-1][0]<=w)
            {
                KS[n][w]=max(VW[n-1][1]+KS[n-1][w-VW[n-1][0]],KS[n-1][w]);
            }
            else
            {
                KS[n][w]=KS[n-1][w];
            }
            
        }
    }
    cout<<KS[N][W];
    return 0;   
}

Measured memory_bytes: 82436
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int tmp,n;
    cin>>tmp;
    int k=tmp;
    n=(1LL<<tmp);
    multiset<int>s;
    f(i,1,n)
    {
        cin>>tmp;
        tmp=-tmp;
        s.insert(tmp);
    }
    vector<int>vec;
    vec.pb(*s.begin());
    s.erase(*s.begin());
    for(int i=1;i<=k;i++)
    {
          vector<int>nw;
          for(auto x:vec)
          {
               if(s.upper_bound(x)==s.end())
               {
                   cout<<"No"<<endl;
                   return 0;
               }
               nw.pb(*(s.upper_bound(x)));
               s.erase(s.upper_bound(x));
          }
          for(auto x:nw)
          {
              vec.pb(x);
          }
          sort(vec.begin(),vec.end());
    }
    cout<<"Yes"<<endl;
    return 0;

}





































Measured memory_bytes: 18316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    string a,b,c;
    cin >> a >> b >> c;
    cout << "A" << b[0] << "C" << endl;
}




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

int main()
{
	int x,y;
	while(true){
		cin >> x >> y;
		if(x == 0 && y == 0)
			break;
		if(x >= y)
			cout << y << " " << x << "\n";
		else
			cout << x << " " << y << "\n";
	}
	return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for(auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

int LIS(const vector<int>& a) {
   int n = a.size();
   vector<int> dp(n, INF);
   for(int i = 0; i < n; i++) {
      *lower_bound(ALL(dp), a[i]) = a[i];
   }
   return distance(dp.begin(), lower_bound(ALL(dp), INF));
}

signed main()
{
   int n; cin >> n;
   V<int> a(n);
   REP(i, n) {
      cin >> a[i];
   }

   cout << LIS(a) << endl;

   return 0;
}



Measured memory_bytes: 4376
//--------------------------------------------------
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,fma")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//--------------------------------------------------
#include <bits/stdc++.h>
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <stack>
#include <cstring>
//--------------------------------------------------
#define forn(i, n) for(int i = 0; i < n; i++)
#define forw(i, n) for(int i = n-1; i >= 0; --i)
#define forns(i, n, s) for(int i = s; i < n; i++)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
//----------------------------------------------------
using namespace std;
//----------------------------------------------------
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef vector<ll> lnum;
typedef complex<ld> comp;
//----------------------------------------------------
const ll mod = 1e9 + 7, mod2 = 998244353;
const ld eps = 1e-6;
const ll inf = 1e18;
const int base = 1e9;
const ld PI = 3.1415926;
//----------------------------------------------------
//#define endl '\n';
#ifdef MY_DEBUG
void deb(ld x) { cerr << x << endl; };
#else
void deb(ld x){};
#endif
//----------------------------------------------------
//----------------------------------------------------
ld L;
//----------------------------------------------------
unsigned int bitcount(ull val) { return __builtin_popcount(val) + __builtin_popcount(val >> 32); }

void local() {
    freopen("test.in", "r", stdin);
}

void remote() {
}

void read() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> L;
}


int main() {
#ifdef MY_DEBUG
    local();
#else
    remote();
#endif
    read();

    cout << setprecision(12) << (L/3) * (L/3) * (L/3) << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
constexpr int inf = (1 << 30) - 1;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-10;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> constexpr void print(const T& t) {cout << t << "\n";}
template<typename T, typename U> constexpr bool chmax(T& a, const U& b) {if (a < b) a = b; return a < b;}
template<typename T, typename U> constexpr bool chmin(T& a, const U& b) {if (a > b) a = b; return a > b;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {rep(i, sz(v)) is >> v[i]; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) os << v[i] << (i + 1 != sz(v) ? " " : ""); return os;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;



int main() {
    ll n; cin >> n;
    int mi = inf;
    rep(i, 1, sqrt(n) + 1) {
        if (n % i == 0) {
            chmin(mi, (int)(log10(n / i)) + 1);
        }
    }
    print(mi);
}

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

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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


void solve() {
  ll A, B, C, D;

  //input
  cin >> A >> B >> C >> D; 
  
  ll nc=B/C-(A-1)/C;
  ll nd=B/D-(A-1)/D;
  ll cd=lcm(C,D);
  ll ncd=B/cd-(A-1)/cd;
  ll ans = B-A+1-(nc+nd-ncd);
  
  cout << ans << endl;
  
 
  return;
}

signed main() {
    
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define vi vector<int>
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a),end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int tree[505][2];

int countTrees(int w, int h, int s, int t, int n){
    int trees = 0, count;
    range(i,1,h - t + 2){
        range(j,1,w - s + 2){
            count = 0;
            rep(k,n){
                if(j <= tree[k][0] && j + s - 1 >= tree[k][0] &&
                   i <= tree[k][1] && i + t - 1 >= tree[k][1]){
                    count++;
                }
            }
            trees = max(trees, count);
        }
    }
    return trees;
}

int solve(int w, int h, int s, int t, int n){
    return max(countTrees(w, h, s, t, n), countTrees(h, w, s, t, n));
}

int main(){
    int n;
    while(cin >> n, n){
        rep(i,505) rep(j,2) tree[i][j] = 0;
        int w, h, s, t;
        cin >> w >> h;
        rep(i,n){
            cin >> tree[i][0] >> tree[i][1];
        }
        cin >> s >> t;
        cout << solve(w, h, s, t, n) << endl;
    }
}

Measured memory_bytes: 1164
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors
def examA():
    M, D = LI()
    c = D//10
    ans = 0
    for i in range(2,M+1):
        d = make_divisors(i)
#        print(d)
        for j in range(len(d)//2):
            cur0 = d[j*2+1]; cur10 = d[j*2]
            if cur10==1:
                continue
            if cur0<=9:
                if cur10<c:
                    ans +=1
#                    print(cur10,cur0)
                elif cur10==c and cur0+cur10*10<=D:
                    ans +=1
#                    print(cur10,cur0)
        for j in range(len(d) // 2):
            cur0 = d[j * 2];cur10 = d[j * 2+1]
            if cur0 == 1:
                continue
            if cur10 <= 9:
                if cur10 < c:
                    ans += 1
                elif cur10 == c and cur0 + cur10 * 10 <= D:
                    ans += 1
        if len(d)%2==1:
            cur0 = d[-1]; cur10 = d[-1]
            if cur10==1:
                continue
            if cur0<=9:
                if cur10<c:
                    ans +=1
#                    print(cur10,cur0)
                elif cur10==c and cur0+cur10*10<=D:
                    ans +=1
#                    print(cur10,cur0)
    print(ans)
    return

class Bit():
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        return
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return
def examB():
    N, K = LI()
    A = LI()
    bit = Bit(max(A))
    cur = 0
    for i, a in enumerate(A):
        bit.add(a, 1)
        cur += i + 1 - bit.sum(a)
    As = 0
    A.sort()
    now = 0
    for i in range(1,N):
        if A[i]!=A[i-1]:
            now = i
        As += now
#    print(cur,As)
    ans = (As*(K**2) - (As-2*cur)*K)//2
    ans %=mod
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 41708
import sys
from itertools import accumulate
n, m, q = [int(i) for i in sys.stdin.readline().split()]
graph = [[0 for i in range(n+1)] for j in range(n+1)]
for j in range(m):
    l, r = [int(i) for i in sys.stdin.readline().split()]
    graph[l][r] += 1
accum_ls = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j, k in enumerate(accumulate(graph[i])):
        accum_ls[i][j] = k
for j in range(q):
    p, _q = [int(i) for i in sys.stdin.readline().split()]
    res = 0
    for k in range(p, _q+1):
        res += accum_ls[k][_q] - accum_ls[k][p-1]
    print(res)

Measured memory_bytes: 62428
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];

int main() {
	string str[]={"SUN","MON","TUE","WED","THU","FRI","SAT" };
	string s;
	cin>>s;
	rep(i,7){
		if(s==str[i]){
			cout<<7-i<<endl;

		}
	}
	return 0;
}


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

typedef long long ll;
using namespace std;

struct UnionFind {
    vector<int> parent;

    UnionFind(int n) : parent(n) {
        parent = vector<int>(n);
        for (int i = 0; i < n; i++) parent[i] = i;
    }

    int root(int n) {
        if (parent[n] == n) return n;
        return parent[n] = root(parent[n]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        parent[rx] = ry;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int p[n], index[n];
    UnionFind uni(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
        index[p[i]] = i;
    }
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        x--;
        y--;
        uni.unite(x, y);
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (uni.root(p[i]) == uni.root(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll mod=(1e9+7);
const ll inf=(1ll<<61);
const int MX=3e5+9;
int t,a,b;
int main(){
    cin>>a>>b>>t;
    cout<<b*(t/a)<<endl;
}


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

//macro
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, n, m) for(int i = m; i < n; ++i)
#define LL long long

using namespace std;

typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int main(){
        int r, g, b;
        cin >> r >> g >> b;

        if((r*100+ g * 10 + b )% 4 == 0){
        cout << "YES" << endl;
        return 0;
        }

        cout << "NO" << endl;

        return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

d = Counter(A)

sub_s = sum(A)

for b, c in BC:
    sub_s += d[b] * (c - b)
    d[c] += d[b]
    d[b] = 0

    print(sub_s)


Measured memory_bytes: 40236
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,c,k;
int a[114514];
signed main() {
	cin>>n>>c>>k;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int ans=0;
	int memo=a[0];
	int mm=0;
	for(int i=0;i<n;i++){
		if(a[i]-memo>k||i-mm>=c){
			ans++;
			memo=a[i];
			mm=i;
		}
	}
	cout<<ans+1<<endl;
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np


def solve(S):
    dp = np.zeros(2019, np.int64)
    temp = np.empty_like(dp)
    pow10 = 1
    answer = 0
    for x in S[::-1]:
        dp[0] += 1
        x = x * pow10 % 2019
        temp[x:] = dp[:-x]
        temp[:x] = dp[-x:]
        dp, temp = temp, dp
        answer += dp[0]
        pow10 *= 10
        pow10 %= 2019
    return answer


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i4[:],)')(solve)
    cc.compile()


try:
    from my_module import solve
except:
    cc_export()
    exit()

S = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')
print(solve(S))


Measured memory_bytes: 29192
n = int(input())
A = list(map(int,input().split()))

A = sorted(A)

acum = [0]*(n+1)
for i in range(n):
  acum[i+1]=acum[i]+A[i]
  
for i in range(n):
  if acum[-i-2]*2 < A[-i-1]:
    break
    
print(i+1)

Measured memory_bytes: 14252
import sys

def main():
    n = int(input())
    edges = []
    for i in range(n):
        edges.append( list(map(int, sys.stdin.readline().split())) )
    
    # ?±?????????????????????????????????°??????
    # ????????????????????°?????????????????????????????????????????¨????????????
    # ??????????????????????????¨????¨?????????????????????§????´?????°???????????????????????????°??????

    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans += min(edges[i][j], edges[j][i])

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 8012
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define ll long long
const int INF = 1e8;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;

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

string s[200];
int n, l;
bool strcmp(string s, string t){
    for (int i = 0 ; i < l; i++){
        if (s[i] > t[i]) return true;
        else
            if (s[i] < t[i]) return false;
    }
    return false;
}
void solve(){
    cin >> n >> l;
    for (int i = 1; i <= n; i++){
        cin >> s[i];
        for (int j = 0; j < l; j++){
            if (s[i][j] >= 'A' && s[i][j] < 'Z')
                s[i][j] = char( 'a' + s[i][j] - 'A');
        }
    }
    for (int i = 1; i <= n - 1; i++){

        for (int j = i + 1; j <= n; j++){
        //cout << s[i] << " " << s[j] << " " << strcmp(s[i], s[j]) << endl;
        if (strcmp(s[i], s[j])){
                string t = s[i];
                s[i] = s[j];
                s[j] = t;
            }
        }
    }

    for (int i = 1; i <= n; i++)
        cout << s[i];
}
/*
 4 4
 abdc
 defg
 aefg
 bdce
 */
int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(7);
    //freopen("inevit.in", "r", stdin);
    //freopen("inevit.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++)
        solve();

}

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

int main(){
  int N;
  int A[2][100];
  int ans[2][100];
  cin >> N;
  for(int i=0; i<2; i++){
    for(int j=0; j<N; j++){
      cin >> A[i][j];
    }
  }
  for(int i=1; i<N; i++){
    A[0][i]+=A[0][i-1];
  };
  A[1][0]+=A[0][0];
  for(int i=1; i<N; i++){
    A[1][i]+=max(A[0][i],A[1][i-1]);
  }
  cout << A[1][N-1] << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut n: usize = read();
    let mut counter = 0;
    let mut i = 2;
    while i * i <= n {
        let mut incount = 0;
        while n % i == 0 {
            incount += 1;
            n /= i;
        }
        let mut sub = 1;
        while incount >= sub {
            incount -= sub;
            sub +=1;
            counter += 1;
        }
        i+=1;
    }
    if n != 1 {
        counter +=1;
    }
    print!("{}", counter);
}


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

using namespace std;

const int mod = 1e9+7;
 
struct Mint {
	long long x; Mint() : x(0) {}
	Mint(long long _x) : x ((_x%mod + mod)%mod) {}
	Mint& fix() { x = (x%mod + mod)%mod; return *this; }
	Mint& operator+=(const Mint& other) { if ((x += other.x) >= mod) { x-= mod; } return *this;}
	Mint& operator-=(const Mint& other) { if ((x += mod-other.x) >= mod) { x -= mod; } return *this; }
	Mint& operator*=(const Mint& other) { (x*=other.x)%=mod; return *this; }
	Mint operator+(const Mint& other) const { return Mint(*this) += other; }
	Mint operator-(const Mint& other) const { return Mint(*this) -= other; }
	Mint operator*(const Mint& other) const { return Mint(*this) *= other; }
	Mint operator-() const { return Mint(0) - *this; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	bool operator<(const Mint& other) const { return x < other.x; }
	bool operator==(const Mint& other) const { return x == other.x;} 
	// convert n to ll before using fstexp
	Mint fstexp(long long n) const { 
		Mint res(1), a(x);
		while (n > 0) { if (n & 1) { res  *= a; } a *= a; n >>= 1; }
	return res; }
	Mint operator ~ () const { return (*this).fstexp(mod - 2);}
};
ostream& operator << (ostream& out, const Mint& val) { return out << val.x; }
istream& operator >> (istream& in, Mint& val ) { in >> val.x; return in;}
string to_string (const Mint& s) { return to_string(s.x); }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<vector<int>> adj(n, vector<int> (n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> adj[i][j];
		}
	}
	vector<Mint> dp(1 << n);
	dp[0] = 1;
	for (int i = 0; i < (1 << n); i++) {
		int a = __builtin_popcount(i);
		for (int j = 0; j < n; j++) {
			if ((i & (1 << j)) == 0) {
				if (adj[a][j]) {
					dp[i | (1 << j)] += dp[i];
				}
			}
		}
	}
	cout << dp[(1 << n) - 1] << "\n";
	return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s, t;
  cin >> s >> t;
  int min = 99999999;
  int diff = 0;
  
  for(int i=0; i<(int)s.length() - (int)t.length() + 1; i++){
    string _s = s.substr(i,(int)t.length());
    diff = 0;
    for(int j=0; j<(int)t.length(); j++){
      if(_s[j] != t[j]){
	    diff++;
      }
    }
    if(min > diff){
      min = diff;
    }
    //cout << min << " " << _s << " " << t << endl;
    
    if(min == 0){
	  cout << min << endl;
      return 0;
    }
  }
  
  cout << min << endl;
  return 0;
}


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

int main(void){
	int n;
	int ans = 0;

	cin >> n;

	for(int i=0; i<n; i++){
		int x;
		cin >> x;

		int j=2;
		for(; j<=sqrt(x); j++){
			if(x % j == 0) break;
		}
		if(j > sqrt(x)) {
			ans++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int main(){
    string s,t="2019/04/30";
    cin>>s;
    if(s>t){
        cout<<"TBD"<<endl;
        return 0;
    }
    else 
    cout<<"Heisei"<<endl;
}

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

using namespace std;

#define MAX_N 1
#define INF 1000000000 //1e9
#define PI 3.14159265359
#define mod 1000000007
#define ll long long int

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b,c;
	cin >> a >>b >> c;
	
	cout << c <<" " <<  a<< " " << b ;
	
	
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
  if(a<=8 && b<=8){
    System.out.println("Yay!");
  }else{
    System.out.println(":(");
  }
  }
}


Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
 
int32_t main()
{
  int x,n;
  cin>>x>>n;
  int a[n];
  map<int,int> m;
  forn(i,n){cin>>a[i];m[a[i]]=i;}
  int pl=x+1;
  int mi=x-1;
  // for(auto i=m.begin();i!=m.end();i++)
  // {
  //   cout<<i->first;
  // }
  if(m.find(x)==m.end()){cout<<x;return 0;}
  while(1)
  {
    //cout<<m.find(pl);
    if(m.find(mi)!=m.end()){}
    else {cout<<mi;break;}
    if(m.find(pl)!=m.end()){}
    else{cout<<pl;break;}
    
    pl++;
    mi--;
  }
}

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

int main(){
  int N, dan = 1;
  int d[100];
  cin >> N;
  for(int i=0; i<N; ++i) cin >> d[i];
  
  sort(d, d+N);
  for(int i=0; i<N-1; ++i)
    if(d[i] != d[i+1]) dan++;
  cout << dan << endl;
  return 0;
  
}

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

m = max(A)
l = []
for a in A:
    if a != m:
        l.append(m - a)

if len(l) == 0:
    print(0)
    exit()
if len(l) == 1:
    if l[0] % 2 == 0:
        print(l[0] // 2)
    else:
        print(l[0] // 2 + 2)
    exit()

l.sort()

ans = 0

tmp = l[1] - l[0]

if tmp % 2 == 0:
    ans += tmp // 2 + l[0]
else:
    ans += tmp // 2 + 2 + l[0]

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std ; 
int main()
{
    int n ; 
    cin>>n ; 
    vector<int> v(n) ; 
    for(int i =0 ;i<n;i++)
        cin>>v[i] ; 
    sort(v.begin() , v.end()) ; 
    long long  ans = 0 ; 
    for(int i =0 ;i<n;i++)
    {
        for(int j = i+1 ; j<n;j++)
        {
            int temp = v[i] + v[j] ;
            
            auto  l = lower_bound(v.begin() , v.end() , temp)  ; 
            l-- ; 
            if(*l >= temp)
                continue ; 
            ans += (l-v.begin() - j) ;  
            
            
        }
    }
    cout <<ans ;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let s: Vec<char> = itr.next().unwrap().chars().collect();

    let mut cnt = 0;
    let mut lack = 0;
    for i in 0..n {
        if s[i] == '(' {
            cnt += 1;
        } else {
            if cnt > 0 {
                cnt -= 1;
            } else {
                lack += 1;
            }
        }
    }
    let mut out = Vec::new();
    for _ in 0..lack {
        write!(out, "(").ok();
    }
    let t = s.into_iter().collect::<String>();
    write!(out, "{}", t).ok();
    for _ in 0..cnt {
        write!(out, ")").ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 2124
using System;
using System.Collections.Generic;
using System.Linq;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var n = h[0];
		var rs = new int[h[1]].Select(_ => read()).Select(r => { r[2] -= h[2]; return r; }).ToArray();
		var map = rs.ToLookup(r => r[0]);

		var cs = Enumerable.Repeat(long.MinValue, n + 1).ToArray();
		cs[1] = 0;
		for (long c, i = 0; i < n; i++)
			foreach (var r in rs)
				if (cs[r[0]] != long.MinValue && cs[r[1]] < (c = cs[r[0]] + r[2])) cs[r[1]] = c;

		var u = new bool[n + 1];
		var q = new Stack<int>();
		foreach (var r in rs)
		{
			if (cs[r[0]] == cs[0] || cs[r[1]] >= cs[r[0]] + r[2]) continue;
			u[r[1]] = true;
			q.Push(r[1]);
			while (q.Any())
				foreach (var np in map[q.Pop()])
				{
					if (u[np[1]]) continue;
					u[np[1]] = true;
					q.Push(np[1]);
				}
		}
		Console.WriteLine(u[n] ? -1 : Math.Max(cs[n], 0));
	}
}


Measured memory_bytes: 16096
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, p = sc.nextInt()
    val as = Array.fill(n)(sc.nextInt())

    val ans =
      if (as.forall(_ % 2 == 0)) {
        p match {
          case 1 => 0L
          case 0 => math.pow(2L, n.toLong)
        }
      } else {
        math.pow(2L, n - 1)
      }

    println(ans.toLong)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


Measured memory_bytes: 25420
#include<cstdio>
#include<cstring>
#define MAXN 105
char a[MAXN],b[MAXN],c[MAXN];
int main()
{
	scanf("%s\n%s\n%s",a+1,b+1,c+1);
	int la=strlen(a+1),lb=strlen(b+1),lc=strlen(c+1);
	int na=2,nb=1,nc=1;
	char turn=a[1];
	while(1)
	{
		if(turn=='a')
		{
			if(na>la){printf("A\n"); return 0;}
			turn=a[na];
			na++;
		}
		if(turn=='b')
		{
			if(nb>lb){printf("B\n"); return 0;}
			turn=b[nb];
			nb++;
		}
		if(turn=='c')
		{
			if(nc>lc){printf("C\n"); return 0;}
			turn=c[nc];
			nc++;
		}
	}
}

Measured memory_bytes: 128
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SORT(v) sort(all(v))
#define TROS(v) sort(all(v), std::greater<Type>());
#pragma endregion

int main() {
    // template
    string s;cin>>s;
    s.at(3)='8';
    cout<<s<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int comp(const void*a,const void*b){
    return (*(int*)a-*(int*)b);
}
int dp[100000+5];
int main() {
	int a[100];
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i+=1){
	    scanf("%d",&a[i]);
	    dp[a[i]]=1;
	}
	for(int i=0;i<=k;i+=1){
	    for(int j=0;j<n&&(i-a[j])>-1;j+=1){
	        dp[i]|=!dp[i-a[j]];
	    }
	}
	if(dp[k]){
	    printf("First");
	}
	else{
	    printf("Second");
	}
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
using namespace std;
#define MAX_LIST 10000000



int main(){
	bool *prime=(bool *)malloc(sizeof(bool)*MAX_LIST);
	//bool prime[MAX_LIST];
	for(int i=0;i<MAX_LIST;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=0;i*i<MAX_LIST;i++){
		if(prime[i]==1){ 
			for(int j=i*2;j<MAX_LIST;j=j+i){
				prime[j]=0;
			}
		}
	}
	int in;
	while(cin>>in,in){
		int ans=0;
		int i=0;
		while(prime[in+i]==0){
			ans++;
			i++;
		}
		i=0;
		while(prime[in-i]==0){
			ans++;
			i++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 10944
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	string S;
	cin >> S;
	ll ans = 0, cnt = 0;
	for(int i = 0; i < S.length(); i++){
		if(S[i] == 'B'){
			cnt++;
		} else {
			ans += cnt;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
from collections import Counter
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
A=[A1,A2,A3]
N=int(input())
for _ in range(N):
  b=int(input())
  #穴をあける
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  
#bingoチェック
  
#たて
if True in [ not False in [A[j][i]==A[j+1][i] for j in range(len(A)-1)] for i in range(len(A[0]))]:
  print("Yes")
#よこ
elif len(Counter(A[0]))==1 or len(Counter(A[1]))==1 or len(Counter(A[2]))==1:
  print("Yes")
#ななめ
elif A[1][1]==-1 and (A[0][0] == A[2][2] or A[0][2]==A[2][0]):
  print("Yes")
#ダメ
else:
  print("No")


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n , m;
int a , b;
int deg[N];
int main(){
	scanf("%d %d" , &n , &m);
	for(int i = 1 ; i <= m ; ++i){
		scanf("%d %d" , &a , &b);
		deg[a] ^= 1;
		deg[b] ^= 1;
	}
	puts(*max_element(deg + 1 , deg + 1 + n) ? "NO" : "YES");
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
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)
 
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; }
 
 
long long solve(long long a) {
    long long res = 0;
    for (long long d = 60; d >= 1; --d) {
        if (a & (1LL<<d)) {
            if (a % 2 == 0) res += (1LL<<d);
        }
    }
    if ( ((a+1)/2) % 2 == 0 ) res ^= 1;
    return res;
}
 
int main() {
    long long A, B;
    while (cin >> A >> B) {
        cout << (solve(B) ^ solve(A-1)) << endl;
    }
}
 

Measured memory_bytes: 256