akhauriyash/Code-Regression huggingface dataset:
#UnionFindクラス
class UnionFind:

  def __init__(self,n):
    self.par =  [-1 for _ in range(n)]

  # xの根を返す
  def root(self, x):
    if self.par[x] < 0:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  
  # xとyの根を結合させる
  def merge(self, x, y):
    x = self.root(x)
    y = self.root(y)
    if x != y:
      if self.par[x] > self.par[y]:
        x, y = y, x
      self.par[x] += self.par[y]
      self.par[y] = x
  
  # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）
  def is_same(self, x, y):
    return self.root(x) == self.root(y)

  # xが含まれる木の要素数を返す
  def get_size(self, x):
    return -self.par[self.root(x)]
    
n,m = map(int,input().split())
info = [list(map(int,input().split())) for i in range(m)]
uf = UnionFind(n)
ans = [0]*m
ans_ =0

for i in range(n):
  ans_ = ans_+i
  
ans[m-1]= ans_
for i in range(1,m)[::-1]:
  if uf.is_same(info[i][0]-1,info[i][1]-1):
    ans[i-1] = ans[i] 
  else:
    ans[i-1] = ans[i]-uf.get_size(info[i][0]-1)*uf.get_size(info[i][1]-1)
    uf.merge(info[i][0]-1,info[i][1]-1)
for i in range(m):
  print(ans[i])

Measured memory_bytes: 34632
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    using P = pair<int, int>;
    vector<vector<int>> v(4, vector<int>(4, 0));
    for (int i = 0; i < 3; ++i) {
        int a, b;
        cin >> a >> b;
        v[a-1][b-1] = v[b-1][a-1] = 1;
    }
    vector<int> s = {0, 1, 2, 3};
    do {
        int x = 1;
        for (int i = 0; i < 3; ++i) {
            x &= v[s[i]][s[i+1]];
        }
        if(x) {
            puts("YES");
            return 0;
        }
    }while(next_permutation(s.begin(), s.end()));
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll a,b;cin>>a>>b;
  cout<<(a-1)*(b-1)<<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(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main(){
  ll a;
  string b;
  cin >> a >> b;
  string k=b.substr(0,1)+b.substr(2,2);
  int c=stoi(k);
  a*=c;
  cout << a/100 << endl;
}


Measured memory_bytes: 3628
import scala.io.StdIn.readLine

object Main {
  def main(args:Array[String]) = {
    val s1 = readLine
    val s2 = readLine
    for(i<-0 to s1.length-s2.length)
      if(s1(i)==s2(0))
        if(s1.slice(i,i+s2.length)==s2)
          println(i)
  }
}

Measured memory_bytes: 43908
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    double ans;
    double a;
    if(n==1)
    {
        printf("1.0000000000");
    }
    else if(n%2==0)
    {
        printf("0.5000000000\n");
    }
    else if(n%2==1)
    {
        a= n/2 + 1;
        ans= a/n;
        printf("%.7lf\n",ans);
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int H,W;
	scan(H>>W);
	rep(i,H){
		rep(j,W){
			string S;
			scan(S);
			if(S=="snuke"){
				printf("%c%d\n",'A'+j,i+1);
				return 0;
			}

		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 100005;
const int MM = 1000000007;

int A[MX];
int N;

struct BIT{
	int t[MX*2];
	int read(int x){
		int r = 0;
		while(x) r += t[x], x -= x&-x;
		return r;
	}
	int update(int x, int v){
		while(x < MX*2) t[x] += v, x += x&-x;
	}
} tree;

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", A+i);
	int s = 0, e = 1e9;
	while(s <= e){
		int m = (s+e) / 2;
		for(int i = 0; i < MX*2; i++) tree.t[i] = 0;
		int pr = 0;
		ll tot = 0;
		
		for(int i = 1; i <= N; i++){
			tree.update(N+pr, 1);
			pr += A[i] >= m? 1 : -1;
			tot += tree.read(N+pr);
		}
		tot = (ll)N*(N+1)/2 - tot;
		if(tot >= (ll)N*(N+1)/2/2+1) e = m-1;
		else s = m+1;
	}swap(s, e);
	printf("%d\n", s);
}


Measured memory_bytes: 1408
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
constexpr int MAX = 50;
struct Edge {int to; int cost;};

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    
    vector<vector<Edge>> g(MAX + 1);
    rep(i, 1, MAX + 1) rep(j, 1, MAX + 1) {
        g[j].push_back(Edge{j % i, i});
    }
    vector<bool> use(MAX + 1, true);
    
    auto bfs = [&](int v) -> vector<bool> {
        vector<bool> searched(MAX + 1, false);
        queue<int> que;
        searched[v] = true;
        que.push(v);
        while (!que.empty()) {
            int u = que.front();
            que.pop();
            for (auto e: g[u]) {
                if (!use[e.cost]) continue;
                if (searched[e.to]) continue;
                searched[e.to] = true;
                que.push(e.to);
            }
        }
        return searched;
    };
    
    rep(i, n) {
        vector<bool> vec = bfs(a[i]);
        if (!vec[b[i]]) {
            cout << "-1\n";
            return 0;
        }
    }
    
    ll ans = 0;
    for (int i = MAX; i >= 1; --i) {
        use[i] = false;
        bool f = true;
        rep(j, n) {
            vector<bool> vec = bfs(a[j]);
            if (!vec[b[j]]) f = false;
        }
        if (!f) {
            use[i] = true;
            ans += (1LL << i);
        }
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	int n, k;;
	cin >> n >> k;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	int ans = 0;
	rep(i, n + 1) rep(j, n - i + 1) {
		int rest = k - i - j;
		if (rest < 0) continue;
		deque<int> q(v.begin(), v.end());
		priority_queue<int> poppen;
		int tans = 0;
		rep(k, i) {
			int t = q.front(); q.pop_front();
			tans += t;
			poppen.push(-t);
		}
		rep(k, j) {
			int t = q.back(); q.pop_back();
			tans += t;
			poppen.push(-t);
		}
		rep(k, rest) {
			if (poppen.empty()) break;
			int t = -poppen.top();
			if (t < 0) {
				tans -= t;
				poppen.pop();
			} else break;
		}
		chmax(ans, tans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n;

const int MAX = 100000;
bool IsPrime[MAX];
vector<int> Era(int n = MAX) {
    vector<int> res;
	IsPrime[0] = false; IsPrime[1] = false; 
	for (int i = 2; i < n; ++i) IsPrime[i] = true;
	for (int i = 2; i < n; ++i) {
		if (IsPrime[i]) {
            res.push_back(i);
			for (int j = i*2; j < n; j += i) IsPrime[j] = false;
		}
	}
    return res;
}


int main() {
    vint prime = Era();
    while (cin >> n) {
        int it = lower_bound( ALL(prime), n ) - prime.begin();
        if ( prime[it] == n ) {
            cout << prime[it-1] << " " << prime[it+1] << endl;
        }
        else {
            cout << prime[it-1] << " " << prime[it] << endl;
        }
    }
    
    return 0;
}


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

int charToInt( char a ){
  return (int)( a-'A' );
}

int compareHex( char a, char b ){
  int numA = charToInt(a);
  int numB = charToInt(b);
  if( numA==numB )
    return 0;
  if( numA < numB )
    return -1;
  return 1;
}

int main(){
  char a, b;
  cin >> a >> b;
  int result = compareHex( a, b );
  if( result == 0 ){
    cout << "=";
  }else if( result == -1 ){
    cout << "<";
  }else{
    cout << ">";
  }
  cout << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
int n, cnt;
int dp[51][51][2501];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	cin >> n >> cnt;
	dp[0][0][0] = 1;
	rep(i, n) rep(j, n + 1) rep(k, cnt + 1) if(dp[i][j][k]){
		if(k + 2 * j <= cnt) (dp[i + 1][j][k + 2 * j] += (2ll * j + 1) * dp[i][j][k] % mod) %= mod;
		if(k + 2 * j + 2 <= cnt && j < n) (dp[i + 1][j + 1][k + 2 * j + 2] += dp[i][j][k]) %= mod;
		if(k + 2 * j - 2 <= cnt && j) (dp[i + 1][j - 1][k + 2 * j - 2] += (ll)j * j * dp[i][j][k] % mod) %= mod;
	}
	cout << dp[n][0][cnt] << endl;
	return 0;
}

Measured memory_bytes: 23552
#include<iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int cnt = 0;
    while (n != 0) {
        if (n % 10 == 2) {
            cnt++;
        }
        n /= 10;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner


object Main {

  case class ResidueRing(private val input: Long) {
    val representative: Long = ((input % ResidueRing.mod) + ResidueRing.mod) % ResidueRing.mod

    def +(that: ResidueRing): ResidueRing = ResidueRing(this.representative + that.representative)

    def -(that: ResidueRing): ResidueRing = ResidueRing(this.representative - that.representative)

    def *(that: ResidueRing): ResidueRing = ResidueRing(this.representative * that.representative)

    def unary_- : ResidueRing = ResidueRing(-this.representative)

  }

  object ResidueRing {
    val mod: Long = (1e9 + 7).toLong
    val zero: ResidueRing = ResidueRing(0)
    val one: ResidueRing = ResidueRing(1)
  }

  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val s = sc.next()
    (n, s)
  }

  def solve(n: Int, s: String): Long = {
    // 1 <= n <= 100,000
    val si = s.map(c => c - 'a')
    // 'a', 'b', ..., 'z' => 0, 1, ..., 25
    val nAlphabets = 26
    val countArray: Array[Int] = Array.fill(nAlphabets)(0)
    for (i <- si) {
      countArray(i) += 1
    }
    val result = countArray.map(i => ResidueRing(i)).map(r => r + ResidueRing.one).foldLeft(ResidueRing.one)(_ * _) - ResidueRing.one
    result.representative
  }

  def main(args: Array[String]): Unit = {
    val (n, s) = read()
    println(solve(n, s))
  }
}

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

typedef long long ll;

string printPath(vector<vector<int>>& path, string& b, int i, int j)
{
	if(!i || !j)
		return "";
	if(path[i][j] == 1)
	{
		auto temp = printPath(path, b, i-1, j-1) + string(1,b[j-1]);
		// cout << "i: " << i << " j: " << j << " " << temp << endl;
		return temp;
	}
	else if(path[i][j] == 0)
		return printPath(path, b, i, j-1);
	else
		return printPath(path, b, i-1, j);
}

int main()
{
	string a, b;
	cin >> a >> b;
	vector<vector<int>> dp_arr(a.length()+1,vector<int>(b.length()+1,0));
	vector<vector<int>> path(a.length()+1,vector<int>(b.length()+1,0));
	for(int i = 0; i <= a.length(); i++)
	{
		for(int j = 0; j <= b.length(); j++)
		{
			if(i == 0)
				dp_arr[i][j] = 0;
			else if(j == 0)
				dp_arr[i][j] = 0;
			else if(a[i-1] == b[j-1])
			{
				dp_arr[i][j] = 1 + dp_arr[i-1][j-1];
				path[i][j] = 1;
			}
			else
			{
				if(dp_arr[i-1][j] > dp_arr[i][j-1])
				{
					dp_arr[i][j] = dp_arr[i-1][j];
					path[i][j] = 2;
				}
				else
				{
					dp_arr[i][j] = dp_arr[i][j-1];
					path[i][j] = 0;					
				}
			}
		}
	}
	// for(auto i : path)
	// {
	// 	for(auto j : i)
	// 		cout << j << " ";
	// 	cout << endl;
	// }
	cout << printPath(path, b, a.length(), b.length());
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;
string s;
const int mod = 1e9 + 7;
const int N = 13;
ll a[N]; // remainder 0 - 12
ll b[N];

int main() {
    cin >> s;
    int n = s.length();
    a[0] = 1;
    for (int k = 0; k < n; ++k) {
        if (s[k] == '?') {
            for (int i = 0; i < N; ++i) {
                for (int j = 0; j < 10; ++j) {
                    int cur = (i * 10 + j) % N;
                    b[cur] += a[i];
                }
            }
        } else {
            int o = s[k] - '0';
            for (int i = 0; i < N; ++i) {
                int cur = (i * 10 + o) % N;
                b[cur] += a[i];
            }
        }
        for (int i = 0; i < N; ++i) {
            a[i] = b[i] % mod;
        }
        memset(b, 0, sizeof b);
    }
    cout << a[5] << endl;
    return 0;
}


Measured memory_bytes: 3736
#include<stdio.h>
#include<string.h>
int main(void){
  
char s[100001];
  scanf("%s",&s);
  int len=strlen(s);
  char ss[500001];
  
  for(int i=200000;i<len+200000;i++){
    ss[i]=s[i-200000];
    //printf("%c",ss[i]);
  }
  //printf("\n");
 int top=200000;
 int tail=200000+len-1;
  
  int q;
  scanf("%d",&q);
  int t[q+1],f[q+1];
  char c[q+1];
  for(int i=0;i<q;i++){
scanf("%d",&t[i]);
    if(t[i]==2){
      scanf("%d %c",&f[i],&c[i]);
    }
   // printf("t[%d]=%d,f[%d]=%d,c[%d]=%c\n",i,t[i],i,f[i],i,c[i]);
  }
     
  int flag=0;  // flag=0:順方向,flag=1:逆方向
  for(int i=0;i<q;i++){
    //printf("%d回目\n",i);
    if(t[i]==1){//反転
      flag=1-flag;
    /* for(int j=0;j<len/2;j++){
      char w=s[j];
       s[j]=s[len-1-j];
       s[len-1-j]=w;
    }*/
    }
    
    if(t[i]==2){
      if(f[i]==1){  //先頭に挿入	
        if(flag==0){
          top--;
          ss[top]=c[i];
        }
         else {
           tail++;
           ss[tail]=c[i];
         }
      }
      else if(f[i]==2){
        if(flag==0){
          tail++;
           ss[tail]=c[i];
        }
        else{
          top--;
          ss[top]=c[i];
        }
      }
    }
  }
     if(!flag){
       for(int i=top;i<=tail;i++){
         printf("%c",ss[i]);
       }
     }
    else {
      for(int i=tail;i>=top;i--){
        printf("%c",ss[i]);
       }
     }
  
    return 0;
  }
           
          

Measured memory_bytes: 2560
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n; 


signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        
    cin >> n;
    if(n%2==0){
    	n--;
    }
    cout << (n/2) << endl;

return 0;
}
///....


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

int main(){
    int n, c, ans=0;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v.at(i);
    for(int i = 0; i < n; i++){
        cin >> c;
        if(v.at(i)>c) ans += v.at(i)-c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
import numpy as np

def get_rotation_matrix(rad):
    """ 
    指定したradの回転行列を返す
    """
    rot = np.array([[np.cos(rad), -np.sin(rad)],
                  [np.sin(rad), np.cos(rad)]])
    return rot

A, B, H, M = map(int, input().split())

tan = np.array([0, A])
chou = np.array([0, B])

tanrot = get_rotation_matrix(((-30*H-0.5*M)*np.pi)/180) #分にも影響される
chourot = get_rotation_matrix(((-6*M)*np.pi)/180)

tan = np.dot(tanrot, tan)
chou = np.dot(chourot, chou)
zero = np.array([0, 0])

print(np.linalg.norm(chou-tan))

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

typedef long long ll;
int x;
int main()
{
	scanf("%d",&x);
	if (x<1200)	printf("ABC\n");else
	if (x<2800)	printf("ARC\n");else
	printf("AGC\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int X, Y, N, M, L;
  cin>>X>>Y>>N>>M>>L;
  vector<Int> A(N);
  cin>>A;
  vector<Int> B(M);
  cin>>B;
  vector<Int> C(L);
  cin>>C;

  multiset<Int> SA;
  for(Int a:A) SA.insert(a);
  multiset<Int> SB;
  for(Int b:B) SB.insert(b);
  priority_queue<Int> SC;
  for(Int c:C) SC.push(c);

  while((Int)SA.size() > X) SA.erase(SA.begin());
  while((Int)SB.size() > Y) SB.erase(SB.begin());

  while(!SC.empty()){
    Int c = SC.top(); SC.pop();
    if((Int)SA.size() < X) SA.insert(c);
    else if((Int)SB.size() < Y) SB.insert(c);
    else{
      Int a = *SA.begin();
      Int b = *SB.begin();
      if(a < b) SA.insert(c), SA.erase(SA.begin());
      else SB.insert(c), SB.erase(SB.begin());
    }
  }

  Int ans = 0;
  for(auto a:SA) ans += a;
  for(auto b:SB) ans += b;
  cout<<ans<<endl;



  return 0;
}


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

def is_valid_ID(S, T):
    if S == T[:-1]: return True
    else:  return False

def main():
    S = input()
    T = input()
    if is_valid_ID(S, T): print("Yes")
    else:  print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 8940
S = input()
Q = int(input())
count = 0
right = ''
left = ''
for i in range(Q):
    arr = list(input().split())
    if len(arr) == 1:
        count += 1
    else:
        if arr[1] == '1':
            if count%2==0:
                left = arr[2] + left
            else:
                right = right + arr[2]
        else:
            if count%2!=0:
                left = arr[2] + left
            else:
                right = right + arr[2]
S = left + S + right
if count%2 == 0:
    print(S)
else:
    print(S[::-1])

Measured memory_bytes: 4572
package main

import (
  "bufio"
  "fmt"
  "os"
  "sort"
  "strconv"
  "strings"
)

const INF = 1<<31-1

var g [][]int
var vis,act,isc []bool
var a,c []int

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,10000)}
  n := input.NextInt()
  p := input.NextIntArray()
  g = make([][]int,n)
  a = make([]int,n)
  for i:=0;i<n;i++ {
    g[p[i]-1] = append(g[p[i]-1],i)
    a[i] = -1
  }
  vis = make([]bool,n)
  act = make([]bool,n)
  isc = make([]bool,n)
  for i:=0;i<n;i++ {
    if !vis[i] && dfs1(i) { break }
  }
  c = c[:len(c)-1]
  a[c[0]] = n
  if dfs2(c[0]) != a[c[1]] { fmt.Println("POSSIBLE");return }
  for i:=0;i<n;i++ {
    if i == c[0] { continue }
    a[i] = -1
  }
  x := a[c[0]]
  if dfs2(c[0]) == x {
    fmt.Println("POSSIBLE")
  } else {
    fmt.Println("IMPOSSIBLE")
  }
}

func dfs1(u int) bool {
  vis[u],act[u] = true,true
  for _,v := range g[u] {
    if act[v] {
      c = append(c,v)
      c = append(c,u)
      isc[u],isc[v] = true,true
      return true
    }
    if dfs1(v) {
      if isc[v] && (len(c) == 0 || (len(c) > 0 && v != c[0])) {
        c = append(c,u)
        isc[u] = true
        return true
      }
    }
  }
  act[u] = false
  return false
}

func dfs2(u int) int {
  b := []int{0,INF}
  for _,v := range g[u] {
    if a[v] == -1 { b = append(b,dfs2(v));continue }
    b = append(b,a[v])
  }
  sort.Ints(b)
  for i:=0;;i++ {
    if b[i+1] > b[i]+1 {
      a[u] = b[i]+1
      return a[u]
    }
  }
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) NextIntArray() []int {
  s := strings.Fields(i.NextLine())
  a := make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}

Measured memory_bytes: 77312
import java.util.*;

public class Main {
	
	public static boolean judge(String s[], int r, int l) {
		if(s[r].charAt(l) != '#')return false;
		if(s[r - 1].charAt(l) != '#' && s[r + 1].charAt(l) != '#' && s[r].charAt(l - 1) != '#' && s[r].charAt(l + 1) != '#')
			return false;
		return true;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		String s[] = new String[h + 2];
		StringBuffer tmp = new StringBuffer();
		for(int i = 0; i < w + 2; ++i)
			tmp.append('.');
		s[0] = tmp.toString();
		StringBuffer tmp2 = new StringBuffer();
		for(int i = 1; i <= h; ++i) {
			tmp2.append('.');
			s[i] = sc.next();
			tmp2.append(s[i]);
			tmp2.append('.');
			s[i] = tmp2.toString();
			tmp2.delete(0,  tmp2.length());
		}
		s[h + 1] = tmp.toString();
		sc.close();
		String ans[] = {"Yes", "No"};
		int a = 0, t = -1;
		for(int i = 1; i <= h; ++i) {
			t = -1;
			for(int j = 1; j <= w; ++j) {
				if(s[i].charAt(j) == '#') {
					if(!judge(s, i, j)) {
						t = 0;
						a = 1;
						break;
					}
				}
			}
			if(t != -1) 
				break;
		}
		System.out.println(ans[a]);
	}

}


Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int N; cin >> N;
	vector<int> overwork;
	ll sum = 0;
	int ans = 0;
	int a[N], b[N];
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) cin >> b[i];

	for (int i = 0; i < N; i++) {
		if (a[i] < b[i]) { // 準備が足りてなければ
			sum += (b[i] - a[i]);
			ans++;
		}
		else if (a[i] > b[i]) { // 準備が過剰だったら
			overwork.push_back(a[i] - b[i]);
		}
	}

	sort(overwork.begin(), overwork.end(), greater<int>());
	int i = 0;
	while (sum > 0 && (!overwork.empty())) {
		ans++;
		sum -= overwork[0];
		overwork.erase(overwork.begin());
	}

	if (sum > 0) cout << -1 << endl;
	else cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{	
  ll a,b,c,d,e,f;
  
  cin>>a>>b>>c>>d;
  
  e=max(a*c,a*d);
  f=max(b*c,b*d);
 
  cout<<max(e,f);
  
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);
using namespace std;
int32_t main()
{
	int n;
	cin >> n;
	cout << n*n*n;
}


Measured memory_bytes: 256
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;

template<class T>
using vec2d = std::vector<std::vector<T>>;


template<class T>
vec2d<T> makeVec2d(const int n1, const int n2) {
  return vec2d<T>(n1, vec<T>(n2));
}

template<class T>
vec2d<T> makeVec2d(const int n1, const int n2, const T initValue) {
  return vec2d<T>(n1, vec<T>(n2, initValue));
}


#define FOR(i, n) for (int i = 0; i < (n); ++i)


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


const int MOD = (int)1e9 + 7;

void solve(istream& in, ostream& out) {
  auto num = next<string>(in);
  auto d = next<int>(in);

  vec2d<int> dp = makeVec2d<int>(d, 2);
  vec2d<int> nxt = makeVec2d<int>(d, 2);

  int dd = num[0] - '0';
  FOR(i, dd) {
    dp[i % d][0] += 1;
  }
  dp[dd % d][1] += 1;

  FOR(i, num.length()) if (i) {
    FOR(j, d) {
      FOR(w, 2) {
        if (!dp[j][w]) continue;
        if (w == 1) {
          // continue prefix
          FOR(nd, num[i] - '0' + 1) {
            int newJ = j + nd;
            newJ %= d;
            (nxt[newJ][nd == num[i] - '0' ? 1 : 0] += dp[j][w]) %= MOD;
          }
        } else {
          FOR(nd, 10) {
            int newJ = j + nd;
            newJ %= d;
            (nxt[newJ][0] += dp[j][w]) %= MOD;
          }
        }
      }
    }
    dp = nxt;
    nxt = makeVec2d<int>(d, 2, 0);
  }

  int res = 0;
  FOR(j, 2) {
    res += dp[0][j];
    if (res >= MOD) {
      res -= MOD;
    }
  }
  --res;
  if (res < 0) res += MOD;
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    a.at(0) -= 32;
    b.at(0) -= 32;
    c.at(0) -= 32;
    cout<<a.at(0)<<b.at(0)<<c.at(0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const string need = "keyence";

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	int n = (int)s.size();
	for (int i = 0; i <= (int)need.size(); i++) {
		if (s.substr(0, i) == need.substr(0, i) && s.substr(n - (int)need.size() + i, (int)need.size() - i) == need.substr(i, (int)need.size() - i)) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
}



Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std; 
 


int main() 
{ 
    ll n,a,b;
    cin>>n>>a>>b;
    if(n==1){
        if(a==b) cout<<1;
        else cout<<0;
    }
    else{
        if(a>b) cout<<0;
        else{
            ll ans=((b-a)*(n-2))+1;
            cout<<ans;
        }
    }
} 


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

int n, m, k;
bool flag = 0;

int main()
{
	scanf ("%d %d %d", &n, &m, &k);
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= m; j++){
			if (i * m + j * n - 2 * i *j == k){
				flag = 1;
				break;
			}
		}
		if (flag)	break;
	}
	if (flag)	printf ("Yes\n");
	else printf ("No\n");
}

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

int main(){

 int W,H,x,y,r;
 int result;

 cin >> W >> H >> x >> y >> r;

 (( x>=r && x <= W-r) && (y>=r && y <= H-r)) ? cout << "Yes"  << endl : cout << "No"<<endl;

 return 0;

}




Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 998244353;

int main(){
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    vector<ll> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    sort(ALL(p));
    for (int i = 0; i < K; i++) {
        ans += p[i];
    }
    printf("%lld\n", ans);
    
}


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

typedef long long ll;

inline int read(){
	char c=getchar(); int x=0,ft=1;
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') ft=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
	return x*ft;
}

const int N=1e5+5;

int n,m,v,p,a[N]; ll sum[N];

int main(){
	n=read(); m=read(); v=read(); p=read();
	for(int i=1;i<=n;++i) a[i]=read();
	std::sort(a+1,a+1+n);
	for(int i=1;i<=n;++i) sum[i]=sum[i-1]+a[i];
	int ans=n-p;
	while(ans){
		if(a[ans]+m<a[n-p+1]) break;
		if(1ll*(ans+p-1)*m
		 +1ll*(n-ans-p+1)*(a[ans]+m)
		 -(sum[n-p+1]-sum[ans])
		 >=1ll*v*m) --ans;
		else break;
	}
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 1280
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,D; cin >> N >> D;
    int ans = 0;
    rep(i,N) {
        ll p,q; cin >> p >> q;
        if (p*p+q*q <= D*D) ans++;
    }

    cout << ans << ln;
}


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

using namespace std;
typedef long long ll;
int n;
int a[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int cnt=0;
	for(int i=0;i+2<n;i++){
		if(a[i]<a[i+1] && a[i+1]<a[i+2]){
			cnt++;
			if(i+3<n && a[i+1]>a[i+3]){
				swap(a[i+2],a[i+3]);
			}else{
				swap(a[i+1],a[i+2]);
			}
			
		}else if(a[i]>a[i+1] && a[i+1]>a[i+2]){
			cnt++;
			if(i+3<n && a[i+1]<a[i+3]){
				swap(a[i+2],a[i+3]);
			}else{
				swap(a[i+1],a[i+2]);
			}
		}
	}
	/*
	for(int i=0;i+1<n;i++){
		if(a[i]<a[i+1] && i%2==0){
			cnt++;
			swap(a[i],a[i+1]);
		}
		if(a[i]>a[i+1] && i%2==1){
			cnt++;
			swap(a[i],a[i+1]);
		}
	}
	int cnt2=0;
	for(int i=0;i+1<n;i++){
		if(a[i]<a[i+1] && i%2==1){
			cnt2++;
			swap(a[i],a[i+1]);
		}
		if(a[i]>a[i+1] && i%2==0){
			cnt2++;
			swap(a[i],a[i+1]);
		}
	}
	*/
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 3628
use std::collections::BTreeSet;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();
    let a = sc.chars();
    let b = sc.chars();
    let c = sc.chars();

    let mut ans = 0;
    for i in 0..n {
        let mut set = BTreeSet::new();
        set.insert(a[i]);
        set.insert(b[i]);
        set.insert(c[i]);

        match set.len() {
            1 => {}
            2 => {
                ans += 1;
            }
            3 => {
                ans += 2;
            }
            _ => unreachable!(),
        }
    }

    println!("{}", ans);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
)

func main() {
	var n, x int

	for {
		fmt.Scan(&n, &x)
		if n == 0 && x == 0 {
			break
		}

		c := 0
		for i := 1; i <= n-2; i++ {
			for j := i + 1; j <= n-1; j++ {
				for k := j + 1; k <= n; k++ {
					if i+j+k == x {
						c++
					}
				}
			}
		}
		fmt.Println(c)
	}
}



Measured memory_bytes: 1120
import re
while 1:
    try:f=input()
    except:break
    s=any([len(x)>1 and x[0]=='X' for x in re.split('[+=]',f)])
    f=f.replace('=','==')
    for i in '0123456789'[s:]:
        if eval(f.replace('X',i)):print(i);break
    else:print('NA')

Measured memory_bytes: 7892
<?php
while ($line = fgets(STDIN)) {
 $array[] = trim($line);
}
$a = $array[0];
$b = $array[1];
$num = explode(' ',$b);
 $s = 0;
 for ($i=0; $i<$a; $i++) {
   $c = 1/$num[$i];
   $s = $s + $c;
}
  $t = 1/$s;
  echo $t;
?>


Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
int32_t main()
{
  int n; cin >> n;
  int mn = 0,ans=0;
  fr(_,n){
  	int x; cin >> x;
  	mn = max(mn,x);
  	ans += mn - x;
  }
  cout << ans;
}

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

class Point {
  public:
    int x;
    int y;
};

int main() {
    
    int x, y;
    cin>>x>>y;
    
    Point top_right, under_left;
    top_right.x = 1;
    top_right.y = 1;
    under_left.x=0;
    under_left.y=0;
    
    for (int i = 0;; i++) {
        if (top_right.x > x && top_right.y > y && under_left.x <= x && under_left.y <= y) {
            cout<<(i % 3) + 1<<endl;
            break;
        }
        
        if (i % 4 == 0) top_right.x += top_right.y - under_left.y;
        else if (i % 4 == 1) top_right.y += top_right.x - under_left.x;
        else if (i % 4 == 2) under_left.x += under_left.y - top_right.y;
        else under_left.y += under_left.x - top_right.x;
    }

    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
int n, a[N];
vector<int> occ[N]; // occurrence vectors
int main() {
  	cin >> n;
  	for (int i = 0; i < n; ++i) {
      	cin >> a[i];
    	occ[a[i]].push_back(i);
    }
  	int prev = -1, taken = 0;
  	for (int val = 1; val <= n; ++val) {
  		bool found = false;
    	for (auto idx: occ[val]) {
        	if (idx > prev) {
             	prev = idx; 
              	taken++;
              	found = true;
             	break;
            }
        }
        if (!found)
        	break;
    }
  	if (taken == 0)
      	cout << -1 << endl;
	else
  		cout << n - taken << endl;
 	return 0;
}


Measured memory_bytes: 11904
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int[] a = new int[n];
		int ans = 0, o = 0, e = 0;

		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if (x % 2 == 0) {
				a[e] = x;
				e++;
			} else {
				o++;
			}
		}
		if (o != n) {
			for (int i = 0; i < e; i++) {
				while (a[i] % 2 == 0) {
					ans++;
					a[i] = a[i] / 2;
				}
			}
		}
		
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 34332
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1275>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int n,k,m;
int rec(int N){
    if(N == 1) return 0;
    return (rec(N-1)+k)%N;
}
int solve(){
    int res = (rec(n-1)+m)%n + 1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> n >> k >> m,n){
        cout << solve() << endl;
    }
    return 0;
}



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



def main():
    N = int(input())
    S = input()

    x = xmax = 0
    for c in S:
        if c == "I":
            x += 1
            if x > xmax:
                xmax = x
        elif c == "D":
            x -= 1

    print(xmax)

if __name__ == "__main__": main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
using namespace std;
int n, dx, dy;
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		int x = 0, y = 0, px = 0, py = 0;
		while(cin >> dx >> dy, dx | dy) {
			x += dx, y += dy;
			if((10000LL * (px * px + py * py) + px) < (10000LL * (x * x + y * y) + x)) px = x, py = y;
		}
		cout << px << ' ' << py << endl;
	}
}

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

long long MaxProfit(int n, long long *Rt){
	long long max= LLONG_MIN;
	long long MinRt = Rt[0];
	for(int j=1; j<n; j++){
		long long tmp = Rt[j]-MinRt;
		if(max<tmp) max = tmp;
		if(MinRt>Rt[j]) MinRt = Rt[j];
	}
	return max;
}

int main(){

int n; cin >> n;
long long Rt[n];
long long max;
for(int i=0; i<n; i++)
	cin >> Rt[i];	
max = MaxProfit(n,Rt);
cout << max << endl;
return 0;
};

Measured memory_bytes: 4628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define mod 1000000007
#define mk make_pair
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];int c[n];
    for(int i=0;i<n;i++)
    {cin>>a[i];c[i]=2000000000;}
    c[0]=0;
    c[1]=abs(a[1]-a[0]);
    for(int j=2;j<n;j++)
    {
        for(int i=j-1;i>=0&&j-i<=k;i--)
        {
            c[j]=min(c[j],c[i]+abs(a[i]-a[j]));
        }
    }
    cout<<c[n-1];
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var ABK = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        var (A, B, K) = (ABK[0], ABK[1], ABK[2]);

        A -= K;
        if(A < 0)
        {
            B += A;
            A = 0;

            if (B < 0)
                B = 0;
        }

        WriteLine($"{A} {B}");
    }
}


Measured memory_bytes: 28144