akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n;
	cin>>n;
	int avg=0;
	int a[n];
	for(int i=0;i<n;i++) {cin>>a[i];avg+=a[i];}
	avg/=n;
	int mn=1e18;
	int ans=0;
	for(int i=0;i<n;i++){ans+=(avg-a[i])*(avg-a[i]);}
	mn=min(mn,ans);
	ans=0;
	for(int i=0;i<n;i++){ans+=(avg+1-a[i])*(avg+1-a[i]);}
	mn=min(mn,ans);
	cout<<mn<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()

if len(a)%2==0:
	for i in range(len(a)-1,0,-2):
		print(a[i], end=" ")
	for i in range(0,len(a),2):
		print(a[i], end=" ")
else:
	for i in range(len(a)-1,-1,-2):
		print(a[i], end=" ")
	for i in range(1,len(a),2):
		print(a[i], end=" ")

Measured memory_bytes: 32136
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll K;
    cin>>K;
    string S;
    cin>>S;
    
    if(S.size()<=K){
        cout<<S<<endl;
    }else{
        for(ll i=0;i<K;i++){
            cout<<S[i];
        }
        cout<<"..."<<endl;
    }
    
    return 0;
}
 


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
  int n, m;
  cin >> n >> m;
  V<int> a(n);
  rep(i,n) cin >> a[i];
  sort(rall(a));
  int sum = 0;
  rep(i,n) sum += a[i];
  int cnt = 0;
  rep(i,n) {
    if(sum <= 4*m*a[i]) cnt++;
  }
  YesorNo(cnt >= m);
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>

int main() {
    std::string s, t; std::cin >> s >> t;
    int n = s.size(), m = t.size();
    std::vector<int> sa(n + 2), sb(n + 2), ta(m + 2), tb(m + 2);
    auto acm = [](const std::string &s, std::vector<int> &v, char c) {
        int n = s.size();
        for (int i = 0; i < n; i++) v[i + 1] += v[i] + (s[i] == c);
    };
    acm(s, sa, 'A'); acm(s, sb, 'B');
    acm(t, ta, 'A'); acm(t, tb, 'B');
    int q; std::cin >> q;
    while (q--) {
        int l1, r1, l2, r2;
        std::cin >> l1 >> r1 >> l2 >> r2;
        int csa = sa[r1] - sa[l1 - 1], csb = sb[r1] - sb[l1 - 1];
        int cta = ta[r2] - ta[l2 - 1], ctb = tb[r2] - tb[l2 - 1];
        int diff = (r2 - l2) - (r1 - l1);
        if (diff < 0) {
            diff *= -1;
            std::swap(csa, cta);
            std::swap(csb, ctb);
        }
        if ((cta - csa + diff) % 3 != 0) {
            std::cout << "NO" << std::endl;
            continue;
        }
        int k = (cta - csa + diff) / 3;
        int u = csa - diff + 3 * k;
        int v = csb + 2 * diff - 3 * k;
        std::cout << (u == cta && v == ctb ? "YES" : "NO") << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
#define MAX_N 200000
vector<int>X[MAX_N], D[MAX_N], C;
int Depth[MAX_N], a[MAX_N], b[MAX_N], N, Q, A, B, cnt = 1;
stack<int>S;
inline void dfs(int p) {
	int A = S.top();
	for (int i = 0; i < X[A].size(); i++) {
		if (a[X[A][i]] == -1) { S.push(X[A][i]); a[X[A][i]] = cnt; b[cnt] = X[A][i]; cnt++; dfs(X[A][i]); }
	}
	S.pop();
}
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A; for (int j = 0; j < A; j++) { cin >> B; X[i].push_back(B); }
	}
	for (int i = 0; i < MAX_N; i++) { Depth[i] = 1 << 30; a[i] = -1; }
	Depth[0] = 0; S.push(0); a[0] = 0; cin >> Q;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < X[i].size(); j++) { Depth[X[i][j]] = Depth[i] + 1; }
	}
	int C1 = 0; dfs(0);
	for (int i = 0; i < N; i++) { D[Depth[i]].push_back(a[i]); }
	for (int i = 0; i < N; i++) { sort(D[i].begin(), D[i].end()); }
	for (int i = 0; i < Q; i++) {
		cin >> A >> B; int W = min(Depth[A], Depth[B]); A = a[A]; B = a[B];
		int L = 1, R = W, M;
		if (W == 0 || (Depth[b[A]] == 1 && Depth[b[B]] == 1 && A != B)) { cout << "0" << endl; continue; }
		while (true) {
			int M = (L + R) / 2;
			int pos1 = upper_bound(D[M - 1].begin(), D[M - 1].end(), A) - D[M - 1].begin(); pos1--;
			int pos2 = upper_bound(D[M - 1].begin(), D[M - 1].end(), B) - D[M - 1].begin(); pos2--;
			int pos3 = upper_bound(D[M].begin(), D[M].end(), A) - D[M].begin(); pos3--;
			int pos4 = upper_bound(D[M].begin(), D[M].end(), B) - D[M].begin(); pos4--;
			bool p1 = false, p2 = false; if (pos1 == pos2) { p1 = true; }if (pos3 == pos4) { p2 = true; }
			if (p1 == true && p2 == false) {
				cout << b[D[M - 1][pos1]] << endl; break;
			}
			if (p1 == true && p2 == true) { L = M + 1; }
			if (p1 == false && p2 == false) { R = M; }
			if (p1 == true && p2 == true && M == W) {
				cout << b[D[M][pos3]] << endl; break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 21548
import math

N, K = map(int, input().split())


kakuritsu = []
for x in range(1, N + 1):
    if x >= K:
        kakuritsu.append(1 / N)
        continue

    kaisu = math.ceil(math.log(K / x, 2))
    kakuritsu.append(1 / N * pow(0.5, kaisu))

print(sum(kakuritsu))


Measured memory_bytes: 6296
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

struct Z_algorithm
{
  vector< int > prefix;

  void build(const string &s)
  {
    prefix.assign(s.size(), 0);
    for(int i = 1, j = 0; i < s.size(); i++) {
      if(i + prefix[i - j] < j + prefix[j]) {
        prefix[i] = prefix[i - j];
      } else {
        int k = max(0, j + prefix[j] - i);
        while(i + k < s.size() && s[k] == s[i + k]) ++k;
        prefix[i] = k;
        j = i;
      }
    }
    prefix[0] = (int) s.size();
  }

  int operator[](const int k) const
  {
    return (prefix[k]);
  }

  size_t size()
  {
    return(prefix.size());
  }
};


int main(){
	ll n; cin >> n;
	vl a(n),b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	string s;
	rep(i,n) s.push_back(b[i]^b[(i+1)%n]);
	s.push_back('#');
	rep(i,n) s.push_back(a[i]^a[(i+1)%n]);
	rep(i,n) s.push_back(a[i]^a[(i+1)%n]);
	Z_algorithm z;
	z.build(s);
	vl ans;
	REP(i,n,z.size()-n){
		if(z.prefix[i]==n) ans.push_back(i-1-n);
	}
	for(auto i : ans){
		print2(i,b[0]^a[i]);
	}
}

Measured memory_bytes: 11644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = 0;
		int m = 0;
		int s = 0;
		while(S >= 3600) {
			S = S - 3600;
			h++;
		}
		while(S >= 60) {
			S = S - 60;
			m++;
		}
		s = S;
		System.out.println(h + ":" + m + ":" + s);
	}
}

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

int main() {
  int64_t N; 
  cin >> N;
  int64_t ans;
  ans = N * (N-1) / 2;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> sieve(n+1,0);
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
            sieve[j]++;
    }
    long long ans = 0;
    for(int i=1;i<=n-1;i++)
    {
        ans += sieve[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7144
#include<iostream>
#include<vector>
#include<string>

int main(){
	int n, k;
	std::string s;

	std::cin>>n>>k;
	std::cin>>s;

	int sum=0;
	int numChanged=0;

	int numCont= 1;

	for(int i=1; i<n; i++){
		if(s[i]!= s[i-1]){
			sum+= numCont-1;
			numChanged++;

			numCont= 0;
		}
		numCont++;
	}
	sum+= numCont-1;

	int ans= 0;

	if(k>= (numChanged+1)/2)
		ans= n-1;
	else
		ans= sum+ 2*k;

	std::cout<<ans<<std::endl;
	


	return 0;
}

Measured memory_bytes: 512
n,m,*t=map(int,open(0).read().split())
d=[0,0]+[1e18]*n
for l,r,c in sorted(zip(*[iter(t)]*3)):
 for i in range(r,l,-1):
  if d[l]+c<d[i]:d[i]=d[l]+c
  else:break
print(-(d[-2]>1e17)or d[-2])

Measured memory_bytes: 124200
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

template<class Integer>
class BinaryIndexedTree
{
private:
	ull maxSize_;
	vector<Integer> values_;
public:
	BinaryIndexedTree(ull maxSize) : maxSize_(maxSize), values_(maxSize_, 0) {}

	void update(ll index, Integer increment)
	{
		if (maxSize_ <= index)
		{
			throw invalid_argument("Index should be less than maxSize.");
		}
		++index;

		while (index <= maxSize_)
		{
			values_[index - 1] += increment;
			index += index & -index;
		}
	}

	Integer query(ll index)
	{
		if (maxSize_ <= index)
		{
			throw invalid_argument("Index should be less than maxSize.");
		}
		++index;

		Integer res = 0;
		while (index > 0)
		{
			res += values_[index - 1];
			index -= index & -index;
		}
		return res;
	}
};
using bit = BinaryIndexedTree<ll>;

int solve() {
	ll n, q;
	cin >> n >> q;

	vector<ll> as(n);
	vector<tuple<ll, ll, ll>> rlis;
	ll l, r;
	REPD(i, 0, n) cin >> as[i];
	REPD(i, 0, q){
		cin >> l >> r;
		--l, --r;
		rlis.emplace_back(r, l, i);
	}
	sort(rlis.begin(), rlis.end());

	bit counters(n);
	map<ll, ll> color_to_max_idx;
	vector<ll> results(q);
	ll idx, curr_r = 0;
	REPD(i, 0, q) {
		tie(r, l, idx) = rlis[i];
		while(curr_r <= r) {
			counters.update(curr_r, 1LL);
			if (color_to_max_idx.count(as[curr_r]) != 0LL) {
				counters.update(color_to_max_idx[as[curr_r]], -1LL);
			}
			color_to_max_idx[as[curr_r]] = curr_r;
			++curr_r;
		}
		results[idx] = counters.query(r) - (l > 0LL ? counters.query(l - 1LL) : 0LL);
	}

	REPD(i, 0, q) cout << results[i] << endl;

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int n1, n2, n3;
  n1 = min(min(a, b), min(b, c));
  n3 = max(max(a, b), max(b, c));
  n2 = a+b+c - (n1+n3);
  int ans = 0;
  ans += n3 - n2;
  n1 += n3 - n2;
  n2 = n3;
  if ((n3-n1)%2 == 0) {
    ans += (n3-n1)/2;
  } else {
    ans += (n3-n1)/2 + 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())

def calc(n):
  for i in range(n + 1):
    div = -1
    if(i != 0 and n % i == 0):
      div = n / i
    
    if div < 10 and i < 10 and div != -1:
      return "Yes"
  return "No"

print(calc(n))

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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int N;
  cin >> N;

  int cnt = 0;
  bool can = false;
  for (int i = 0; i < N; i++) {
    int di, dj;
    cin >> di >> dj;
    if (di == dj)
      cnt++;
    else cnt = 0;
    if (cnt == 3) {
      can = true;
    }
  }

  cout << (can ? "Yes" : "No");
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  cout << nl;
  // }

  return 0;
}

Measured memory_bytes: 3648
class Team
  def initialize tid, problem_num
    @tid = tid
    @correct_num = 0
    @penalty = 0
    @problems = {}
    1.upto(problem_num) do |pid|
      @problems[pid] = 0
    end
  end

  def correct pid, time
    @correct_num += 1
    @penalty += @problems[pid] * 1200 + time
  end

  def wrong pid
    if @problems[pid].nil?
      @problems[pid] = 1
    else
      @problems[pid] += 1
    end
  end

  def <=> team
    return 1 if @correct_num > team.correct_num
    return -1 if @correct_num < team.correct_num
    return 1 if @penalty < team.penalty
    return -1 if @penalty > team.penalty
    return 1 if @tid < team.tid
    return -1 if @tid > team.tid
    return 0
  end

  attr_reader :tid, :correct_num, :penalty
end

def main
  loop do
    t,p,r = gets.chomp.split(' ').map(&:to_i)
    break if (t|p|r) == 0

    teams = make_teams(t, p)
    log_analyze(teams, r)
    print_ranking(teams)
  end
end

def make_teams t, p
  teams = []
  t.times do |i|
    teams << Team.new(i+1, p)
  end
  teams
end

def log_analyze teams, r
  r.times do
    tid,pid,time,message = gets.chomp.split(' ')
    if message == 'CORRECT'
      teams[tid.to_i-1].correct(pid.to_i, time.to_i)
    else
      teams[tid.to_i-1].wrong(pid.to_i)
    end
  end
end

def print_ranking teams
  teams.sort{|a, b| b <=> a}.each do |team|
    puts "#{team.tid} #{team.correct_num} #{team.penalty}"
  end
end

main

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

int ar(int *a,int n){
    int num,f=0;
    for (int i=0;i<n;i++) {
        cin>>a[i];
        for(int j=0;j<i;j++)
        if(a[i]==a[j])i--,n--,f++;
		      int tmp=a[i],j;
		      for(j=i-1;j>=0&&tmp<a[j]&&!f;j--)a[j+1]=a[j];
		      a[j+1]=tmp,num=n,f=0;
	   }
    return num;
}

int main(){
    int p,q,a[10000],b[1000],n=0;
    cin>>p,p=ar(a,p);
    cin>>q,q=ar(b,q);
    for(int i=0;i<p;i++)
        for(int j=0;j<q;j++)
            if(a[i]==b[j])n++;
    cout<<n<<endl;
    
    return 0;
}

Measured memory_bytes: 3092
import java.util.*;
import java.io.*;
 
public class Main {
    static long[] c;
    static long[][] dc;
    //static int[] last;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int d = sc.nextInt();
        c = sc.nextLongArray(26);
        dc = new long[d][26];
        int[] schedule = new int[d];
        for(int i = 0; i < d; i++){
            long maxV = -Integer.MAX_VALUE;
            int max = 1;
            for(int j = 0; j < 26; j++){
                dc[i][j] = sc.nextLong();
                if(maxV < dc[i][j]){
                    maxV = dc[i][j];
                    max = j+1;
                }
            }
            schedule[i] = max;
        }
        printSchedule(schedule);
    }
    
    public static void printSchedule(int[] schedule){
        for(int d : schedule){
            System.out.println(d);
        }
        return;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 27740
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
string S,T;
//=============================
void input()
{
    cin>>S;
    cin>>T;
}

void solve()
{

    int ans = 1;
    map<char,char> m;
    for (int i = 0; i < S.size(); ++i){
        if (!m[S[i]]) {
        m[S[i]] = T[i];
        }
        else {
            if (m[S[i]] == T[i]) continue;
            else {
                ans = 0;
                break;
            }
        }

    }
    map<char,char> n;
    for (int i = 0; i < S.size(); ++i){
        if (!n[T[i]]) {
        n[T[i]] = S[i];
        }
        else {
            if (n[T[i]] == S[i]) continue;
            else {
                ans = 0;
                break;
            }
        }

    }

    cout<<(ans ?  "Yes" : "No") <<endl;
}

//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 776
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

round3 :: Double -> Double
round3 = (/1000) . fromIntegral . floor . (+0.5) . (*1000)

ccenter (x1,y1) (x2,y2) (x3,y3) = [xc,yc,r]
  where
    ta = 2 * (x2 - x1)
    tb = 2 * (y2 - y1)
    tc = 2 * (x3 - x1)
    td = 2 * (y3 - y1)
    tx = (x2 + x1) * (x2 - x1) + (y2 + y1) * (y2 - y1)
    ty = (x3 + x1) * (x3 - x1) + (y3 + y1) * (y3 - y1)
    det = ta*td - tb*tc
    dx = tx*td - tb*ty
    dy = ta*ty - tx*tc
    xc = dx / det
    yc = dy / det
    r = sqrt $ (x1 - xc) ^ 2 + (y1 - yc) ^ 2

main = getInt >>= flip replicateM getDoubles >>= mapM_ ((\[x,y,r] -> printf "%.3f %.3f %.3f\n" x y r) . map round3 . apply3 ccenter . map (apply2 (,)) . splitRec 2)
    


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

using namespace std;

string s;
int main(){
    cin >> s;
    int l = s.length();
    string t = "";
    for(int i=0; i<l; i++){
        if(s[i]=='B' ) {
            if(t.empty()!=1)t.erase(t.length()-1);
        }
        else t += s[i];
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

// n^p mod m (繰り返し二乗法)
fn repeat_square(n: u64, p: u64, m: u64) -> u64 {
    if p == 0 {
        1
    } else if p == 1 {
        n % m
    } else if p % 2 == 0 {
        repeat_square(n, p / 2, m).pow(2) % m
    } else {
        (n * repeat_square(n, p - 1, m)) % m
    }
}

fn ncr_mod(n: u64, r: u64, m: u64) -> u64 {
    let mut denominator = n;
    let mut numerator = 1;
    for i in 1..r {
        denominator = (denominator * (n - i)) % m;
        numerator = (numerator * (i + 1)) % m;
    }
    (denominator * repeat_square(numerator, m - 2, m)) % m
}

fn main() {
    input! {
        s: u64,
    }

    let divisor = 10_u64.pow(9) + 7;
    let mut ans = 0;
    // 項の数が i (すべての項は 3 以上)
    for i in 1..s {
        if 3 * i > s {
            break;
        } else if 3 * i == s {
            ans += 1;
            break;
        }

        let needed = s - (3 * i);
        ans += ncr_mod(i + needed - 1, needed, divisor);
        ans = ans % divisor;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <functional>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define endl '\n'
#define pb push_back

// debug 도구

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto& x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}\n";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)

// debug 도구 end

using llong = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VPII = vector<pair<int, int>>;
using VLL = vector<long long>;
using PII = pair<int, int>;

int main() {
    llong n, d;
    cin >> n >> d;
    int cnt = 0;
    rep(i, 0, n) {
        llong x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BalancedPath solver = new BalancedPath();
        solver.solve(1, in, out);
        out.close();
    }

    static class BalancedPath {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            // 2 * 80 * 80
            final int MAX = 13000;

            int h = in.nextInt();
            int w = in.nextInt();
            int[][] a = new int[h + 1][w + 1];
            int[][] b = new int[h + 1][w + 1];
            int[][] c = new int[h + 1][w + 1];
            boolean[][][] dp = new boolean[h + 1][w + 1][2 * MAX + 100];

            for (int i = 1; i <= h; i++) {
                for (int j = 1; j <= w; j++) {
                    a[i][j] = Integer.parseInt(in.next());
                }
            }
            for (int i = 1; i <= h; i++) {
                for (int j = 1; j <= w; j++) {
                    b[i][j] = Integer.parseInt(in.next());
                }
            }
            for (int i = 1; i <= h; i++) {
                for (int j = 1; j <= w; j++) {
                    c[i][j] = a[i][j] - b[i][j];
                }
            }

            dp[1][1][MAX + c[1][1]] = true;
            dp[1][1][MAX - c[1][1]] = true;

            for (int i = 1; i <= h; i++) {
                for (int j = 1; j <= w; j++) {
                    for (int k = -MAX; k <= MAX; k++) {
                        if (dp[i][j][MAX + k]) {
                            if (i + 1 <= h) {
                                dp[i + 1][j][MAX + k + c[i + 1][j]] = true;
                                dp[i + 1][j][MAX + k - c[i + 1][j]] = true;
                            }
                            if (j + 1 <= w) {
                                dp[i][j + 1][MAX + k + c[i][j + 1]] = true;
                                dp[i][j + 1][MAX + k - c[i][j + 1]] = true;
                            }
                        }
                    }
                }
            }

            int result = Integer.MAX_VALUE;
            for (int k = 0; k <= MAX; k++) {
                if (dp[h][w][MAX + k]) {
                    result = Math.min(result, k);
                }
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 275624
#include <bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long int 
#define pb  push_back
#define mp  make_pair
#define pii pair<int, int>
using namespace std;

const ll mod = 1e9+7;
const int N = 5e5;
ll dp[N] = {0};
ll h[N] = {0};
ll a[N] = {0};
//int siz = 1;
ll tree[2*N+1] = {0};

ll func(ll a, ll b){
	return max(a, b);
}

void update(int node, int start, int end, int ind, ll x){
	if(start == end){
		if(x>tree[node]){
			tree[node] = x;
		}
		//cout << node << endl;
		return;
	}

	int mid = (start+end)/2;

	if( ind >= start && ind <= mid){
		update(2*node, start, mid, ind, x);
	}
	else{
		update(2*node+1, mid+1, end, ind, x);	
	}

	tree[node] = func(tree[2*node], tree[2*node+1]);
	//cout << node << endl;
	return;
}

ll query(int node, int start, int end, int l, int r){
	if( l>end or r<start ){
		return 0;
	}

	if( l<= start and r>=end ){
		return tree[node];
	}

	int mid = (start+end)/2;
	ll left = query(2*node, start, mid, l, r);
	ll right = query(2*node+1, mid+1, end, l, r);

	//cout << left << right << node << endl;

 	return func(left, right);
}

void solve(){
  	int n;
	cin >> n;

	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	for(int i=0;i<n;i++){
		cin >> a[i];
	}

	/*
	while(siz < n){
		siz *= 2;
	}
	*/
	//vector<ll> tree(2*siz);

	for(int flower=0;flower<n;flower++){
		/*
		if(h[flower] == 1){
			d[1] = func(dp[1], a[flower]);
			continue;
		}
		*/


		ll prev_max = 0;
		if(h[flower] != 1){
			prev_max = query(1, 1, n, 1, h[flower]-1);
		}
		//cout << prev_max << endl;
		update(1, 1, n, h[flower], prev_max+a[flower]);

		/*
		for(int i=1;i<16;i++){
			cout << tree[i] << " ";
		}
		cout << endl;
		*/
		//dp[h[flower]] = func(dp[h[flower]], prev_max+a[flower]);
		/*
		for(int j=0;j<h[i];j++){
			dp[h[i]] = max(dp[h[i]], a[i]+dp[j]);
		}
		*/
	}

	/*
	ll maxi = 0;
	for(int i=0;i<=n;i++){
		maxi = max(maxi, dp[i]);
	}
	*/
	cout << tree[1] << endl;

}


int main(){
    ll t=1;
   // cin >> t;
    while(t--){
        solve();
    }
}



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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=3001;

int n;
ll v[N];

ll f(ll x) {
    ll ans=0;
    for(int i=1;i<=n;i++)
        ans+=x%v[i];
    return ans;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++) {
        cin>>v[i];
        ans+=v[i]-1;
    }
    cout<<ans<<"\n";
    return 0;
}
/**
 35420


**/


Measured memory_bytes: 256
n = int(input())

def prime(n_):
    if n_ == 1:
        return []
    num = int(pow(n_, 0.5)) + 1
    pr = [True] * (num + 1)
    pr[0], pr[1] = False, False
    for i in range(2, int(pow(num, 0.5) + 1)):
        if not pr[i]:
            continue
        for j in range(i * 2, num + 1, i):
            pr[j] = False
    return [i for i in range(num + 1) if pr[i]]

def factorization(num):
    pr = prime(num)
    data = []
    temp = num
    for i in pr:
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            data.append([i, count])
    if temp != 1:
        data.append([temp, 1])
    if data == []:
        data.append([n, 1])
    return data

def main():
    ans = 0
    pr = factorization(n)
    for i, j in pr:
        count = 1
        sub = j
        while sub >= count:
            ans += 1
            sub -= count
            count += 1
    if n == 1:
        ans = 0
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20280
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

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

int main()
{
    IOS
    int n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<"\n";
    }
    else{
        cout<<r+100*(10-n)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Policy;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static int[] cotbl;

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        cotbl = new int[n+1];

        long y = 0;
        for (int i=2; i <= n; i++) {
            long x = i;
            int j = 1;
            while(x <= n) {
                cotbl[x]++;
                x = (long)i * (++j);
            }
            y += (long)i * (long)(cotbl[i] + 1);
        }
        //1の分
        y += 1;

        return y;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        if(n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 66488
x = int(input())

A = [0] * (10**6)
for i in range(10**6 - 2):
    j = i + 2
    if A[j] == 0:
        if j >= x:
            break
        else:
            for k in range(10**6 // j):
                A[j * (k)] = 1

print(j)


Measured memory_bytes: 16608
#include <iostream>
#include <queue>

int main(void)
{
    int n;
    std::cin >> n;
    std::priority_queue<int> q;
    for (int i = 0; i < n; ++i)
    {
        int v;
        std::cin >> v;
        q.push(v);
    }
    int alice = 0, bob = 0;
    bool alice_turn = true;
    while (!q.empty())
    {
        if (alice_turn)
        {
            alice += q.top();
        }
        else
        {
            bob += q.top();
        }
        q.pop();
        alice_turn = !alice_turn;
    }
    std::cout << (alice - bob) << std::endl;
}


Measured memory_bytes: 256
n = int(input())
s_l = [ str(input()) for _ in range(n)  ]

m = int(input())
t_l = [ str(input()) for _ in range(m)  ]
d = {}
for s in s_l:
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
for t in t_l:
    if t not in d:
        d[t] = -1
    else:
        d[t] -= 1
ans = 0
for k, v in d.items():
    ans = max(v, ans)
print(ans)

Measured memory_bytes: 9204
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    string s;
    cin >> s;

    if(s=="SAT") {
        print(1);
    } else if(s=="SUN") {
        print(7);
    } else if(s=="MON") {
        print(6);
    } else if(s=="TUE") {
        print(5);
    } else if(s=="WED") {
        print(4);
    } else if(s=="THU") {
        print(3);
    } else if(s=="FRI") {
        print(2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define CONSTRAINT 100005
#define LL long long
using namespace std;

int counts[CONSTRAINT] = {0};
int main(int argc, char const *argv[])
{
	int count, operations;
	LL sum = 0;
	int current, former, latter;
	cin >> count;
	for (int i = 0; i < count; ++i)
	{
		cin >> current;
		sum += current;
		counts[current] ++;
	}
	cin >> operations;
	for (int i = 0; i < operations; ++i)
	{
		cin >> former >> latter;
		sum += (latter - former) * counts[former];
		counts[latter] += counts[former];
		counts[former] = 0;
		cout << sum << endl;
	}
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli a , b , h ;
    cin >> a >> b >> h ;
    cout << (a + b) * h / 2 ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
s = input()
t = input()

sn = len(s)
tn = len(t)

dp = tuple([0] * (tn + 1) for _ in range(sn + 1))

for si in range(sn):
    for ti in range(tn):
        if s[si] == t[ti]:
            dp[si + 1][ti + 1] = dp[si][ti] + 1
        else:
            dp[si + 1][ti + 1] = max(dp[si + 1][ti], dp[si][ti + 1])
        # 漸化式で必要になる項は、使うときには更新済みになっている

rest = dp[sn][tn]

si = sn - 1
ti = tn - 1

res = ''
while rest > 0:
    if s[si] == t[ti]:
        res = s[si] + res
        si -= 1
        ti -= 1
        rest -= 1
    elif dp[si + 1][ti + 1] == dp[si + 1][ti]:
        ti -= 1
    else:
        si -= 1
print(res)


Measured memory_bytes: 112220
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define mp make_pair
#define int long long int
#define double long double
#define bp __builtin_popcountll
#define inf 1000000000000000000
#define f(i,a,b) for(int i=a;i<=b;i++)
#define r(i,a,b) for(int i=a;i>=b;i--)
const int M=1e9+7;
const int N=1e5+5;
int32_t main()
{
	FAST
	int n,m;
	cin>>n>>m;
	vector<pair<int,int> > v(m);
	for(int i=0;i<m;i++)
	{
		int a,b,ans=0,x;
		cin>>a>>b;
		for(int j=0;j<b;j++)
		{
			cin>>x;
			x--;
			ans+=(1<<x);
		}
		v[i].ff=a;
		v[i].ss=ans;
	}
	int dp[(1<<n)+5];
	for(int i=0;i<(1<<n);i++)
	dp[i]=inf;
	dp[0]=0;
	for(int mask=0;mask<(1<<n);mask++)
	{
		for(int i=0;i<m;i++)
		{
			int tt=v[i].ss;
			int pp=v[i].ff;
			dp[mask|tt]=min(dp[mask|tt],dp[mask]+pp);
		}
	}
	if(dp[(1<<n)-1]==inf)
	cout<<-1;
	else
	cout<<dp[(1<<n)-1];
}

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

int main() {
  int N ;
  cin >> N ;
  
  if (N % 2 ==0){
    cout << N/2 << endl ; 
  }
  
  else {
    cout << N/2 +1 << endl ; 
  }
  
  
  
  
  
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string s;
    cin >> s;
    int n;
    cin >> n;
    vector<string> vs;
    for(char j = 'a'; j <= 'z'; j++){
        string tmp = "";
        for(int k = 0; k < n; k++){
            tmp += j;
        }
        int seq = (int)s.find(tmp);
        if(seq>=0){seq=1;}
        for(int i = 0; i < s.size(); i++){

            if(s[i] == j){
                int cnt = 0;
                if(seq){
                int num = min((int)s.size()-i,10);
                for(int k = 0; k < num ; k++){
                    auto itr = find(vs.begin(), vs.end(), s.substr(i,k+1));
                    if( itr == vs.end() ) {
                        cnt++;
                        vs.push_back(s.substr(i,k+1));
                    }
                    if(cnt>=n){break;}
                }}
                else{
                for(int k = 0; k < s.size()-i; k++){
                    auto itr = find(vs.begin(), vs.end(), s.substr(i,k+1));
                    if( itr == vs.end() ) {
                        cnt++;
                        vs.push_back(s.substr(i,k+1));
                    }
                    if(cnt>=n){break;}
                }}
            }
        }
        if(vs.size()>=n){break;}
    }
    sort(vs.begin(),vs.end());


    cout << vs[n-1] << endl;




    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int N,counter1,counter2,counter3;
    scanf("%d",&N);
    
    int h[N],Flower[N];
    //配列の初期化
    for(counter1=1;counter1<=N;counter1++){
        Flower[counter1-1]=0;
    }
    for(counter1=1;counter1<=N;counter1++){
        scanf("%d",&h[counter1-1]);
    }
    
    //counter1の初期化
    counter1=0;
    for(counter3=1;counter3<=100;counter3++){
        for(counter2=1;counter2<=N;counter2++){
            if(Flower[counter2-1]<h[counter2-1]){
                Flower[counter2-1]++;
                if(counter2<=(N-1) && Flower[counter2]==h[counter2]){
                    counter1++;
                }else if(counter2==N){
                    counter1++;
                }
            }
        }
    }
    printf("%d\n",counter1);
    
    return 0;
}


Measured memory_bytes: 128
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let line = read_as_vec::<u32>();
    let q = line[1];
    let helix = read_as_string();

    let mut cul_sum: Vec<u32> = vec![0];
    let mut counter = 0;
    for (c1, c2) in helix.chars().zip(helix.chars().skip(1)){
        if c1 == 'A' && c2 == 'C'{
            counter += 1;
        }
        cul_sum.push(counter);
    }

    for _ in 0..q{
        let line = read_as_vec::<usize>();
        let (l, r) = (line[0], line[1]);
        println!("{}", cul_sum[r-1] -cul_sum[l-1]);
    }
}


Measured memory_bytes: 4860
n = int(input())
a = list(map(int, input().split()))
ans = 0
now = 0
for i,j in enumerate(a):
  if i == j-1:
    now += 1
    if now == 2:
      ans += 1
      now = 0
  else:
    if now == 1:
      ans += 1
      now = 0
if now == 1:
  ans += 1
print(ans)

Measured memory_bytes: 14008