akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll n,x,m,mi=1e15;
  cin>>n>>x;
  for(int i=0;i<n;i++){
    cin>>m;
    x-=m;
    mi=min(mi,m);
  }
  cout<<n+x/mi<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int n;cin>>n;
  cout<<n*n*n<<endl;
  return 0;
}

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

int main()
{
  int n, t, a;
  cin >> n >> t >> a;
  double d = 1000;
  auto p = 0;
  for (auto i = 0; i < n; i++) {
    double h;
    cin >> h;
    double x = abs(a - (t - h * 0.006));
    if (x < d) {
      d = x;
      p = i + 1;
    }
  }
  cout << p << endl;
}


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

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if (a<=b&&b<=c){
    cout<< a << " " << b << " " << c <<endl;
  } else if (a<=c&&c<=b){
    cout<< a << " " << c << " " << b <<endl;
  } else if (b<=a&&a<=c){
    cout<< b << " " << a << " " << c <<endl;
  } else if (b<=c&&c<=a){
    cout<< b << " " << c << " " << a <<endl;
  } else if (c<=a&&a<=b){
    cout<< c << " " << a << " " << b <<endl;
  } else {
    cout<< c << " " << b << " " << a <<endl;
  }
}


Measured memory_bytes: 3080
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,rest;
	while(cin >>a>>b){
		int a2=a,b2=b;
		if(a>b){c=a;a=b;b=c;}
		while((rest=b%a)!=0){
			b=a;
			a=rest;
		}
		cout <<a <<" "<<a2/a*b2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
operator fun Int.not() = if (this != 0) false else true
operator fun Int.plus(other: Boolean) = this + if (other) 1 else 0
data class Point(val x: Int, val y: Int) {
    constructor(xy: List<Int>): this(xy[0], xy[1])
}
fun main(args: Array<String>) {
    val N = nextInt()
    val XY = Array<Point>(N) { Point(listOfInt()) }
    val odd = (Math.abs(XY.first().x) + Math.abs(XY.first().y)) % 2
    if (XY.any { (Math.abs(it.x) + Math.abs(it.y)) % 2 != odd }) {
        println(-1); return
    }
    println(31 + !odd)
    if (!odd) print("1 ")
    for (b in 30 downTo 0) {
        print("${1 shl b}${if (b == 0) '\n' else ' '}")
    }
    for (xy in XY) {
        val buf =  StringBuilder()
        var (x, y) = xy
        if (!odd) {
            x -= 1
            print("R")
        }
        for (b in 30 downTo 0) {
            val t = 1 shl b
            if (Math.abs(x) < Math.abs(y)) {
                if (y > 0) {
                    y -= t
                    buf.append("U")
                } else {
                    y += t
                    buf.append("D")
                }
            } else {
                if (x > 0) {
                    x -= t
                    buf.append("R")
                } else {
                    x += t
                    buf.append("L")
                }
            }
        }
        println(buf.toString())
    }
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 42148
#include<iostream>//C++头文件
#include<algorithm>//标准头文件
using namespace std;
int n,a[100001],ans=0;//根据题意定义，都在int范围内，ans用来记录和。
int main(){
    cin>>n;//读入n
    for(int i=1;i<=n;i++){
        cin>>a[i];
         ans+=a[i];//记录总数值
    }
    if(ans%2==0)cout<<"YES"<<endl;//满足题意，输出YES换行。
    else cout<<"NO"<<endl;//不行就输出NO
    //大写！大写！大写！
    return 0;//结束
}

Measured memory_bytes: 768
#include <iostream>
#include <cmath>

using LL = long long;

LL gcd(LL a, LL b) {
  return b == 0 ? a : gcd(b, a % b);
}

int solve(LL a, LL b) {
  LL d = gcd(a, b);
  int res = 1;  // '1' 
  LL sqrt = std::sqrt(d + 0.5);
  for (int i = 2; i <= sqrt; ++i) {
    if (d % i == 0) {
      ++res;
      while (d % i == 0) d /= i;
    }
  }
  if (d > 1) ++res;
  return res;
}

int main() {
  LL a, b;
  std::cin >> a >> b;
  std::cout << solve(a, b) << std::endl;
  return 0;
}


Measured memory_bytes: 256
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
    return (x&(-x));
}
void solve(){
    int h,w; cin>>h>>w;
    int dp[h+1][w+1];
    char map[h][w];
    haha(i,0,h)
        haha(j,0,w) cin>>map[i][j];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            if(map[i-1][j-1]=='#'){
                dp[i][j]=-1;
            }
    for(int i=1;i<=h;i++)
        if(dp[i][1]==0) dp[i][1]=1LL;
        else break;
    for(int j=2;j<=w;j++)
        if(dp[1][j]==0) dp[1][j]=1LL;
        else break;
    /*haha(i,0,h+1){
        haha(j,0,w+1) cout<<dp[i][j]<<" ";
        cout<<endl;}*/
    for(int i=2;i<=h;i++){
        for(int j=2;j<=w;j++){
            if(dp[i][j]==-1) continue;
            if(dp[i-1][j]!=-1) dp[i][j] = (dp[i][j]+dp[i-1][j])%why;
            if(dp[i][j-1]!=-1) dp[i][j] = (dp[i][j]+dp[i][j-1])%why;
        }
    }
    cout<<dp[h][w]%why;
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
        solve();
    }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<int> b(N),p(M),a(N);
    for (int i=0;i<N;++i) cin >> b[i];
    for (int i=0;i<M;++i) cin >> p[i];
    int now=0,one=1;
    for (int i=0;i<M;++i){
        for (int j=0;j<p[i];++j){
            a[now+j]=(one?1:0);
        }
        now+=p[i]; one^=1;
    }
    vector<int> pos;
    for (int i=0;i<N;++i) if (b[i]) pos.emplace_back(i);
    int ans=INF,cnt=0;
    now=0,one=0;
    for (int i=0;i<N;++i) if (a[i]){
        if (now==pos.size()){cnt=INF; break;}
        if (a[i]) cnt+=abs(pos[now++]-i),++one;
    }
    if (one!=pos.size()) cnt=INF;
    ans=min(ans,cnt);
    cnt=now=one=0;
    for (int i=0;i<N;++i){
        if (!a[i]){
            if (now==pos.size()){cnt=INF; break;}
            cnt+=abs(pos[now++]-i),++one;
        }
    }
    if (one!=pos.size()) cnt=INF;
    ans=min(ans,cnt);
    cout << ans << '\n';
}


Measured memory_bytes: 3236
// abc137c.cpp : Green Bin
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

	vector<ll> v;
	while (n--){
		string s; cin>>s;
		sort(s.begin(), s.end());
		ll k = 0LL;
		for(char c: s) k = k*26LL + c-'a';
		v.push_back(k);
	}

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

	ll ans = 0LL, c = 1LL, d = v[0];
	for(int i=1; i<v.size(); i++){
		if(d==v[i]) c++;
		else{
			ans += c * (c-1LL) / 2LL;
			c = 1LL;
			d = v[i];
		}
	}
	ans += c * (c-1LL) / 2LL;
	cout<< ans << endl;
}

Measured memory_bytes: 1400
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		int diff = 1000000000;
		for(int i = 0; i <= n-k; i++) {
			int tmpDiff = h[i+k-1] - h[i];
			if(tmpDiff < diff) {
				diff = tmpDiff;
			}
		}
		System.out.println(diff);
	}
}

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

int a[100005];
bool comp (int i, int j){
    return (a[i]<a[j]);
}

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

    int student[n];

    for(int i=0; i<n;++i){
        int ai; cin>> ai;
        student[i]=i;
        a[i] = ai;
    }
    sort(student, student+n, comp);

    for(int i=0; i<n;++i){
        cout << student[i] + 1<< " ";
    }
}


Measured memory_bytes: 1536
h,w,k = map(int, input().split())

if w == 1:
    print(1)
    exit(0)

case = []

def createCase(s):
    if (len(s) == w-1):
        case.append(s)
        return
    if len(s) != 0 and s[-1] == "1" :
        createCase(s+"0")
    else:
        createCase(s+"0")
        createCase(s+"1")

createCase("")

for i in range(len(case)):
    case[i] = "0"+case[i]+"0"

# print(case)

move = [[0]*3 for _ in range(w)]

for i in range(w):
    for j in case:
        if j[i] == j[i+1] == "0":
            move[i][1] += 1
        if j[i+1] == "1":
            move[i][2] += 1
        if j[i] == "1":
            move[i][0] += 1

# print(move)

dp = [[0]*w for _ in range(h)]

fib = [0, 1, 2, 3, 5, 8, 13, 21]

dp[0][0] = fib[w-1]
dp[0][1] = fib[w-2]

for i in range(1, h):
    dp[i][0] = (dp[i-1][0]*move[0][1] + dp[i-1][1]*move[1][0]) % 1000000007
    for j in range(1, w-1):
        dp[i][j] = (dp[i-1][j]*move[j][1] + dp[i-1][j-1]*move[j-1][2] + dp[i-1][j+1]*move[j+1][0]) % 1000000007
    dp[i][-1] = (dp[i-1][-2]*move[-2][2] + dp[i-1][-1]*move[-1][1]) % 1000000007

# print(dp)

print(dp[-1][k-1])


Measured memory_bytes: 3188
#include <cstdio>
#include <algorithm>
#include <cmath>

int main()
{
	int n, min;
	scanf("%d%d", &n, &min);
	int ans = 1;
	for (int i = 1; i < n; ++i)
	{
		int a;
		scanf("%d", &a);
		if (a <= min)
		{
			++ans;
			min = a;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int arr[200001];
int main()
{
    fast_io;
    int n;
    cin >> n;
    set <int> s;
    for(int i =0 ; i < n; i++)
    {
        int x;
        cin >> x;
        s.insert(x);
    }
    if(n == s.size())
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }
}


Measured memory_bytes: 13004
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        String[] line = scanner.nextLine().split(" ", n);
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }
        Arrays.sort(arr);

        int sum = 0;
        for (int i = 0; i < n - 1; i++) {
            sum += arr[i];
        }
        if (arr[n-1] < sum) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

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

int main() {
	ll N;
	string S;
	cin >> N >> S;
	vector<ll> R(N+1,0), G(N+1,0), B(N+1,0);
	for (ll i = N-1;i>=0;i--) {
		if (S[i] == 'R') R[i]++;
		if (S[i] == 'G') G[i]++;
		if (S[i] == 'B') B[i]++;
	}
	for (ll i = N-1;i>=0;i--) {
		R[i] += R[i+1];
		G[i] += G[i+1];
		B[i] += B[i+1];
	}
	ll ans = 0;
	rep(i,0,N){
		rep(j,i+1,N) {
			if (S[i] == S[j]) continue;
			if (S[i] == 'R' && S[j] == 'G' || S[i] == 'G' && S[j] == 'R') {
				ans += B[j+1];
				if (j - i + j < N && S[j - i + j] == 'B') ans--;
			}
			if (S[i] == 'G' && S[j] == 'B' || S[i] == 'B' && S[j] == 'G') {
				ans += R[j+1];
				if (j - i + j < N && S[j - i + j] == 'R') ans--;
			}
			if (S[i] == 'B' && S[j] == 'R' || S[i] == 'R' && S[j] == 'B') {
				ans += G[j+1];
				if (j - i + j < N && S[j - i + j] == 'G') ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3704
// WeirdBugsButOkay

#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
 
using namespace std;

ll pow3(ll a,ll b,ll m=1000000007)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

void solve()
{
    ll k,n;
    cin>>k>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll ans=0;
    ans=max(ans,-a[n-1]+k+a[0]);
    for(ll i=0;i<n-1;i++)
        ans=max(ans,a[i+1]-a[i]);
    cout<<k-ans;
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q=1;
    //cin>>q;
    for(ll i=0;i<q;i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k;
bool d[10];

bool contain(int t) {
    stringstream ss;
    ss << t;
    string s = ss.str();
    for (int i = 0; i < s.size(); i++) {
        if (d[s[i]-'0']) return true;
    }
    return false;
}

int solve() {
    int t = n;
    while (true) {
        if (!contain(t)) break;
        t++;
    }
    return t;
}

void input() {
    cin >> n >> k;
    memset(d, false, sizeof(d));
    int D;
    for (int i = 0; i < k; i++) {
        cin >> D;
        d[D] = true;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  string s, t;
  cin >> s >> t;
  vector<char> p(26);
  for (int i = 0; i < int(s.size()); ++i) {
    if (p[s[i] - 'a'] != 0 && p[s[i] - 'a'] != t[i]) {
      cout << false << endl;
      return 0;
    }
    p[s[i] - 'a'] = t[i];
  }
  for (int i = 0; i < 26; ++i) {
    if (p[i] == 0) continue;
    for (int j = i + 1; j < 26; ++j) {
      if (p[i] == p[j]) {
        cout << false << endl;
        return 0;
      }
    }
  }
  cout << true << endl;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int cnt_neg = 0;
    ll min_abs = mod;
    ll sum = 0;
    rep(i, N){
        ll a; cin >> a;
        if(a < 0) cnt_neg++;
        min_abs = min(min_abs, abs(a));
        sum += abs(a);
    }
    if(cnt_neg % 2) cout << sum-min_abs-min_abs << endl;
    else cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
def nyu():
    N = int(input())
    return N

def check(N):

    success_flg = False
    while N >= 0:
        if N % 4 == 0:
            success_flg = True
            break
        
        N -= 7

        if N == 0:
            success_flg = True
            break
    
    if success_flg == True:
        print("Yes")
    else:
        print("No")







N = nyu()
check(N)


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int q = sc.nextInt();
			ArrayList<Integer> query = new ArrayList<>();
			for(int i = 0;i < q;i++) {
				int mode = sc.nextInt();
				switch(mode) {
				case 0:
					int x = sc.nextInt();
					query.add(x);
					break;
				case 1:
					int p = sc.nextInt();
					System.out.println(query.get(p));
					break;
				case 2:
					query.remove(query.size()-1);
					break;
				}
			}
		}
	}
}



Measured memory_bytes: 140756
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String t = sc.next();

        String[] ss = new String[s.length()];
        for (int i = 0; i < s.length(); i++) {
            ss[i] = String.valueOf(s.charAt(i));
        }
        Arrays.sort(ss);

        String[] tt = new String[t.length()];
        for (int i = 0; i < t.length(); i++) {
            tt[i] = String.valueOf(t.charAt(i));
        }
        Arrays.sort(tt, Comparator.reverseOrder());

        int lim = Math.max(s.length(), t.length());
        String ans = "No";
        for (int i = 0; i < lim; i++) {
            int sVal = ss[i].codePointAt(0);
            int tVal = tt[i].codePointAt(0);

            System.err.printf("%s %s \n", sVal, tVal);
            if (sVal == tVal) {
                if (i + 1 >= ss.length && ss.length < tt.length) {
                    ans = "Yes";
                    break;
                } else if (i + 1 >= tt.length && ss.length > tt.length) {
                    ans = "No";
                    break;
                }
                continue;
            }

            if (sVal < tVal) {
                ans = "Yes";
                break;
            } else {
                ans = "No";
                break;
            }
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 21844
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int len = scan.nextInt();
		long[] array = new long[len];
		int count = 0;

		for(int i=0;i<len;i++) {
			array[i] = scan.nextLong();
		}

		for(long x:array) {
			while(true) {
			if(x%2 == 0) {
				x = x/2;
				count++;
			}else {
				break;
			}
			}
		}

		System.out.println(count);
		scan.close();

	}

}


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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
typedef unsigned int UINT;
typedef long long ll;

int fib[50];

void fibfunc()
{

	FOR(i, 2, 50)
	{
		fib[i] = fib[i - 1] + fib[i - 2];
	}

}

int main()
{
	fib[1] = 1;
	fib[0] = 1;
	int n;
	cin >> n;

	fibfunc();

	cout << fib[n] << endl;

	return 0;
}

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

int main() {
    int a;
    set<int> st;
    rep(i, 3) {
        cin >> a;
        st.insert(a);
    }
    if(st.size() == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
	int ans=0;

	int n,k;
	cin >> n >> k;

	ll a[n];
	rep(i,n) cin >> a[i];

	ll l=0,mid,r=1e9;

	while(r-l>1){
		mid=(l+r)/2;
		int bunkatu=0;

		rep(i,n){
			bunkatu += (a[i]-1)/mid;
		}

		if(bunkatu <= k) r=mid;
		else l = mid;
	}

	cout << r << endl;
}


Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
long long bpow(long long a, long long b, long long m) 
{
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}
template<typename P> struct Cmp
{
    bool operator()(const P &p1, const P &p2)
    {
        if(p1.ss <= p2.ss) return true;
        //if(p1.ss>p2.ss && p1.ff==p2.ff) return p1.ss < p2.ss;
        //if(p1.ss<p2.ss && p1.ff==p2.ff) return p1.ss < p2.ss;
        return false;
    }
};


int main()
{
  fast_io
  go();
  //
  //
  //
  intt a,v,b,w,t;cin>>a>>v>>b>>w>>t;
  if(a==b)
    cout << "YES";
  else if(a<b)
  {
    intt d1=v*t;
    intt d2=w*t;
    if(d1+a>=d2+b)
      cout << "YES";
    else
      cout << "NO";
  }
  else if(b<a)
  {
    intt d1=v*t;
    intt d2=w*t;
    if(a-d1<=b-d2)
      cout << "YES";
    else
      cout << "NO";
  }
}










Measured memory_bytes: 3640
(loop repeat (read)
      with ac = 0
      with wa = 0
      with tle = 0
      with re = 0
      for line = (read-line)
      do (cond ((equal line "AC") (incf ac))
               ((equal line "WA") (incf wa))
               ((equal line "TLE") (incf tle))
               (t (incf re)))
      finally (format t "AC x ~A~%WA x ~A~%TLE x ~A~%RE x ~A~%" ac wa tle re))

Measured memory_bytes: 58908
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() 
{
  double x_one, x_two, y_one, y_two;
  cin >> x_one >> y_one >> x_two >> y_two;
  cout << fixed << setprecision(8) << sqrt((x_two - x_one) * (x_two - x_one) + (y_two - y_one) * (y_two - y_one)) << "\n";
}



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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<string,ll> mp;
  rep(i,n){
    string s;
    cin >> s;
    sort(all(s));
    mp[s]++;
  }
  ll ans = 0;
  for(auto x :mp){
    ans += x.second * (x.second-1) / 2;
  }
  cout << ans << endl;
  return 0;
}


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


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

    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i * i <= n; i++){
        if (n % i == 0)
            ans = i-1+n/i-1;
    }
    cout << ans;

}

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

int main() {
	int n,t,a;
	cin >> n>>t>>a;
	vector<double> tem(n);
	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;
		tem.at(i) = abs(t - h * 0.006 - a);
	}
	double min = tem.at(0);
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (min > tem.at(i)) {
			min = tem.at(i);
			ans = i + 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {

    int n1 = mid - left;
    int n2 = right - mid;

    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];

    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;

    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j] ) {
            A[k] =  L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}


void mergeSort(int A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main() {

    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for (i=0; i < n; i++) cin >> A[i];

    mergeSort(A, n, 0, n);

    for(i=0; i< n; i++ ) {
        if (i) cout << " ";
        cout << A[i];
    }

    cout << endl;

    cout << cnt << endl;

    return 0;
}

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

bool solve() {
    string s, t; cin >> s >> t;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (s == t) return true;
        rotate(begin(s), begin(s) + 1, begin(s) + n);
    }
    return false;
}

int main() {
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	int A;
	int B;
	int quotient;
	int remainder;
	int tempSum;
	int totalSum = 0;

	cin >> N >> A >> B;
	
	for (int i = 1; i <= N; i++) {

		tempSum = 0;
		quotient = i;
		
		// 各桁の和を求める
		while ( quotient > 0 ) {
			remainder = quotient % 10;
			tempSum += remainder;
			quotient /= 10;
		}
		
		if (A <= tempSum && tempSum <= B) {
			totalSum += i;
		}
	}

	cout << totalSum << endl;
	return 0;
}

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

int main()
{
  	int a,b,c;
  	cin>>a>>b>>c;
  	for(int i=1 ; i<=b ; ++i)
    {
    	if((a*i)%b==c)
        {
        	cout<<"YES"<<endl;
          	return 0;
        }
    }
  	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
Nd=[[] for i in range(10)]
Ns=[0 for i in range(10)]
Nl=[-1 for i in range(10)]
Nr=[-1 for i in range(10)]
for i,s in enumerate(S):
  if Ns[int(s)]==0:
    Nl[int(s)]=i
  
  Ns[int(s)]+=1
  Nr[int(s)]=i
  for j in range(10):
    Nd[j].append(Ns[j])
#print(Ns)
#print(Nd)

    
ans=0    
for i in range(10):
  if Nl[i]==-1:
    continue
  for j in range(10):
    if Nl[j]==-1:
      continue
    for k in range(10):
      if Nl[k]==-1:
        continue
      a=Nl[i]
      c=Nr[k]
      if Nd[j][max(c-1,0)]-Nd[j][a]>0:
        ans+=1
print(ans)
      

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll n;
    cin >> n;
    ll ans = 0;
    REP(i, n){
        REP(j, n){
            REP(k, n){
                ll g = __gcd((ll)i+1, (ll)j+1);
                g = __gcd(g, (ll)k+1);
                ans += g;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"

using namespace std;

int main() {
	string T;
	cin >> T;
	for (int n = 0;n < T.length();++n) {
		if ('?' == T[n]) {
			T[n] = 'D';
		}
	}
	cout << T  << endl;


	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
using namespace std;
int main(){
	string S;
	cin >> S;
	string::iterator itr = S.begin();
	int cnt = 0;
	int i = 0;
	while(i + 1< S.length()){
		if(*(itr + i) != *(itr + 1 + i)){
			S.erase(itr + i, itr + 2 + i);
			cnt = cnt + 2;
			itr = S.begin();
			if(i > 0){
				i--;
			}
		}
		else{
			i++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N; cin>>N;
    map<P, ll> m;
    int keta = 1;
    for(int i=1; i<=N; i++){
        if(i==keta*10) keta *= 10;
        m[P(i/keta, i%10)]++;
    }
    ll res = 0;
    for(int i=1; i<=9; i++){
        for(int j=i+1; j<=9; j++){
            res += m[P(i, j)] * m[P(j, i)] * 2;
        }
    }
    for(int i=1; i<=9; i++){
        res += m[P(i, i)] * m[P(i, i)];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

// https://atcoder.jp/contests/arc100/submissions/15483644
void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    
    vector<ll> acc(n + 1);
    rep(i, n) acc[i + 1] = acc[i] + a[i];
    
    ll ans = INF;
    int b = 4;
    rep3(bi_, 2, n - 1) { // debuged, 後半の始め位置
        if (bi_ <= 1 || bi_ >= n - 1) continue;
        
        // 前半を2分割
        int it2 = lb(acc, acc[bi_] / 2);
        rep3(qu_, it2 - b, it2 + b + 1) { // 前半後半の始め位置
            if (qu_ <= 0 || qu_ >= bi_) continue;
            
            int it22 = lb(acc, acc[bi_] + (acc[n] - acc[bi_]) / 2);
            rep3(qu_2, it22 - b, it22 + b + 1) { // 後半後半の始め位置
                if (qu_2 <= bi_ || qu_2 >= n) continue;
                
                vector<ll> v;
                v.eb(acc[qu_]);
                //(0+...+(bi_-1)) - (0+...+(qu_-1)) = (qu_+...+(bi_-1))
                v.eb(acc[bi_] - acc[qu_]);
                v.eb(acc[qu_2] - acc[bi_]);
                v.eb(acc[n] - acc[qu_2]);
                sort(all(v));
                chmin(ans, v[3] - v[0]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5532
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

const i64 INF = 1e18;

int main()
{
  i64 n, ma, mb;
  cin >> n >> ma >> mb;
  vector<i64> a(n), b(n), c(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i] >> b[i] >> c[i];
  vector<vector<vector<i64>>> dp(n + 1, vector<vector<i64>>(n * 10 + 1, vector<i64>(n * 10 + 1, INF)));
  dp[0][0][0] = 0;
  for (i64 i = 0; i < n; i++)
    for (i64 j = 0; j <= n * 10; j++)
      for (i64 k = 0; k <= n * 10; k++)
        if (dp[i][j][k] != INF)
        {
          dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
          dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
        }
  i64 ans = INF;
  for (i64 i = 1; i <= n * 10; i++)
    for (i64 j = 1; j <= n * 10; j++)
      if (i * mb == j * ma)
        ans = min(ans, dp[n][i][j]);
  cout << (ans == INF ? -1 : ans) << endl;

  return 0;
}


Measured memory_bytes: 53504
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
bool visited[100005];
const int max_N=1e5+10;
int H,W,h,w;
int board[105][105];
int mxindex,mxchain=0;
string S;
int N;
int X;
int tmp;
int minimum=10000;
int main(void)
{
  cin >> S;

  N=S.size();
  for(int i=0; i<N-2; i++){
    //cout << S[i] << ' ' << S[i+1] << ' ' << S[i+2] << endl;
    string now="";
    for(int j=0;j<3;j++)
      {
	now+=S[i+j];
      }
    //cout << now << endl;
    X = stoi(now);

    tmp = 753 - X;
    if(tmp<0) tmp= tmp*(-1);
    if(minimum > tmp)minimum =tmp;
  }

  cout << minimum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

vector<ll> col;
vector<vector<ll>> net;
vector<ll> num;

// 各頂点と根とする部分技の頂点数
vector<ll> nc;

// 各頂点を根とする部分技において、各色を根とする部分技に含まれる頂点の数
vector<unique_ptr<unordered_map<ll, ll>>> nc_by_col;

void dfs(ll cur, ll par){
    const ll curc = col.at(cur);
    nc.at(cur) = 1;
    ll maxidx = -1;

    for(ll nxt : net.at(cur)){
        if(nxt == par){ continue; }
        dfs(nxt, cur);

        const ll tmp = nc.at(nxt) - (*nc_by_col.at(nxt))[curc];
        num.at(curc) += tmp * (tmp - 1) / 2 + tmp;

        nc.at(cur) += nc.at(nxt);

        if(maxidx == -1 ||
           nc_by_col.at(nxt)->size() > nc_by_col.at(maxidx)->size()){
            maxidx = nxt;
        }
    }

    if(maxidx == -1){  // leaf
        nc_by_col.at(cur).reset(new unordered_map<ll, ll>());
    }else{
        nc_by_col.at(cur) = move(nc_by_col.at(maxidx));
        for(ll nxt : net.at(cur)){
            if(nxt == par || nxt == maxidx){ continue; }
            for(auto it = nc_by_col.at(nxt)->cbegin();
                it != nc_by_col.at(nxt)->cend(); ++it){
                (*nc_by_col.at(cur))[it->first] += it->second;
            }
        }
    }
    (*nc_by_col.at(cur))[curc] = nc.at(cur);
}

int main(){
    ll n;
    cin >> n;

    col.resize(n);
    REP(i, n){
        cin >> col.at(i);
        col.at(i)--;
    }

    net.resize(n);
    REP(i, n - 1){
        ll ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        net.at(ai).push_back(bi);
        net.at(bi).push_back(ai);
    }

    num.resize(n, 0);
    nc.resize(n);
    nc_by_col.resize(n);
    dfs(0, -1);

    REP(c, col.size()){
        const ll tmp = nc.at(0) - (*nc_by_col.at(0))[c];
        num.at(c) += tmp * (tmp - 1) / 2 + tmp;
    }

    REP(i, n){
        cout << n * (n - 1) / 2 + n - num.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 67808
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll n, m;
    cin >> n >> m;
    // Scc
    // S: n, c: m
    // c, c -> S
    // c*4 -> Scc
    // t = min(S, c/2)
    // c -= t * 2
    // ans = t + c / 3;
    ll t = min(n, m / 2);
    m = max(0LL, m - t * 2);
    ll ans = t + m / 4;
    cout << ans << '\n';
}


Measured memory_bytes: 3612
#include<iostream>
#include<queue>
#include<map>
#include<cassert>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 4;
const int inf = (1<<20);
bool edge[N][N][N][N];
int cost[(1<<16)];
char m[N][N+1];

int encode(bool in[4][4]){
  int ret=0;
  rep(i,4){
    rep(j,4){
      if (in[i][j])ret|=((1<<(j+i*4)));
    }
  }
  return ret;
}

void decode(bool in[4][4],int now){
  rep(i,4){
    rep(j,4){
      in[i][j]=now%2==1;
      now/=2;
    }
  }
}

int fill(int t,int b,int l,int r,bool st[4][4],char color){
  bool cpy[4][4];
  rep(i,4)rep(j,4)cpy[i][j]=st[i][j];
  for(int i=t;i<=b;i++){
    for(int j=l;j<=r;j++){
      if (color == m[i][j])cpy[i][j]=true;
      else cpy[i][j]=false;
    }
  }
  return encode(cpy);
}

string color="RGB";
int solve(){
  bool st[4][4];
  rep(i,(1<<16))cost[i]=inf;
  queue<int> Q;
  Q.push(0);
  cost[0]=0;
  while(!Q.empty()){
    int now=Q.front();Q.pop();
    if (now == (1<<16)-1)return cost[now];
    decode(st,now);
    rep(i,4){
      REP(ii,i,4){
	rep(j,4){
	  REP(jj,j,4){
	    if (!edge[i][ii][j][jj])continue;
	    rep(l,4){
	      int next=fill(i,ii,j,jj,st,color[l]);
	      if (cost[next] == inf){
		cost[next]=cost[now]+1;
		Q.push(next);
	      }
	    }
	  }
	}
      }
    }

  }
  return -1;
}

void makePattern(int h,int w){
  for(int i=-3;i < 4;i++){//top
    if (i+h <= 0)continue;
    for(int j=-3;j < 4;j++){//left
      if (j+w <= 0)continue;
      int l=max(0,j),r=min(3,j+w-1),t=max(0,i),b=min(3,i+h-1);
      edge[t][b][l][r]=true;
    }
  }
}

main(){
  int n;
  while(cin>>n){
    rep(i,4)rep(j,4)rep(k,4)rep(l,4)edge[i][j][k][l]=false;
    rep(i,n){
      int w,h;
      cin>>w>>h;
      makePattern(w,h);
    }
    rep(i,4)cin>>m[i];
    cout << solve() << endl;
  }
  return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            var cnt = new int[(int)Math.Pow(10, 5) + 2];
            for (int i = 0; i < N; i++)
            {
                cnt[A[i] + 1]++;
                cnt[A[i]]++;
                cnt[A[i] + 2]++;
            }
            var ans = 0;
            foreach (var i in cnt) if (i > ans) ans = i;

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 20576
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func loadints(n int) []int {
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = loadint()
	}
	return xs
}

type Pair struct {
	k int
	v int
}

type PairList []Pair

func (a PairList) Len() int {
	return len(a)
}

func (a PairList) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a PairList) Less(i, j int) bool {
	return a[j].v < a[i].v
}

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

func main() {
	n := loadint()
	v := loadints(n)
	odd_counter := make(map[int]int)
	even_counter := make(map[int]int)
	for i := 0; i < n; i += 2 {
		odd_counter[v[i]]++
		even_counter[v[i+1]]++
	}
	odd_cs := PairList{Pair{0, 0}}
	for k, v := range odd_counter {
		odd_cs = append(odd_cs, Pair{k, v})
	}
	even_cs := PairList{Pair{0, 0}}
	for k, v := range even_counter {
		even_cs = append(even_cs, Pair{k, v})
	}
	sort.Sort(odd_cs)
	sort.Sort(even_cs)
	result := n
	if odd_cs[0].k == even_cs[0].k {
		result = n - max(odd_cs[0].v+even_cs[1].v, odd_cs[1].v+even_cs[0].v)
	} else {
		result = n - odd_cs[0].v - even_cs[0].v
	}
	fmt.Println(result)
}


Measured memory_bytes: 11648
/*Ankon Ghosh
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
///#include <ext/pb_ds/detail/standard_policies.hpp>*/
///using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define inf 1e16
#define MAX 100005
#define mod 998244353
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) printf("Case %lld: ",i)
#define setpre(number) cout<<fixed<<setprecision(10)<<number<<endl
#define pf(a) printf("%lld ",a)
#define pff(a,b) printf("%lld %lld\n",a,b)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll i=x;i<=y;i++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p make_pair
#define ff first
#define ss second
#define p_b push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define output freopen("output.txt","w",stdout)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp1;
vector<pair<ll,ll> >vpp,vp1;
vector<ll>v,v1,v2,fin;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb,mb1;
ll a,b,c,n,d,e,f,ta,sum=0,cnt=0,m,l,req,sz,maxi,k;
int main()
{
    cin>>n;
    ll arr[n+10];
    FOR(i,n)
    {
        cin>>a;
        v.p_b(a);
    }
    ll ans=0;
    sort(v.rbegin(),v.rend());
    for(ll i=1;i<=n;i++) arr[i]=v[i-1];
    for(ll i=2;i<=n;i++)
    {
        ll x=(i+1)/2;
        ans+=arr[x];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

// DAME:
int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    int active = 0;
    rep(i, n){
        if(active >= h[i]){
            active = h[i];
        }else{
            ans += h[i] - active;
            active = h[i];
        }
    }

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

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

int main(){
	int n;
	
	cin >> n;
	
	int maxA = -1000000;
	int minA =  1000000;
	long int sum  =  0;
	
	for(int i=0; i<n; i++){
		int a;
		
		cin >> a;
		
		sum += a;
		maxA = max(a, maxA);
		minA = min(a, minA);
	}
	cout << minA << " " << maxA << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 50;
const int mod = 1e9 + 7;
inline int add(int x, int y) {int res = x + y; if (res >= mod) res -= mod; return res;}
inline int mul(int x, int y) {ll res = (ll)x * y; res -= res / mod * mod; return res;}
struct Mat
{
    int mat[N][N], n;
    Mat(int _n):n(_n){memset(mat, 0, sizeof(mat));}
    Mat(){}
    void init() { for (int i = 0; i < n; i++) mat[i][i] = 1;}
    Mat operator * (const Mat &rhs) const 
    {
        Mat res(n);
        for (int k = 0; k < n; k++)
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    res.mat[i][j] = add(res.mat[i][j], mul(mat[i][k], rhs.mat[k][j]));
        return res;
    }
    void print()
    {
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                printf("%d%c", mat[i][j], j == n - 1? '\n' : ' ');
    }
};
int main()
{
    int n; ll k; scanf("%d%lld", &n, &k); 
    Mat bs(n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf("%d", &bs.mat[i][j]);
    Mat res(n); res.init(); 
    while (k)
    {
        if (k & 1) res = res * bs;
        bs = bs * bs;
        k /= 2;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = add(ans, res.mat[i][j]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;

int main()
{
	int n, i, cnt = 1;
	string s;
	cin >> n;
	cin >> s;
	for(i = 1; i < n; i++) {
	   cnt += (s[i-1]!=s[i])?1:0;
	}
	cout << cnt << endl;	
	return 0;
}


Measured memory_bytes: 512
n=int(input())
dic=dict()
for i in range(n):
  s = ''.join(sorted(list(input())))
  if s in dic:
    dic[s] += 1
  else:
    dic[s]=1
res = sum([x*(x-1)//2 for x in dic.values() if x > 1])
print(res)

Measured memory_bytes: 17808