akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        
        String[] array1 = line1.split(" ");
        int n = Integer.parseInt(array1[0]);
        int m = Integer.parseInt(array1[1]);
        
        String result = "No";
        
        if(n == m)
        {
            result = "Yes";
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
N,K = map(int,input().split())

def f(X):
    ans = 0
    while (2**ans)*X < K:
        ans += 1
    return ans

b = 0.0
for i in range(1,N+1):
    b += 1/(2**f(i))

print("{:.10}".format(b/N))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
using namespace std;
 
int main() {
  int N; cin >> N;
 
  pair<pair<string,int>,int> p[N];
  rep( i, 0, N ) {
    string S;
    int P;
    cin >> S >> P;
    p[i] = make_pair( make_pair( S, -P ), i );
  }
 
  sort( p, p+N );
  rep( i, 0, N ) cout << p[i].second+1 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

//ll ceil(ll val) return

void Main()
{
	ll N,A,B,C,D,E;
	ll result=0;
	cin>>N>>A>>B>>C>>D>>E;

	result=1+((N-1)/min({A,B,C,D,E}))+4;

	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int X,Y,Z;
    cin >> X >> Y >> Z;

    cout << (X-Z)/(Y+Z) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
int N,prs;
bool co[3000001];
vector<int> ans;
void sf(int n=300000)
{
  for (int i=2;i*i<=n;i++)
    if (!co[i]) 
    {
      for (int j=i*i;j<=n;j+=i)
        co[j]=true;
    }
}
int main()
{
  cin>>N;
  sf();
  for (int i=2;ans.size()<N;i++)
  {
    if (i%5==1&&!co[i]) ans.push_back(i);
  }
  for (int i=0;i<N;i++)
    cout<<ans[i]<<" \n"[i==N-1];
  //system("pause");
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

int main() {
  makes(s1);
  makes(s2);
  makes(s3);
  cout<<s1[0]<<s2[1]<<s3[2]<<endl;
}

Measured memory_bytes: 256
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			while (true)
			{

				int n = int.Parse(Console.ReadLine());
				if (n == 0)
				{
					Console.Write("\n");
					break;
				}
				double m = 0, sq = 0;
				string[] str = Console.ReadLine().Split(' ');
				double[] s = new double[str.Length];
				for (int i = 0; i < str.Length; i++)
				{
					s[i] = double.Parse(str[i]);
					m += s[i];
					sq += s[i] * s[i];

				}
				m /= (double)n;
				sq /= (double)n;
				Console.WriteLine(Math.Sqrt(sq - m * m));
			}
		}
	}
}

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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    double p = 0.0;
    for (int i = 1; i <= min(K-1, N); ++i) {
        int po = ceil(log2(((double)K)/i));
        p += pow(0.5, po);
    }
    if (N >= K)
        p += N - K + 1;
    cout << setprecision(12) << p/N << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int n = 100000;
class nanika {
	int fac[100001], inv[100001];
public:
	constexpr nanika() : fac(), inv() {
		fac[0] = 1;
		rep1(i, n) fac[i] = ll(fac[i - 1]) * i % mod;
		ll ifac = 1;
		ll A = fac[n];
		ll B = mod - 2;
		while (B > 0) {
			if (B & 1) ifac = ifac * A % mod;
			A = A * A % mod;
			B >>= 1;
		}
		for (int i = n; i > 0; i--) {
			inv[i] = fac[i - 1] * ifac % mod;
			ifac = ifac * i % mod;
		}
	}
	int operator[](int n) {
		return inv[n];
	}
	int getfac(int n) {
		return fac[n];
	}
} test;

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


	int N = getint();
	int kei = 0;
	ll kotae = 0;
	int mae = getint();
	rep1(i, N - 1) {
		int tugi = getint();
		ll X = tugi - mae;
		kei = (kei + test[i]) % mod;
		kotae += kei * X % mod;
		mae = tugi;
	}

	printf("%lld\n", kotae % mod * test.getfac(N - 1) % mod);


	Would you please return 0;
}

Measured memory_bytes: 256
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

  int k, n;
	cin >> k >> n;
  int a[n], sa[n];
  int m = -1;
  FOR(i, 0, 2*n-2) {
    if (i <= n-1) {
      int at;
      cin >> at;
      a[i] = at;
    }
    if (i >= 1 && i <= n) {
      sa[i-1] = a[i] - a[i-1];
      if (i == n) {
        sa[i-1] = min(a[i-1]-a[0], k-a[i-1]+a[0]);
      }
      if (sa[i-1] > m) {
        m = sa[i-1];
      }
    }
  }
	cout << k-m << "\n";
}


Measured memory_bytes: 1656
#include<cstdio>
#include<cmath>
int main()
{
	int a,b,c,d,s1,s2;
	scanf("%d%d",&a,&b);
	scanf("%d%d",&c,&d);
	s1=a*b;
	s2=c*d;
	if(s1>s2) printf("%d\n",s1);
	else printf("%d",s2);
	return 0;
}

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

int N, M;
vector<int> v[100010];
int s[100010] = {};
bool gone[100010] = {};

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        int A, B;
        scanf("%d%d", &A, &B);
        v[A].push_back(B);
        v[B].push_back(A);
    }

    queue<pair<int, int>> q;
    q.push(make_pair(1, -1));
    while(!q.empty()) {
        auto e = q.front();
        q.pop();
        int cur = e.first;
        int par = e.second;
        if(gone[cur]) continue;
        gone[cur] = true;
        s[cur] = par;
        for(int child : v[cur]) {
            q.push(make_pair(child, cur));
        }
    }

    for(int i = 2; i <= N; ++i) {
        if(!gone[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int i = 2; i <= N; ++i) {
        cout << s[i] << endl;
    }
}


Measured memory_bytes: 12456
#include<stdio.h>
int main(void)
{
  int x;
  scanf("%d",&x);
  if(x>=400&&x<=599){
    printf("8\n");
  }
  else if(x>=600&&x<=799){
    printf("7\n");
  }
  else if(x>=800&&x<=999){
    printf("6\n");
  }
  else if(x>=1000&&x<=1199){
    printf("5\n");
  }
  else if(x>=1200&&x<=1399){
    printf("4\n");
  }
  else if(x>=1400&&x<=1599){
    printf("3\n");
  }
  else if(x>=1600&&x<=1799){
    printf("2\n");
  }
  else if(x>=1800&&x<=1999){
    printf("1\n");
  }
  return 0;
}

                         
           


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;

  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  ll l = 0, r = 0;
  ll ans = 0;
  ll sum = 0;

  while (l < n) {
    if (r == n) {
      ans += r - l;
      l++;
      continue;
    }
    if (sum + a[r] == (sum ^ a[r])) {
      sum += a[r++];
    } else {
      ans += r - l;
      sum -= a[l];
      l++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	string a,b;
  	cin >> a >> b;
  	int sum=0;
  	for(int i=0;i<a.size();i++){
    	if(a[i]!=b[i]){
          sum++;
        }
    }
  	cout << sum << endl;
}

Measured memory_bytes: 3856
#include <stdio.h>

int selectionSort(int A[], int n){
    int i, j, t, sw=0, min_i;
    for(i=0;i<n-1;i++){
        min_i=i;
        for(j=i;j<n;j++){
            if(A[j]<A[min_i]) min_i=j;
        }
        t=A[i];A[i]=A[min_i];A[min_i]=t;
        if(i!=min_i) sw++;
    }
    return sw;
}

int main(){
    int A[100], n, i, sw;
    scanf("%d", &n);
    for(i=0;i<n;i++)scanf("%d", &A[i]);
    sw=selectionSort(A,n);
    for(i=0;i<n;i++){
        if(i>0)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);
    return 0;
}

Measured memory_bytes: 1036
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main() {
	int n, i, j = 0;
	scanf("%d", &n);
	char s[n];
	for (i = 0; i < n; i++){
		scanf("%s", &s[i]);
	}
	while (j < n) {
		if (s[j] == 'Y') break;
		j++;
	}
	if (j < n) printf("%s\n", "Four");
	else printf("%s\n", "Three");
	return 0;
}

Measured memory_bytes: 128
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
goal = gets.chomp.to_i
result = 0

0.upto(a) do |gohyaku|
  0.upto(b) do |hyaku|
    0.upto(c) do |goju|
      result += 1 if goal == gohyaku * 500 + hyaku * 100 + goju * 50
    end
  end
end

puts result


Measured memory_bytes: 1788
#include<cstdio>

int n =0;
long long int a =0;
long long int ans =0;
long long int gcdr = 0;

long long int gcd(long long int a,long long int b){    //辗转相除法
	    if (b==0) return a;
	    
    	return gcd(b, a%b);
}

int main(void){
	scanf("%d",&n);
	scanf("%lld",&a);
	ans = a;
	for(int i=1;i<n;i++){
		scanf("%lld",&a);
		gcdr = gcd(a,ans);
		ans = a*(ans/gcdr);
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  string a,b,c;
  cin>>a>>b>>c;

  cout<<a[0]<<b[1]<<c[2]<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ','));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var args = new double[1001];
			args[0] = 0;
			args[1] = 0;
			for(int i = 2; i < 1001	; i++) {
				args[i] = args[i - 1] + Acos((i + (i - 1) - 1) / (2 * Sqrt(i) * Sqrt(i - 1)));
			}
			while(true) {
				var lineNo = cin.ReadInt;
				if(lineNo < 0) break;
				var r = Sqrt(lineNo);
				var th = args[lineNo];
				Console.WriteLine($"{r * Cos(th)}\n{r * Sin(th)}");
			}
		}
		
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

}



Measured memory_bytes: 16448
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x/gcd(x,y)*y;
}
int main(){
	int n,m;
	cin >> n >> m;
	string s,t;
	cin >> s >> t;
	vector<char> c;
	ll l=lcm(n,m);
	bool ans=true;
	//int nn=0,mm=0;
	ll k=lcm(l/n,l/m);
	for(ll i=1;i<=l;i+=k){
		if(s[(i-1)*n/l]!=t[(i-1)*m/l]) ans=false;
	}
	/*
	for(ll i=1;i<=l;i++){
		if(i==nn*l/n+1 && i==mm*l/m+1) if(s[nn]!=t[mm]) ans=false;
		if(i==nn*l/n+1) nn++;
		if(i==mm*l/m+1) mm++;
		if(nn==n) nn=0;
		if(mm==m) mm=0;
		if(nn==0 && mm==0) break;
	}
	*/
	if(ans) cout << l << endl;
	else cout << -1 << endl;
}


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

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

	ll i,j,k,l,m,n,t;

	cin >> n;

	if(n%1000 == 0)
		cout << 0 << '\n';
	else
		cout << 1000-n%1000 << '\n';

}

Measured memory_bytes: 3644
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int q;
	cin >> q;
	while (q--) {
		int c, a, n, ans = 0;
		cin >> c >> a >> n;
		for (int z = 0; z <= n; ++z) {
			for (int x = 0; x <= a - z; ++x) {
				int y = (c - 2 * x - z) / 3;
				if (y >= 0 && 2 * x + 3 * y + z <= c) {
					ans = max(ans, x + y + z);
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int M,N,K;

int cumsum[4][1024][1024];

int main(){
  cin >> M >> N >> K;
  rep(i,M){
    string str;
    cin >> str;
    rep(j,N) cumsum[str[j]=='J'?0:str[j]=='O'?1:2][i+1][j+1]++;
  }
  
  rep(k,3){
    rep(i,M+1) rep(j,N) cumsum[k][i][j+1] += cumsum[k][i][j];
    rep(j,N+1) rep(i,M) cumsum[k][i+1][j] += cumsum[k][i][j];
  }

  /*  rep(k,3){
    rep(i,M+1){
      rep(j,N+1) cout << cumsum[k][i][j] << " "; cout << endl;
    }cout << endl;
    }*/

  rep(i,K){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    rep(j,3)
      cout << (j?" ":"") << cumsum[j][a-1][b-1] - cumsum[j][a-1][d] - cumsum[j][c][b-1] + cumsum[j][c][d];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 13492
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let mut n: i64 = input();
    let mut s_vec: Vec<u64> = Vec::new(); 
    let mut i = -2;
    if n == 0 {
        println!("0");
        return
    }
    while n != 0 {
        // println!("i = {}, n = {}", i, n);
        if n % i == 0 {
            s_vec.push(0);
        } else {
            s_vec.push(1);
            n -= i / -2;
        }        
        i *= -2;
    }
    s_vec.reverse();
    for s in s_vec {
        print!("{}", s);
    }
    println!();
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = deque<bool>;
using pii = pair<int, int>;
using pll = pair < ll, ll>;

#define FOR(i,N) for(int i=0;i<N;i++)
#define FOR2(i, N) for(int i=1;i<=N;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define all(x) x.begin(), x.end() 

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

constexpr int PRIME_NUM = 100000;
vector<int> primes;
bitset<10000000> primebits = 3;
void primes_sieve(void) {
    for (int i = 2; i < PRIME_NUM; i++) {
        if (!primebits[i]) {
            primes.push_back(i);
            for (int j = i; j < PRIME_NUM; j += i) {
                primebits[j] = true;
            }
        }
    }
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	
    primes_sieve();
    vi ness;
    for(int i:primes) {
        if (i % 2 == 1  && binary_search(all(primes), (i + 1) / 2)) {
            ness.pb(i);
        }
    }
    int Q;
    cin >> Q;
    FOR(i, Q) {
        int l, r;
        cin >> l >> r;
        cout << distance(lower_bound(all(ness), l), upper_bound(all(ness), r)) << endl;
    }

	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   string s;
   cin>>s;
   int cr=0;
   for(int i=0;i<s.length();i++)
   {
       if(s[i]=='R')cr++;
   }
   int cr1=0;
   for(int i=0;i<cr;i++)
   {
       if(s[i]=='R')cr1++;
   }
   cout<<(cr - cr1)<<endl;
}


Measured memory_bytes: 3756
w = list(input())
ans = {}
for i in w :
    if i in ans : ans[i] += 1
    else : ans[i] = 1
count = 0
for i in ans.keys():
    if ans[i] % 2 == 0 :
        pass
    else: count += 1
if count == 0: print("Yes")
else: print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long int s=0;
  for(int i=1;i<=n;++i)
  {
    if(i%3!=0 && i%5!=0)
    {
      s+=i;
    }
  }
  cout<<s;
}


Measured memory_bytes: 3636
n, c, k = gets.split.map(&:to_i)
ts = n.times.map { gets.to_i }.sort!.reverse!

ans = 1
base = ts.first
passengers = 1

1.upto(n - 1) do |i|
  if ts[i] + k < base || passengers == c
    ans += 1
    base = ts[i]
    passengers = 0
  end

  passengers += 1
end

puts ans


Measured memory_bytes: 4016
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


int main() {
    Int N,ans;
    ans =0;
    cin >> N;
    vi A = vi(N);
    rep(i,N){
        cin >> A[i];
    }

    vi B = A;

    sort(B.begin(),B.end());
    rep(i,N){
        if (A[i] == B[N-1]){
            cout << B[N-2] << endl;
        }else{
            cout << B[N-1] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4736
// B - Frog 2
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N, K; cin>>N>>K;
	vector<int> h(N); for(int i=0; i<N; i++) cin>>h[i];
	vector<int> dp(N, INT_MAX);
	dp[0] = 0;
	for(int n=0; n<N-1; n++){
		for(int k=1; k<=min(N-1-n, K); k++){
			dp[n+k] = min(dp[n+k], dp[n] + abs(h[n] - h[n+k]));
		}
	}
	cout<< dp[N-1] <<endl;
}

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

int main(void){
	int n;
	while(true){
		cin >> n;
		if(!n) break;
		vector<int> a(n);
		for(int i = 0; i < n; ++i){
			cin >> a[i];
		}
		sort(a.begin(), a.end());
		int ans = a[1] - a[0];
		for(int i = 0; i < n-1; ++i){
			ans = min(ans, a[i+1] - a[i]);
		}
		cout << ans << endl;
	}
	return 0;
}


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

int alphabet[('z' - 'a' + 1)];

int main() {
    string S;
    cin >> S;
    if(S.size() < 26) {
        for(auto &p : S) ++alphabet[p - 'a'];
        for(int i = 0; i < 'z' - 'a' + 1; ++i) {
            if(!alphabet[i]) {
                cout << (S + (char)(i + 'a')) << endl;
                return 0;
            }
        }
    }

    int i = S.size()-1;
    while(i-1 >= 0 && S[i-1] > S[i]) --i;
    //cout << i << endl;
    if(i == 0) {
        cout << -1 << endl; 
    }
    else {
        char ch = 'z';
        for(int j = S.size()-1; j >= i; --j) {
            if(S[j] > S[i-1]) {
                ch = min(ch, S[j]);
            }
        }
        cout << (S.substr(0, i-1) + ch) << endl;
    }
    return 0;
}

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

int main() {
    int ans = 0;
    string str;
    cin >> str;
    rep(i, str.length() - 1) {
        if(str.at(i) != str.at(i + 1)) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
  int a = 0, b = 0;
  cin >> a >> b;
  if (a * b % 2 == 0)
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
}

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

class SegmentTreeRSQ {
private:
    int n;
    vector<LL> node, lazy;

public:
    void init(vector<LL> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, LL x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

   LL getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        LL vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        LL vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main(){
    string s;cin >> s;
    vector<deque<int>> cnt(26);
    vector<LL> vec;
    for(int a = 0;a < s.size();a++){
        cnt.at(s.at(a)-'a').push_back(a);
        vec.push_back(a);
    }
    map<char,int> mp;
    for(int a = 0;a < s.size();a++){
        mp[s[a]]++;
    }
    int result = 0;
    for(auto  a : mp){
        if(a.second%2 == 1)result++;
    }
    if(s.size()%2 != result){
        cout<<-1<<endl;
        return 0;
    }
    SegmentTreeRSQ Seg;
    Seg.init(vec);
    LL ans = 0;
    for(int i = 0;i < s.size()/2;i++){
        int cost = 1e9;
        int index = -1;
        for(int j = 0;j < 26;j++){
            if(cnt.at(j).size() <= 1)continue;
            if(cost > Seg.getsum(cnt.at(j).front(),cnt.at(j).front()+1) + (s.size()-1-Seg.getsum(cnt.at(j).back(),cnt.at(j).back()+1)-i*2)){
                cost = Seg.getsum(cnt.at(j).front(),cnt.at(j).front()+1) + (s.size()-1-Seg.getsum(cnt.at(j).back(),cnt.at(j).back()+1)-i*2);
                index = j;
            }
        }
   //     cout<<cnt.at(index).front()<<" "<<cnt.at(index).back()<<endl;
        ans += cost;
        Seg.add(cnt.at(index).front(),s.size(),-1);
        Seg.add(cnt.at(index).back(),s.size(),-1);
        cnt.at(index).pop_front();
        cnt.at(index).pop_back();
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 12604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    map<ll,ll> m;
    ll ans=0;
    rep(i,n){
        int a;
        cin>>a;
        m[a]++;
        ans+=a;
    }
    int q;
    cin>>q;
    rep(i,q){
        ll b,c;
        cin>>b>>c;
        if(m[b]>0){
            ans+=(c-b)*m[b];
            m[c]+=m[b];
            m[b]=0;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 9244
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];


int main () {
    string S, T, U;
    cin >> S >> T;

    int A, B;
    cin >> A >> B;

    cin >> U;
    if( U == S) A-=1;
    if( U == T) B-=1;

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long l,m,n,sum=0;
    int i,j,k;
    scanf("%lld %lld %lld",&l,&m,&n);
    long long a[l][m],b[m][n],c[l][n];
    for(i=0;i<l;i++){
        for(j=0;j<m;j++){
            scanf("%lld",&a[i][j]);
        }
    }
     for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            scanf("%lld",&b[i][j]);
        }
    }
    for(i=0;i<l;i++){
        for(j=0;j<n;j++){
            for(k=0;k<m;k++){
                sum=sum+(a[i][k]*b[k][j]);
            }
            c[i][j]=sum;
            sum=0;
        }
    }
    for(i=0;i<l;i++){
        for(j=0;j<n-1;j++){
            printf("%lld ",c[i][j]);
        }
        printf ("%lld\n",c[i][j]);
    }
    return 0;
}


Measured memory_bytes: 2100
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	int can1 = 1;
	int pos = 1;
	int l = 1;
	while (pos < s.length())
	{
		++can1;
		if (l == 2)
		{
			++pos;
			l = 1;
		}
		else if (s[pos - 1] == s[pos])
		{
			pos += 2;
			l = 2;
		}
		else ++pos;
	}
	if (pos > s.length())--can1;

	int can2 = 1;
	reverse(all(s));
	pos = 1;
	l = 1;
	while (pos < s.length())
	{
		++can2;
		if (l == 2)
		{
			++pos;
			l = 1;
		}
		else if (s[pos - 1] == s[pos])
		{
			pos += 2;
			l = 2;
		}
		else ++pos;
	}
	if (pos > s.length())--can2;

	cout << max(can1, can2) << endl;
}

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

using namespace std;

int dp1[1000500];
int dp2[1000500];

int main(void)
{
	vector <int> data;
	int n = 1;
	while (1){
		int tmp = n * (n + 1) * (n + 2) / 6;
		if (1000000 < tmp) break;
		data.push_back(tmp);
		n++;
	}
	fill(dp1, dp1 + 1000500, 99999);
	fill(dp2, dp2 + 1000500, 99999);
	dp1[0] = dp2[0] = 0;
	for (int i = 0; i < 1000500; i++){
		for (int j = 0; j < data.size(); j++){
			if (1000500 < i + data[j]) break;
			dp1[i + data[j]] = min(dp1[i + data[j]], dp1[i] + 1);
		}
	}
	for (int i = 0; i < 1000500; i++){
		for (int j = 0; j < data.size(); j++){
			if (1000000 < i + data[j]) break;
			if (data[j] % 2 == 1) dp2[i + data[j]] = min(dp2[i + data[j]], dp2[i] + 1);
		}
	}

	while (cin >> n, n){
		cout << dp1[n] << " " << dp2[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 9036
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <vector>

using namespace std;

typedef pair<int ,int> pii;
typedef long long ll;
const int maxn = 1e5 + 10;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;

int main()
{
	int n;
	while (cin>>n){
		int k=n;
		int ans=0;
		while (k){
			ans+=k%10;
			k/=10;
		}
		if (n%ans==0)printf ("Yes\n");
		else printf ("No\n");
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int w,h,n; cin >> w >> h >> n;
  vi x(n),y(n),a(n); rep(i,n) cin >> x[i] >> y[i] >> a[i];
  vector<vector<bool>> white(h,vector<bool>(w,true));

  rep(i,n){
    if(a[i] == 1) rep(j,h) rep(k,x[i]) white[j][k] = false;
    else if(a[i] == 2) rep(j,h) for(int k = x[i]; k < w; k++) white[j][k] = false;
    else if(a[i] == 3) rep(j,y[i]) rep(k,w) white[j][k] = false;
    else if(a[i] == 4) for(int j = y[i]; j < h; j++) rep(k,w) white[j][k] = false;
  }
  int ans = 0;
  rep(i,h) rep(j,w) if(white[i][j]) ans++;
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3616
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1e9+7;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int T[2000005];
int32_t main()
{
    speed
    int n;
    cin>>n;
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                T[i*i+j*j+k*k+i*j+i*k+j*k]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout<<T[i]<<"\n";
    return 0;
}


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

#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pr1(a) printf("%d\n",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define loop(i,a,b) for(ll i=a;i<b;i+=1)
#define ll long long int
#define ld long double
#define lvec vector<long long int> v
#define vec vector<int> v
#define ite1 vector<int>:: iterator it1
#define ite2 vector<int>:: iterator it2
#define ite3 vector<int>:: iterator it3
#define mp make_pair
#define pb push_back
#define pf push_front
#define pff pop_front
#define pbb pop_back
#define ft first
#define sd second

int main()
{
    int t=1;

    //cin>>t;           // comment this line when number of testcases = 1

    while(t--)
    {
        ll n,cap;
        cin>>n>>cap;
        ll w[n];
        ll v[n];
        loop(i,0,n)
        {
            cin>>w[i]>>v[i];
        }
       // cout<<"G";
        ll dp[n][100000];
       // cout<<"H";
        loop(i,0,n)
        {
            loop(j,0,100000)
            {
                dp[i][j]=100000000000000;
            }
        }

        loop(i,1,v[0])
        {
            dp[0][i] = w[0];
        }

        loop(i,1,n)
        {
            loop(j,0,v[i])
            {
                dp[i][j] = min(dp[i-1][j],w[i]) ;
            }

            loop(j,v[i],100000)
            {
                dp[i][j] = min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            }
        }

        for(int i=100000-1; i>=0; i--)
        {
            if(dp[n-1][i]<=cap)
            {
                cout<<i+1;
                break;
            }
        }
    }
}


Measured memory_bytes: 78336
import java.util.Scanner;

public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int count = 0;
		int[] a = new int[n+5];
		
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		
		for (int i = 1; i <= n; i++) {
			if (i == a[a[i]]) {
				count++;
				a[a[i]] = 0;
			}
		}
		
		System.out.println(count);
	}
	
}


Measured memory_bytes: 32356
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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


signed main() {

    int n,m,x;cin >>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> sc(n,vector<int>(m));
    rep(i,n){
        cin >>c[i];
        rep(j,m){
            cin >>sc[i][j];
        }
    }

    int ans=-1;//if -1,ans=cnt
    for(int bit=0;bit<(1<<n);bit++){
        int cnt=0;
        vector<int> rikai(m);
        rep(i,n){
            if(bit&(1<<i)){
                cnt+=c[i];
                rep(j,m){
                    rikai[j]+=sc[i][j];
                }
            }
        }
        bool ju=true;
        rep(i,m){
            if(rikai[i]<x)ju=false;
        }
        if(ju){
            if(ans==-1)ans=cnt;
            else ans=min(ans,cnt);
        }
    }
    cout <<ans<<endl;
}


















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

using namespace std;

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

    int x, y;
    cin >> x >> y;
    if(y & 1)
    {
        cout << "No";
        return 0;
    }
    if((x << 2) < y)
    {
        cout << "No";
        return 0;
    }
    y >>= 1;
    if(x > y)
    {
        cout << "No";
        return 0;
    }
    cout << "Yes";

    return 0;
}


Measured memory_bytes: 3656
N = int(input())
H_raw = input()
H = H_raw.split(' ')
count = 0
max = 0
for i in range(N):
  if i == 0:
    continue
  if int(H[i]) <= int(H[i - 1]):
    count = count + 1
  else:
    if count > max:
      max = count
    count = 0
    
if count > max:
  max = count
  
print(max)

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
    int a[100005];
    int b[100005];



int getp(int x){
    if(b[x]==x)return x;
    else {
            int p=getp(b[x]);
            b[x]=p;
    //printf("%d:%d\n",x,p);
    return p;
    }

}
bool can(int x,int y){
    if(getp(x)==getp(y))return true;
    else return false;
}
void seti(int x,int y){
    if(x==y)return;
    if(x>y){
        x=x^y;
        y=x^y;
        x=x^y;
    }
    int px=getp(x);
    int py=getp(y);
    if(px!=py){
        int t=px<py?px:py;
        b[px]=b[py]=t;
    }else return;


}
int main()
{
    int n,m;
    cin>>n>>m;

    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i+1]);
        b[i+1]=i+1;
    }
    for(int i=0; i<m; i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        seti(x,y);
    }
    int res=0;
    for(int i=1;i<=n;i++){
       // printf("test%d:%d\n",i,a[i]);
        if(a[i]==i)res++;
        else if(can(a[i],i))res++;
    }
    printf("%d",res);


}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
typedef long long ll;
 
ll n,k;
ll w[100000];
 
bool check(int x){
  ll cost=0,cnt=0;
  for(ll i=0;i<n;i++){
    cost+=w[i];
    while(cost>x){
      cost=w[i];
      cnt++;
      if(cnt==k)return false;
    }
  }
  return true;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  for(ll i=0;i<n;i++)cin>>w[i];
  ll l=0,r=1000000000LL,m;
  while(l<r){
    m=(l+r)/2;
    if(check(m))r=m;
    else l=m+1;
  }
  cout<<l<<endl;
  return 0;
}


Measured memory_bytes: 3996
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
void solve(){
    int a,b; cin>>a>>b;
    if(a<b) cout<<0;
    else cout<<10;
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256