akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    int n;
    while(cin >> n && n != -1) {
        double x = 1.0;
        double y = 0.0;
        double theta = M_PI_2;
        for(int i = 1; i < n; i++) {
            x += cos(theta);
            y += sin(theta);
            theta = atan2(y, x) + M_PI_2;
        }
        printf("%.2f", x);
        cout << endl;
        printf("%.2f", y);
        cout << endl;
    }
     
    return 0;
}

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

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}


//------------------------------------------------------------------------------------------------------------------------------


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

	INPUT_INT(N);

	INPUT_VECTOR_INT(A, N);
	INPUT_VECTOR_INT(B, N);
	INPUT_VECTOR_INT(C, N-1);

	int n = 0;

	REP(i, N) {

		n += B[A[i]-1];

		if (i > 0 && A[i] == A[i-1]+1) {
			n += C[A[i-1]-1];
		}
	}

	OUTPUT(n);

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
void F(double m, int M[]) {
	if (m >= 1.1) M[0]++;
	else if (m >= 0.6) M[1]++;
	else if (m >= 0.2)M[2]++;
	else M[3]++;
}
int main() {
	double l, r;
	int L[4] = { 0 }, R[4] = { 0 },i;
	while (~fscanf(stdin, "%lf%lf", &l, &r)) {
		F(l, L), F(r, R);
	}
	for (i = 0; i < 4; i++) fprintf(stdout, "%d %d\n", L[i], R[i]);
	return 0;
}

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

inline int ceiling_div(int a, int b){
  int ans= ((a>=0 && b > 0) || (a<=0 && b < 0)) ? (abs(a)+abs(b)-1)/abs(b)
                                                    : -abs(a)/abs(b);
  return ans;
}

int main(){
  int L,R,d;
  cin >> L >> R >> d;

  int ans= (R/d)- ceiling_div(L,d)+ 1;
  
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define fi              first
#define se              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
const int N=2e5+5;
		
		
int main()
{
	 FIO;
	 
	 ll n,k;
	 cin>>n>>k;
	 
	 ll arr[n+1]={0};
	 for(ll i=0;i<k;i++)
	 {
		 ll d;
		 cin>>d;
		 
		 for(ll j=0;j<d;j++)
		 {
			 ll u;
			 cin>>u;
			 arr[u]++;
		 }
	 }
	 ll ans=0;
	 for(ll i=1;i<=n;i++)
	 {
		 if(arr[i]==0)
			ans++;
	 }
	 cout<<ans;
	 
				
			
			 
}


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

int order[100099];
int A[100099];
long long sum = 0;

int main() {
	// your code goes here
	
	int n,k;cin>>n>>k;
	
	for(int i=0;i<n;i++) {cin>>A[i];sum+=A[i];}
	
	int i = 0, j = n-1, p = 0;
	bool flag=false;
	
for(;i<n-1;i++){
	if(A[i]+A[i+1]>=k){
		flag=true;
		break;
	}
}
if(!flag){
	cout<<"Impossible"<<endl;
}
else{
	cout<<"Possible"<<endl;
		for(int k=0;k<i;k++) cout<<k+1<<endl;
			for(int k=n-1;k>i;k--) cout<<k<<endl;
			//cout<<i+1<<endl;
}
	


	
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int x; cin >> x;
  string result;
  if (x<1200) result = "ABC";
  else result = "ARC";
  cout << result << endl;
  return 0;
}

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

template<size_t mx>
class SnukeNumber{
private:
    constexpr long long int digitsum(long long int a){
        long long int ret = 0;
        while(a){
            ret += a % 10;
            a /= 10;
        }
        return ret;
    }

    constexpr long double f(long long int a){
        long long int ret = digitsum(a);
        return a / static_cast<long double>(ret);
    }

public:
    long long int ans[mx];

    constexpr SnukeNumber() : ans(){
        size_t cnt = 0;
        long double a = f(1), b = f(2);
        long long int s = 1, t = 1;

        for(long long int i = 1; cnt < mx; i += s){
            b = f(i + s);

            if(a < b){
                s = t;
                b = f(i + s);
            }
            if(a > b){
                if(s == t)t *= 10;
            }else{
                ans[cnt] = i;
                ++cnt;
            }

            long double tmp = a;
            a = b;
            b = tmp;
        }
    }
};

constexpr SnukeNumber<792> S = SnukeNumber<792>();

long long int K;

int main(){
    scanf("%lld", &K);
    for(int i = 0; i < K; ++i)printf("%lld\n", S.ans[i]);
    return 0;
}

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

namespace AOJ.Volume2
{
    public class RockPaperScissors
    {
        public static int Main()
        {
            while (true)
            {
                // 5人の手を読み込む
                var hand = new List<int>();
                hand.Add(int.Parse(Console.ReadLine()));
                if (hand[0] == 0) { break; }

                hand.Add(int.Parse(Console.ReadLine()));
                hand.Add(int.Parse(Console.ReadLine()));
                hand.Add(int.Parse(Console.ReadLine()));
                hand.Add(int.Parse(Console.ReadLine()));

                // 全員同じ手、またはすべての手がある場合はあいこ
                var gp = hand.GroupBy(x => x).Select(y => new { Key = y.Key, Count = y.Count() });
                if (gp.Count() == 1 || gp.Count() == 3)
                {
                    for (int i = 0; i < 5; i++) { Console.WriteLine(3); }
                    continue;
                }

                // どの手が勝ちか判定
                int h1 = 0, h2 = 0;
                int cnt = 0;
                foreach (var h in gp)
                {
                    if (cnt == 0) { h1 = h.Key; }
                    else { h2 = h.Key; }
                    cnt++;
                }

                int win = 0;
                if (h1 == 1)
                {
                    if (h2 == 2) { win = h1; }
                    else { win = h2; }
                }
                else if (h1 == 2)
                {
                    if (h2 == 1) { win = h2; }
                    else { win = h1; }
                }
                else
                {
                    if (h2 == 1) { win = h1; }
                    else { win = h2; }
                }

                // 勝ち負けを出力
                foreach (var h in hand)
                {
                    if (h == win) { Console.WriteLine(1); }
                    else { Console.WriteLine(2); }
                }
            }
            return 0;
        }
    }
}

Measured memory_bytes: 10152
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
  int get() const { return x; }
};

ModInt<int(1e9 + 7)> dp[51][51][2501];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, K;
  cin >> n >> K;
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = 0; k <= n * n; k++) {
        if (j > 0 && k + 2 * (j - 1) <= n * n)
          dp[i + 1][j - 1][k + 2 * (j - 1)] += dp[i][j][k] * j * j;
        if (k + 2 * j <= n * n)
          dp[i + 1][j][k + 2 * j] += dp[i][j][k] * (2 * j + 1);
        if (j + 1 <= n && k + 2 * (j + 1) <= n * n)
          dp[i + 1][j + 1][k + 2 * (j + 1)] += dp[i][j][k];
      }
  cout << dp[n][0][K] << '\n';
  return 0;
}


Measured memory_bytes: 29072
#include <iostream>
int main()
{
	int a,b,c;
	std::cin >> a >> b >> c;
	if((a+b) == c || (b+c) == a || (c+a) == b)
	{
		std::cout << "Yes" << std::endl;
		return 0;
	}
	std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli n,c=0;
    lli i,j;
    cin>>n;
    rep(i,1,N){
        c+=i;
//        cout<<"cは"<<c<<endl;
        if(n<=c){
            break;
        }
    }
//    cout<<c<<" "<<i<<endl;
    rep(j,1,i+1){
        if(c-n!=j){
            cout<<j<<endl;
        }
    }
}



Measured memory_bytes: 256
import std.stdio, std.math, std.conv, std.algorithm, std.string, std.array;

double[12][1 << 12] dp;
int[] arr;

double search_min_length(int used, int[] rest, int last) {
  if (used == ((1 << arr.length) - 1)) return arr[last];
  if (dp[used][last] != -1) return dp[used][last];
  double res = int.max;
  foreach(int i, x; arr) {
    if (((used >> i) & 1) == 0) {
      double d = 2 * sqrt((arr[last] * arr[i]).to!double);
      res = min(res, d + search_min_length(used | (1 << i), [x] ~ rest, i));
    }
  }
  dp[used][last] = res;
  return res;
}

void main() {
  string str;
  while((str = readln.chomp).length != 0) {
    arr = str.split(" ").map!(x => x.dup.to!int).array;
    double threshold = arr.front.to!double;
    double ans = double.max;
    arr.popFront;
    foreach(ref d; dp)
      foreach(ref x; d) x = -1.0;
    foreach(int i, x; arr) {
      ans = min(ans, (search_min_length(1 << i, [x], i) + x));
    }
    writeln(threshold >= ans ? "OK" : "NA");
  }
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k) cout << s << endl;
  else {
    s = s.substr(0, k);
    cout << s << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
	int input;
	
	cin >> input;
	
	int h, m, s;
	
	s = input % 60;
	m = input / 60;
	h = m / 60;
	m %= 60;
	
	cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x;
    cin >> x;
    if(x == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<int> a(0);
    for(int i = 2;i <= 1000;i++) {
        for(int j = 2;(int)pow(i,j) <= x;j++) {
            a.push_back((int)pow(i,j));
        }
    }
    sort(a.begin(),a.end());
    cout << a.at(a.size() - 1) << endl;
}


Measured memory_bytes: 384
N = int(input())
n = [0 for _ in range(N)]

def cob(m):
    if m <= 0:
        return m
    return m + cob(m-1)

# x > y > z
test = 0
for x in range(1,N+1):
    for y in range(1,x+1):
        if N < x*y:
            break
        for z in range(1,y+1):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if len(set([x,y,z])) == 3:
                cnt = 6
            elif len(set([x,y,z])) == 2:
                cnt = 3
            else:
                cnt = 1
            if ans > N:
                break
            n[ans-1] += cnt

for i in range(N):
    print(n[i])



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

int main() {
    int a, p;
    cin >> a >> p;
    p += a * 3;
    int ans = p / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,n);
	long double ans=0.0;
	REP(i,n){
		VAR(double,x);
		VAR(string,u);
		if(u=="BTC") x *= 380000.0;
		ans += x;
	}
	printf("%llf\n",ans);
	
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	std::vector<int> A(3);
	A[0] = a;
	A[1] = b;
	A[2] = c;
	for (int i = 0; i < 2; i++) {
		for (int j = 2; j > 0; j--) {
			if (A[j] < A[j - 1]) {
				int t = A[j];
				A[j] = A[j - 1];
				A[j - 1] = t;
			}
		}
	}
	std::cout << A[0] << " " << A[1] << " " << A[2] << "\n";
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
typedef long long int LLI;
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=100000;
  rep(i,n){
    ans*=1.05;
    if(ans%1000){
      ans-=ans%1000;
      ans+=1000;
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  vector<vector<int>> A(N, vector<int>(M));
  
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  int counter = 0;
  for (int i = 0; i < N; i++) {
    int score = 0;
    for (int j = 0; j < M; j++) {
      score += A.at(i).at(j) * B.at(j);
    }
    if (score+C > 0) {
      counter++;
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0:
    break
  elif result > 1000000000000000000:
    break

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)


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

int main() {
  string A,B,C;
  cin >> A >> B >> C;
  int N = A.size();
  int M = B.size();
  if (A[N-1] == B[0] && B[M-1] == C[0]) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_d
//D - Knapsack 1

#include <bits/stdc++.h>
using namespace std;

using ll=long long;

void max_self(ll& a, ll b){
	a=max(a,b);
}

int main() {
	
	int n,W;
	cin>>n>>W;
	vector<ll> dp(W+1); // 0...W
	// dp[i] - the maximum total value of items with total weight exactly
	for(int item=0; item<n; ++item){
		int weight, value;
		cin>>weight>>value;
		// dp[0] -> dp[3] -> dp[6]
		for(int weight_alredy=W-weight; weight_alredy>=0; --weight_alredy){
			max_self(dp[weight_alredy+weight], dp[weight_alredy]+value);
		}
	}
	ll answer=0;
	for(int i=0; i<=W; ++i){
		max_self(answer, dp[i]);
	}
	
	cout<<answer<<"\n";
	
	return 0;
}

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

L = [2**(i+2) - 3 for i in range(51)] + [0]
P = [2**(i+1) - 1 for i in range(51)] + [0]

answer = 0
for i in range(N, -1, -1):
  if K == (L[i] + 1) // 2:
    answer += P[i-1] + 1
    break
  elif K > (L[i] + 1) // 2:
    answer += P[i-1] + 1
    K -= (L[i] + 1) // 2
  else:
    K -= 1
  if K == 0:
    break
print(answer)

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi; 
typedef pair<pair<ll ,ll >,ll > pii; 
ll MOD = 1000000007;

int main(){
    
    ll H, W, K;
    cin >> H >> W >> K;

    vector<vector<ll > >dp(H+10, vector<ll >(W + 10, 0));
    //初期化
    dp[0][0] = 1;
    
    for(ll row = 0; row < H; row++){
        //横棒の数だけループを回す
        for(ll col = 0; col < (1 << W - 1); col++){
            //ビットの位置を確認
            bool continue_f = false;
            for(ll conf = 0; conf < W - 2; conf++){
                //1が連続していたら制約に当てはまらない
                if((col >> conf) & 1 && (col >> conf + 1) & 1){
                    continue_f = true;
                    break;
                }
            }
            if(continue_f == true){
                continue;
            }

            vector<ll > col_line(W, 0);
            //初期化
            for(ll i = 0; i < W; i++){
                col_line[i] = i;
            }

            for(ll i = 0; i < W - 1; i++){
                if((col >> i) & 1 == 1){
                    //入れ替える→横棒がはられている縦棒同士の移動
                    swap(col_line[i], col_line[i + 1]);
                }
            }
            
            //場合の数を更新
            //移動する先は横棒がはられていなければ下，はられていれば左右のどちらか
            for(ll r_row = 0; r_row < W; r_row++){
                dp[row + 1][col_line[r_row]] += dp[row][r_row] % MOD;
                dp[row + 1][col_line[r_row]] %= MOD;
                //cout << dp[row + 1][col_line[r_row]] << endl;
            }

        }
    }

    ll ans = dp[H][K - 1];
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int ans=1;
map<int,int> mp;
int arr[n+1];
int mod=998244353;
for(int i=1;i<=n;i++)
{
    cin>>arr[i];
}
if(arr[1]!=0)
{//cout<<"yes"<<endl;
    cout<<0<<endl;
    return 0;
}
arr[0]=0;
sort(arr,arr+n+1);
mp[0]=1;
for(int i=2;i<=n;i++)
{
    ans*=mp[arr[i]-1];
    ans%=mod;
    mp[arr[i]]++;
}
cout<<ans<<endl;
















    return 0;
}


Measured memory_bytes: 10648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 100005
bool vis[100005]={0};
vector<ll>v;
void seive()
{
    for(int i=3;i<=sqrt(mx);i+=2)
    {
        if(vis[i]==0)
        {
            for(int j=i*i;j<mx;j+=2*i)
            {
                vis[j]=1;
            }
        }
    }
    v.push_back(2);
    for(int i=3;i<mx;i+=2)
    {
        if(vis[i]==0)
        {
            v.push_back(i);
        }
    }

}
int main()
{

    seive();
    ll n;
    cin>>n;
    ll x=lower_bound(v.begin(),v.end(),n)-v.begin();
    cout<<v[x]<<endl;


}



Measured memory_bytes: 3824
#配列作成
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

#標準入力を整数値として取得
K = gets.chomp.to_i

#配列sのK番目を出力
puts s[K-1]

Measured memory_bytes: 14384
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,mod=1000000007,dp[51][51][130],pi,p[130];
vector <long long> v[59];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	for(c=1; c<=a; c++){
		for(d=1; d<=a; d++){
			cin>>e;
			if(e==1){
				v[c].push_back(d);
			}
		}
	}
	pi++;
	p[pi]=b;
	c=b;
	while(c>1){
		if(c%2==1){
			pi++;
			p[pi]=c-1;
			pi++;
			p[pi]=c/2;
		}else{
			pi++;
			p[pi]=c/2;
		}
		c/=2;
	}
	for(b=1; b<=pi/2; b++) swap(p[b],p[pi-b+1]);
	for(b=1; b<=a; b++){
		for(int h=0; h<v[b].size(); h++){
			dp[b][v[b][h]][1]=1;
		}
	}
	for(b=2; b<=pi; b++){
		for(c=1; c<=a; c++){
			for(d=1; d<=a; d++){
				for(e=1; e<=a; e++){
					if(p[b]==p[b-1]+1){
						dp[c][d][b]+=dp[c][e][b-1]*dp[e][d][1];
						dp[c][d][b]%=mod;
					}else{
						dp[c][d][b]+=dp[c][e][b-1]*dp[e][d][b-1];
						dp[c][d][b]%=mod;
					}
				}
			}
		}
	}
	d=0;
	for(b=1; b<=a; b++){
	    for(c=1; c<=a; c++){
	        d+=dp[b][c][pi];
	        d%=mod;
	    }
	}
	cout<<d;
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int main(void)
{
	int N; cin >> N;
	int K = 0, max = 1;
	rep(i, 0, N) {
		int tmp; cin >> tmp;
		if (tmp == max) {
			K++;
			max++;
		}
	}
	if (K > 0)cout << (N - K) << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353

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

llint n;
llint w[1005];
vector<llint> G[1005];
llint dp[1005][2];
llint dp2[1005][5005][2];

void dfs(int v)
{
	llint m = G[v].size();
	for(int i = 0; i < m; i++) dfs(G[v][i]);
	
	for(int i = 0; i <= m; i++){
		for(int j = 0; j <= 5000; j++){
			for(int k = 0; k < 2; k++){
				dp2[i][j][k] = inf;
			}
		}
	}
	dp2[0][0][0] = dp2[0][0][1] = 0;
	
	llint sum = 0;
	for(int k = 0; k < 2; k++){
		for(int i = 0; i < m; i++){
			int u = G[v][i];
			for(int j = 0; j <= 5000; j++){
				if(j+w[u] <= 5000) chmin(dp2[i+1][j+w[u]][k], dp2[i][j][k] + dp[u][1-k]);
				if(j+dp[u][1-k] <= 5000) chmin(dp2[i+1][j+dp[u][1-k]][k], dp2[i][j][k] + w[u]);
			}
		}
	}
	
	dp[v][0] = dp[v][1] = inf;
	for(int k = 0; k < 2; k++){
		for(int i = 0; i <= w[v]; i++){
			chmin(dp[v][k], dp2[m][i][k]);
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint p;
	for(int i = 2; i <= n; i++){
		cin >> p;
		G[p].push_back(i);
	}
	for(int i = 1; i <= n; i++) cin >> w[i];
	
	dfs(1);
	
	//for(int i = 1; i <= n; i++) cout << dp[i][0] << " " << dp[i][1] << endl;
	
	if(dp[1][0] < inf/2 || dp[1][1] < inf/2) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	
	return 0;
}

Measured memory_bytes: 78592
#include<bits/stdc++.h>
#define MAXN 100005
#define MAXM 525
#define INF 1000000000000000000
#define MOD 998244353
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m[3];
vector<int> G[MAXN];
int sg[3][MAXN];
int weight[3][MAXM];
bool has[MAXM];
int p[3*MAXN];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<MOD) a+=MOD;}
int main()
{
    ll x=INF%MOD;
    p[0]=1;
    for(int i=1;i<=300000;i++) p[i]=1LL*p[i-1]*x%MOD;
    scanf("%d",&n);
    for(int i=0;i<3;i++)
    {
        scanf("%d",&m[i]);
        for(int j=1;j<=n;j++) G[j].clear();
        for(int j=0;j<m[i];j++)
        {
            int x,y;
            scanf("%d%d",&x,&y);
            if(x>y) swap(x,y);
            G[x].push_back(y);
        }
        for(int j=n;j>=1;j--)
        {
            memset(has,false,sizeof(has));
            for(auto to:G[j]) has[sg[i][to]]=true;
            int k=0;
            for(;has[k];k++);
            sg[i][j]=k;
            add(weight[i][k],p[j]);
        }
    }
    int ans=0;
    for(int i=0;i<512;i++)
        for(int j=0;j<512;j++)
        {
            int k=i^j;
            add(ans,1LL*weight[0][i]*weight[1][j]%MOD*weight[2][k]%MOD);
        }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for(int i=0;i<S.size();i++){
    if(S[i] == T[i]) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200001
ll s[N << 2], t[N << 2];
vector<pair<int, int> > a[N];
void add(int x, int L, int R, int l, int r, ll c) {
    if (l <= L && R <= r) return (void)(s[x] += c, t[x] += c);
    int mid = (L + R) >> 1;
    if (l <= mid) add(x << 1, L, mid, l, r, c);
    if (r > mid) add(x << 1 | 1, mid + 1, R, l, r, c);
    s[x] = max(s[x << 1], s[x << 1 | 1]) + t[x];
}
int n, m;
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1, x, y, z; i <= m; i++) {
        scanf("%d%d%d", &x, &y, &z);
        a[y].emplace_back(x, z);
    }
    for (int i = 1; i <= n; i++) {
        add(1, 1, n, i, i, s[1]);
        for (auto &it : a[i]) add(1, 1, n, it.first, i, it.second);
    }
    printf("%lld\n", max(s[1], 0ll));
    return 0;
}

Measured memory_bytes: 22912
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		long[]A = new long[N];
		string[] str = Console.ReadLine().Split();
		long[]B = new long[N];
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
			B[A[i]-1]++;
		}
		long ans = 0;
		for(var i=0;i<N;i++){
			if(B[i]>0){
				ans += B[i]*(B[i]-1)/2;
			}
		}
		for(var i=0;i<N;i++){
			long ans1 = ans;
			long a1 = B[A[i]-1];
			ans1 -= B[A[i]-1]*(B[A[i]-1]-1)/2;
			if(a1>1){
				ans1 += (B[A[i]-1]-1)*(B[A[i]-1]-2)/2;
			}
			Console.WriteLine(ans1);
		}
	}
}

Measured memory_bytes: 34992
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m;
main(){
  cin>>n>>m;
  int a[n];
  r(i,n)cin>>a[i];
  r(i,m)r(j,n-1){
    int k=i+1;
    if(a[j]%k>a[j+1]%k)swap(a[j],a[j+1]);
  }
  r(i,n)cout<<a[i]<<endl;
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const int N = 2e5 + 1e3;

template<int Maxn>
struct Union_Set {

	int fa[Maxn];

	void Init(int n) {
		For (i, 1, n)
			fa[i] = i;
	}

	int find(int x) {
		return x == fa[x] ? x : fa[x] = find(fa[x]); 
	}

	inline bool Connect(int u, int v) {
		return find(u) == find(v);
	}

	inline void Union(int u, int v) {
		if (!Connect(u, v))
			fa[find(u)] = find(v);
	}

};

Union_Set<N> S, T;

map<int, int> M[N];

int main () {

	File();

	int n = read(), k = read(), l = read();

	S.Init(n); T.Init(n);
	For (i, 1, k)
		S.Union(read(), read());

	For (i, 1, l)
		T.Union(read(), read());

	For (i, 1, n)
		++ M[S.find(i)][T.find(i)];

	For (i, 1, n)
		printf ("%d%c", M[S.find(i)][T.find(i)], i == iend ? '\n' : ' ');

    return 0;

}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

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

//8近傍
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

void solve() {
    string s; cin >> s;
    int n = s.size();
    rep(i,n-1){
        int cnt = 0;
        FOR(j,i,i+3){
            if(j == n) break;
            if(s[i] == s[j]) cnt++;
            if(cnt >= 2){
                cout << i + 1 << " " << j + 1 << endl;
                return;
            }
        }
    }
    cout << "-1 -1" << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
Int ans[111][111];
int ans4[4][3]={{1,3,2},{2,3,0},{3,0,1},{1,2,0}};
void dfs(Int y,Int x,Int n){
  if(n==4){
    for(int i=0;i<n;i++)
      for(int j=0;j+1<n;j++)
	ans[y+i][x+j]=y+ans4[i][j];
    return;
  }
  if(n&1){
    for(Int i=0;i<n;i++)
      for(Int j=0;j+1<n;j++)
	ans[y+i][x+j]=y+(i+j+1)%n;
  }else{
    Int k=n/2;
    for(Int i=0;i<k;i++)
      for(Int j=0;j<k;j++)
	ans[y+i][x+j]=y+k+(i+j)%k;

    for(Int i=0;i<k;i++)
      for(Int j=0;j<k;j++)
	ans[y+k+i][x+j]=y+(i+k-1-j)%k;
    
    dfs(y,x+k,k);
    dfs(y+k,x+k,k);
  }
}
signed main(){
  Int n;
  cin>>n;
  if(n==2){
    cout<<-1<<endl;
    return 0;
  }
  dfs(0,0,n);
  
  for(Int i=0;i<n;i++){
    for(Int j=0;j+1<n;j++){
      if(j) cout<<" ";
      cout<<ans[i][j]+1;
    }
    cout<<endl;
  }
  
  for(Int j=0;j+1<n;j++){
    for(Int i=0;i<n;i++){
      //cout<<i<<" "<<j<<":"<<ans[i][j]<<" "<<ans[ans[i][j]][j]<<endl;
      assert(ans[ans[i][j]][j]!=i);
    }
  }
  
  return 0;
}


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

const int64_t MOD=1000000007;

vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}

int main(){
  int N;
  cin>>N;
  vector<int> primes=sieve_of_eratosthenes(N+1);

  int64_t ans=1;
  for(int i=0;i<=N;++i){
    if(primes.at(i)>0){
      int64_t sum=1;
      int64_t N_plus=N;
      while(N_plus/i>0){
        sum += N_plus/i;
        N_plus /= i;
      }
      ans=ans*sum %MOD;
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque

H ,W = map(int, input().split())
maze = []
for h in range(H):
    maze.append([s for s in input()])

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def bfs_maze(sx,sy):
    que = deque([])
    d = [[float("inf")] * W for i in range(H)]
    que.append((sx,sy))
    d[sx][sy] = 0
    
    while que:
        p = que.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            
            if (0 <= nx < H) and (0 <= ny < W) and (maze[nx][ny] != "#") and (d[nx][ny] == float("inf")):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d

max_d = 0
for w in range(W):
    for h in range(H):
        if maze[h][w] == ".":
            res = bfs_maze(h,w)
            for i in res:
                for j in i:
                    if j !=float("inf") and max_d < j:
                        max_d = j
print(max_d)

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	cout << n*(n-1)/2 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a;
	cin >> a;
	cout << (a + (a * a) + (a * a * a)) << endl;
}

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

	solve();
}



Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int i, num,alt,max=0,min=0;
  scanf("%d",&num);
  int buf[num];
  for(i=0;i<num;i++){
    scanf("%d",&buf[i]);
  }
  max=buf[1]-buf[0];
  min=buf[0]; 
  for(i=1;i<num;i++){
    if(max<buf[i]-min)max=buf[i]-min;
    if(min>buf[i])min=buf[i];
  
  }
  printf("%d\n",max);
  return 0;
}



Measured memory_bytes: 2564
#include<bits/stdc++.h>
#define ll long long
#define pp prev_permutation
#define np next_permutation
#define pi acos(-1)
#define  all(v) (v).begin(),(v).end()
#define gcd(x,y)      __gcd(x,y);
#define lcm(x,y)      ( x / __gcd(x,y) ) * y
///---------------STL-------------------
#define b_s(v,n)    binary_search((v).begin(),(v).end(),n)  /// return bool
#define u_b(v,n)   upper_bound((v).begin(),(v).end(),n)    ///return pointer iterator
#define l_b(v,n)    lower_bound((v).begin(),(v).end(),n)   ///return pointer iterator
///--------------PAIR----------------------
#define mp make_pair
///---------------VECTOR-----------------
#define pb push_back
#define v_sort(v)  sort((v).begin(),(v).end())
#define rv_sort(v) sort((v).rbegin(),(v).rend())
#define  v_sum(v)  accumulate((v).begin(),(v).end(),0)
#define v_min(v)  *min_element(v.begin(),v.end())
#define v_max(v)  *max_element(v.begin(),v.end())
#define v_unique(v)     v.erase(unique(v.begin(),v.end()),v.end()); ///only for sorted vector.
///----------------STRING-----------------
#define get(s) getline(cin.ignore(),s)

using namespace std;

int main()
{
    ll tc=1,n,a,b,c,d,i,ans=0;
    //vector<pair<int,string>>v;
     vector<ll>v;
    string s,ss;
   //cin>>tc;
    while(tc--)
    {
       cin>>s>>ss;
       for(i=0; i<s.size(); i++)
              if(s[i] != ss[i])
                  ans++;
       cout<<ans<<endl;
    }

    return 0;
}



Measured memory_bytes: 3916
#include<stdio.h>
#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int);
int left(int);
int right(int);
void buildMaxHeap(int);


int main()
{

	
    int i;
	
	scanf("%d",&H);
	
	for(i=1;i<=H;i++) scanf("%d",&A[i]);	
    
    maxHeapify(i);
    
    
	for(i=H/2;i>=1;i--)
	{
		maxHeapify(i);
	}
    
    for(i=1;i<=H;i++)printf(" %d",A[i]);
    
    
    printf("\n");
    return 0;
 

}


void maxHeapify(int i)
{
	int l,r,a,largest;
	l=left(i);
	r=right(i);
	
	if (l<=H&&A[l]>A[i])largest=l;
	else largest=i;
	
	if(r<=H&&A[r]>A[largest])largest=r;
	
	if(largest!=i)
	{
		a=A[i];
		A[i]=A[largest];
		A[largest]=a;
		
		maxHeapify(largest);
	}
}


int left(int i)
{
	return 2*i;
}
int right(int i)
{
	return 2*i+1;
}



Measured memory_bytes: 3664
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;
int main(void) {
  int h, w;
  cin >> h >> w;
  string board[50];
  for (int i = 0; i < h; ++i) cin >> board[i];
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  for (int i = 0; i < h; ++i) {
  for (int j = 0; j < w; ++j) {
  if (board[i][j] == '#') continue;
  int num = 0;
  for (int d = 0; d < 8; ++ d) {
  const int ni = i + dy[d];
  const int nj = j + dx[d];

  if (ni < 0 or h <= ni) continue;
  if (nj < 0 or w <= nj) continue;
  if (board[ni][nj] == '#') num++;
  }
  board[i][j] = char(num + '0');
  }
  }
  for (int i = 0; i < h; ++i) cout << board[i] << endl;
  return 0;
  }


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);

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

    int cnt = 0;

    for (int i = 1; i < N - 1;i++){
        if((A[i] < A[i-1] && A[i] > A[i+1]) || (A[i] < A[i+1] && A[i] > A[i-1]))
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
    long long mul[]={1,1,2,3,5,8,13,21};
    int h,w,k; cin>>h>>w>>k;
    long long dp[h+1][w]={};
    dp[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dp[i+1][j]=(dp[i+1][j]+dp[i][j]*mul[j]*mul[w-1-j]%MOD)%MOD;
            if(j>0)dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j]*mul[j-1]*mul[w-1-j]%MOD)%MOD;
            if(j<w-1)dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j]*mul[j]*mul[w-1-(j+1)]%MOD)%MOD;
        }
    }
    cout<<dp[h][k-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int, input().split()))

dp=[0]*(n)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1])
print(dp[n-1])

Measured memory_bytes: 13908
#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()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,h;
  cin >> a >> b >> h;

  cout << (a+b)*h/2 << '\n';
  return 0;
}


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

int main() {
	// your code goes here
	
	int  n = 3, c;
	//cin >> n;
	int a[1234];
	
	for(int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	
	int m = *max_element(a, a + 3);
	
	int mn = *min_element(a, a + 3);
	
	cout << m - mn <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, q;
	cin >> n >> q;
	long long ans = 1LL * (n - 2) * (n - 2);
	vector<int> row(n + 1), col(n + 1);
	int pos_row = n, pos_col = n;
	for (int i = 0; i < q; i++) {
		int op, pos;
		cin >> op >> pos;
		if (op == 1) {
			if (pos < pos_col) {
				ans -= pos_row - 2;
				while (pos_col > pos) col[pos_col--] = pos_row - 2;
			} else {
				ans -= col[pos];
			}
		} else {
			if (pos < pos_row) {
				ans -= pos_col - 2;
				while (pos_row > pos) row[pos_row--] = pos_col - 2;
			} else {
				ans -= row[pos];
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4748
#include<stdio.h>

int main()
{
    int i,a,x[5];
    for(i=0;i<5;i++)
    {
        scanf("%d",&x[i]);
        if (x[i]==0)
        {
            a=i+1;
        }
    }    
    printf("%d",a);
    return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){
    if(b==0)
    return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;base%=mod;
        pow/=2;
    }return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}
 
const int M = 2e5 + 5;


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


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

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int k=scan.nextInt();
int a=scan.nextInt();
int b=scan.nextInt();

int sum=0;
if(a%k==0){
    sum=sum+1;
}else if(b%k==0){
    sum=sum+1;
}else if(b/k-a/k>=1){
    sum=sum+1;
}

if(sum==1){
    System.out.println("OK");
}
if(sum==0){
    System.out.println("NG");
}

}
}

Measured memory_bytes: 35732
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
typedef long long ll;
char str[maxn];
ll dp[maxn][20];
const int mod=1e9+7;
int main()
{
    scanf("%s",str+1);
    int len=strlen(str+1);
    dp[0][0]=1;
    for(int i=1;i<=len;i++){
        if(str[i]!='?'){
            for(int j=0;j<13;j++){
                dp[i][(j*10+str[i]-'0')%13]=(dp[i][(j*10+str[i]-'0')%13]+dp[i-1][j])%mod;
            }
        }
        else{
            for(int j=0;j<=9;j++){
                for(int k=0;k<13;k++){
                    dp[i][(k*10+j)%13]=(dp[i][(k*10+j)%13]+dp[i-1][k])%mod;
                }
            }
        }
    }
    printf("%lld\n",dp[len][5]);
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

class UnionFind{
public:
	vector<int> par;
	//0-indexed
	void init(int n = 1) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		else{
			return par[x] = root(par[x]);
		}
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		else par[x] = y;
	}
	int setsize(){
		int l = par.size();
		boost::dynamic_bitset<> bs(l);
		for(auto x:par){
			bs[root(x)] = 1;
		}
		return bs.count();
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n,m,a,b,c;
	cin >> n >> m;
	UnionFind uf;
	uf.init(n);
	FOR(i,0,m){
		cin >> a >> b >> c;
		uf.unite(a-1,b-1);
	}
	cout << uf.setsize() << endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>                          
using namespace std;
int f=1;
string s,t;                                          
int main(){	
    cin>>s>>t;
    for(int i=0,j=0;i<s.size(),j<t.size();i++,j++)
        if(t[j]<s[i]) {f=2;break;}
    if(f==1) cout<<s<<t;
    else cout<<t<<s;
	return 0;
}

Measured memory_bytes: 256