akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vll divisor(ll n) {
    vll ans;
    for (ll i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ans.push_back(i);
            if (i*i != n) ans.push_back(n/i);
        }
    }
    sort(all(ans));
    return ans;
}

int main() {
    ll n;
    cin >> n;
    auto g = divisor(n);
    ll ans = LINF;
    for (auto gi : g) {
        ll x, y;
        x = gi - 1;
        y = n / gi - 1;
        ans = min(ans, x+y);
    }

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

Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		sc.close();
		int count = 0;
		for(long l = A;l <= B;l++) {
			String s = String.valueOf(l);
			String[] ss = s.split("");
			if(ss[0].equals(ss[4]) && ss[1].equals(ss[3])) count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 64384
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())
 
s=input()

def check(s):
    j=len(s)-1
    i=0
    while i<j:
        
        if s[i]!=s[j]:
            return 0
        i+=1
        j-=1
    return 1
sum=0
sum=sum+1
if len(s)%2==0:
    print("No")
else:
    if check(s)==0:
        print("No")
    else:
        n=len(s)
        s1=[s[i] for i in range(0,n//2)]
        s2=[s[i] for i in range(n//2+1,n)]
        if check(s1)==1:
            print("Yes")
        else:
            print("No")
            


Measured memory_bytes: 3316
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if (a < c && c < b) || (b < c && c < a) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

const int N=2e5+10;

int n,a[N];

int pos[N];
int solve(){
        for(int i=1;i<=n;i++) pos[a[i]]=i;
        int ans=0,len=0;
        for(int i=n;i>=1;i--) {
                
                if (pos[i]<pos[i+1]) len++;
                else len=1;
                ans=max(ans,len);
        }
        return n-ans;
}
int main(){
        cin>>n;
        for(int i=1;i<=n;i++)
                cin>>a[i];
        cout<<solve();        
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
using namespace std;
static ll imin = std::numeric_limits<ll>::min() / 10;
static ll imax = std::numeric_limits<ll>::max() / 10;
#define rep(i, n) for (ll i = 0; (i) < (n); ++(i))
#define rep1(i, n) for (ll i = 1; (i) < (n); ++(i))
#define rev_rep(i, n) for (ll i = (n)-1; (i) >= 0; --(i))
#define range(a, i, b) for (ll i = (a); (i) < (b); ++(i))

#ifdef LOCAL
#define dump(x) cout << #x << ":" << x << "\n";
#endif
#ifndef LOCAL
#define dump(x)
#endif

#define all(v) v.begin(), v.end()
#define readl(N) \
  ll N;          \
  cin >> N;
#define readlv(N, vec) \
  vector<ll> vec(N);   \
  rep(i, N) { cin >> vec[i]; }
#define greater_than [](ll l, ll r) { return l > r; }
template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::map<T1, T2>& mp);
template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& pair);
template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& vec);
template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& pair) {
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& vec) {
  std::size_t n = vec.size();
  if (n == 0) {
    return os;
  }
  os << " ";
  for (ll i = 0; i < n - 1; ++i) {
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::map<T1, T2>& mp) {
  std::size_t n = mp.size();
  if (n == 0) {
    return os;
  }
  os << " ";
  for (auto&& x : mp) {
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template <class T>
std::ostream& operator<<(std::ostream& os, std::set<T>& mp) {
  std::size_t n = mp.size();
  if (n == 0) {
    return os;
  }
  os << " ";
  for (auto&& x : mp) {
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template <class T>
inline bool chmin(T& a, T const b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T const b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll fact(ll n) {
  ll res = 1;
  while (n > 0) {
    res *= n;
    n--;
  }
  return res;
}

ll pow(ll i, ll n) {
  ll res = 1;
  while (n >= 0) {
    res *= i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r) {
  if (l < r) {
    return gcd(r, l);
  }
  if (r == 0) {
    return l;
  }
  return gcd(r, l % r);
}

template <class T>
vector<T> accum_sum(vector<T> const& a) {
  vector<T> b(a.size() + 1);
  b[0] = 0;
  rep(i, a.size()) { b[i + 1] = b[i] + a[i]; }
  return b;
}
constexpr ll mod = 1e9 + 7;
int main(int argc, char const* argv[]) {
  readl(A);
  readl(B);
  readl(C);

  cout << min(B / A, C);

  return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

STICKS = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = Array.new(n + 1, -1)
dp[0] = 0

0.upto(n) do |i|
  as.each do |a|
    if i - STICKS[a] >= 0 && dp[i - STICKS[a]] != -1
      dp[i] = [dp[i], dp[i - STICKS[a]] * 10 + a].max
    end
  end
end

p dp[n]


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


ll N;
ll res;

void input() {
	cin>>N;
}

void solve() {
	for(int i=1; i<=N; i++) {
		res+=i*(N/i)*(N/i+1)/2;
	}
	cout<<res<<endl;
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

int main(){
	int t;
	for(cin >> t; t--; ){
		int n, x, y, a = 0, b = 0;
		cin >> n;
		for(int i = 0; i < n; ++i){
			cin >> x;
			if(i != 0){
				int d = x - y;
				a = max(a, d);
				b = max(b, -d);
			}
			y = x;
		}
		cout << a << ' ' << b << '\n';
	}
}

Measured memory_bytes: 1160
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2199

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int MAX = INT_MAX;

int N,M;
int dp[20001][256];

vector<int> C;
vector<int> x;

int round255(int n)
{
	if(n > 255){ return 255; }
	else if(n < 0){ return 0;}
	else{ return n; }
}

int main()
{
	while(cin >> N >> M && N)
	{
		C.resize(M);
		x.resize(N);
		fill_n((int *)dp, sizeof(dp)/sizeof(int), MAX);

		rep(i,M){ cin >> C[i]; }
		rep(i,N){ cin >> x[i]; }

		dp[0][128] = 0;

		rep(i,N)
		{
			rep(j,256)
			{
				if(dp[i][j] == MAX){ continue; }	
				rep(k,M)
				{
					int yn = j + C[k];
					yn = round255(yn);
					int sum2 = (x[i] - yn)*(x[i] - yn);
					dp[i+1][yn] = min(dp[i+1][yn], dp[i][j]+sum2);
				}
			}
		}

		cout << *min_element(dp[N],dp[N]+256) << endl;
	}
	return 0;
}

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

public class AtCoder_153_B
{
    public static void Main()
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int[] line1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int h = line1[0];

        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int sum = 0;
        for (int i = 0; i < a.Length; i++)
        {
            sum += a[i];
        }

        if (h > sum)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 18144
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll a, b;
	cin >> a >> b;
	cout << (a*b) << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define TEST(t) int inox,t;cin>>t; for(inox=1;inox<=t;inox++)
using namespace std;

int main(){
	ll t,n,s=0;
	cin>>t>>n;
	ll a[n],i;
	for(i=0;i<n;i++){cin>>a[i];s+=a[i];}
		if(s>=t)cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main(){

    int a = 0;
    int b = 0;
    char A[10];
    char B[10];
    char C[10];

    scanf("%s",A);
    scanf("%s",B);
    scanf("%s",C);

    a = strlen(A);
    b = strlen(B);

    if (A[a-1] == B[0]){
        if (B[b-1] == C[0]){     
            puts("YES");
	}
    else{
        puts("NO");
    }
}
  else{
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib> 
#include<sstream>
#include<cstdio>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
#define me(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=1111122;
const int M=200005;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;
   // system("pause");
    return 0;
}







/*------------------我要ac，我要蓝名-------------------------------*/

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const LL INF = 1LL<<60;
const double eps = 1e-13;

vector<int> adj[100009];
int dist[100009][2];

void dfs(int x,int t,int p=-1){
	for(int i:adj[x]){
		if(i==p)continue;
		dist[i][t]=dist[x][t]+1;
		dfs(i,t,x);
	}
}

int main(){
	DRI(n);
	REP(i,n-1){
		DRII(a,b);a--;b--;
		adj[a].PB(b);adj[b].PB(a);
	}
	dfs(0,0);
	dfs(n-1,1);
	int f=0,s=0;
	REP(x,n){
		if(dist[x][0]<=dist[x][1])f++;
		else s++;
	}
	//printf("%d %d",f,s);
	if(f>s)puts("Fennec");
	else puts("Snuke");
}


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

typedef long long ll;
const int maxn = 2e5 + 10;
int n; ll k, ans, a[maxn], lef[maxn], rig[maxn];

int main() {
  scanf("%d %lld", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", a + i), ans += a[i];
  }
  ans += (n - 1) * k;
  lef[1] = a[1];
  for (int i = 2; i <= n; i++) {
    lef[i] = min(a[i], lef[i - 1] + k);
  }
  rig[n] = a[n];
  for (int i = n - 1; i; i--) {
    rig[i] = min(a[i], rig[i + 1] + k);
  }
  for (int i = 2; i < n; i++) {
    ans += min(lef[i], rig[i]);
  }
  printf("%lld", ans);
  return 0;
}

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

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = x2 - x1;
    int dy = y2 - y1;

    int x3 = x2 - dy;
    int y3 = y2 + dx;

    int x4 = x3 - dx;
    int y4 = y3 - dy;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    // int n; cin >> n;
    // int res = 0;
    // int a, b; 
    // while(n > 0){
    //     if(n >= 9){
    //         // cout << n << endl;
    //         a = b = 1;
    //         while(pow(9, a) <= n) a++;
    //         while(pow(6, b) <= n) b++;
    //         a--; b--;
    //         int s = pow(9, a);
    //         int t = pow(6, b);
    //         if(s >= t){
    //             n -= s;
    //         }else{
    //             n -= t;
    //         }
    //             // cout << a << " [a] " << s << endl;
    //             // cout << b << " [b] " << t << endl;
    //         res++;
    //         // cout << "n = " << n << endl;
    //         // cout << s+n << endl;
    //         // cout << t+n << endl;
    //     }else{
    //         res += n;
    //         n = 0;
    //     }
    //     // cout << a << " " << n << endl;
    // }
    int N;
vector<int> c;
int dp[111111];
    cin >> N;

    // コインの種類を配列に追加
    c.push_back(1);
    for (int i = 6; i <= N; i*=6) { c.push_back(i); }
    for (int i = 9; i <= N; i*=9) { c.push_back(i); }

    // DPテーブルを初期化
    fill(dp, dp+N+1, INF);
    dp[0] = 0;

    // DP
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < c.size(); j++) {
            if (i >= c[j]) {
                dp[i] = min(dp[i], dp[i-c[j]]+1);
            }
        }
    }

    cout << dp[N] << endl;
    // cout << res << endl;
    // int n = 127;
    // int a, b; a = b = 1;
    // while(pow(9, a) <= n) a++;
    // while(pow(6, b) <= n) b++;
    // a--; b--;
    // cout << n << endl;
    // cout << pow(9, a) << endl;
    // cout << n - pow(9, a) << endl;
    // n = n - pow(9, a);
    // cout << n << endl;
    // if(pow(9, a) > pow(6, b)){ n -= pow(9, a); cout << pow(9, a) << endl; cout << n + pow(9, a) << endl; }
    // else { n -= pow(6, b); cout << pow(6, b) << endl; cout << n + pow(6, b) << endl; }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	map<int,int> mp;
	int n,res=0;
	cin>>n;
	for(int i=0;i<n;++i){
		int x;
		cin>>x;
		mp[x]++;
	}
	for(auto it:mp)
		if(it.second>it.first) res+=it.second-it.first;
		else if(it.second<it.first) res+=it.second;
	cout<<res<<'\n';
}



Measured memory_bytes: 8160
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        c: Chars,
    }
    let mut red_count = 0;
    for i in 0..n {
        if c[i] == 'R' {
            red_count += 1;
        }
    }
    let mut left_red_count = 0;
    for i in 0..red_count {
        if c[i] == 'R' {
            left_red_count += 1;
        }
    }
    println!("{}", red_count - left_red_count);
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a (n);
    vector<vector<int>> x (n);
    vector<vector<int>> y (n);
    int b,c;
    for(int i=0; i<n; i++){
        cin >> a.at(i);
        for(int j=0; j<a.at(i); j++){
            cin >> b >> c;
            b--;
            x.at(i).push_back(b);
            y.at(i).push_back(c);
        }
    }
    int ans = 0;
    int count;
    for(int b=1; b<(1 << n); b++){
        count = 0;
        bool judge = true;
        for(int i=0; i<n; i++){
            if(b & (1 << i)) count++;
            else continue;
            for(int j=0; j<a.at(i); j++){
                if(((b >> (x.at(i).at(j)))&1) ^ y.at(i).at(j)) judge = false;
            }
        }
        if(ans < count && judge) ans = count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a;
  cin>>a;
  if(a%11==0) cout<<(a/11)*2<<endl;
  else if(a%11<7) cout<<(a/11)*2+1<<endl;
  else cout<<(a/11)*2+2<<endl;
  return 0;
}

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

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  int max = x / 100;
  int sum = x % 100;
  if(sum > 5 * max) cout << 0 << "\n";
  else cout << 1 << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

vector<pair<int, int> > g[100000];

pair<int, int> tddfs(int v, int par = -1) {
  pair<int, int> ret = {0, v};
  for (auto &x : g[v]) {
    int w, cost;
    tie(w, cost) = x;
    if (w == par)
      continue;
    auto r = tddfs(w, v);
    ret = max(ret,  {cost+r.first, r.second});
  }
  return ret;
}

int treeDiameter() {
  auto v = tddfs(0);
  auto w = tddfs(v.second);
  return w.first;
}

int main() {
  int n;
  scanf(" %d", &n);
  REP (i, n-1) {
    int x, y, d;
    scanf(" %d %d %d", &x, &y, &d);
    g[x].push_back({y, d});
    g[y].push_back({x, d});
  }
  int ret = treeDiameter();
  printf("%d\n", ret);
  
  return 0;
}

Measured memory_bytes: 14856
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)

class Team{
public:
    int time;
    int tnum;
    int ans;
    Team(){ time=tnum=ans=0; }
};

bool cmp(const Team &a,const Team &b){
    if(b.ans<a.ans){
        return true;
    } else if(b.ans==a.ans){
        if(b.time>a.time){
            return true;
        } else if(b.time==a.time){
            if(a.tnum>b.tnum){
                return true;
            }
        }
    }
    return false;
}

bool eql(Team &a,Team &b){
    return (b.ans==a.ans && b.time==a.time);
}

int main(){
    while(1){
        int M,T,P,R;
        cin>>M>>T>>P>>R;
        if(M==0){
            break;
        }
        int miss[T][P];
        Team ts[T];

        rep(i,T){
            rep(j,P){
                miss[i][j]=0;
            }
        }

        rep(k,T){
            ts[k].tnum=k+1;
        }

        rep(i,R){
            int m,t,p,j;
            cin>>m>>t>>p>>j;
            if(j==0){
                ts[t-1].ans++;
                ts[t-1].time+=m+miss[t-1][p-1]*20;
            }
            else
            {
                miss[t-1][p-1]++;
            }
        }

        sort(&ts[0],&ts[T],cmp);
        rep(i,T){
            if(i>=1){
                if(eql(ts[i-1],ts[i])){
                    cout<<"=";
                }
                else{
                    cout<<",";
                }
            }
            cout<<ts[i].tnum;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1164
import java.util.*; 
import java.io.*; 

public class Main {
	public static void main(String[] args) throws IOException {
     Scanner sc = new Scanner(System.in);
     int n = sc.nextInt(); 
     HashSet<Integer> set = new HashSet<>(); 
     for(int i =0; i<n; i++) {
    	 set.add(sc.nextInt()); 
     }
     if(set.size() == n) {
    	 System.out.println("YES");
     }
     else System.out.println("NO"); 
	}
}

Measured memory_bytes: 99772
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if (i*500 + j*100 + k*50) == X:
                count += 1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>

struct point {
        double x;
        double y;
};
int ccw(struct point, struct point, struct point, struct point);
main()
{
        int i, n;
        struct point p[4];
        scanf("%d", &n);
        for (i = 0; i < n; i++) {
                scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &p[0].x, &p[0].y
                                  , &p[1].x, &p[1].y, &p[2].x, &p[2].y, &p[3].x, &p[3].y);
                if (ccw(p[0], p[1], p[2], p[3])<=0 && ccw(p[2], p[3], p[0], p[1])<=0) {
                        printf("1\n");
                } else {
                        printf("0\n");
                }
        }
}
int ccw(struct point p0, struct point p1, struct point p2, struct point p3)
{
        long long int ans;
        struct point v[3];
        v[0].x = p1.x - p0.x; v[0].y = p1.y - p0.y;
        v[1].x = p2.x - p0.x; v[1].y = p2.y - p0.y;
        v[2].x = p3.x - p0.x; v[2].y = p3.y - p0.y;
        ans = (v[0].x * v[1].y - v[0].y * v[1].x)
                * (v[0].x * v[2].y - v[0].y * v[2].x);
        if (!ans) {
        if ((v[0].x * v[1].x + v[0].y * v[1].y) < 0
            && (v[0].x * v[2].x + v[0].y * v[2].y) < 0) {
            return 1;
        } else if ((v[0].x * v[1].x + v[0].y * v[1].y) > 0
            && (v[0].x * v[2].x + v[0].y * v[2].y) > 0){
            return 0;
        } else {
            return -1;
        }
    }else if (ans < 0){
        return -1;
    } else {
        return 1;
    }
}


Measured memory_bytes: 2044
N, M = map(int, input().split())
SC = [input().split() for _ in range(M)]
ans = -1

for i in range(0, 1000):
    str_i = str(i)
    if len(str_i) != N:
        continue
    flag = True
    for si, ci in SC:
        if str_i[int(si)-1] != str(ci):
            flag = False
    if flag:
        ans = i
        break
print(ans)


Measured memory_bytes: 3060
from bisect import insort
s = input().strip()
k = int(input())

sublist = []
for i in range(len(s)):
    if len(sublist)>k:
        sublist = sublist[:k]
    for j in range(i+1,len(s)+1):
        if len(sublist)>=k and sublist[k-1]<s[i:j]:
            break
        if s[i:j] not in sublist and (len(sublist)<k or sublist[k-1]>s[i:j]):
            insort(sublist,s[i:j])

print(sublist[k-1])

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  map<string, int> mp;
  while (n--) {
    string s; cin >> s;
    ++mp[s];
  }
  cout << "AC x " << mp["AC"] << '\n';
  cout << "WA x " << mp["WA"] << '\n';
  cout << "TLE x " << mp["TLE"] << '\n';
  cout << "RE x " << mp["RE"] << '\n';
  return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){
  int N;cin>>N;
  vector<int> a(N);
  cin>>a;

  sort(begin(a),end(a));
  bool f = true;
  for(int i = 0;i < N-1; ++i){
      if(a[i]==a[i+1]){
          f = false;
          break;
      }
  }
  if(f == false){
    cout<<"NO"<<endl;
  }else
  {
    cout<<"YES"<<endl;
  }
  
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

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

  string S;
  cin >> S;
  int n = 0;
  int w = 0;
  int s = 0;
  int e = 0;
  for (char c : S) {
    if (c == 'N')
      ++n;
    else if (c == 'W')
      ++w;
    else if (c == 'S')
      ++s;
    else if (c == 'E')
      ++e;
  }
  if (((n > 0 && s > 0) || (n == 0 && s == 0)) &&
      ((w > 0 && e > 0) || (w == 0 && e == 0)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    int N;
    while(cin>>N)
    {
        int a[200005],i;
        for(i=1; i<=N; i++)
            cin>>a[i];
        int maxnum=0,cnt=0,maxmid=0;
        for(i=1; i<=N; i++)
        {
            if(a[i]>maxnum)
            {
                maxnum=a[i];
                cnt=1;
            }
            else if(a[i]==maxnum)
                cnt++;
        }
        for(i=1;i<=N;i++)
        {
            if(maxmid<a[i]&&a[i]!=maxnum)
                maxmid=a[i];
        }
        if(cnt==1)
        {
            for(i=1; i<=N; i++)
                if(a[i]==maxnum)
                    cout<<maxmid<<endl;
                else
                    cout<<maxnum<<endl;
        }
        else
        {
            for(i=1; i<=N; i++)
                cout<<maxnum<<endl;
        }
    }
    return 0;
}


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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

int main(){
int N,min,count=0;
cin>>N;
int A[N];
REP(i,N)cin>>A[i];

REP(j,N){
    min=j;
    FOR(i,j,N){
    if(A[min]>A[i]){
        min=i;
    }
    }
    if(A[j]!=A[min])count++;
    swap(A[min],A[j]);
}
REP(i,N-1)cout<<A[i]<<" ";
cout<<A[N-1]<<endl<<count<<endl;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=1ll<<60,mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,a[100000]={0},n,t,ans=0;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>t;
		a[t]++;
	}
	for (i=0;i<100000;i++){
		if (i==0){
			ans=max(ans,a[i]+a[i+1]);
		}
		else if (i==99999){
			ans=max(ans,a[i]+a[i-1]);
		}
		else {
			ans=max(ans,a[i]+a[i-1]+a[i+1]);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8, i8[:]), cache=True)
def solve_naive(H, M, A):
    visited = np.zeros(7 * H, np.bool_)
    for a in A:
        visited[a::M] = 1
    st = np.empty(7 * H + 10, np.int64)
    ncomp = 0
    for v in range(7 * H):
        if visited[v]:
            continue
        ncomp += 1
        st[0] = v
        p = 1
        while p:
            p -= 1
            v = st[p]
            x, y = divmod(v, 7)
            for d in (1, -1, 7, -7):
                w = v + d
                if w < 0 or w >= 7 * H:
                    continue
                x1, y1 = divmod(w, 7)
                if abs(x - x1) + abs(y - y1) != 1:
                    continue
                if visited[w]:
                    continue
                visited[w] = True
                st[p] = w
                p += 1
    return ncomp

N, M, Q = map(int, readline().split())
A = np.array(readline().split(), np.int64)

if N <= 5 * M:
    x = solve_naive(N, M, A)
else:
    q, r = divmod(N, M)
    a, b = solve_naive(r + 3 * M, M, A), solve_naive(r + 4 * M, M, A)
    x = a + (q - 3) * (b - a)
print(x)

Measured memory_bytes: 111968
s = input()

result = "WA"
if s[0] == 'A' and s[2: -1].count('C') == 1:
    idx = s[2: -1].index('C')
    new = s[1:idx+2] + s[idx+3:]
    if new.islower():
        result = 'AC'
print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
bool prime(int n){
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return n!=1;
}
int gcd(int x,int y){
    if(x<y)swap(x,y);
    if(y==0)return x;
    return (y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}
int kai(int n){
    if(n==0)return 1;
    return kai(n-1)*n;
}
int mod_pow(int x,int y,int mod){
    int res=1;
    while(y>0){
        if(y&1){
            res=res*x%mod;
        }
        x=x*x%mod;
        y>>=1;
    }
    return res;
}

signed main(){
    string s;
    int cnt=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='2')cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int countRain = 0;
        String[] weather = sc.next().split("");
        boolean yesterdayIsRain = false;
        sc.close();

        for (String we : weather) {
            if ("R".equals(we)) {
                if (yesterdayIsRain) {
                    countRain++;

                } else {
                    countRain = 1;
                }
                yesterdayIsRain = true;
            } else {
                yesterdayIsRain = false;
            }
        }
        System.out.println(countRain);
    }
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

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

int N;
int a[101];
ll calc_cost(ll m) {
    ll ret = 0;
    REP(i,N) {
        ret+=(a[i]-m)*(a[i]-m);
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i,N) {
        cin >> a[i];
    }
    
    ll ans = INF;
    FOR(i,-100,101) {
        ans = min(ans, calc_cost(i));
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int a[26];
	for (int i = 0; i< 26; i++) a[i] = 0;
	for (int i = 0; i < s.size(); i++) a[(int)(s[i] - 97)]++;
	for (int i = 0; i < 26; i++) {
		if (a[i] != 0 && a[i] != 1) { cout << "no" << endl; return 0; }
	}
	cout << "yes" << endl;
	int x;
	cin >> x;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  vector<int>B(N);
  for(int i=0;i<N;i++){
    B[i]=A[i];
  }
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  for(int i=0;i<N;i++){
    if(A[i]==B[0]){
      cout << B[1] << endl;
    }
    else{
      cout << B[0] << endl;
    }
  }
}
    
      


Measured memory_bytes: 3200
import java.util.Scanner;

//Day Count
public class Main{

	static class T implements Comparable<T>{
		static int[] day = {0,31,28,31,30,31,30,31,31,30,31,30,31};
		int y,m,d;
		public T(int y, int m, int d) {
			this.y = y;
			this.m = m;
			this.d = d;
		}
		public int compareTo(T o) {
			return y!=o.y?y-o.y:m!=o.m?m-o.m:d-o.d;
		}
		public T n(){
			if(m==12){
				if(d==day[m])return new T(y+1,1,1);
				else return new T(y,m,d+1);
			}
			if(m!=2){
				if(d==day[m])return new T(y,m+1,1);
				else return new T(y,m,d+1);
			}
			if(y%4==0&&(y%100!=0||y%400==0)){
				if(d==29)return new T(y,m+1,1);
				else return new T(y,m,d+1);
			}
			if(d==day[m])return new T(y,m+1,1);
			else return new T(y,m,d+1);
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			T s = new T(sc.nextInt(),sc.nextInt(),sc.nextInt());
			T t = new T(sc.nextInt(),sc.nextInt(),sc.nextInt());
			if(s.y==-1)break;
			int c = 0;
			while(s.compareTo(t)<0){
				c++;
				s = s.n();
			}
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	string s;
	char r[11]={'h','i','j','k','l','m','n','o','p','u','y'};
	while(cin>>s and s!="#"){
		int m=s.size();
		int a[m]={};
		rep(i,m){
			rep(j,11){
				if(s[i]==r[j]) a[i]=1;
			}
		}
		int ans=0;
		rep(i,m-1){
			if(a[i]!=a[i+1]) ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); //number 
#define ll long long                      //of element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after 
using namespace std;                      // sort use as s.f();
using namespace __gnu_pbds;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll t=1;
	//cin>>t;
	while(t--)
	{
	ll n,x,y;
	cin>>n>>x>>y;
    ll d=y-x;
	ll ans[20001];
	memset(ans,0,sizeof(ans));

	for(ll i=1;i<=n;i++)
	{
	for(ll j=i+1;j<=n;j++)	
		{
		ll p=min(j-i,abs(x-i)+1+abs(y-j));
	     ans[p]++;
			
		}
	}



	for(ll i=1;i<n;i++)
	{
		cout<<ans[i]<<endl;
		}
	
	
	}
	
return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int a[100010];
bool b[100010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];
  sort(a, a+n);
  ll s = 0;
  REP(i, n-1) {
    s += a[i];
    if(s*2 >= a[i+1]) b[i] = true;
    else b[i] = false;
  }
  b[n-1] = true;

  int ans = n;
  for(int i=n-1; i>=0; --i) {
    if(!b[i]) {
      ans = n-i-1;
      break;
    }
    //cout << b[i] << " ";
  }
  //cout << endl;

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define NMAX 22
using namespace std;
int n,a[NMAX][NMAX];
long long dp[NMAX][1<<22];
const long long MOD=1e9+7;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        if(a[0][i])
            dp[0][1<<i]=1;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[i][j])
            {
                for(int k=1;k<(1<<n);k++)
                {
                    if(!((1<<j)&k))
                    {
                        dp[i][k^(1<<j)]=(dp[i][k^(1<<j)]+dp[i-1][k])%MOD;
                    }
                }
            }
        }
    }
    cout<<dp[n-1][(1<<n)-1];
    return 0;
}

Measured memory_bytes: 375040
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
typedef long long ll;

using namespace std;

int main(){
	int N;
  	cin >> N;
  	vector<int> P(N);
  	vector<int> idx(N);
  	set<int> s;
  	ll ans = 0;
  	for(int i = 0; i < N; i++){
    	cin >> P[i];
      	P[i]--;
    }
  	for(int i = 0; i < N; i++){
    	idx[P[i]] = i;
    }
  	for(int x = N-1; x >= 0; --x){
    	ll c = 0;
      	int i = idx[x];
      	{
          s.insert(i);
          vector<int> l(2, -1);
          vector<int> r(2, N);
          {
              auto it = s.find(i);
              for(int j = 0; j < 2; j++){
                  if(it == s.begin()) break;
                  --it;
                  l[j] = *it;
              }
          }
          {
              auto it = s.find(i);
              for(int j = 0; j < 2; j++){
                  ++it;
                  if(it == s.end()) break;
                  r[j] = *it;
              }
          }
          vector<int> ls(2);
          ls[0] = i - l[0]; ls[1] = l[0]-l[1];
          vector<int> rs(2);
          rs[0] = r[0] - i; rs[1] = r[1]-r[0];
          c = (ll)ls[0]*rs[1] + (ll)ls[1]*rs[0];
      	}
      	ans += c*(x+1);
    }
  	cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>


bool check(unsigned long long middle, std::vector<unsigned long long>& A, std::vector<unsigned long long>& B, unsigned long long k, unsigned long long n, unsigned long long m)
{
	unsigned long long time = 4294967295;
	for (unsigned long long i = 0; i <= n; i++)
	{
		if (middle - i <= m)
			time = std::min(time, A[i] + B[middle - i]);
		if (time <= k)
			return true;
	}
	if (time > k)
		return false;
	return true;
}

int main()
{
	unsigned long long n, m, k;
	std::cin >> n >> m >> k;
	std::vector<unsigned long long> A(n + 1);
	std::vector<unsigned long long> B(m + 1);
	A[0] = 0;
	B[0] = 0;
	for (int i = 1; i < n + 1; i++)
	{
		unsigned long long a;
		std::cin >> a;
		A[i] = a + A[i - 1];
	}
	for (int i = 1; i < m + 1; i++)
	{
		unsigned long long b;
		std::cin >> b;
		B[i] = b + B[i - 1];
	}
	unsigned long long bottom = 0;
	unsigned long long top = m + n;
	while (bottom + 1 < top)
	{
		unsigned long long middle = (bottom + top) / 2;
		if (check(middle, A, B, k, n, m))
			bottom = middle;
		else
			top = middle; 
	}
	if (check(top, A, B, k, n, m))
		std::cout << top << '\n';
	else
		std::cout << bottom << '\n';
	return 0;
}

Measured memory_bytes: 6424
#include<cstdio>
using namespace std;
int n,k,ans,p;
int map[12][6]={
    {4,2,0,9,7},
    {1,10,8,6,4},
    {9,7,5,3,1},
    {6,4,2,0,9},
    {3,1,10,8,6},
    {0,9,7,5,3},
    {8,6,4,2,0},
    {5,3,1,10,8},
    {2,0,9,7,5},
    {10,8,6,4,2},
    {7,5,3,1,10}};
int main()
{
	scanf("%d%d",&n,&k);
	n-=2;
	p=n%11;
	n/=11;
	ans=n*5;
	for(int i=0;i<p;i++){
		for(int j=0;j<5;j++){
			if(map[i][j]==k){
				ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

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

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

    long long ans = 0;
    for(int i = 0; i < n; i++){
        ans += abs(a[i] -a[n/2]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
//#include<bits_stdc++.h>
#include <iostream>
#include <math.h>
#include <vector>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define ll long long
using namespace std;
int main() {
    int n, res = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    bool flg = true;
    while(flg) {
        flg = false;
        for(int i = n - 1; i > 0; i--) {
            if(a[i] < a[i - 1]) {
                swap(a[i], a[i - 1]);
                flg = true;
                res++;
            }
        }
    }
    rep(i, n - 1) cout << a[i] << " ";
    cout << a[n - 1] << endl;
    cout << res << endl;
}


Measured memory_bytes: 3080
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007LL;
const ll INF=1000000000;
const int MAX=100001;
const double EPS=1e-10;
int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int b=k+1;b<=n;b++){
        ans+=(n/b-1)*(b-k)+max(0,n%b-k+1);
        ans+=b-k;
        if(k==0){
            ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

                           


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
Alice=0
Bob=0
a.sort(reverse=True)
for i in range(N):
    if i % 2 == 0:
        Alice+=a[i]
    else:
        Bob+=a[i]
if Alice>Bob:
    print(Alice-Bob)
else:
    print(Bob-Alice)

Measured memory_bytes: 3060
import Control.Applicative ((<$>))
import Control.Monad (replicateM)


solve [] a b = a+b
solve ([l,r]:xss) a b =
  let k = maximum [div (a+l-1) l, div (b+r-1) r] in
    solve xss (k*l) (k*r)


main = do
  n <- read <$> getLine :: IO Int
  xss <- fmap (fmap read) <$> fmap words <$> replicateM n getLine :: IO [[Int]]
  putStrLn . show $ solve xss 1 1

Measured memory_bytes: 1788
import re
n=int(input())
A=[]
for i in range(n):
    B=["."]*n
    for x,y in [list(map(int,input().split())) for k in range(int(input()))]:
        B[x-1]=str(y)
    A.append("".join(B))
ans=0
for i in range(2**n):
    num=format(i,"b").zfill(n)
    cnt,flag=0,1
    for k,j in enumerate(num):
        result=re.search(r"".join(A[k]),num)
        if result is not None and j=="1":
            cnt +=1
        elif (result is not None and j == "0") or (result is None and j == "1"):
            flag=0
            break
    if flag:
        ans=max(ans,cnt)
print(ans)

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

int main(){

    /*O(k^3) の例

    /*
    for(int x = 1; x <= k; x++){
        for(int y = 1; y <= k; y++){
            for(int z = 1; z <= k; z++){
                if(x + y + z == s) ans++;
            }
        }
    }

    */


    int k, s; cin >> k >> s;
    int ans = 0;


    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            int z = s - x - y;
            if(0 <= z && z <= k) ans++;
        }
    }

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

Measured memory_bytes: 256