akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll n,a;
  string s;
  cin >> s;
  n=s.length();
  a=n;
  rep(i,n){
    if(s[i]=='C'){
      a=i;
      break;
    }
  }
  FOR(i,a,n){
    if(s[i]=='F'){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
}

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

std::vector<long long int> dicisor(long long int n);

int main(){
    long long int N, M;
    scanf("%lld%lld", &N, &M);
    std::vector<long long int> ans = dicisor(M);
    for (long long int i = 0; i < ans.size(); i++){
        if(ans[i] <= M/N){
            printf("%lld", ans[i]);
            break;
        }
    }
    return 0;
}

std::vector<long long int> dicisor(long long int n){
    std::vector<long long int> ans;
    for (long long int i = 1; i * i <= n; i++){
        if(n % i == 0){
            ans.push_back(i);
            if(n/i != i)
                ans.push_back(n / i);
        }
    }
    std::sort(ans.begin(), ans.end());
    std::reverse(ans.begin(), ans.end());
    return ans;
}

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

using namespace std;
int a[1000];
int sum;
int dp[1000];
int ans[1000];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            sum+=a[i];
        }
    sort(a+1,a+1+n);
    if(sum%10!=0)
        {
            printf("%d",sum);
            return 0;
        }
    for(int i=1;i<=n;i++)
    {
        if(a[i]%10!=0)
        {
            printf("%d",sum-a[i]);
            return 0;
        }
    }
    printf("0");
    return 0;
}


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

int A[1005][1005];
int p[1005];
bool use[1005];
int n;

bool al() {
  bool a = true;
  for(int i = 0; i < n; i++) {
    if(p[i] == n - 1) continue;
    a = false;
  }

  return a;
}

void init_u() {
  for(int i = 0; i < n; i++) use[i] = false;
}

int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n - 1; j++) {
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  int ans = 1;
  queue<int> q,nextq;
  
  for(int i = 0; i < n; i++) {
    if(use[i] || p[i] == n - 1) continue;
    if(!use[A[i][p[i]]] && i == A[A[i][p[i]]][p[A[i][p[i]]]]) {
      use[i] = true;
      use[A[i][p[i]]] = true;
      q.push(i);
      q.push(A[i][p[i]]);
      p[A[i][p[i]]]++;
      p[i]++;
    }
  }

  if(q.empty()) {
    cout << -1 << endl;
    return 0;
  }

  if(al()) {
    cout << ans << endl;
    return 0;
  }

  while(true) {
    init_u();
    
    while(!q.empty()) {
      int i = q.front();
      q.pop();
      if(use[i] || p[i] == n - 1) continue;
      if(!use[A[i][p[i]]] && i == A[A[i][p[i]]][p[A[i][p[i]]]]) {
	use[i] = true;
	use[A[i][p[i]]] = true;
	nextq.push(i);
	nextq.push(A[i][p[i]]);
	p[A[i][p[i]]]++;
	p[i]++;
      }
    }

    ans++;
    // cout << "ijiji"<<endl;
    if(nextq.empty()) {
      cout << -1 << endl;
      return 0;
    }

   
  if(al()) {
    cout << ans << endl;
    return 0;
  }
  // cout << "#" << endl;
  init_u();

    while(!nextq.empty()) {
      int i = nextq.front();
      nextq.pop();
      if(use[i] || p[i] == n - 1) continue;
      if(!use[A[i][p[i]]] && i == A[A[i][p[i]]][p[A[i][p[i]]]]) {
	use[i] = true;
	use[A[i][p[i]]] = true;
	q.push(i);
        q.push(A[i][p[i]]);
	p[A[i][p[i]]]++;
	p[i]++;
      }
    }

    ans++;

    if(q.empty()) {
      cout << -1 << endl;
      return 0;
    }
    if(al()) {
      cout << ans << endl;
      return 0;
    }
  }

}
  
    

 
  
  
  


Measured memory_bytes: 4224
#include <cstdio>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;
typedef long long ll;

ll N, D, A, X, H, a, b, d, ans;
priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > pq;

int main() {
  scanf("%lld %lld %lld", &N, &D, &A);
  for (ll i = 0; i < N; i++) {
    scanf("%lld %lld", &X, &H);
    pq.push(make_pair(X+D+1, (H+A-1)/A));
  }
  while (pq.size()) {
    a = pq.top().first;
    b = pq.top().second;
    pq.pop();
    if (b > d) {
      ans += b - d;
      pq.push(make_pair(a+2*D+1, d - b));
      d = b;
    }
    if (b < 0) d += b;
  }

  printf("%lld\n", ans);
}


Measured memory_bytes: 6128
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) a.begin(), a.end()
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}

int pow(int a, int b) {
  int res = 1;
  rep(i, b) res *= a;
  return res;
}
 
class Solver {
public:
  int A, B, K;

  void solve() {
    cin >> A >> B >> K;
    set<int> set1;
    rep(i, K) {
      if (A+i <= B) set1.insert(A+i);
      if (B-i >= A) set1.insert(B-i);
    }
    for (auto v : set1) {
      cout << v << endl;
    }
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


Measured memory_bytes: 256
rows = []
for i in range(3):
    row = [int(x) for x in input().split()]
    rows.append(row)


columns = []
for k in range(3):
    column = [rows[l][k] for l in range(3)]
    columns.append(column)

left = []
for m in range(3):
    left.append(rows[m][m])

right = []
o = 2
for n in range(3):
    right.append(rows[n][o])
    o -= 1


N = int(input())
choice = []
for j in range(N):
    choice.append(int(input()))


matches = []
for row in rows:
    matches.append([c for c in row if c in choice])

for column in columns:
    matches.append([c for c in column if c in choice])

matches.append([c for c in left if c in choice])
matches.append([c for c in right if c in choice])


isPrinted = False
for match in matches:
    if (len(match) == 3):
        print("Yes")
        isPrinted = True
        break

if (not isPrinted):
    print("No")


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

int main()
{
    int n;
    cin>>n;
    char s1[101];
    char s2[101];
    int c=0,k=0;
    
    for(int i=0;i<n;i++){
        cin>>s1>>s2;
        if(strcmp(s1,s2)==0){
         c++;
         k++;
       }
       else if(strcmp(s1,s2)>0)c+=3;
       else k+=3;
    }
    cout<<c<<" "<<k<<"\n";
   return 0;
}


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

int main() {
  int N, K,sum;
  sum =1;
  cin>>N>>K;
  
  for(int i=0;i<N;i++){
  	if(sum<=K){
    	sum = sum*2;
    }
    else if(sum>=K){
    	sum += K;
    }
   // cout<<sum<<endl;
  }
  cout<<sum<<endl;
}

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

int days(int y, int m, int d)
{
    if (m <= 2) {
        --y;
        m += 12;
    }
    int dy = 365 * (y - 1);
    int c = y / 100;
    int dl = (y >> 2) - c + (c >> 2);
    int dm = (m * 979 - 1033) >> 5;
    return dy + dl + dm + d - 1;
}

int main() {
    int y1, m1, d1, y2, m2, d2;
    while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
        if (y1<0 || m1<0 || d1<0 || y2<0 || m2<0 || d2<0) {
            break;
        }
        cout << days(y2, m2, d2) - days(y1, m1, d1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	if( abs(a-x)<=abs(b-x) )
		cout<<"A";
	else
		cout<<"B";	
	cout<<endl;
	return 0;	
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N,M;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextInt();
		long [][]LR = new long [N][3];
		long [][]l=new long[N][2],r=new long[N][2];
		for(int i=0;i<N;i++) {
			LR[i][0]=nextLong();
			LR[i][1]=nextLong();
			LR[i][2]=LR[i][1]-LR[i][0]+1;
			l[i][0] = LR[i][0];
			r[i][0] = LR[i][1];
			l[i][1] = i;
			r[i][1] = i;
		}
		Arrays.sort(l,(a1,a2)->Long.compare(a2[0],a1[0]));
		Arrays.sort(r,(a1,a2)->Long.compare(a1[0],a2[0]));

		long []onesum = new long[N];
		for(int i=0;i<N;i++) {
			long L = l[0][0];
			long R = r[0][0];
			if(l[0][1]==i)L = l[1][0];
			if(r[0][1]==i)R = r[1][0];
			long abs = R-L+1;
			if(abs <= 0)abs = 0;
			onesum[i]=LR[i][2]+abs;
		}
		Arrays.sort(onesum);

		Arrays.sort(LR,(a1,a2)->MyComparator(a1[0],a2[0],a1[1],a2[1]));
		//Arrays.sort(LR,(a1,a2)->absComp(a1[0],a2[0],a1[1],a2[1]));
		long L = LR[0][0];
		long R = LR[0][1];
		long Abs = R - L + 1;
		long []lrA = new long[N];
		lrA[0] = Abs;
		for(int i=1;i<N-1;i++) {
			L=Math.max(L,LR[i][0]);
			R=Math.min(R,LR[i][1]);
			long abs = R-L+1;
			if(abs <= 0)break;
			lrA[i] = abs;
		}
		long [] lrB = new long [N];
		L = LR[N-1][0];
		R = LR[N-1][1];
		for(int i=N-1;i>0;i--) {
			L=Math.max(L,LR[i][0]);
			R=Math.min(R,LR[i][1]);
			long abs = R-L+1;
			if(abs <= 0)break;
			lrB[i] = abs;
		}

		long max = onesum[N-1];
		for(int i=0;i<N-1;i++) {
			max = Math.max(max, lrA[i]+lrB[i+1]);
		}
		out.println(max);

	}


	private int absComp(long a1, long a2, long b1, long b2) {
		if(b1 - a1 < b2 - a2)return 1;
		if(b1 - a1 > b2 - a2)return -1;
		return 0;
	}

	private int MyComparator(long a1, long a2, long b1, long b2) {
		if(b1 - a1 < b2 - a2)return 1;
		if(b1 - a1 > b2 - a2)return -1;
		if(a1 > a2) return 1;
		else if(a1 < a2) return -1;
		if(b1 > b2) return 1;
		else if(b1 < b2) return -1;
		return 0;
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
struct edge { int v, w; };
const ll INF = LLONG_MAX / 2;
const int MOD = 1e9 + 7;
const ll e18 = 1e18;

pair<vector<ll>, vector<ll>> dijkstra(int N, vector<vector<edge> >& G, int s) {
	vector<ll> d(N, INF); d[s] = 0;
	vector<ll> way(N, s); way[s] = 1;
	priority_queue<ll_i, vector<ll_i>, greater<ll_i> > pq;
	pq.push(ll_i(0, s));
	while (pq.size()) {
		ll_i p = pq.top(); pq.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (edge e: G[u]) {
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				way[e.v] = 0;
				pq.push(ll_i(d[e.v], e.v));
			}
			if (d[e.v] == d[u] + e.w)
				way[e.v] = (way[e.v] + way[u]) % MOD;
		}
	}
	return {d, way};
}

int main() {
	int N, M; cin >> N >> M;
	int s, t; cin >> s >> t, s--, t--;
	vector<vector<edge>> G(N);
	while (M--) {
		int u, v, w; scanf("%d%d%d", &u, &v, &w);
		u--, v--;
		G[u].pb({v, w}), G[v].pb({u, w});
	}
	vector<ll> ds = dijkstra(N, G, s).first;
	vector<ll> ws = dijkstra(N, G, s).second;
	vector<ll> dt = dijkstra(N, G, t).first;
	vector<ll> wt = dijkstra(N, G, t).second;
	ll D = ds[t];
	ll tot = 0;
	rep(u, N) if (ds[u] + dt[u] == D && ds[u] == dt[u]) {
		ll z = ws[u] * wt[u] % MOD;
		tot = (tot + z * z) % MOD;
	}
	rep(u, N) for (edge e: G[u]) {
		int v = e.v;
		if (ds[u] + e.w + dt[v] == D && ds[u] * 2 < D && dt[v] * 2 < D) {
			ll z = ws[u] * wt[v] % MOD;
			tot = (tot + z * z) % MOD;
		}
	}
	ll ans = (ws[t] * ws[t] - tot) % MOD;
	cout << (ans + MOD) % MOD << endl;
}


Measured memory_bytes: 15924
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0]
for i in range(n):
    d = min(a[i], b[i])
    c[i] += d
    b[i] -= d
    c.append(min(a[i+1], b[i]))
    a[i+1] -= c[-1]
print(sum(c))

Measured memory_bytes: 18624
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


int main()
{
	int n; cin >> n;
	Vi v(n);

	REP(i, n) cin >> v[i];

	int ans = 0;
	for (int i = 1; i < n - 1; ++i)
	{
		if (v[i - 1] < v[i] && v[i] < v[i + 1])
			++ans;
		else if (v[i - 1] > v[i] && v[i] > v[i + 1])
			++ans;
	}

	cout << ans << endl;
}


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

using namespace std;

int dp[2][2];
void solve() {
    string s; cin >> s;
    while (s.back() == '0') {
        s.pop_back();
    }
    s = "0" + s;
    int n = s.size();
    //vector<int> sum(n + 1);
    //for (int i = 1; i <= n; i++) {
    //    sum[i] = sum[i-1] + (s[i-1] - '0');
    //}
    //int res = sum[n];
    //int cry = min(10 - (s[n-1] - '0'), (s[n-1]-'0') + 1);
    //for (int i = n-2; i >= 0; i--) {
    //    int x = s[i] - '0';
    //    if (x == 9) continue;
    //    res = min(res, 1 + sum[i+1] + cry);
    //    cry += min(9-x, x+2);
    //}
    //cout << res;
    
    int crt = 0;
    for (int _ = 0; _ < n; _++) {
        int x = s[_]-'0';
        int nxt = crt ^ 1;
        memset(dp[nxt], 0x3f, sizeof dp[nxt]);
        for (int i = 0; i < 10; i++) {
            for (int j: {0,1}) if (j || x<=i) {
                int d = j*10 + (i-x);
                dp[nxt][0] = min(dp[nxt][0], dp[crt][j] + d + i);
                if(d)dp[nxt][1] = min(dp[nxt][1], dp[crt][j] + d-1 + i);
            }
        }
        crt ^= 1;
    }
    cout << dp[crt][0];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 2332
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 405, base = 1013, MOD = 1000007;
typedef long long i64;
typedef unsigned long long u64;
typedef pair<int, int> pii;

int C[MAX_N][4], N;

class Hash_Table {
public:
  int head[MOD], cnt, nxt[MOD], num[MOD];
  u64 key[MOD];
  void add(pair<pii, pii> x, int v) {
    u64 val = (u64)x.first.first * base + (u64)x.first.second * base * base;
    val += (u64)x.second.first * base * base * base;
    val += (u64)x.second.second * base * base * base * base;
    
    int temp = val % MOD;
    for (int i = head[temp]; i; i = nxt[i])
      if (key[i] == val) {
	num[i] += v;
	return;
      }
    nxt[++cnt] = head[temp], head[temp] = cnt, num[cnt] = v, key[cnt] = val;
  }
  int query(pair<pii, pii> x) {
    u64 val = (u64)x.first.first * base + (u64)x.first.second * base * base;
    val += (u64)x.second.first * base * base * base;
    val += (u64)x.second.second * base * base * base * base;
    
    int temp = val % MOD;
    for (int i = head[temp]; i; i = nxt[i])
      if (key[i] == val) return num[i];
    return 0;
  }
} cnt;

void insert(int col[4]) {
  static int t[4];
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) t[j] = col[(j + i) % 4];
    cnt.add(make_pair(make_pair(t[0], t[1]), make_pair(t[2], t[3])), 1);
  }
}

void substract(int col[4]) {
  static int t[4];
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) t[j] = col[(j + i) % 4];
    cnt.add(make_pair(make_pair(t[0], t[1]), make_pair(t[2], t[3])), -1);
  }  
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    for (int j = 0; j < 4; ++j)
      scanf("%d", &C[i][j]);

  i64 res = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j < i; ++j) {
      substract(C[j]);
      for (int d = 0; d < 4; ++d) {
	static int t[4], A[4], vis[MAX_N];
	i64 num = 1;
	for (int k = 0; k < 4; ++k) t[k] = C[j][((k + d) % 4) ^ 1];
	for (int k = 0; k < 4; ++k) {
	  A[0] = C[i][(k + 1) % 4], A[1] = C[i][k];
	  A[3] = t[(k + 1) % 4], A[2] = t[k];
	  int temp = cnt.query(make_pair(make_pair(A[0], A[1]), make_pair(A[2], A[3])));
	  num *= temp, vis[k] = 0;
	  if (temp) substract(A), vis[k] = 1;
	}
	for (int k = 0; k < 4; ++k) {
	  A[0] = C[i][(k + 1) % 4], A[1] = C[i][k];
	  A[3] = t[(k + 1) % 4], A[2] = t[k];
	  if (vis[k]) insert(A);
	}
	res += num;
      }
      insert(C[j]);
    }
    insert(C[i]);
  }

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


Measured memory_bytes: 8064
from collections import deque
s = input()
n = int(input())
query = []
for i in range(n):
    query.append(input().split())
cond = 1
word = deque(s)
for i in range(n):
    if query[i] == ['1']:
        cond *= -1
    else:
        if cond == 1:
            if query[i][1] == '1':
                word.appendleft(query[i][2])
            else:
                word.append(query[i][2])
        else:
            if query[i][1] == '2':
                word.appendleft(query[i][2])
            else:
                word.append(query[i][2])

result = ''.join(word)
if cond == -1:
    result = result[::-1]
print(result)


Measured memory_bytes: 44652
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct 
{
  char mozi;
  int value;
}card;

void printkansu(card *);
void BubbleSort(card *);
void SelectionSort(card *);
int inStable(card *,card *);
int length; 
card key; 
card S[36];
int i=0,j=0;


int main(){
  
  scanf("%d",&length);//長さ入力
  card C[36];
  card M[36];
  while(i < length){//柄と数の入力
    scanf(" %c%d",&C[i].mozi,&C[i].value);
    M[i] = C[i];
    S[i] = C[i];
    i++;
  }
  
  BubbleSort(C) ;
  SelectionSort(M);
  return 0;
}


void BubbleSort(card *C)
{
  for(i = 0;i < length-1;i++){//BubbleSort(C, N)
    for(j = length-1;j >= 1;j--){
      
      if(C[j].value < C[j-1].value){
	key = C[j];
	C[j] = C[j-1];
	C[j-1] = key;
      }
    }
  }
  printkansu(C);
}
void SelectionSort(card *C)
{
  int min;

  for(i = 0;i < length-1;i++){//SelectionSort(C, N)
    min = i;
    for(j = i;j <= length-1;j++){
      if(C[j].value < C[min].value){
	min = j;
      }
    }
    key = C[i];
    C[i] = C[min];
    C[min] = key;
  }
  printkansu(C);
}

void printkansu(card *C)
{
  for(i = 0;i < length-1;i++){//表示
    printf("%c%d ",C[i].mozi,C[i].value);
  }
  printf("%c%d\n",C[i].mozi,C[i].value);
  if(inStable(S,C)==1)printf("Stable\n");
  else printf("Not stable\n");
}
int inStable(card *in ,card *out)
{
  int a, b;
  for(i = 0;i < length-1;i++){
    for(j = i+1;j < length-1;j++){
      for(a = 0;a < length-1;a++){
	for(b = a+1;b < length-1;b++){

	  if(in[i].value == in[j].value && in[i].value == out[b].value && in[i].mozi == out[b].mozi && in[j].value == out[a].value && in[j].mozi == out[a].mozi) return 0;
	}
      }
    }
  }
  return 1;
}

Measured memory_bytes: 608
/*
 AtCoder XXX 000
 */
 
#include <stdio.h>
 
int main(void){
  unsigned long long n,k;
  unsigned long long i;
  unsigned long long cnt;
  
  scanf("%llu %llu",&n,&k);
  
  cnt=0;
  if(k==0)
  {
    printf("%llu\n",n*n);
    return 0;
  }
  
  for(i=1; i<=n; i++){
    if(i>k)
    {
      cnt += (i-k)*(n-n%i)/i;
      cnt += (n%i)>=k ? (n%i)-k+1 : 0;
    }
  }
  
  printf("%llu\n",cnt);
  return 0;
}

Measured memory_bytes: 128
int main(){
  
  int a, b, c;
  int cnt_5 = 0, cnt_7 = 0;
  
  scanf("%d%d%d", &a, &b, &c);

  if(a == 5){
    cnt_5++;
  }if(a == 7){
    cnt_7++;
  }if(b == 5){
    cnt_5++;
  }if(b == 7){
    cnt_7++;
  }if(c == 5){
    cnt_5++;
  }if(c == 7){
    cnt_7++;
  }

  if(cnt_5 == 2 && cnt_7 == 1){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String []args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);

		//a???????????????
		int a = sc.nextInt();
		//b???????????????
		int b = sc.nextInt();
		//c???????????????
		int c = sc.nextInt();
		//??°????????????????????????
		int temp;

		//a > b
		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}

		//b > c
		if(b > c){
			temp = b;
			b = c;
			c = temp;
		}

		//
		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}
		//??¨???
		System.out.println(a + " " + b + " " + c);

	}
}

Measured memory_bytes: 26300
while True:
    a, op, b = input().split()

    if op=='+':
        print(int(a)+int(b))
    elif op=='-':
        print(int(a)-int(b))
    elif op=='*':
        print(int(a)*int(b))
    elif op=='/':
        print(int(a)//int(b))
    else:
        break



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

bool IsPrime(int num){
    if (num<2) return false;
    else if (num == 2) return true;
    else if (num%2 == 0) return false;
    
    double sqrtNum = sqrt(num);
    for (int i =3; i<=sqrtNum; i+=2){
        if (num%i == 0) return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    int cnt = 0;
    for (int i=0; i<n; i++){
        cin >> a[i];
        if (IsPrime(a[i])) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);

            if (0 == B % A)
            {
                Console.WriteLine(A + B);
            }
            else
            {
                Console.WriteLine(B - A);
            }
        }
    }
}




Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N, ans=0; cin>>N;
  vector<ll> R(N+1,0),B(N+1,0),G(N+1,0);
  string S; cin>>S;
  for(int i=0; i<N; i++){
    if (S[i]=='R') R[i]++;
    else if (S[i]=='B') B[i]++;
    else if (S[i]=='G') G[i]++;
  }
  for(int i=0; i<N; i++){
    R[i+1]=R[i]+R[i+1];
    B[i+1]=B[i]+B[i+1];
    G[i+1]=G[i]+G[i+1];
  }
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      if(S[i]==S[j])
        continue;
      if((S[i]=='R' && S[j]=='B') || (S[i]=='B' && S[j]=='R')){
        ans+=G[N]-G[j];
        if(S[j+(j-i)]=='G') ans--;
      }
      else if((S[i]=='B' && S[j]=='G') || (S[i]=='G' && S[j]=='B')){
        ans+=R[N]-R[j];
        if(S[j+(j-i)]=='R') ans--;
      }
      else if((S[i]=='R' && S[j]=='G') || (S[i]=='G' && S[j]=='R')){
        ans+=B[N]-B[j];
        if(S[j+(j-i)]=='B') ans--;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3660
#include <cstdio>
using namespace std;
typedef long long ll;
int n, k;

int main() {
    scanf("%d", &n);
    int ans1, ans2, ans3;
    ans1 = n / 3600;
    n %= 3600;
    ans2 = n / 60;
    n %= 60;
    ans3 = n;
    printf("%d:%d:%d\n", ans1, ans2, ans3);
    return 0;
}


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

int main(void){
  int N, cnt, max_cnt = 0;
  int a[100010], num_cnt[100010] = {0};
  //入力
  cin >> N;
  for(int i = 0; i < N; i++){cin >> a[i];}
  //各々の数の個数リストを作る
  for(int i = 0; i < N; i++){num_cnt[a[i]]++;}
  //Xを選び個数リストからX-1, X, X+1の和を求める。
  for(int i = 0; i < 100005; i++){
    if(i == 0){cnt = num_cnt[i] + num_cnt[i + 1];}
    else{cnt = num_cnt[i - 1] + num_cnt[i] + num_cnt[i + 1];}
    if(max_cnt < cnt){max_cnt = cnt;}
  }
  cout << max_cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
dic = {}
list = []

maxnum=0

for i in range(0,n,1):
	name = input()
	
	if name in dic:
		dic[name] = dic[name]+1
	else:
		dic[name] = 1
	
	if dic[name] > maxnum:
		maxnum = dic[name]

for name in dic.keys():
	if dic[name] == maxnum:
		list.append(name)
		
for i in sorted(list):
	print(i)

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

int dfs(int sum, int N, vector<int> &oknum){
    if (sum>=N){
        //cout << sum << endl;
        return sum;
    }

    int minsum = 100000;
    for(int x: oknum){
        int nv =sum*10 + x;
        if (nv==0) continue;
        int s = dfs(nv, N, oknum);
        minsum = min(s, minsum);
        //cout << x << " " << s << endl;
    }
    return minsum;
}

int main()
{
    int N, K;
    cin >> N>>K;
    vector<int> ngnum(10);
    REP(i, K){
        int a;
        cin >> a;
        ngnum[a] = 1;
    }
    vector<int> oknum;
    REP(i, 10){
        if (ngnum[i] == 0){
            oknum.push_back(i);
            //cout << i << " ";
        }
    }
    //cout << endl;
    int minsum = dfs(0,N, oknum);
    cout << minsum << endl;
   return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
	static void Main(string[] args)
	{
		var InputValue = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToList<int>();

		if (InputValue[0] < InputValue[1] && InputValue[1] < InputValue[2])
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}


	}
}




Measured memory_bytes: 9420
// input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// body

fn main() {
    input! {
        a: usize,
        b: usize,
    };

    if a >= 13 {
        println!("{}", b);
    } else if a >= 6 {
        println!("{}", b / 2);
    } else {
        println!("0")
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int N=305;
int n,m,mod,f[N][N],sum[N][N],C[N][N];
int main(){
	scanf("%d%d%d",&n,&m,&mod);
	C[0][0]=1;
	for(int i=1;i<=300;C[i++][0]=1)
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	for(int i=0;i<=m;i++)f[1][i]=1;
	sum[1][0]=f[1][0];
	for(int i=1;i<=m;i++)sum[1][i]=(sum[1][i-1]+f[1][i])%mod;
	for(int i=2;i<=n+1;i++){
		for(int j=0;j<=m;j++){
			for(int k=1;k<i;k++){
				f[i][j]=(f[i][j]+1ll*C[i-2][k-1]*(sum[k][m]-sum[k][j])%mod*f[i-k][j])%mod;
			}
		}
		sum[i][0]=f[i][0];
		for(int j=1;j<=m;j++)sum[i][j]=(sum[i][j-1]+f[i][j])%mod;
	}
	cout<<(f[n+1][0]+mod)%mod<<"\n";
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ll long long int
using namespace std;

const int mxn = 1e7 + 1;

int spf[mxn];

void sieve()
{
	spf[1] = 1;
	for (int i = 2; i < mxn; i++)

		spf[i] = i;

	for (int i = 4; i < mxn; i += 2)
		spf[i] = 2;

	for (int i = 3; i * i < mxn; i++)
	{
		if (spf[i] == i)
		{
			for (int j = i * i; j < mxn; j += i)
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}

ll fctrz(int x)
{
	map<int, int> mp;
	while (x != 1)
	{
		mp[spf[x]]++;
		x = x / spf[x];
	}
	ll res = 1;
	for (auto p : mp) {
		res *= (p.second + 1);
	}
	return res;
}

void solve() {
	sieve();
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += (i * fctrz(i));
	}

	cout << ans << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 42684
package main

import "fmt"

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}

func main() {
	var N, K, val int
	fmt.Scan(&N, &K)
	val = 1
	for i := 1; i <= N; i++ {
		val = min(val*2, val+K)
	}
	fmt.Println(val)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std; 
long long n,a[2002000],l=1,sum[2002000],x[2002000];
int main()
{
	cin>>n;
	cin>>a[1];
	long long ans=0;
	sum[1]=a[1];x[1]=a[1];
	for (int i=2;i<=n;i++) 
	    cin>>a[i],sum[i]=sum[i-1]+a[i],x[i]=x[i-1]^a[i];
	int l=1;
	for (int r=1;r<=n;r++)
	{
		while ((sum[r]-sum[l-1])!=(x[r]^x[l-1])) l++; 
	    ans+=r-l+1;
	}
	cout<<ans; 
	return 0;
}

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

vector<string> v;

signed main(){

  string s; cin >> s;
  int K; cin >> K;

  for(int i = 0; i < s.size(); i++){
    for(int j = 1; j <= 5; j++){
      if(i+j > s.size()) break;
      v.push_back( s.substr(i,j) );
    }
  }
  sort(v.begin(),v.end());
  v.erase( unique(v.begin(),v.end()),v.end() );
  cout << v[K-1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define frep(i, m, n) for(int i = m;i < n;i++)
#define frepr(i, m, n) for(int i = m;i >= n;i--)
#define vsort(v) sort(v.begin(),v.end())
#define ll long long
#define inf 999999999
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef pair<int,P> PP;
typedef pair<ll,LP> LPP;


int main(){
    ll n,k,q;
    cin >> n >> k >> q;
    vi p(n,k);
    rep(i,q){
        int a;
        cin >> a;
        p[a-1]++;
    }
    rep(i,n){
        if(p[i]-q>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 1024
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    A, B = [int(n) for n in input().split()]

    print((A+B)//2 if (A+B)%2 == 0 else "IMPOSSIBLE")



if __name__ == "__main__":
    main()


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int h,w;
  cin>>h>>w;
  REP(i,h){
    string s;
    cin>>s;
    REP(_,2)cout<<s<<endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

// http://www.prefield.com/algorithm/container/union_find.html
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  while(true){
    int n,m;
    cin>>n>>m;
    if(n==0 && m==0)break;
    int res = 0;
    vector< pair<int,pii> > edges(m);
    REP(i,m){
      int a,b,c;
      cin>>a>>b>>c;
      edges[i] = make_pair(c,make_pair(a,b));
    }
    sort(ALL(edges));
    UnionFind uf(n);
    REP(i,m){
      int a,b,c;
      c = edges[i].first;
      a = edges[i].second.first;
      b = edges[i].second.second;
      if(!uf.findSet(a,b)){
        uf.unionSet(a,b);
        res += c;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let X = readIntSplit(by: " ")[2]
let A = readIntSplit(by: " ")
print(min(A.filter{$0<X}.count, A.filter{$0>X}.count))


Measured memory_bytes: 7400
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
struct edge{int cost,u,v;};
int INF = 100000000;
int V,E;
bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}
vector<edge> es;
vector<int> par;
vector<int> depth;
void init(){
  par.resize(V);
  depth.resize(V,0);
  REP(i,V)par[i] = i;
}

int find(int x){
  if(x == par[x]){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x==y)return;
  if(depth[x] < depth[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(depth[x] == depth[y])depth[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int kruskal(){
  sort(es.begin(),es.end(),comp);
  init();
  int res = 0;
  for (int i = 0;i<E;i++){
    edge e = es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res += e.cost;
    }
  }
  return res;
}
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> V >> E;
  es.resize(E);
  REP(i,E){
    int s,t,c;
    cin >> s >> t >> c;
    es[i].u = s;es[i].v = t;
    es[i].cost = c;
  }
  cout << kruskal() << endl;
  
  return 0;
}

Measured memory_bytes: 4256
from collections import deque

def dfs(q):
    if len(q)==N:
        print(''.join(q))
        return
    
    for i in range(min(26, ord(max(q))-ord('a')+2)):
        q.append(alpha[i])
        dfs(q)
        q.pop()
    
N = int(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
dfs(deque(['a']))

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

int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin>>l.at(i);
    }
    sort(l.begin(),l.end(),greater<int>());
    int count = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int t = l.at(i) - l.at(j);
            for(int k=j+1;k<n;k++){
                if(t < l.at(k)){
                    count++;
                }else{
                    break;
                }
                
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647;
const long long int llINF = 9223372036854775807;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vl A(N + 1, 0);
  REP(i, M) {
    ll l, r;
    cin >> l >> r;
    A[l - 1]++;
    A[r]--;
  }
  ll ans = 0;
  ll now = 0;
  REP(i, N) {
    now += A[i];
    if (now == M)
      ans += 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
from sys import stdin
from math import isinf
n, e = map(int, stdin.readline().split())
d = [[float('inf')] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for i in range(e):
    u, v, c = map(int, stdin.readline().split())
    d[u][v] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]
for i in range(n):
    if d[i][i] < 0:
        print("NEGATIVE CYCLE")
        exit(0)
for di in d:
    print(' '.join(('INF' if isinf(dij) else str(dij) for dij in di)))

Measured memory_bytes: 8120
#include<iostream>

using namespace std;

int main(void) {
	int now, count;

	while(true) {
		cin >> now;
		if(now == 0) { break; }
		count = 0;
		now = 1000 - now;
		while(now > 0) {
			if(now >= 500) {
				now -= 500;
				count++;
			} else if(now >= 100) {
				now -= 100;
				count++;
			} else if(now >= 50) {
				now -= 50;
				count++;
			} else if(now >= 10) {
				now -= 10;
				count++;
			} else if(now >= 5) {
				now -= 5;
				count++;
			} else {
				now -= 1;
				count++;
			}
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 0