akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0].to!int;
    auto A = s[1];
    auto B = s[2];
    auto S = N.iota.map!(_ => readln.chomp.to!long).array;
    S ~= - 10L ^^ 18 - 10;
    S.sort();

    auto st1 = new SegmentTree(N + 1);
    auto st2 = new SegmentTree(N + 1);
    st1.add(0, 1);
    st2.add(0, 1);
    int lb1 = 0;
    int lb2 = 0;

    foreach (i; 2..N+1) {
        int j = S.assumeSorted.lowerBound(S[i] - A + 1).length.to!int - 1;
        int k = S.assumeSorted.lowerBound(S[i] - B + 1).length.to!int - 1;
        st2.add(i - 1, st1.sum(lb1, min(j, i - 2)));
        st1.add(i - 1, st2.sum(lb2, min(k, i - 2)));
        if (S[i] - S[i - 1] < A) lb2 = i - 1;
        if (S[i] - S[i - 1] < B) lb1 = i - 1;
    }

    writeln( (st1.sum(lb1, N + 1) + st2.sum(lb2, N + 1)) % MOD );
}

class SegmentTree {
    long[] table;
    int size;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new long[](size);
    }

    void add(int pos, long num) {
        return add(pos, num, 0, 0, size/2-1);
    }

    void add(int pos, long num, int i, int left, int right) {
        (table[i] += num) %= MOD;
        if (left == right)
            return;
        auto mid = (left + right) / 2;
        if (pos <= mid)
            add(pos, num, i*2+1, left, mid);
        else
            add(pos, num, i*2+2, mid+1, right);
    }

    long sum(int pl, int pr) {
        if (pl > pr) return 0;
        return sum(pl, pr, 0, 0, size/2-1);
    }

    long sum(int pl, int pr, int i, int left, int right) {
        if (pl > right || pr < left)
            return 0;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                (sum(pl, pr, i*2+1, left, (left+right)/2) +
                 sum(pl, pr, i*2+2, (left+right)/2+1, right)) % MOD;
    }
}


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

int main() {

	int N;
	int D;
	cin >> N;
	cin >> D;

	vector<vector<int>> X(N, vector<int>(D, 0));
	for (int i = 0; i < X.size(); i++) {
		for (int j = 0; j < X[i].size(); j++) {
			cin >> X[i][j];
		}
	}

	double d;
	size_t id;
	double jdg;
	int ans = 0;
	for (int i1 = 0; i1 < (X.size() - 1); i1++) {
		for (int i2 = i1 + 1; i2 < X.size(); i2++) {
			d = 0.0;
			for (int j = 0; j < X[i1].size(); j++) {
				d += double(X[i1][j] - X[i2][j]) * double(X[i1][j] - X[i2][j]);
			}
			d = sqrt(d);
			id = size_t(d);
			jdg = d - double(id);
			if (jdg == 0.0) {
				ans += 1;
			}
		}
	}

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

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

int main(void){
  ll n;cin>>n;
  ll ans=0;
  ans=(n*(n-1))/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define CMD 16

typedef struct node_t{
  long key;
  struct node_t *prev;
  struct node_t *next;
} node; 

node *head, *tail;

int insert(node *add){
  if (!add)
    return -1;
  else if (!head)
    // when add a first node
    head = tail = add;
  else {
    head->prev = add;
    add->next = head;
    head = add;
  }
  return 0;
}

node *search(long searchKey){
  node *tmp = head;
  while (tmp) {
    if (tmp->key == searchKey)
      return tmp;
    tmp = tmp->next;
  }
  return NULL;
}

int delete(long deleteKey){
  node *del;
  if (!(del = search(deleteKey)))
    return -1;
  else {
    if (del == head) {
      head = head->next;
      if (head)
    	head->prev = NULL;
      else
	// list is empty
    	head = tail = NULL;
    }
    else if (del == tail) {
      tail = tail->prev;
      tail->next = NULL;
    }
    else {
      // delete node is middle in the list
      del->prev->next = del->next;
      del->next->prev = del->prev;
    }
    free(del);
    return 0;
  }
  return 1;
}

int deleteFirst(){
  if (head == tail && tail == NULL)
    return -1;
  else {
    head = head->next;
    if (head)
      head->prev = NULL;
    else
      // list is empty
      head = tail = NULL;
    return 0;
  }
}

int deleteLast(){
  if (head == tail && tail == NULL)
    return -1;
  else {
    tail = tail->prev;
    if (tail)
      tail->next = NULL;
    else
      // list is empty
      head = tail = NULL;
    return 0;
  }
}

int main(void){
  long n, i, key;
  char command[CMD] = {0};
  char ins[] = "insert", del[] = "delete";
  char delF[] = "deleteFirst", delL[] = "deleteLast";
  node *tmp;
  scanf("%ld", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %ld", command, &key);
    if (!(strcmp(command, ins))) {
      tmp = (node *)malloc(sizeof(node));
      tmp->key = key;
      tmp->next = NULL;
      tmp->prev = NULL;
      insert(tmp);
    }
    else if(!(strcmp(command, del)))
      delete(key);
    else if(!(strcmp(command, delF)))
      deleteFirst();
    else if(!(strcmp(command, delL)))
      deleteLast();
    else
      puts("Not available command!");
  }
  
  // output
  tmp = head;
  for (i = 0; i < n; i++) {
    if(i)
      printf(" ");
    printf("%ld", tmp->key);
    if (tmp == tail)
      break;
    tmp = tmp->next;
  }
  puts("");
  return 0;
}

Measured memory_bytes: 34996
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	int n;
	cin >> n;
	vector<int>l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int sum = 0;
	for (int i = 0; i < n - 1; i++) {
		sum += l[i];
	}
	if (sum > l[n - 1])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
lst = [8, 1, 1, 0]
for i in range(n - 1):
    a = lst[0]*8
    b = lst[0] + lst[1]*9
    c = lst[0] + lst[2]*9
    d = lst[3]*10 + lst[1] + lst[2]
    a = a%(10**9 + 7)
    b = b%(10**9 + 7)
    c = c%(10**9 + 7)
    d = d%(10**9 + 7)
    lst = [a, b, c, d]
print(lst[3])


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

#define maxn 51
#define maxsum 2600
using namespace std;
int N, A;
// dp[i][j][k] = j carti din primele i carti care dau suma k
// dp[1][0][0] = 1
// dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - v[i]]
long long dp[maxn][maxn][maxsum];
int v[maxn];
int main()
{
    int mini = 100;
    long long rez = 0;
    scanf("%d %d", &N, &A);
    for (int i = 1; i <= N; ++i) {
        scanf("%d", &v[i]);
        mini = min(v[i], mini);
        // dp[i][1][v[i]] = 1;
        dp[i][0][0] = 1;
    }
    dp[0][0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= i; ++j) {
            for (int k = 0; k < maxsum; ++k) {
                dp[i][j][k] = dp[i - 1][j][k];
                if (k - v[i] >= 0) {
                    dp[i][j][k] += dp[i - 1][j - 1][k - v[i]];
                }
            }
        }
    }
    for (long long i = 1; i <= N; ++i) {
        rez += dp[N][i][i * A];
    }
    printf("%lld", rez);
    return 0;
}


Measured memory_bytes: 51072
n,p=map(int,input().split())

d={}
x=p
for i in range(2,p):
  while x%i==0:
    if i in d:
      d[i]+=1
    else:
      d[i]=1
    x//=i
  if i*i>=p:
    break
if x>1:
  d[x]=1

ans=1
for k,v in d.items():
  for i in range(v//n):
    ans*=k

print(ans)


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

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

    int a, b;
    cin >> a >> b;

    if(a*b%2) puts("Yes");
    else puts("No");
}

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

int main(){
  string S;
  cin>>S;
  if(S.size()%2 !=0){
    cout<<"No"<<endl;
    return 0;
  }
  while(S.size()!=0){
    if(S.at(0)=='h' && S.at(1)=='i'){
      S=S.substr(2);
    }
    else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int h[100009],n,ans1,ans2,dp[100009];
int f(int i)
{
    if(i==n)
        return 0;
        if(dp[i]!=-1)
            return dp[i];

    ans1=abs(h[i]-h[i+1])+f(i+1);
    if(i<n-1)
    ans2=abs(h[i]-h[i+2])+f(i+2);
    else
        ans2=INT_MAX;
    dp[i]=min(ans1,ans2);
    return dp[i];
}
int main()
{
    memset(dp,-1,sizeof(dp));
    //int
    cin>>n;
    for(int i=1;i<=n;i++)
    {

        cin>>h[i];

    }
    cout<<f(1);
}


Measured memory_bytes: 4096
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int[] a = new int[5];
		int i;
		Scanner sc = new Scanner(System.in);
		for(i=0; i<5; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		sc = null;
		int sum = 0;
		int min = 9;
		int tmp;
		boolean f=false;
		for(i=0; i<5; i++) {
			tmp = a[i] % 10;
			sum += (a[i] / 10) * 10;
			if(tmp > 0) {
				f=true;
				sum += 10;
				if(tmp < min) min = tmp;
			}
		}
		if(f)System.out.println(sum - 10 + min);
		else System.out.println(sum);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    string ans="No";
    rep(i,26){
        rep(j,15){
            if(N==i*4+j*7) ans="Yes";
        }
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
typedef long long ll;
using namespace std;

int main(){
  string line;
  getline(cin,line);
  split_str(line,' ')
    printf("%c",toupper(res.front()));

  puts("");
  return 0;
}

Measured memory_bytes: 256
while True:
    m, r, f = map(int, input().split())
    grade = "null"

    if m == -1 and r == -1 and f == -1:
        break

    if m + r >= 80:
        grade = "A"
    elif m + r >= 65 and m + r < 80:
        grade = "B"
    elif m + r >= 50 and m + r < 65:
        grade = "C"
    elif m + r >= 30 and m + r < 50:
        grade = "D"
    elif m + r <= 30:
        grade = "F"

    if grade == "D" and f >= 50:
        grade = "C"

    if m == -1 or r == -1:
        grade = "F"

    print(grade)



Measured memory_bytes: 5596
// Written by newbiechd
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>
#define int long long

const int BUFFER_SIZE = 1 << 25 | 1;
struct InputOutputStream {
  char ibuf[BUFFER_SIZE], *s;
  InputOutputStream() : s(ibuf) {
    ibuf[fread(ibuf, 1, BUFFER_SIZE, stdin)] = '\0';
  }
  template <typename T>
  inline InputOutputStream &operator>>(T &x) {
    while (!isdigit(*s)) ++s;
    for (x = 0; isdigit(*s); ++s)
      x = x * 10 + (*s ^ '0');
    return *this;
  }
}IO;

template <typename lhs, typename rhs>
inline lhs min(const lhs &x, const rhs &y) { return x < y ? x : y; }
template <typename lhs, typename rhs>
inline lhs max(const lhs &x, const rhs &y) { return x > y ? x : y; }

const int maxN = 1000003;
std::pair<int, int> seg[maxN];
inline bool cmp(std::pair<int, int> lhs, std::pair<int, int> rhs) {
  return lhs.second != rhs.second ? lhs.second < rhs.second
                                                 : lhs.first < rhs.first;
}

signed main() {
  int n;
  IO >> n;
  for (int i = 1; i <= n; ++i) {
    int x, len;
    IO >> x >> len;
    seg[i] = {x - len, x + len};
  }
  std::sort(seg + 1, seg + n + 1, cmp);
  
  int mx = -1e18, ans = 0;
  for (int i = 1; i <= n; ++i)
    if (seg[i].first >= mx)
      mx = seg[i].second, ++ans;
  printf("%lld\n", ans);
  return 0;
}


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

#define int long long

signed main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> st;
    for(int i=0; i<k; ++i)
        if(a+i <= b) st.insert(a + i);
    for(int i=0; i<k; ++i)
        if(b-k+i+1>=a) st.insert(b - k + i + 1);
    for(auto it=st.begin(); it!=st.end(); ++it) {
        cout << *it << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <inttypes.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   Int dist[300][300];
   void solve() {
      Int inf = 1LL << 53;
      for(Int i = 0; i < 300; ++i) {
         for(Int k = 0; k < 300; ++k) {
            dist[i][k] = inf;
         }
         dist[i][i] = 0;
      }
      Int n, m, r; scan(n, m, r);
      LI rs(r); scan(rs);
      for(Int i = 0; i < m; ++i) {
         Int a, b, c; scan(a, b, c);
         dist[a][b] = dist[b][a] = c;
      }
      for(Int k = 1; k <= n; ++k) {
         for(Int i = 1; i <= n; ++i) {
            for(Int j = 1; j <= n; ++j) {
               dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
            }
         }
      }
      std::sort(rs.begin(), rs.end());
      Int res = inf;
      do {
         Int t = 0;
         for(Int i = 1; i < r; ++i) {
            t += dist[rs[i-1]][rs[i]];
         }
         res = std::min(res, t);
      } while( next_permutation(rs.begin(), rs.end()) );
      printf("%ld\n", res);
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}
 

Measured memory_bytes: 960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c;
int main(){
	cin>>a>>b>>c;
	if(c>=a) c-=a,a=0;
	else a-=c,c=0;
	if(c>=b) b=0;
	else b-=c;
	cout<<a<<' '<<b;
	return 0;
}


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

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



int main()
{
  int N, K; cin >>  N >> K;
  vector<int> array(N);
  REP(i, N){ cin >> array[i]; }

  int count = 0;
  REP(i, N){
    if( K <= array[i] ){ count++;}
  }

  cout << count << endl;
  return 0;
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToArray();
        var kp = n / 2;
        var res = (l[kp - 1] == l[kp]) ? 0 : l[kp] - l[kp - 1];
        Console.WriteLine(res);
    }
}


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

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> P(N);
    int max = -1;
    for (int i=0; i<N; ++i) {
        std::cin >> P[i];
        if (P[i] > max) max = P[i];
    }
    std::vector<int> LMAX(N);
    LMAX[0] = P[0];
    for (int i=1; i<N; ++i) {
        LMAX[i] = (LMAX[i-1] < P[i]) ? P[i] : LMAX[i-1];
    }
    std::vector<int> RMAX(N);
    RMAX[N-1] = P[N-1];
    for (int i=N-2; i>=0; --i) {
        RMAX[i] = (RMAX[i+1] < P[i]) ? P[i] : RMAX[i+1];
    }

    long sum = 0;
    for (int i=0; i<N; ++i) {
        int second = P[i];
        if (second == max) continue;

        int l=-1;
        int j = i - 1;
        for (; j>=0; --j) {
            if (LMAX[j] < second) break;
            if (P[j] > second) {
                l = j;
                j -= 1;
                break;
            }
        }
        int ll = -1;
        for (; j>=0; --j) {
            if (LMAX[j] < second) break;
            if (P[j] > second) {
                ll = j;
                break;
            }
        }
        int r = N;
            j = i + 1;
        for (; j<N; ++j) {
            if (RMAX[j] < second) break;
            if (P[j] > second) {
                r = j;
                j += 1;
                break;
            }
        }
        int rr = N;
        for (; j<N; ++j) {
            if (RMAX[j] < second) break;
            if (P[j] > second) {
                rr = j;
                break;
            }
        }
        // ll, l, second, r, rr
        long c = 0;
        if (l > -1) {
            // ll [ l s ] r rr
            int minl = ll + 1;
            int maxl = l;
            int minr = i;
            int maxr = r - 1;
            c += (maxl - minl + 1) * (maxr - minr + 1);
        }
        if (r < N) {
            // ll l [ s r ] rr
            int minl = l + 1;
            int maxl = i;
            int minr = r;
            int maxr = rr - 1;
            c += (maxl - minl + 1) * (maxr - minr + 1);
        }
        sum += c * second;
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
 
using namespace std;
 
const int MAX = 101;
const int INF = (1<<20);
 
int cost[MAX][MAX];
int mincost[MAX];
bool used[MAX];
int V;
 
int prim(){
  mincost[0] = 0;
  int res = 0;
 
  while(1){
 
    int v = -1;
    for(int i = 0; i < V; i++)
      if(!used[i] && (v == -1 || mincost[i] < mincost[v])) v = i;
 
    if(v == -1) break;
 
    used[v] = true;
    res+=mincost[v];

    for(int i = 0; i < V; i++)
      mincost[i] = min(mincost[i],cost[v][i]);
 
  }
  return res;
}
 
void init(){
  fill(mincost,mincost+MAX,INF);
  fill(used,used+MAX,false);
  for(int i = 0; i < MAX; i++)
    for(int j = 0; j < MAX; j++)
      cost[i][j] = INF;
}
int main(){
  int m;
  while(cin >> V  >> m && V+m){
    init();
   
    while(m--){
      int f,t,cos;
      cin >> f >> t >> cos;
      cost[f][t] = cost[t][f] = cos;
    }
    cout << prim() << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
using System;
using System.Collections.Generic;
public class ABC134B {
    public static void Main() {
        int N, D, ans = 0;
        string[] str = Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        D = int.Parse(str[1]);
        ans = N / (2 * D + 1) + ((N % (2 * D + 1) == 0) ? 0 : 1);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

typedef vector<int> vec;
typedef vector<vec> mat;

int n, m, z;

mat mul(mat &A, mat &B){
    mat C(A.size(), vec(B[0].size()));
    for(int i=0;i<int(A.size());i++){
        for(int k=0;k<int(B.size());k++){
            for(int j=0;j<int(B[0].size());j++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) > 0;
            }
        }
    }
    return C;
}

mat pow(mat A, ll x){
    mat B(A.size(), vec(A.size()));
    for(int i=0;i<int(A.size());i++){
        B[i][i] = 1;
    }
    while(x > 0){
        if(x & 1) B = mul(B,A);
        A = mul(A, A);
        x >>= 1;
    }
    return B;
}

int main() {
    while(cin >> n >> m >> z, n){
        int g[55][55]{};
        for(int i=0;i<m;i++){
            int s, d;
            cin >> s >> d;
            s--; d--;
            g[s][d] = 1;
            g[d][s] = 1;
        }
        mat A(n*n);

        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    for(int l=0;l<n;l++){
                        if(j != k && i==l){
                            A[i*n+j].push_back(g[i][k]);
                        }
                        else{
                            A[i*n+j].push_back(0);
                        }
                    }
                }
            }
        }
        vec ls;
        for(int i=n-1;i>=0;i--){
            for(int j=n-1;j>=0;j--){
                if(i==0 && j==0)continue;
                if(g[i][j]==0){
                    A.erase(A.begin()+i*n+j);
                    for(auto &v : A){
                        v.erase(v.begin()+i*n+j);
                    }
                }
                else{
                    ls.push_back(i);
                }
            }
        }
        ls.push_back(0);
        reverse(ls.begin(), ls.end());
        /*
        for(auto v:A){
            for(auto i:v){
                cout << i << " ";
            }
            cout << endl;
        }
        */
        mat ans = pow(A, z);
        bool ok = false;
        for(int i=0;i<int(ans.size());i++){
            if(ls[i]==n-1 && ans[0][i]>0){
                ok = true;
            }
        }

        cout << (ok?"yes":"no") << endl;

    }
    return 0;
}


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

int main(){
  int a,b,k,work,tmp;
  cin >> a >> b >> k;
  work = min(b-a,k);
  if(work == 0){
    cout << a << endl;
    return 0;
  }
  tmp = 0;
  vector<int> A(work),B(work);
  for(int i = 0;i < work;i++){
    A.at(i) = a++;
    B.at(i) = b--;
  }
  reverse(B.begin(),B.end());
  for(int i = 0;i < work;i++){
    if(A.at(i) > b){
      tmp = A.at(i-1);
      break;
    }else{
    cout << A.at(i) << endl;
    }
  }
  for(int j = 0;j < work;j++){
    if(B.at(j) < tmp){
      continue;
    }else{
      cout << B.at(j) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0 && c>0)
  {
    c= c-b;
    a= a-d;
    if(c<=0)
    {
     cout<<"Yes";
      break;
    }
    if(a<=0)
    {
      cout<<"No";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int N,b,cnt,tmp;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N;
    for(int i=1;i<=N;i++){
        int x;
        cin>>x;
        if(b){
            cnt++;
            x=tmp;
        }
        b=(i==x);
        tmp=x;
    }
    cout<<cnt+b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main () {
    ll x, k, d;
    cin >> x >> k >> d;
    ll ret;
    if (x < 0) x *= (-1);
    if (x >= 0) {
        if (x / k >= d)  {
            ret = x - d * k;
        } 
        else if (((k - x / d) % 2 == 0)) {
            ret = x % d;
        }
        else {
            ret = d - x % d;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){

	int n=0,count=0;
	int f=0,x=0,as=0,bs=0;
	int flag=0;
	int a[204]={0};
	int b[204]={0};
	cin >> n;
	if(n==0)break;
	as=n;
	bs=n;
	for(int i=0;i<n;i++){
        cin >> a[i];
        }
    sort(a,a+n);
   // for(int i=0;i<n;i++)cout << "--"<<a[i]<<endl;
    for(int j=1;j<=2*n;j++){
        flag=0;
        for(int i=0;i<n;i++){
            if(a[i]==j)flag=1;
        }
        if(flag==0)b[count]=j,count++;
    }
    f=0;
    for(;;){

        flag=0;
        for(int i=0;i<n;i++){

            if(a[i]>f){
                f=a[i];
              //  cout << "..."<<f<<endl;
                a[i]=0;
                flag =1;
                as--;
                break;
            }

        }
        if(as==0)break;
        if(flag==0){
            f=0;
        //    cout << "..."<<f<<endl;
            }
        flag=0;

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

            if(b[i]>f){
                f=b[i];
              //  cout << "..."<<f<<endl;
                b[i]=0;
                flag =1;
                bs--;
                break;
            }

        }
        if(bs==0)break;
        if(flag==0){
         //   cout << "..."<<f<<endl;
            f=0;
            }
        }

        cout << bs << endl << as << endl;
    }
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
const int MOD = 1e9 + 7, N = 40, L = 17;
int n, x, y, z, f[ N + 1 ][ 1 << L ];
int main( )
{
 std::ios::sync_with_stdio( false );
 std::cin >> n >> x >> y >> z;
 int mx = ( 1 << ( x + y + z ) ) - 1, ans = 1;
 int haiku = ( 1 << x + y + z >> 1 ) | ( 1 << y + z >> 1 ) | ( 1 << z >> 1 );
 f[ 0 ][ 0 ] = 1;
 for( int i = 0; i < n; ++i, ans = ans * 10LL % MOD )
 {
  for( int s = 0; s <= mx; ++s )
  {
   if( !f[ i ][ s ] )
    continue;
   for( int j = 1; j <= 10; ++j )
   {
    int trs = ( s << j | ( 1 << j >> 1 ) ) & mx;
    if( ( trs & haiku ) ^ haiku )
     f[ i + 1 ][ trs ] = ( f[ i + 1 ][ trs ] + f[ i ][ s ] ) % MOD;
   }
  }
 }
 int sub = 0;
 for( int i = 0; i <= mx; ++i )
  sub = ( sub + f[ n ][ i ] ) % MOD;
 std::cout << ( ans - sub + MOD ) % MOD;
 return 0;
}

Measured memory_bytes: 22268
#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 ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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 GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    ll n;cin >> n;
    ll ans = INF;
    for(ll i=1;i*i<=n;i++){
        if(n%i!=0)continue;
        chmin(ans,n/i+i-2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
void __dump(int x){cerr << x;}
void __dump(long long x){cerr << x;}
void __dump(long double x){cerr << fixed << setprecision(3) << x;}
void __dump(char x){cerr << '\'' << x << '\'';}
void __dump(const string &x){cerr << '"' << x << '"';}
void __dump(const char *x){cerr << '"' << x << '"';}
void __dump(bool x){cerr << (x ? "true" : "false");}
void _dump(){cerr << "\n";}
template <typename T, typename U> void __dump(const pair<T, U> &x){cerr << '{'; __dump(x.first); cerr << ','; __dump(x.second); cerr << '}';}
template <typename T, typename U, typename V> void __dump(const tuple<T, U, V> &x){cerr << '{'; __dump(get<0>(x)); cerr << ',';  __dump(get<1>(x)); cerr << ',';  __dump(get<2>(x)); cerr << '}';}
template <typename T> void __dump(const T& x){int f=0; cerr << '{'; for(auto&i:x) cerr << (f++ ? "," : ""), __dump(i); cerr << "}";}
template <typename T, typename ... U> void _dump(T t, U ... u){__dump(t); if(sizeof...(u)) cerr << ", "; _dump(u...);}
#define dump(x ...) cerr  <<  "|| "  <<  # x  <<  "  =  ", _dump(x) 
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define __ ' '
#define LL long long
#define LD long double
#define pii pair<int,int>
const int INF = 2e9;
const int N = 2e4;
const int X = 3e4;
int n;
vector<int> nums;
int sum;

int main(){ FAST
	cin >> n;

	if(n == 3){
		nums = {2, 3, 25};
	}
	else if(n == 4){
		nums = {2, 3, 4, 9};
	}
	else if(n == 5){
		nums = {2, 3, 4, 6, 9};
	}
	else{
		for(int i=2; i<=X; ++i) if(size(nums) < n && (i%2 == 0 || i%3 == 0)) nums.emplace_back(i);

		for(int x: nums) sum += x;

		int replace = -1;
		int add = -1;

		assert(sum %6 != 1);
		if(sum %6 == 2) replace = 8, add = 0;
		else if(sum %6 == 3) replace = 9, add = 0;
		else if(sum %6 == 4) replace = 4, add = 0;
		else if(sum %6 == 5) replace = 9, add = 4;

		if(replace != -1){
			auto it = find(all(nums), replace);
			assert(it != nums.end());
			nums.erase(it);

			int cur = nums.back()+1;
			while(!(cur %6 == add)) ++cur;
			
			nums.emplace_back(cur);
		}
	}

	assert(size(nums) == n);
	assert(nums.back() <= X);

	for(int x: nums) cout << x << __;
	cout << ln;

}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
void next_lunlun(string &N) {
	bool inc = true;
	for (int i = 1; i < N.size(); ++i) inc = inc && N[i] > N[i - 1];
	if (inc) {
		if (N[0] != '9') {
			++N[0];
			for (int i = 1; i < N.size(); ++i) N[i] = max((char) (N[i - 1] - 1), '0');
			return;
		}
	} else {
		for (int i = N.size() - 1; i > 0; --i) {
			if (N[i] <= N[i - 1] && N[i] != '9') {
				++N[i];
				for (int j = i + 1; j < N.size(); ++j) N[j] = max((char) (N[j - 1] - 1), '0');
				return;
			}
		}
		if (N[0] != '9') {
			++N[0];
			for (int i = 1; i < N.size(); ++i) N[i] = max((char) (N[i - 1] - 1), '0');
			return;
		}
	}
	N = "1" + N;
	for (int i = 1; i < N.size(); ++i) N[i] = '0';
}
int main() {
	int K;
	scanf("%d", &K);
	string lunlun = "0";
	for (int i = 0; i < K; ++i) next_lunlun(lunlun);
	printf("%s\n", lunlun.c_str());
	return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Mon Sep 23 18:52:34 2019
//
package main

import "fmt"

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

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)

	dp := make([][]int, n)
	for i := range dp {
		dp[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		if s[i] == s[n-1] {
			dp[i][n-1] = 1
			dp[n-1][i] = 1
		}
	}

	for i := n - 2; i >= 0; i-- {
		for j := n - 2; j >= 0; j-- {
			if s[i] == s[j] {
				dp[i][j] = dp[i+1][j+1] + 1
			}
		}
	}

	ans := 0
	for i := range dp {
		for j := range dp[i] {
			ans = max(ans, min(dp[i][j], i-j))
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 208056
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

map<char,char> mp;
int main(){
    mp['A']='T';
    mp['T']='A';
    mp['G']='C';
    mp['C']='G';
    char b; cin>>b;
    cout<<mp[b]<<endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
import math
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
res = 0
for v in itertools.combinations(x, 2):
    dist = 0
    for i in range(d):
        dist += abs(v[0][i]-v[1][i])**2
    if math.sqrt(dist).is_integer():
        res += 1
print(res)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

const int MAX = 200010;

ll mod(ll a, ll b) {
    ll ret = a % b;
    if (ret < 0) ret += b;
    return ret;
}

int f(ll n) {
    int ret = 0;
    while (n > 0) {
        ret++;
        n %= __builtin_popcount(n);
    }
    return ret;
}

int main() {
    int n; cin >> n;
    string x; cin >> x;

    bitset<MAX> bt(x), bs(x);
    int popx = bs.count();

    if (popx == 0) {
        rep(i, n) cout << 1 << endl;
        return 0;
    }

    ll MOD1 = popx + 1;
    ll MOD2 = popx - 1;
    if (popx == 1) MOD2 = 1;

    // pow1[i] = 2^i mod (popx + 1)
    // pow2[i] = 2^i mod (popx - 1)
    vector<ll> pow1(n, 1), pow2(n, 1);
    for (int i = 1; i < n; i++) {
        pow1[i] = mod(2 * pow1[i-1], MOD1);
        pow2[i] = mod(2 * pow2[i-1], MOD2);
    }

    // x1 = X mod (popx + 1)
    // x2 = X mod (popx - 1);
    ll x1 = 0, x2 = 0;
    for (int i = 0; i < n; i++) {
        x1 += pow1[i] * (x[n-i-1] - '0');
        x2 += pow2[i] * (x[n-i-1] - '0');
    }

    vector<int> ans(n);
    // 下から調べる
    rep(i, n) {
        // x + 2^i % MOD1
        if (x[n-i-1] == '0') {
            ll next = mod(x1 + pow1[i], MOD1);
            ans[i] = 1 + f(next);
        } else {
            if (popx == 1) {
                ans[i] = 0;
            } else {
                ll next = mod(x2 - pow2[i], MOD2);
                ans[i] = 1 + f(next);
            }
        }
    }

    repr(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 7616
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
b=[]
for i in range(n):
    b.append(list(map(int,input().split())))
b.sort()
a=sorted(a,key=lambda x: -x[1])
ans=0
vb=[]
for i in range(n):
    for j in range(n):
        if not j in vb:
            if a[i][0]<b[j][0] and a[i][1]<b[j][1]:
                vb.append(j)
                ans+=1
                break
print(ans)


Measured memory_bytes: 39152
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#define endl '\n'
using namespace std;
int main()
{
	int n,d,x;
	cin>>n>>d>>x;
	int v[101];
	for(int i = 0; i<n; i++)
		cin>>v[i];
	int tot = 0;
	for(int stu = 0; stu<n; stu++){
		int a = 1,b = v[stu];
		tot++;
		while(a <= d){
			v[stu]=a+b;
			if(v[stu]<=d)tot++,a = v[stu];
			else break;
		}
	}
	cout<<tot+x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  int n, m, k, z = 0;
  ll a[200005] = {}, b[200005] = {};
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1];
  for (int i = 1; i <= m; i++) cin >> b[i], b[i] += b[i - 1];
  for (int i = 0; i <= n; i++) if (a[i] <= k) {
    int l = 0, r = m + 1;
    while (l + 1 < r) {
      int x = (l + r) / 2;
      if (a[i] + b[x] <= k) l = x;
      else r = x;
    }
    z = max(z, i + l);
  }
  cout << z << '\n';
}



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

using namespace std;
using ii = pair<int, int>;

const int MAX { 2010 };

vector<ii> rs[MAX];

int rows[MAX][MAX], cols[MAX][MAX];

int solve(int H, int W, const vector<string>& xs)
{
    for (int i = 0; i < H; ++i)
    {
        int L = 0;

        while (L < W)
        {
            if (xs[i][L] == '#')
            {
                ++L;
                continue;
            }

            auto R = L + 1;

            while (R < W and xs[i][R] != '#')
                ++R;

            for (int k = L; k < R; ++k)
                rows[i][k] = (R - L);

//cout << "row " << i << ", [" << L << ", "  << R << "], size = " << R - L << endl;
            L = R + 1;
        }
    }

    for (int i = 0; i < W; ++i)
    {
        int L = 0;

        while (L < H)
        {
            if (xs[L][i] == '#')
            {
                ++L;
                continue;
            }

            auto R = L + 1;

            while (R < H and xs[R][i] != '#')
                ++R;

            for (int k = L; k < R; ++k)
                cols[k][i] = (R - L);

//cout << "col " << i << ", [" << L << ", "  << R << "], size = " << R - L << endl;
            L = R + 1;
        }
    }

    int ans = 0;

    for (int x = 0; x < H; ++x)
        for (int y = 0; y < W; ++y)
            ans = max(ans, rows[x][y] + cols[x][y] - 1);

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;

    vector<string> xs(H);

    for (int i = 0; i < H; ++i)
        cin >> xs[i];

    auto ans = solve(H, W, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 36096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    //
    vector<vector<int>> A(3, vector<int>(3));

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> A[i][j] ;
        }
    }
    //
    int N;
    cin >> N;
    //
    vector<int> B(N);
    
    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    //
    //for judge vector 
    vector<vector<int>> Judge(3, vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
             Judge[i][j]=0 ;    // 0 label
        }
    }
    //
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if( B[i] == A[j][k]){
                    Judge[j][k] = 1;
                }
            }
        }
    }
    // 1
    if(((Judge[0][0]==1)&&(Judge[1][0]==1))&&(Judge[2][0]==1)){
        cout << "Yes" << endl;
    }
    else if(((Judge[0][1]==1)&&(Judge[1][1]==1))&&(Judge[2][1]==1)){
        cout << "Yes" << endl;
    }
    else if(((Judge[0][2]==1)&&(Judge[1][2]==1))&&(Judge[2][2]==1)){
        cout << "Yes" << endl;
    }
    // 2
    else if(((Judge[0][0]==1)&&(Judge[0][1]==1))&&(Judge[0][2]==1)){
        cout << "Yes" << endl;
    }
    else if(((Judge[1][0]==1)&&(Judge[1][1]==1))&&(Judge[1][2]==1)){
        cout << "Yes" << endl;
    }
    else if(((Judge[2][0]==1)&&(Judge[2][1]==1))&&(Judge[2][2]==1)){
        cout << "Yes" << endl;
    }
    // 3
    else if(((Judge[0][0]==1)&&(Judge[1][1]==1))&&(Judge[2][2]==1)){
        cout << "Yes" << endl;
    }
    else if(((Judge[2][0]==1)&&(Judge[1][1]==1))&&(Judge[0][2]==1)){
        cout << "Yes" << endl;
    }
    //
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3608
n, m = map(int, input().split())
ans = 0
box = [1] * n
flag = [False] * n
flag[0] = True
for i in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    box[x] -= 1
    box[y] += 1
    if flag[x]:
        flag[y] = True
    if box[x] == 0:
        flag[x] = False
print(sum(flag))

Measured memory_bytes: 4596
#include"iostream"
#include<stdio.h>
#include"string.h"
using namespace std;
int main(void) {
	string a;
	int b = 0;
	cin >> a;
	for (int i = 0 ;  i < (int)(a.length()) / 2 ; i++) {
    	if (a.at(i)!= a.at(a.length() - i-1)) {
			b++;
		}
	 }
	 cout << b;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;


int main() {
    
    
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> m0;
    map<int, int> m1;
    
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
        if (i % 2)
        {
            m1[v[i]]++;
        }
        else
        {
            m0[v[i]]++;
        }
    }
    
    vector<pair<int, int>> mpv0;
    vector<pair<int, int>> mpv1;
    
    for (auto itr = m0.begin(); itr != m0.end(); ++itr)
    {
        mpv0.push_back(make_pair((n / 2) - itr->second, itr->first));
    }
    
    for (auto itr = m1.begin(); itr != m1.end(); ++itr)
    {
        mpv1.push_back(make_pair((n / 2) - itr->second, itr->first));
    }
    
    sort(mpv0.begin(), mpv0.end());
    sort(mpv1.begin(), mpv1.end());
    
    int ret = mpv0[0].first + mpv1[0].first;
    if (mpv0[0].second == mpv1[0].second)
    {
        if (mpv0.size() < 2 || mpv1.size() < 2)
        {
            ret = min(mpv0[0].first + (n / 2), (n / 2) + mpv1[0].first);
            if (mpv0.size() >= 2)
            {
                ret = min(ret, mpv0[1].first + mpv1[0].first);
            }
            if (mpv1.size() >= 2)
            {
                ret = min(ret, mpv1[1].first + mpv0[0].first);
            }
        }
        else
        {
            ret = min(mpv0[0].first + mpv1[1].first, mpv0[1].first + mpv1[0].first);
        }
    }
    
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 6520
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d", &N);

	int i, cnt = 0;
	for (i = 1; i <= N; i++) {
		int p;
		scanf("%d", &p);
		if (i != p)
			cnt++;
	}
	puts(cnt <= 2 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 128
object Main extends App {	
  val in = readLine.split(" ").map(_.toInt).toList.sorted
  
  def seracheCost(list: List[Int], exe: Int, count: Int): Int = list match {
  	case Nil => count
    case head :: tail => seracheCost(tail, head, count + head - exe)
  }
  
  println(seracheCost(in.tail, in.head, 0))
}

Measured memory_bytes: 27336
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
typedef long long int ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define FOREQ(i, a, b) for (int i = (a); i <= (b); i++)
#define REPEQ(i, n) FOREQ(i, 0, n)

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D)
    {
        cout << "Left" << endl;
    }
    else if (A + B < C + D)
    {
        cout << "Right" << endl;
    }
    else
    {
        cout << "Balanced" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
s = [i for i in input()]
animal = ['S','W']

for x in animal:
    ans = [i for i in range(N)]
    ans[-1] = x

    for y in animal:
        ans[0] = y
        for i in range(N):
            if (s[i] == 'o' and ans[i] == 'S') or (s[i] == 'x' and ans[i] == 'W'):
                if i < N-2:
                    ans[i+1] = ans[i-1]
                elif i == N-2:
                    if ans[i-1] != ans[-1]:
                        break
                elif i == N-1:
                    if ans[i-1] == ans[0]:
                        print(''.join(ans))
                        sys.exit()
            elif (s[i] == 'x' and ans[i] == 'S') or (s[i] == 'o' and ans[i] == 'W'):
                if i < N-2:
                    if ans[i-1] == 'S':
                        ans[i+1] = 'W'
                    elif ans[i-1] == 'W':
                        ans[i+1] = 'S'
                elif i == N-2:
                    if ans[i-1] == ans[-1]:
                        break
                elif i == N-1:
                    if ans[i-1] != ans[0]:
                        print(''.join(ans))
                        sys.exit()

print(-1)


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


int main(){

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;


	vector<int>r(a), g(b), h(c);

	priority_queue<int>pq;


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

	for(int i=0; i<b; i++) cin >> g[i];

	for(int i=0; i<c; i++) cin >> h[i];
	

	sort(r.rbegin(), r.rend());	
	sort(g.rbegin(), g.rend());	
	sort(h.rbegin(), h.rend());
	

	for(int i=0; i<x; i++)pq.push(-r[i]);
	
	for(int i=0; i<y; i++)pq.push(-g[i]);

	
	for(int i=0; i<c; i++){
		int t = -pq.top();
		
		if(h[i] > t){
			pq.pop();
			pq.push(-h[i]);
		}

	}	


	long long ans = 0;

	while(!pq.empty()){
		ans += -pq.top();
		pq.pop();
	}

	cout << ans << endl;


	return 0;
} 


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch) {
    if (ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    else return 0;
}

// 文字列から数値へ変換してkeyを生成する
long long getKey(char str[]) {
    long long sum=0, p=1, i;
    for (i=0; i<strlen(str); i++) {
        sum += p*getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1+key%(M-1); }

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i=0; ; i++) {
        h = (h1(key) + i+h2(key)) % M;
        if( strcmp(H[h], str) == 0) return 1;
        else if( strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i=0; ; i++) {
        h = (h1(key) + i+h2(key)) % M;
        if( strcmp(H[h], str) == 0) return 1;
        else if( strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i=0; i<M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%s %s", com, str);
        
        if(com[0] == 'i') {
            insert(str);
        } else {
            if(find(str)) {
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int v[n + 5] = {};
    f1(n) {
        cin >> v[i];
    }
    for (int i = 0 ; i < m ; i++) {
        int del[n + 5] = {};
        for (int j = 1 ; j <= n ; j++) {
            del[max(j - v[j],1)]++;
            del[min(j + v[j]+1,n+1)]--;
        }
        int cur = 0;
        int f = 0;
        for (int j = 1 ; j <= n ; j++) {
            //cout << del[j] << endl;
            cur += del[j];
            v[j] = cur;
            if (cur != n) {
                f = 1;
            }
        }
        if (!f) {
            break;
        }
        //cout << "here"<<i << endl;
    }
    f1(n) {
        cout << v[i] <<' ';
    }
    cout << '\n';
}

Measured memory_bytes: 5176